def load_game(path, user_callback=None, before_callback=None): def out_callback(line): if 'Established control over the server. You have command access level' in line: start_button = ui.Dialog( ui.get_screen(), ui.Button('Touch to start game', callback)) start_button.back = callback ui.set(start_button, anim=False) sc_client = gamescreen.ScreenClient() port = random.randint(1500, 12000) start_server(port, ('-f', path), line_callback=sc_client.server_line_callback) sc_client.out_window_callback = out_callback try: sc_client.connect_to_server('player', localhost, port) except client.ConnectionError: ui.message('Failed to connect to game server, try again', type='error') return def callback(): if before_callback() if before_callback else True: load_game_now(port, get_save_username(path)) if user_callback: user_callback() ui.replace(client.client.ui) ui.message('Loading...')
def __init__(self, no_quit=False): super(ServerGUI, self).__init__() gamescreen.ScreenClient(no_quit=no_quit) self.ui = ui.ScrollWrapper(self) self.has_ui = False self.setup_loading_ui() self.server_lines = [] self.server_console = None
def __init__(self, port, host=localhost, login='******', no_quit=False): super(ServerGUI, self).__init__() sc_client = gamescreen.ScreenClient(no_quit=no_quit) sc_client.connect_to_server(login, host, port) self.has_ui = False self.setup_loading_ui()