Continued implementation of functions needed for network play
This commit is contained in:
parent
f4680cc631
commit
c7947d9790
3 changed files with 96 additions and 26 deletions
|
@ -6,7 +6,7 @@ import pygame
|
|||
from pygame.locals import *
|
||||
import sgc
|
||||
from sgc.locals import *
|
||||
|
||||
import socket
|
||||
|
||||
|
||||
class GUI:
|
||||
|
@ -63,9 +63,12 @@ class GUI:
|
|||
self.quit_btn.activate = sys.exit
|
||||
self.quit_btn.add()
|
||||
|
||||
# self.waiting
|
||||
self.wait_dialog = sgc.widgets.Dialog(title="Please wait...", widget=sgc.widgets.Label(text='Waiting for a connection'))
|
||||
self.wait_dialog.rect.center = self.screen.rect.center
|
||||
|
||||
# pygame.time.set_timer(USEREVENT, 1000)
|
||||
# Generate a spurious event once a second, just to
|
||||
# force an update
|
||||
pygame.time.set_timer(USEREVENT, 1000)
|
||||
|
||||
|
||||
def do_event(self):
|
||||
|
@ -141,7 +144,20 @@ class GUI:
|
|||
|
||||
# fixme: this uses localhost as a stub
|
||||
def wait_for_game(self):
|
||||
pass
|
||||
self.wait_dialog.add()
|
||||
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.bind(("127.0.0.1", 6859))
|
||||
sock.listen(1)
|
||||
conn, addr = sock.accept()
|
||||
sock.close()
|
||||
|
||||
self.socket = gtpsocket.GTPSocket(conn)
|
||||
self.net_thread = networkthread.NetworkThread(self.goban, conn)
|
||||
self.net_thread.start()
|
||||
self.network_mode = True
|
||||
|
||||
self.wait_dialog.remove()
|
||||
|
||||
|
||||
def do_hover(self, event):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue