示例#1
0
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)

    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))
示例#2
0
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))
示例#3
0
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)
示例#4
0
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))