Exemple #1
0
 def change(type, val):
     tpl[type] += val * 10
     tpl[0] -= val * 10
     a, b, c = map(lambda x: max(0, min(100, x)), tpl)
     self.client.set_tax_values(a, b, c)
     ui.get_screen().tick()
     self.update()
     ui.execute_later(self.update)
 def change(type, val):
     tpl[type] += val * 10
     tpl[0] -= val * 10
     a, b, c = map(lambda x: max(0, min(100, x)), tpl)
     self.client.set_tax_values(a, b, c)
     ui.get_screen().tick()
     self.update()
     ui.execute_later(self.update)
Exemple #3
0
 def get_city_dialog(self, city):
     if isinstance(ui.get_screen(), ui.ScrollWrapper):
         item = ui.get_screen().item
     else:
         item = ui.get_screen()
     if isinstance(item, citydlg.Dialog) and item.city == city:
         return item
     else:
         return None
 def get_city_dialog(self, city):
     if isinstance(ui.get_screen(), ui.ScrollWrapper):
         item = ui.get_screen().item
     else:
         item = ui.get_screen()
     if isinstance(item, citydlg.Dialog) and item.city == city:
         return item
     else:
         return None
Exemple #5
0
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
Exemple #6
0
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
Exemple #7
0
def run():
    ui.set_fill_image(None)
    start = time.time()
    data = graphics.read_window_data()
    compressed = write_image(data, graphics.get_window().get_size())
    stats = {
        'size': len(compressed),
        'time': int((time.time() - start) * 1000)
    }

    data = []
    screen_id = id(ui.get_screen())
    data.append({
        'type': 'frame',
        'data': _cached_image(screen_id, compressed),
        'id': screen_id,
        'back': id(ui.history[0]) if ui.history else None,
        'allow_animation': ui.get_allow_animation(),
        'pos': [0, 0]
    })

    data += _messages
    _messages[:] = []

    def proc_layer(id, surf, pos, offset, size):
        if surf and (surf.get_width() == 0 or surf.get_height() == 0):
            surf = None
        image_data = get_texture_data(surf) if surf else None
        data.append({
            'type': 'layer',
            'layerid': id,
            'data': _cached_image(id, image_data),
            'pos': pos,
            'offset': offset,
            'size': size,
        })

    for layer in layers:
        proc_layer(**layer)

    os.write(features.get('stream.fd'), json.dumps(data) + '\n')

    layers[:] = []
    ui.draw_hooks.add(run)
Exemple #8
0
def run():
    ui.set_fill_image(None)
    start = time.time()
    data = graphics.read_window_data()
    compressed = write_image(data)
    stats = {'size': len(compressed),
             'time': int((time.time() - start) * 1000)}

    data = []
    data.append({
        'type': 'frame',
        'data': compressed.encode('base64'),
        'id': id(ui.get_screen()),
        'back': id(ui.history[0]) if ui.history else None,
        'allow_animation': ui.get_allow_animation()})

    for frame in data:
        os.write(features.get('stream.fd'), json.dumps(frame) + '\n')
    ui.draw_hooks.add(run)
Exemple #9
0
def run():
    ui.set_fill_image(None)
    start = time.time()
    data = graphics.read_window_data()
    compressed = write_image(data, graphics.get_window().get_size())
    stats = {'size': len(compressed),
             'time': int((time.time() - start) * 1000)}

    data = []
    screen_id = id(ui.get_screen())
    data.append({
        'type': 'frame',
        'data': _cached_image(screen_id, compressed),
        'id': screen_id,
        'back': id(ui.history[0]) if ui.history else None,
        'allow_animation': ui.get_allow_animation(),
        'pos': [0, 0]})

    data += _messages
    _messages[:] = []

    def proc_layer(id, surf, pos, offset, size):
        if surf and (surf.get_width() == 0 or surf.get_height() == 0):
            surf = None
        image_data = get_texture_data(surf) if surf else None
        data.append({
            'type': 'layer',
            'layerid': id,
            'data': _cached_image(id, image_data),
            'pos': pos,
            'offset': offset,
            'size': size,
        })

    for layer in layers:
        proc_layer(**layer)

    os.write(features.get('stream.fd'), json.dumps(data) + '\n')

    layers[:] = []
    ui.draw_hooks.add(run)
Exemple #10
0
 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)