Example #1
0
def open_gold_link(then, restart):
    features.set_perm('gold.initiated', True)
    osutil.open_url('%s://%s/sync/login?then=%s&sid=%s' % (
        sync.PROTO, sync.HOST, then, sync.get_sid()))

    def callback():
        ui.async(lambda: check_products(force=True))

    if restart:
        ui.set_dialog(ui.Button('Touch after finishing transaction', callback))
Example #2
0
def change_joystick():
    def set_type(name):
        features.set_perm('app.joystick', name)
        ui.back()

    types = ['new', 'tile']
    panel = ui.LinearLayoutWidget()

    for type in types:
        panel.add(ui.Button(type.capitalize(), functools.partial(set_type, type)))

    ui.set_dialog(panel)
Example #3
0
def change_ruleset():
    def set_ruleset(name):
        features.set_perm('app.ruleset', name)
        ui.back()

    rulesets = ['default', 'civ1', 'civ2']
    panel = ui.LinearLayoutWidget()

    for ruleset in rulesets:
        panel.add(ui.Button(ruleset, functools.partial(set_ruleset, ruleset)))

    ui.set_dialog(panel)
Example #4
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))
Example #5
0
def ask_if_sharing_allowed(then):
    def notokay():
        features.set_perm('civsync.allow_sharing', 'false')
        ui.back()
        then()

    def okay():
        features.set_perm('civsync.allow_sharing', 'true')
        ui.back()
        then()

    msg = \
          'civsync.com may put saves you upload to Dropbox on a public list, for others to play.' \
          '\n\n' \
          'By clicking "I agree" you share your saves on CC0 license (public domain) ' \
          'and allow Freeciv to upload them to civsync.com.'.strip()

    dialog = ui.LinearLayoutWidget()
    panel = ui.HorizontalLayoutWidget(spacing=10)
    panel.add(ui.Button('I agree', okay))
    panel.add(ui.Button('I don\'t agree', notokay))
    dialog.add(help.LongTextWidget(msg, ui.screen_width / 3, ui.smallfont))
    dialog.add(panel)
    ui.set_dialog(dialog)
Example #6
0
 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)
Example #7
0
 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)