def _callback(self):
     try:
         val = features.get(self.feature_key)
         features.set_perm(self.feature_key, not val)
     except ValueError as e:
         ui.message(str(e), type='error')
     self.make_button()
示例#2
0
 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))
def _auth_finished():
    print '_auth_finished'
    key = DropboxHelper.tokenKey
    secret = DropboxHelper.tokenSecret
    features.set_perm('civsync.key', key)
    features.set_perm('civsync.secret', secret)
    tell_civsync()
示例#4
0
 def _callback(self):
     try:
         val = features.get(self.feature_key)
         features.set_perm(self.feature_key, not val)
     except ValueError as e:
         ui.message(str(e), type='error')
     self.make_button()
示例#5
0
def _auth_finished():
    print '_auth_finished'
    key = DropboxHelper.tokenKey
    secret = DropboxHelper.tokenSecret
    features.set_perm('civsync.key', key)
    features.set_perm('civsync.secret', secret)
    tell_civsync()
 def finish():
     try:
         k, v = arg.split('=', 1)
         features.set_perm(k, v)
     except Exception as e:
         traceback.print_exc()
         ui.message(str(e))
示例#7
0
 def _callback(self):
     val = uidialog.inputbox('Value for %s' % self.feature_key)
     try:
         features.set_perm(self.feature_key, val)
     except ValueError as e:
         ui.message(str(e), type='error')
     self.make_button()
示例#8
0
def _auth_finished():
    print "_auth_finished"
    key = DropboxHelper.tokenKey
    secret = DropboxHelper.tokenSecret
    features.set_perm("civsync.key", key)
    features.set_perm("civsync.secret", secret)
    tell_civsync()
示例#9
0
 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))
示例#10
0
 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))
示例#11
0
 def _callback(self):
     val = uidialog.inputbox('Value for %s' % self.feature_key)
     if val is None: return
     try:
         features.set_perm(self.feature_key, val)
     except ValueError as e:
         ui.message(str(e), type='error')
     self.make_button()
示例#12
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))
示例#13
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))
def _message_checker():
    if DropboxHelper.needAuth:
        print 'Authentication requested by DropboxHelper'
        DropboxHelper.needAuth = False
        features.set_perm('civsync.key', None)
        features.set_perm('civsync.secret', None)
        login()

    msg = DropboxHelper.getMessage()
    if msg:
        print 'showing message from DropboxHelper', msg
        ui.message(msg)
    ui.execute_later(_message_checker)
示例#15
0
def _message_checker():
    if DropboxHelper.needAuth:
        print 'Authentication requested by DropboxHelper'
        DropboxHelper.needAuth = False
        features.set_perm('civsync.key', None)
        features.set_perm('civsync.secret', None)
        login()

    msg = DropboxHelper.getMessage()
    if msg:
        print 'showing message from DropboxHelper', msg
        ui.message(msg)
    ui.execute_later(_message_checker)
示例#16
0
def check_products(force=False):
    resp = sync.json_request_with_sid('/sale/products')
    if 'gold0plus' in resp:
        features.set_perm('gold.status', 'gold0plus')
    elif 'gold0' in resp:
        features.set_perm('gold.status', 'gold0')

    if 'session_warning' in resp:
        features.set('gold.session_warning', True)

    if force:
        ui.history = []

    redisplay_menu()
示例#17
0
def check_products(force=False):
    resp = sync.json_request_with_sid('/sale/products')
    if 'gold0plus' in resp:
        features.set_perm('gold.status', 'gold0plus')
    elif 'gold0' in resp:
        features.set_perm('gold.status', 'gold0')

    if 'session_warning' in resp:
        features.set('gold.session_warning', True)

    if force:
        ui.history = []

    redisplay_menu()
示例#18
0
 def set_ruleset(name):
     features.set_perm('app.ruleset', name)
     ui.back()
示例#19
0
 def set_difficulty(name):
     features.set_perm('app.difficulty', name)
     difficulty_button.set_text('Default difficulty for new games: ' + name)
     ui.back()
示例#20
0
def change_screen_size(size):
    features.set_perm('app.forcesize', ('%d,%d' % size) if size else '')
    ui.history = []
    ui.screen = None
    import main
    main.main(init=False)
示例#21
0
 def set_type(name):
     features.set_perm('app.joystick', name)
     ui.back()
示例#22
0
 def okay():
     features.set_perm("civsync.allow_sharing", "true")
     ui.back()
     then()
示例#23
0
 def notokay():
     features.set_perm("civsync.allow_sharing", "false")
     ui.back()
     then()
示例#24
0
 def set_type(name):
     features.set_perm('app.joystick', name)
     ui.back()
示例#25
0
 def finish(val):
     try:
         features.set_perm(self.feature_key, val)
     except ValueError as e:
         ui.message(str(e), type='error')
     self.make_button()
示例#26
0
def get_sid():
    sid = features.get('civsync.sid')
    if not sid:
        sid = ''.join( hex(ord(ch))[2:] for ch in os.urandom(8) )
        features.set_perm('civsync.sid', sid)
    return sid
示例#27
0
 def never():
     features.set_perm('app.marketnotice', False)
     ui.back()
示例#28
0
 def okay():
     features.set_perm('civsync.allow_sharing', 'true')
     ui.back()
     then()
示例#29
0
 def set_ruleset(name):
     features.set_perm('app.ruleset', name)
     ui.back()
示例#30
0
def get_sid():
    sid = features.get('civsync.sid')
    if not sid:
        sid = ''.join( hex(ord(ch))[2:] for ch in os.urandom(8) )
        features.set_perm('civsync.sid', sid)
    return sid
示例#31
0
 def finish(val):
     try:
         features.set_perm(self.feature_key, val)
     except ValueError as e:
         ui.message(str(e), type='error')
     self.make_button()
示例#32
0
 def notokay():
     features.set_perm('civsync.allow_sharing', 'false')
     ui.back()
     then()
示例#33
0
def change_screen_size(size):
    features.set_perm('app.forcesize', ('%d,%d' % size) if size else '')
    ui.history = []
    ui.screen = None
    import main
    main.main(init=False)
示例#34
0
 def okay():
     features.set_perm('civsync.allow_sharing', 'true')
     ui.back()
     then()
示例#35
0
 def never():
     features.set_perm('app.marketnotice', False)
     ui.back()
示例#36
0
 def notokay():
     features.set_perm('civsync.allow_sharing', 'false')
     ui.back()
     then()