def handle_input(): global EXIT_MENU if QUIT: return False if settings.TICK_MODE in ['normal', 'strategy']: if controls.get_input_ord_pressed(constants.KEY_ESCAPE): if ui_dialog.get_active_dialog(): ui_dialog.delete(ui_dialog.get_active_dialog()) elif EXIT_MENU: return False elif ui_menu.get_active_menu(): _menu = ui_menu.get_active_menu() ui_menu.delete(_menu) if ui_panel.ACTIVE_MENU == _menu: ui_panel.close() else: EXIT_MENU = ui_menu.create((constants.WINDOW_WIDTH / 2) - 2, 18, title='Menu') ui_menu.add_selectable(EXIT_MENU, 'Quit', lambda: _quit()) if settings.TICK_MODE == 'strategy': ui_squad_control.handle_keyboard_input() if controls.get_input_char_pressed('k'): display.screenshot('screenshot-%s.bmp' % time.time()) return True
def handle_player_received_memory(entity, memory, message, member_id): _member = entities.get_entity(member_id) ui_dialog.create(5, 5, message, title='Dialog with %s' % _member['stats']['name']) _m = ui_menu.create(5, 15, title='Respond') for life_id in memory: if not life_id in entity['ai']['life_memory']: life.create_life_memory(entity, life_id) entity['ai']['life_memory'][life_id].update(memory[life_id]) ui_menu.add_selectable(_m, 'Bribe', lambda: 1==1 and ui_dialog.delete(ui_dialog.ACTIVE_DIALOG)) ui_menu.add_selectable(_m, 'Leave', lambda: 1==1 and ui_dialog.delete(ui_dialog.ACTIVE_DIALOG))
def focus_on_entity(entity, target_id, show_line=False, pause=False): global HAS_FOCUS, PAUSE if HAS_FOCUS or '--no-fx' in sys.argv: return HAS_FOCUS = target_id PAUSE = pause _entity = ui_dialog.create(18, 7, 'Enemy spotted!') entities.register_event(_entity, 'delete', lambda e: lose_focus()) entities.trigger_event(DIRECTOR, 'create_timer', time=120, exit_callback=lambda e: ui_dialog.delete(_entity)) if show_line: for x, y in shapes.line(movement.get_position(entity), movement.get_position_via_id(target_id)): effects.vapor(x, y, group='effects_freetick', start_alpha=1.0, fade_rate=.01)
def show_mission_details(entity, mission): entities.trigger_event(mission, 'get_briefing') _menu = ui_menu.create((constants.MAP_VIEW_WIDTH/2) - 10, (constants.MAP_VIEW_HEIGHT/2) - 10, title='Mission') ui_menu.add_selectable(_menu, 'Accept', lambda: accept_mission(entity, mission['_id'])) ui_menu.add_selectable(_menu, 'Decline', lambda: ui_dialog.delete(ui_dialog.ACTIVE_DIALOG))
def show_mission_details(entity, mission): entities.trigger_event(mission, 'get_briefing') _menu = ui_menu.create((constants.MAP_VIEW_WIDTH / 2) - 10, (constants.MAP_VIEW_HEIGHT / 2) - 10, title='Mission') ui_menu.add_selectable(_menu, 'Accept', lambda: accept_mission(entity, mission['_id'])) ui_menu.add_selectable(_menu, 'Decline', lambda: ui_dialog.delete(ui_dialog.ACTIVE_DIALOG))
def handle_player_received_memory(entity, memory, message, member_id): _member = entities.get_entity(member_id) ui_dialog.create(5, 5, message, title='Dialog with %s' % _member['stats']['name']) _m = ui_menu.create(5, 15, title='Respond') for life_id in memory: if not life_id in entity['ai']['life_memory']: life.create_life_memory(entity, life_id) entity['ai']['life_memory'][life_id].update(memory[life_id]) ui_menu.add_selectable( _m, 'Bribe', lambda: 1 == 1 and ui_dialog.delete(ui_dialog.ACTIVE_DIALOG)) ui_menu.add_selectable( _m, 'Leave', lambda: 1 == 1 and ui_dialog.delete(ui_dialog.ACTIVE_DIALOG))
def accept_mission(entity, mission_id): entities.trigger_event(entity, 'add_mission', mission_id=mission_id) ui_dialog.delete(ui_dialog.ACTIVE_DIALOG)