def show_login_form(callback): def logged(result): print "Login successful" with open(save.get_save_dir() + "/civsync.sessid.txt", "w") as f: f.write(session.sessid) ui.back(anim=False) callback() def do_login(): request(logged, "login", login_field.get_value(), passwd_field.get_value()) def no_account(): ui.message("Download Freeciv Sync for Desktop\nfrom freeciv.zielinscy.org.pl") panel = ui.LinearLayoutWidget() login = ui.HorizontalLayoutWidget() login.add(ui.Label("Login:"******"Password:"******"Login", do_login)) butts.add(ui.Button("No account?", no_account)) butts.add(ui.Button("Cancel", ui.back)) panel.add(butts) ui.set(panel)
def show(client): tree = load_techtree('data/techtree.index') model = TechtreeClientModel(client) widget = TechTreeWidget(model, *tree) widget = ui.ScrollWrapper(widget, ways=ui.SCROLL_WIDTH | ui.SCROLL_HEIGHT) ui.set(widget)
def menu(): layout = ui.LinearLayoutWidget(marginleft=10) buttons = ui.HorizontalLayoutWidget(spacing=10) text_label = help.LongTextWidget('Loading...', ui.screen_width, ui.smallfont) layout.add(buttons) layout.add(text_label) layout.add(buttons) ui. async (check_products) def text_fetched(text): data = json.loads(text) text_label.set_text(data['text']) for btn in data['buttons']: button = ui.Button( btn['text'], functools.partial(open_gold_link, btn['url'], btn.get('restart'))) buttons.add(button) ui. async (lambda: sync.request_with_sid('/sale/gold_text'), then=text_fetched) ui.set(ui.ScrollWrapper(layout))
def out_callback(line): if 'Established control over the server. You have command access level' in line: ui.back(anim=False) start_button = ui.Dialog(ui.screen, ui.Button('Touch to start game', callback)) start_button.back = callback ui.set(start_button, anim=False) sc_client.out_window_callback = None
def show_options(): options = OptionsPanel(marginleft=10) options.add(ui.Label(("Touch" if osutil.is_android else "Click") + " an option to change")) options.add_feature("Shutdown game after %d seconds of pause", "app.shutdown") # options.add_feature_bool('New joystick', 'Old joystick', 'app.new_joystick') options.add(ui.Button("Change joystick", change_joystick)) options.add(ui.Button("Change ruleset for new games", change_ruleset)) st = "Full city label toggle button:" options.add_feature_bool(st + " show", st + " hide", "app.full_label_toggle_button") if osutil.is_desktop: st = "Fullscreen (restart to take effect): " options.add_feature_bool(st + "Yes", st + "No", "ui.fullscreen") options.add(dropbox.DBButton("Login to Dropbox", lambda: dropbox.login())) if features.get("app.debug"): options.add(ui.Button("Debug", debug_menu)) options.add( ui.Label( "Freeciv for Android is licensed under GNU/GPL. \n" "Dropbox and Dropbox logo are trademarks of Dropbox, Inc.\n" ) ) ui.set(options)
def inputbox(text, default='', finish=None, cancel=None): def _finish(): if text.label: graphics.stop_text_input() finish(text.label) ui.back(allow_override=False) else: _cancel() def reset(): text.set_text('') def _cancel(): graphics.stop_text_input() if cancel: cancel() ui.back(allow_override=False) graphics.start_text_input() container = ui.LinearLayoutWidget() container.back = _cancel container.add(ui.Label('%s' % text)) text = InputBox(default) container.add(text) container.focus = text panel = ui.HorizontalLayoutWidget(spacing=10) panel.add(ui.Button('OK', _finish)) panel.add(ui.Button('Reset', reset)) container.add(panel) ui.set(container)
def show_options(): options = OptionsPanel(marginleft=10) options.add( ui.Label(('Touch' if osutil.is_android else 'Click') + ' an option to change')) options.add_feature('Shutdown game after %d seconds of pause', 'app.shutdown') #options.add_feature_bool('New joystick', 'Old joystick', 'app.new_joystick') options.add(ui.Button('Change joystick', change_joystick)) options.add(ui.Button('Change ruleset for new games', change_ruleset)) st = 'Full city label toggle button:' options.add_feature_bool(st + ' show', st + ' hide', 'app.full_label_toggle_button') if osutil.is_desktop: st = 'Fullscreen (restart to take effect): ' options.add_feature_bool(st + 'Yes', st + 'No', 'ui.fullscreen') options.add(dropbox.DBButton('Login to Dropbox', lambda: dropbox.login())) if features.get('app.debug'): options.add(ui.Button('Debug', debug_menu)) options.add(ui.Label('Freeciv for Android is licensed under GNU/GPL. \n' \ 'Dropbox and Dropbox logo are trademarks of Dropbox, Inc.\n', )) ui.set(options)
def new_game(): port = random.randint(2000, 15000) args = ('-r', './data/%s.serv' % features.get('app.ruleset')) gui = ServerGUI() start_server(port, args=args, line_callback=gui.server_line_callback) gui.connect(port) ui.set(gui.ui)
def load_scenario(): menu = ui.LinearLayoutWidget() for name, path in get_scenarios(): callback = functools.partial(load_game, path) menu.add(ui.Button(name, callback)) ui.set(ui.ScrollWrapper(menu))
def show_options(): options = OptionsPanel() options.add(ui.Label('Touch an option to change')) options.add_feature('Shutdown game after %d seconds of pause', 'app.shutdown') options.add(ui.Button('Change ruleset for new games', change_ruleset)) if features.get('app.debug'): options.add(ui.Button('Debug', debug_menu)) ui.set(options)
def debug_menu(): def fake_screen_size(size): import main main.main(size, init=False) def fake_screen_size_menu(): menu = ui.Menu(center=False) for size in [(320, 240), (480, 320), (640, 480), (1024, 800), (1280, 800)]: menu.add(str(size), functools.partial(fake_screen_size, size)) ui.set_dialog(menu, scroll=True) def change_feature(): def finish(arg): try: features._parse_arg(arg) except Exception as e: traceback.print_exc() ui.message(str(e)) uidialog.inputbox('name=key', finish=finish) def pernament_feature(): def finish(): try: k, v = arg.split('=', 1) features.set_perm(k, v) except Exception as e: traceback.print_exc() ui.message(str(e)) uidialog.inputbox('name=key', finish=finish) def show_features(): s = '\n'.join( '%s=%s' % (k,v) for k, v in sorted(features.features.items()) ) ui.set_dialog(ui.Label(s), scroll=True) def test_inputbox(): import uidialog def finish(text): print 'got', text def cancel(): print 'cancel' uidialog.inputbox('Query?', 'defaultval', finish=finish, cancel=cancel) menu = ui.Menu() menu.add('Fake screen size', fake_screen_size_menu) menu.add('Get screen size', lambda: ui.set_dialog(ui.Label(str(ui.screen_size)))) menu.add('Change feature', change_feature) menu.add('Pernament feature', pernament_feature) menu.add('Show features', show_features) menu.add('Cause exception', lambda: 1/0) menu.add('Test Market URL', osutil.open_market) menu.add('Test inputbox', test_inputbox) ui.set(ui.ScrollWrapper(menu))
def load_dialog(entries): print entries menu = ui.LinearLayoutWidget() menu.add(ui.Label('Save your games to folder /Applications/Freeciv in your Dropbox.')) for entry in entries: name = DropboxHelper.getPath(entry).strip('/') menu.add(ui.Button(name, functools.partial(load_dropbox_save, name))) ui.set(ui.ScrollWrapper(menu))
def show_list(entries): panel = ui.LinearLayoutWidget() panel.add(ui.Label('Saves from %s' % civsync.HOST)) for entry in entries: panel.add(ui.Button('%s - %dkB' % (entry.name, entry.size/1024), functools.partial(download_sync, entry.sha1))) if not entries: panel.add(ui.Label('You have not synced any saves...')) panel.add(ui.Label('Install Freeciv Sync for Desktop from %s' % civsync.HOST)) panel.add(ui.Label('or save game with \'Save & Sync\'')) panel.add(ui.Button('Logout', logout)) ui.set(ui.ScrollWrapper(panel))
def set_dialog(new_screen, scroll=False, no_stack=False): if scroll: item = ui.ScrollWrapper(new_screen, height=ui.screen_height * 0.7, width=ui.screen_width * 0.7, ways=ui.SCROLL_HEIGHT | ui.SCROLL_WIDTH) else: item = new_screen dialog = Dialog(ui.get_screen(), item) ui.set(dialog, anim=False, no_stack=no_stack) return dialog
def load_dialog(): menu = ui.LinearLayoutWidget(marginleft=10) was_any = False menu.add(dropbox.DBButton('Show saves in Dropbox', dropbox.load_from_dropbox)) for name, path in get_saves(): callback = functools.partial(load_game, path) menu.add(ui.Button(name, callback)) was_any = True if not was_any: menu.add(ui.Label('No saved games yet...')) ui.set(ui.ScrollWrapper(menu))
def set_dialog(new_screen, scroll=False, no_stack=False): if scroll: item = ui.ScrollWrapper(new_screen, height=ui.screen_height*0.7, width=ui.screen_width*0.7, ways=ui.SCROLL_HEIGHT|ui.SCROLL_WIDTH) else: item = new_screen dialog = Dialog(ui.get_screen(), item) ui.set(dialog, anim=False, no_stack=no_stack) return dialog
def load_dialog(): menu = ui.LinearLayoutWidget() was_any = False if features.get('civsync.enable'): menu.add(ui.Button('Show CivSync saves', sync.show_load)) for name, path in get_saves(): callback = functools.partial(load_game, path) menu.add(ui.Button(name, callback)) was_any = True if not was_any: menu.add(ui.Label('No saved games yet...')) ui.set(ui.ScrollWrapper(menu))
def load_dialog(entries): print entries menu = ui.LinearLayoutWidget() menu.add( ui.Label( 'Save your games to folder /Applications/Freeciv in your Dropbox.') ) for entry in entries: name = DropboxHelper.getPath(entry).strip('/') menu.add(ui.Button(name, functools.partial(load_dropbox_save, name))) ui.set(ui.ScrollWrapper(menu))
def show_main_menu(): global main_menu main_menu = menu = ui.Menu() menu.add('New game', new_game) menu.add('Load game', save.load_dialog) menu.add('Feedback', feedback) menu.add('Options', options.show_options) if features.get('app.multiplayer'): menu.add('Connect', save.connect_dialog) ui.set(menu)
def client_main(): if try_resume(): ui.main() return ui.set(ui.Label('loading...')) ui.execute_later(app_main) if features.get('app.profile'): profile_main() else: ui.main()
def show_options(): options = OptionsPanel() options.add(ui.Label('Touch an option to change')) options.add_feature('Shutdown game after %d seconds of pause', 'app.shutdown') #options.add_feature_bool('New joystick', 'Old joystick', 'app.new_joystick') options.add(ui.Button('Change joystick', change_joystick)) options.add(ui.Button('Change ruleset for new games', change_ruleset)) st = 'Full city label toggle button:' options.add_feature_bool(st + ' show', st + ' hide', 'app.full_label_toggle_button') if features.get('app.debug'): options.add(ui.Button('Debug', debug_menu)) ui.set(options)
def research_dialog(self): def set_goal(tech): tech.set_as_goal() ui.back() techs = ui.LinearLayoutWidget() techs.add(ui.Label(', '.join(self.client.get_current_tech()))) for tech in self.client.get_techs(): techs.add(ui.Button(tech.name, functools.partial(set_goal, tech))) ui.set(ui.ScrollWrapper(techs))
def show_list(entries): panel = ui.LinearLayoutWidget() panel.add(ui.Label("Saves from %s" % civsync.HOST)) for entry in entries: panel.add( ui.Button("%s - %dkB" % (entry.name, entry.size / 1024), functools.partial(download_sync, entry.sha1)) ) if not entries: panel.add(ui.Label("You have not synced any saves...")) panel.add(ui.Label("Install Freeciv Sync for Desktop")) panel.add(ui.Label("from %s" % civsync.HOST)) panel.add(ui.Button("Logout", logout)) ui.set(ui.ScrollWrapper(panel))
def feedback(): panel = ui.LinearLayoutWidget() panel.add( ui.Label( 'Leaving comments with logs will help me diagnose\npotential problems with game speed and\nunexpected behaviour.' )) panel.add( ui.Button('Leave a comment with a log (preferred)', lambda: sync.comment(sync.get_install_time(), True))) panel.add( ui.Button('Leave a comment without a log', lambda: sync.comment(sync.get_install_time(), False))) ui.set(panel)
def load_dialog(entries): print entries def callback(entry): print "fetching from Dropbox", entry.path ui.message("downloading save from Dropbox...") DropboxHelper.downloadFile(entry.path, get_download_path()) check_downloaded() menu = ui.LinearLayoutWidget() menu.add(ui.Label("Save your games to folder /Applications/Freeciv in your Dropbox.")) for entry in entries: menu.add(ui.Button(DropboxHelper.getPath(entry).strip("/"), functools.partial(callback, entry))) ui.set(ui.ScrollWrapper(menu))
def resume(): name = get_resume_data() if name: remove_pause_file() try: menus.main_menu() ui.set(ui.Label('dummy')) save.load_game(name) except IOError: # loading save failed return False return True else: return False
def show_list(entries): panel = ui.LinearLayoutWidget() panel.add(ui.Label('Saves from %s' % civsync.HOST)) for entry in entries: panel.add( ui.Button('%s - %dkB' % (entry.name, entry.size / 1024), functools.partial(download_sync, entry.sha1))) if not entries: panel.add(ui.Label('You have not synced any saves...')) panel.add( ui.Label('Install Freeciv Sync for Desktop from %s' % civsync.HOST)) panel.add(ui.Label('or save game with \'Save & Sync\'')) panel.add(ui.Button('Logout', logout)) ui.set(ui.ScrollWrapper(panel))
def debug_menu(): def fake_screen_size(size): import main main.main(size, init=False) def fake_screen_size_menu(): menu = ui.Menu(center=False) for size in [(320, 240), (480, 320), (640, 480), (1024, 800), (1280, 800)]: menu.add(str(size), functools.partial(fake_screen_size, size)) ui.set_dialog(menu, scroll=True) def change_feature(): arg = uidialog.inputbox('name=key') try: features._parse_arg(arg) except Exception as e: traceback.print_exc() ui.message(str(e)) def pernament_feature(): arg = uidialog.inputbox('name=key') try: k, v = arg.split('=', 1) features.set_perm(k, v) except Exception as e: traceback.print_exc() ui.message(str(e)) def show_features(): s = '\n'.join('%s=%s' % (k, v) for k, v in sorted(features.features.items())) ui.set_dialog(ui.Label(s), scroll=True) menu = ui.Menu() menu.add('Fake screen size', fake_screen_size_menu) menu.add('Get screen size', lambda: ui.set_dialog(ui.Label(str(ui.screen_size)))) menu.add('Change feature', change_feature) menu.add('Pernament feature', pernament_feature) menu.add('Show features', show_features) menu.add('Cause exception', lambda: 1 / 0) menu.add( 'Test Market URL', lambda: uidialog.open_url( 'market://details?id=pl.org.zielinscy.freeciv')) ui.set(ui.ScrollWrapper(menu))
def load_dialog(entries): def load_save(data): with open(get_download_path(), 'wb') as f: f.write(data) _save.load_game(get_download_path()) def callback(entry): ui.message('Fetching save...') return ui.async(lambda: sync.request_with_sid('/sync/download', name=entry), then=load_save) menu = ui.LinearLayoutWidget() menu.add(ui.Label('Save your games to folder /Applications/Freeciv in your Dropbox.')) for entry in entries: menu.add(ui.Button(entry, functools.partial(callback, entry))) ui.set(ui.ScrollWrapper(menu))
def show_options(): options = OptionsPanel() options.add(ui.Label('Touch an option to change')) options.add_feature('Shutdown game after %d seconds of pause', 'app.shutdown') #options.add_feature_bool('New joystick', 'Old joystick', 'app.new_joystick') options.add(ui.Button('Change joystick', change_joystick)) options.add(ui.Button('Change ruleset for new games', change_ruleset)) st = 'Full city label toggle button:' options.add_feature_bool(st + ' show', st + ' hide', 'app.full_label_toggle_button') options.add(ui.Button('Change zoom (experimental)', change_zoom)) if features.get('app.debug'): options.add(ui.Button('Debug', debug_menu)) ui.set(options)
def no_account(): def do_register(): login = login_field.get_value() passwd = passwd_field.get_value() mail = mail_field.get_value() if not login or not passwd or not mail: ui.message('Fill all fields.') elif passwd != passwd_repeat_field.get_value(): ui.message('Passwords don\'t match.') else: request(logged, 'register', login, passwd, mail) panel = ui.LinearLayoutWidget() login = ui.HorizontalLayoutWidget() login.add(ui.Label('Login:'******'Password:'******'*') passwd.add(passwd_field) panel.add(passwd) passwd_repeat = ui.HorizontalLayoutWidget() passwd_repeat.add(ui.Label('Repeat password:'******'*') passwd_repeat.add(passwd_repeat_field) panel.add(passwd_repeat) mail = ui.HorizontalLayoutWidget() mail.add(ui.Label('Mail:')) mail_field = ui.EditField() mail.add(mail_field) panel.add(mail) butts = ui.HorizontalLayoutWidget(spacing=10) butts.add(ui.Button('Register', do_register)) butts.add(ui.Button('Cancel', ui.back)) panel.add(butts) ui.set(panel)
def show_options(): options = OptionsPanel(marginleft=10) options.add(ui.Label('Touch an option to change')) options.add_feature('Shutdown game after %d seconds of pause', 'app.shutdown') #options.add_feature_bool('New joystick', 'Old joystick', 'app.new_joystick') options.add(ui.Button('Change joystick', change_joystick)) options.add(ui.Button('Change ruleset for new games', change_ruleset)) st = 'Full city label toggle button:' options.add_feature_bool(st + ' show', st + ' hide', 'app.full_label_toggle_button') options.add(dropbox.DBButton('Login to Dropbox', lambda: dropbox.login())) if features.get('app.debug'): options.add(ui.Button('Debug', debug_menu)) options.add(ui.Label('Freeciv for Android is licensed under GNU/GPL. \n' \ 'Dropbox and Dropbox logo are trademarks of Dropbox, Inc.\n', )) ui.set(options)
def debug_menu(): def fake_screen_size(size): import main main.main(size, init=False) def fake_screen_size_menu(): menu = ui.Menu(center=False) for size in [(320, 240), (480, 320), (640, 480), (1024, 800)]: menu.add(str(size), functools.partial(fake_screen_size, size)) ui.set_dialog(menu, scroll=True) def change_feature(): arg = uidialog.inputbox('name=key') try: features._parse_arg(arg) except Exception as e: traceback.print_exc() ui.message(str(e)) def pernament_feature(): arg = uidialog.inputbox('name=key') try: k, v = arg.split('=', 1) features.set_perm(k, v) except Exception as e: traceback.print_exc() ui.message(str(e)) def show_features(): s = '\n'.join( '%s=%s' % (k,v) for k, v in sorted(features.features.items()) ) ui.set_dialog(ui.Label(s), scroll=True) menu = ui.Menu() menu.add('Fake screen size', fake_screen_size_menu) menu.add('Get screen size', lambda: ui.set_dialog(ui.Label(str(ui.screen_size)))) menu.add('Change feature', change_feature) menu.add('Pernament feature', pernament_feature) menu.add('Show features', show_features) menu.add('Cause exception', lambda: 1/0) menu.add('Test Market URL', lambda: uidialog.open_url('market://details?id=pl.org.zielinscy.freeciv')) ui.set(ui.ScrollWrapper(menu))
def menu(): layout = ui.LinearLayoutWidget(marginleft=10) buttons = ui.HorizontalLayoutWidget(spacing=10) text_label = help.LongTextWidget('Loading...', ui.screen_width, ui.smallfont) layout.add(buttons) layout.add(text_label) layout.add(buttons) ui.async(check_products) def text_fetched(text): data = json.loads(text) text_label.set_text(data['text']) for btn in data['buttons']: button = ui.Button(btn['text'], functools.partial(open_gold_link, btn['url'], btn.get('restart'))) buttons.add(button) ui.async(lambda: sync.request_with_sid('/sale/gold_text'), then=text_fetched) ui.set(ui.ScrollWrapper(layout))
def load_dialog(entries): menu = ui.LinearLayoutWidget() menu.add(ui.Label('Save your games to folder /Applications/Freeciv in your Dropbox.')) for entry in entries: menu.add(ui.Button(entry, functools.partial(load_dropbox_save, entry))) ui.set(ui.ScrollWrapper(menu))
def new_game(): port = random.randint(2000, 15000) args = ('-r', './data/%s.serv' % features.get('app.ruleset')) start_server(port, args=args) ui.set(ServerGUI(port))
def show_login_form(callback, msg=None): def logged(result): print 'Login successful' with open(save.get_save_dir() + '/civsync.sessid.txt', 'w') as f: f.write(session.sessid) callback() def do_login(): ui.back(anim=False) request(logged, 'login', login_field.get_value(), passwd_field.get_value()) def no_account(): def do_register(): login = login_field.get_value() passwd = passwd_field.get_value() mail = mail_field.get_value() if not login or not passwd or not mail: ui.message('Fill all fields.') elif passwd != passwd_repeat_field.get_value(): ui.message('Passwords don\'t match.') else: request(logged, 'register', login, passwd, mail) panel = ui.LinearLayoutWidget() login = ui.HorizontalLayoutWidget() login.add(ui.Label('Login:'******'Password:'******'*') passwd.add(passwd_field) panel.add(passwd) passwd_repeat = ui.HorizontalLayoutWidget() passwd_repeat.add(ui.Label('Repeat password:'******'*') passwd_repeat.add(passwd_repeat_field) panel.add(passwd_repeat) mail = ui.HorizontalLayoutWidget() mail.add(ui.Label('Mail:')) mail_field = ui.EditField() mail.add(mail_field) panel.add(mail) butts = ui.HorizontalLayoutWidget(spacing=10) butts.add(ui.Button('Register', do_register)) butts.add(ui.Button('Cancel', ui.back)) panel.add(butts) ui.set(panel) panel = ui.LinearLayoutWidget() login = ui.HorizontalLayoutWidget() login.add(ui.Label('Login:'******'Password:'******'*') passwd.add(passwd_field) panel.add(passwd) butts = ui.HorizontalLayoutWidget(spacing=10) butts.add(ui.Button('Login', do_login)) butts.add(ui.Button('No account?', no_account)) butts.add(ui.Button('Cancel', ui.back)) panel.add(butts) ui.set(panel, anim=False) if msg and msg != 'Not logged': ui.message(msg)
lines.append(words) current_width = 0 words.append(img) current_width += img.get_width() + spacing height = sum( max([word.get_height() for word in line] + [0]) for line in lines) surf = pygame.Surface((width, height), pygame.SRCALPHA) y = 0 for line in lines: if not line: continue x = 0 for word in line: surf.blit(word, (x, y)) x += word.get_width() + spacing y += max(word.get_height() for word in line) return surf if __name__ == '__main__': import os os.chdir('..') pygame.display.set_mode((800, 480)) ui.init() w = LongTextWidget( open('data/android-help.txt').read(), 800, ui.consolefont) ui.set(w) ui.main()
def show(self): ui.set(ui.ScrollWrapper(self))
def show(): global help_topics, help_data help_topics, help_data = load_help() ui.set(HelpPanel())
def debug_menu(): def fake_screen_size(size): import main main.main(size, init=False) def fake_screen_size_menu(): menu = ui.Menu(center=False) for size in [(320, 240), (480, 320), (640, 480), (1024, 800), (1280, 800)]: menu.add(str(size), functools.partial(fake_screen_size, size)) ui.set_dialog(menu, scroll=True) def change_feature(): def finish(arg): try: features._parse_arg(arg) except Exception as e: traceback.print_exc() ui.message(str(e)) uidialog.inputbox('name=key', finish=finish) def pernament_feature(): def finish(arg): try: k, v = arg.split('=', 1) features.set_perm(k, v) except Exception as e: traceback.print_exc() ui.message(str(e)) uidialog.inputbox('name=key', finish=finish) def show_features(): s = '\n'.join('%s=%s' % (k, v) for k, v in sorted(features.features.items())) ui.set_dialog(ui.Label(s), scroll=True) def test_inputbox(): import uidialog def finish(text): print 'got', text def cancel(): print 'cancel' uidialog.inputbox('Query?', 'defaultval', finish=finish, cancel=cancel) def test_eval(): import uidialog def finish(text): exec text uidialog.inputbox('Expr to exec?', '', finish=finish) menu = ui.Menu() menu.add('Fake screen size', fake_screen_size_menu) menu.add('Get screen size', lambda: ui.set_dialog(ui.Label(str(ui.screen_size)))) menu.add('Change feature', change_feature) menu.add('Pernament feature', pernament_feature) menu.add('Show features', show_features) menu.add('Cause exception', lambda: 1 / 0) menu.add('Test Market URL', osutil.open_market) menu.add('Test inputbox', test_inputbox) menu.add('Eval', test_eval) ui.set(ui.ScrollWrapper(menu))
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)
def show(self): ui.set(self)
def popup_city_dialog(self, city): dialog = citydlg.Dialog(self, city) ui.set(dialog.ui)
def feedback(): panel = ui.LinearLayoutWidget() panel.add(ui.Label('Leaving comments with logs will help me diagnose\npotential problems with game speed and\nunexpected behaviour.')) panel.add(ui.Button('Leave a comment with a log (preferred)', lambda: sync.comment(get_install_time(), True))) panel.add(ui.Button('Leave a comment without a log', lambda: sync.comment(get_install_time(), False))) ui.set(panel)
def connect(host, port, login='******'): ui.set(ServerGUI(host=host, port=port, login=login, no_quit=True))
def show(client): widget = TechTreeWidget() widget = ui.ScrollWrapper(widget, ways=ui.SCROLL_WIDTH | ui.SCROLL_HEIGHT) ui.set(widget)