Exemple #1
0
 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
Exemple #2
0
 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 _finish():
     if text.label:
         graphics.stop_text_input()
         finish(text.label)
         ui.back(allow_override=False)
     else:
         _cancel()
Exemple #4
0
def downloaded(data):
    ui.set_dialog(ui.Label("Loading save..."))
    uncompressed = lzma.decompress(data)
    print "Uncompressed size", len(uncompressed)
    dl_path = save.get_save_dir() + "/downloaded_save"
    try:
        os.remove(dl_path)
    except OSError:
        print "not removed..."
    with open(dl_path, "wb") as f:
        f.write(uncompressed)
    ui.back(anim=False)
    save.load_game(dl_path)
Exemple #5
0
def downloaded(data):
    ui.set_dialog(ui.Label('Loading save...'))
    uncompressed = lzma.decompress(data)
    print 'Uncompressed size', len(uncompressed)
    dl_path = save.get_save_dir() + '/downloaded_save'
    try:
        os.remove(dl_path)
    except OSError:
        print 'not removed...'
    with open(dl_path, 'wb') as f:
        f.write(uncompressed)
    ui.back(anim=False)
    save.load_game(dl_path)
Exemple #6
0
def downloaded(data):
    ui.set_dialog(ui.Label('Loading save...'))
    uncompressed = lzma.decompress(data)
    print 'Uncompressed size', len(uncompressed)
    dl_path = save.get_save_dir() + '/downloaded_save'
    try:
        os.remove(dl_path)
    except OSError:
        print 'not removed...'
    with open(dl_path, 'wb') as f:
        f.write(uncompressed)
    ui.back(anim=False)
    save.load_game(dl_path)
Exemple #7
0
def pause():
    if client.client:
        print 'pause occured'
        print 'saving game'
        client.client.chat('/save %s/pause_save.sav.gz' % save.get_save_dir())
        with open(pause_file, 'w') as f:
            f.write('version=1\n')
        time.sleep(features.get('app.shutdown'))
        if not osutil.is_paused():
            remove_pause_file()
            return
        print 'turning off server'
        client.client.disconnect()
        ui.back(allow_override=False)
        osutil.wait_for_resume()
        resume()
    else:
        osutil.wait_for_resume()
Exemple #8
0
def pause():
    if client.client:
        print 'pause occured'
        print 'saving game'
        client.client.chat('/save %s/pause_save.sav.gz' % save.get_save_dir())
        with open(pause_file, 'w') as f:
            f.write('version=1\n')
        time.sleep(featues.get('app.shutdown'))
        if not osutil.is_paused():
            remove_pause_file()
            return
        print 'turning off server'
        client.client.disconnect()
        ui.back(allow_override=False)
        osutil.wait_for_resume()
        resume()
    else:
        osutil.wait_for_resume()
def comment_upload(install_time):
    ui.execute_later(lambda: ui.message('Compressing log...'))

    content = lzma.compress(open(save.get_save_dir() + '/more.log').read())

    ui.execute_later(lambda: ui.back())

    request(lambda result: comment_next(install_time), 'upload_log', content, install_time,
            banner="Uploading log (%dkB)" % (len(content)/1024))
Exemple #10
0
def pause():
    if client.client:
        print "pause occured"
        print "saving game"
        client.client.chat("/save %s/pause_save.sav.gz" % save.get_save_dir())
        with open(pause_file, "w") as f:
            f.write("version=1\n")
        time.sleep(features.get("app.shutdown"))
        if not osutil.is_paused():
            remove_pause_file()
            return
        print "turning off server"
        client.client.disconnect()
        ui.back(allow_override=False)
        osutil.wait_for_resume()
        resume()
    else:
        osutil.wait_for_resume()
Exemple #11
0
def comment_upload(install_time):
    ui.execute_later(lambda: ui.message('Compressing log...'))

    content = lzma.compress(open(save.get_save_dir() + '/more.log').read())

    ui.execute_later(lambda: ui.back())

    request(lambda result: comment_next(install_time),
            'upload_log',
            content,
            install_time,
            banner="Uploading log (%dkB)" % (len(content) / 1024))
Exemple #12
0
def comment_upload(install_time):
    with ui.execute_later_lock:
        ui.execute_later.append(lambda: ui.message("Compressing log..."))

    content = lzma.compress(open(save.get_save_dir() + "/more.log").read())

    with ui.execute_later_lock:
        ui.execute_later.append(lambda: ui.back())

    request(
        lambda result: comment_next(install_time),
        "upload_log",
        content,
        install_time,
        banner="Uploading log (%dkB)" % (len(content) / 1024),
    )
def sync_request(callback, name, args, kwargs):
    func = getattr(client(), name)
    try:
        try:
            result = func(*args, **kwargs)
        except civsync.LoginError as err:
            print 'Login failed:', err
            ui.back(anim=False)
            self = lambda: request(callback, name, *args, **kwargs)
            ui.execute_later(lambda: show_login_form(self, str(err)))
            return
    except Exception as err:
        traceback.print_exc()
        ui.back(anim=False)
        ui.execute_later(lambda: ui.message('Failed to connect to the internet'))
        return
    ui.back(anim=False)
    ui.execute_later(lambda: callback(result))
Exemple #14
0
def sync_request(callback, name, args, kwargs):
    func = getattr(client(), name)
    try:
        try:
            result = func(*args, **kwargs)
        except civsync.LoginError as err:
            print 'Login failed:', err
            ui.back(anim=False)
            self = lambda: request(callback, name, *args, **kwargs)
            ui.execute_later(lambda: show_login_form(self, str(err)))
            return
    except Exception as err:
        traceback.print_exc()
        ui.back(anim=False)
        ui.execute_later(
            lambda: ui.message('Failed to connect to the internet'))
        return
    ui.back(anim=False)
    ui.execute_later(lambda: callback(result))
 def quit():
     self.disconnect()
     ui.back(anim=False) # close dialog
     ui.back(allow_override=False) # close game
Exemple #16
0
def load_game_now(port, username):
    client.client.chat('/take "%s"' % username)
    client.client.chat('/start')
    client.client.tick()
    ui.back(allow_override=False)
Exemple #17
0
 def clicked(it):
     ui.back(anim=False)
     (callback or default_callback)(it)
Exemple #18
0
 def do_login():
     ui.back(anim=False)
     request(logged, 'login', login_field.get_value(),
             passwd_field.get_value())
Exemple #19
0
def comment_next(install_time):
    ui.back()
    uidialog.open_url(
        'http://%s/comment?install_time=%s&sid=%s&ua=%s' %
        (civsync.HOST, install_time, client()._sessid, civsync.USER_AGENT))
 def commit_government_change(gov):
     gov.change_to()
     ui.back()
Exemple #21
0
def logout():
    request(lambda d: ui.back(), 'logout')
 def set_type(name):
     features.set_perm('app.joystick', name)
     ui.back()
 def meet(player):
     ui.back()
     ui.back()
     player.meet()
 def fcallback(action_ident):
     self.client.get_unit_in_focus().perform_activity(action_ident)
     ui.back()
Exemple #25
0
def save_and_sync(client):
    old_set = set(list_saves(save.get_save_dir()))
    client.chat('/save')
    ui.back()
    threading.Thread(target=save_and_sync_next_step, args=(old_set, )).start()
Exemple #26
0
def load_game_now(port, username):
    client.client.chat('/take "%s"' % username)
    client.client.chat('/%s' % features.get('app.difficulty'))
    client.client.chat('/start')
    client.client.tick()
    ui.back(allow_override=False)
Exemple #27
0
 def set_nation(style, id):
     self.city_style = style
     self.nation_id = id
     self.set_nation_settings()
     ui.back()
Exemple #28
0
 def back(self):
     client.client.disconnect()
     ui.back(allow_override=False)
 def save():
     self.chat('/save')
     ui.back()
Exemple #30
0
 def set_goal(tech):
     getattr(tech, func)()
     self.setup_ui()
     ui.back()
 def save_db():
     ui.back()
     self.save_and_get_name(lambda path: dropbox.save(path))
Exemple #32
0
 def do_break_treaty(player, type):
     player.cancel_pact(type)
     ui.back()
     ui.back()
Exemple #33
0
 def call_callback():
     callback()
     ui.back()
Exemple #34
0
 def quit():
     self.disconnect()
     ui.back(anim=False)  # close dialog
     ui.back(allow_override=False)  # close game
Exemple #35
0
 def close(self):
     if self.is_opened():
         ui.back()
Exemple #36
0
 def save_db():
     ui.back()
     self.save_and_get_name(lambda path: dropbox.save(path))
 def set_goal(tech):
     tech.set_as_goal()
     ui.back()
Exemple #38
0
 def back(self):
     ui.back(allow_override=False, anim=False)
 def set_ruleset(name):
     features.set_perm('app.ruleset', name)
     ui.back()
Exemple #40
0
 def okay():
     features.set_perm('civsync.allow_sharing', 'true')
     ui.back()
     then()
 def set_ruleset(name):
     features.set_perm('app.ruleset', name)
     ui.back()
 def set_type(name):
     features.set_perm('app.joystick', name)
     ui.back()
 def set_goal(tech):
     getattr(tech, func)()
     self.setup_ui()
     ui.back()
Exemple #44
0
 def never():
     features.set_perm('app.marketnotice', False)
     ui.back()
 def do_break_treaty(player, type):
     player.cancel_pact(type)
     ui.back()
     ui.back()
Exemple #46
0
 def back(self):
     ui.back(allow_override=False, anim=False)
Exemple #47
0
 def meet(player):
     ui.back()
     ui.back()
     player.meet()
Exemple #48
0
 def close(self):
     if self.is_opened():
         ui.back()
Exemple #49
0
 def focus(unit):
     unit.focus()
     ui.back()
Exemple #50
0
 def call_callback():
     callback()
     ui.back()
Exemple #51
0
 def save():
     self.chat('/save')
     ui.back()
Exemple #52
0
 def clicked(it):
     ui.back(anim=False)
     (callback or default_callback)(it)
Exemple #53
0
 def commit_government_change(gov):
     gov.change_to()
     ui.back()
Exemple #54
0
 def fcallback(action_ident):
     self.client.get_unit_in_focus().perform_activity(action_ident)
     ui.back()
Exemple #55
0
 def never():
     features.set_perm('app.marketnotice', False)
     ui.back()
 def focus(unit):
     unit.focus()
     ui.back()