Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
def create_item_menu(entity, item, x, y, on_path=False):
    _menu = ui_menu.create(ui_cursor.CURSOR['tile']['x'] + 2,
                           ui_cursor.CURSOR['tile']['y'] - 1,
                           title='Context')

    if items.get_list_of_free_holders(
            entity, item['_id']) and item['stats']['equip_to']:
        ui_menu.add_selectable(
            _menu, 'Equip', lambda: create_action_node(
                entity,
                x,
                y,
                30,
                lambda: entities.trigger_event(
                    entity, 'get_and_hold_item', item_id=item['_id']),
                name='Equip %s' % item['stats']['name'],
                on_path=on_path))

    if items.get_list_of_free_containers(entity, item['_id']):
        ui_menu.add_selectable(
            _menu, 'Store', lambda: create_action_node(
                entity,
                x,
                y,
                30,
                lambda: entities.trigger_event(
                    entity, 'get_and_store_item', item_id=item['_id']),
                name='Store %s' % item['stats']['name'],
                on_path=on_path))

    entities.trigger_event(item,
                           'get_interactions',
                           menu=_menu,
                           target_id=entity['_id'])
Ejemplo n.º 3
0
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))
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
def create_action_menu(entity, x, y, on_path=False):
	_menu = ui_menu.create(ui_cursor.CURSOR['tile']['x']+2, ui_cursor.CURSOR['tile']['y']-1, title='Context')
	
	if items.get_items_in_holder(entity, 'weapon'):
		ui_menu.add_selectable(_menu, 'Shoot', lambda: select_target(x, y, on_path))
	
	ui_menu.add_selectable(_menu, 'Reload', lambda: create_action_node(entity,
	                                                                   x,
	                                                                   y,
	                                                                   30,
	                                                                   lambda: entities.trigger_event(entity, 'reload'),
	                                                                   name='Reload',
	                                                                   on_path=on_path))
	ui_menu.add_selectable(_menu, 'Crouch', lambda: create_action_node(entity,
	                                                                   x,
	                                                                   y,
	                                                                   30,
	                                                                   lambda: entities.trigger_event(entity, 'set_motion', motion='crouch'),
	                                                                   name='Crouch',
	                                                                   on_path=on_path))
	ui_menu.add_selectable(_menu, 'Crawl', lambda: create_action_node(entity,
	                                                                   x,
	                                                                   y,
	                                                                   30,
	                                                                   lambda: entities.trigger_event(entity, 'set_motion', motion='crawl'),
	                                                                   name='Prone',
	                                                                   on_path=on_path))
	ui_menu.add_selectable(_menu, 'Stand', lambda: create_action_node(entity,
	                                                                   x,
	                                                                   y,
	                                                                   30,
	                                                                   lambda: entities.trigger_event(entity, 'set_motion', motion='stand'),
	                                                                   name='Stand',
	                                                                   on_path=on_path))
Ejemplo n.º 6
0
def show_weapons(entity):
	global ACTIVE_MENU, REDRAW_TIMES

	_holder_menu = ui_menu.create(1, 1, title='Weapons', surface='ui_inventory', click_offset=(constants.MAP_VIEW_WIDTH-35, 0))
	ACTIVE_MENU = _holder_menu
	REDRAW_TIMES = 3

	_equipped_weapon = items.get_items_in_holder(entity, 'weapon')
	_weapons = []
	
	if _equipped_weapon:
		_weapons.append(_equipped_weapon[0])
	
	for item_id in items.get_items_matching(entity, {'type': 'weapon'}):
		if item_id in _weapons:
			continue
		
		_weapons.add(item_id)
	
	for item_id in _weapons:
		_item = entities.get_entity(item_id)
		
		entities.trigger_event(_item, 'get_display_name')
		
		if item_id in _equipped_weapon:
			_fg = (245, 245, 245)
		else:
			_fg = (230, 230, 230)

		ui_menu.add_selectable(_holder_menu,
		                       _item['stats']['display_name'],
		                       show_weapon_menu,
		                       fore_color=_fg,
		                       item_id=item_id)
Ejemplo n.º 7
0
def get_mission_details(mission, menu, member_id, target_id):
	_target = entities.get_entity(target_id)
	
	for goal_id in mission['goals']:
		_goal = entities.get_entity(goal_id)
		
		for detail in _goal['details']:
			ui_menu.add_selectable(menu, detail['message'], lambda: detail['callback'](member_id, target_id))
Ejemplo n.º 8
0
def create_talk_menu(entity, target_id):
	_menu = ui_menu.create(LAST_CLICKED_POS[0]-camera.X+2, LAST_CLICKED_POS[1]-camera.Y-4, title='Talk')
	_target = entities.get_entity(target_id)
	
	for mission_id in _target['missions']['inactive']:
		_mission = entities.get_entity(mission_id)
		
		ui_menu.add_selectable(_menu, _mission['title'], lambda: show_mission_details(entity, _mission))
Ejemplo n.º 9
0
def show_inventory(entity):
	global ACTIVE_MENU

	display.fill_surface('ui_inventory', (45, 45, 45))
	events.register_event('draw', draw)

	_holder_menu = ui_menu.create(1, 1, title='Inventory', surface='ui_inventory', click_offset=(constants.MAP_VIEW_WIDTH-35, 0))
	ACTIVE_MENU = _holder_menu

	ui_menu.add_selectable(_holder_menu, 'Weapon', lambda: show_weapons(entity))
Ejemplo n.º 10
0
def get_mission_details(mission, menu, member_id, target_id):
    _target = entities.get_entity(target_id)

    for goal_id in mission['goals']:
        _goal = entities.get_entity(goal_id)

        for detail in _goal['details']:
            ui_menu.add_selectable(
                menu, detail['message'], lambda: detail['callback']
                (member_id, target_id))
Ejemplo n.º 11
0
def create_talk_menu(entity, target_id):
    _menu = ui_menu.create(LAST_CLICKED_POS[0] - camera.X + 2,
                           LAST_CLICKED_POS[1] - camera.Y - 4,
                           title='Talk')
    _target = entities.get_entity(target_id)

    for mission_id in _target['missions']['inactive']:
        _mission = entities.get_entity(mission_id)

        ui_menu.add_selectable(_menu, _mission['title'],
                               lambda: show_mission_details(entity, _mission))
Ejemplo n.º 12
0
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))
Ejemplo n.º 13
0
def create_shoot_menu(entity, target_id):
	_tx, _ty = movement.get_position_via_id(target_id)
	_weapon = entities.get_entity(items.get_items_in_holder(entity, 'weapon')[0])
	_menu = ui_menu.create(_tx-camera.X+2, _ty-camera.Y-4, title='Shoot')
	_accuracy = stats.get_accuracy(entity, _weapon['_id'])
	_x, _y = movement.get_position(entity)
	_direction = numbers.direction_to((_x, _y), (_tx, _ty))
	_final_direction = _direction + (_accuracy * numbers.distance((_x, _y), (_tx, _ty)))
	_spray_accuracy = (100 * (_direction / float(_final_direction)))
	
	entities.trigger_event(_weapon, 'get_actions', menu=_menu)
	ui_menu.add_selectable(_menu, 'Spray (Acc: %.2d)' % _spray_accuracy, lambda: entities.trigger_event(entity, 'shoot', target_id=target_id) and settings.set_tick_mode('normal'))
	ui_menu.add_selectable(_menu, 'Snipe (Acc: %s)' % _accuracy, lambda: _)
Ejemplo n.º 14
0
def create_action_menu(entity, x, y, on_path=False):
    _menu = ui_menu.create(ui_cursor.CURSOR['tile']['x'] + 2,
                           ui_cursor.CURSOR['tile']['y'] - 1,
                           title='Context')

    if items.get_items_in_holder(entity, 'weapon'):
        ui_menu.add_selectable(_menu, 'Shoot',
                               lambda: select_target(x, y, on_path))

    ui_menu.add_selectable(
        _menu, 'Reload',
        lambda: create_action_node(entity,
                                   x,
                                   y,
                                   30,
                                   lambda: entities.trigger_event(
                                       entity, 'reload'),
                                   name='Reload',
                                   on_path=on_path))
    ui_menu.add_selectable(
        _menu, 'Crouch',
        lambda: create_action_node(entity,
                                   x,
                                   y,
                                   30,
                                   lambda: entities.trigger_event(
                                       entity, 'set_motion', motion='crouch'),
                                   name='Crouch',
                                   on_path=on_path))
    ui_menu.add_selectable(
        _menu, 'Crawl',
        lambda: create_action_node(entity,
                                   x,
                                   y,
                                   30,
                                   lambda: entities.trigger_event(
                                       entity, 'set_motion', motion='crawl'),
                                   name='Prone',
                                   on_path=on_path))
    ui_menu.add_selectable(
        _menu, 'Stand',
        lambda: create_action_node(entity,
                                   x,
                                   y,
                                   30,
                                   lambda: entities.trigger_event(
                                       entity, 'set_motion', motion='stand'),
                                   name='Stand',
                                   on_path=on_path))
Ejemplo n.º 15
0
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))
Ejemplo n.º 16
0
def _handle_mutated_wild_dog_corpse(entity, corpse_id):
    _corpse = entities.get_entity(corpse_id)

    entities.register_event(
        _corpse, 'get_interactions',
        lambda e, menu, target_id: ui_menu.add_selectable(
            menu, 'Cut off tail', lambda: _handle_cut_tail(e, target_id)))
Ejemplo n.º 17
0
def show_inventory(entity):
    global ACTIVE_MENU

    display.fill_surface('ui_inventory', (45, 45, 45))
    events.register_event('draw', draw)

    _holder_menu = ui_menu.create(1,
                                  1,
                                  title='Inventory',
                                  surface='ui_inventory',
                                  click_offset=(constants.MAP_VIEW_WIDTH - 35,
                                                0))
    ACTIVE_MENU = _holder_menu

    ui_menu.add_selectable(_holder_menu, 'Weapon',
                           lambda: show_weapons(entity))
Ejemplo n.º 18
0
def _show_metas(entity):
	_keys = entity['ai']['meta'].keys()
	_keys.sort()
	
	for meta_key in _keys:
		print meta_key, entity['ai']['meta'][meta_key]
	return
	_menu = ui_menu.create(0, 0, title='Metas')
	_keys = entity['ai']['meta'].keys()
	_keys.sort()
	
	for meta_key in _keys:
		if entity['ai']['meta'][meta_key]:
			_color = (0, 200, 0)
		else:
			_color = (200, 0, 0)
		
		ui_menu.add_selectable(_menu, '%s: %s' % (meta_key, entity['ai']['meta'][meta_key]), lambda: _show_metas(_entity), fore_color=_color)
Ejemplo n.º 19
0
def show_weapon_menu(item_id):
	global ACTIVE_MENU, REDRAW_TIMES
	
	_holder_menu = ui_menu.create(1, 1, title='Actions', surface='ui_inventory', click_offset=(constants.MAP_VIEW_WIDTH-35, 0))
	ACTIVE_MENU = _holder_menu
	REDRAW_TIMES = 3
	
	_item = entities.get_entity(item_id)
	
	#entities.trigger_event(_item, 'get_actions', menu=_holder_menu)
	
	ui_menu.add_selectable(_holder_menu,
	                       'Reload',
	                       lambda: show_weapon_menu,
	                       item_id=item_id)
	ui_menu.add_selectable(_holder_menu,
	                       'Store',
	                       lambda: show_weapon_menu,
	                       item_id=item_id)
Ejemplo n.º 20
0
def create_shoot_menu(entity, target_id):
    _tx, _ty = movement.get_position_via_id(target_id)
    _weapon = entities.get_entity(
        items.get_items_in_holder(entity, 'weapon')[0])
    _menu = ui_menu.create(_tx - camera.X + 2,
                           _ty - camera.Y - 4,
                           title='Shoot')
    _accuracy = stats.get_accuracy(entity, _weapon['_id'])
    _x, _y = movement.get_position(entity)
    _direction = numbers.direction_to((_x, _y), (_tx, _ty))
    _final_direction = _direction + (_accuracy * numbers.distance((_x, _y),
                                                                  (_tx, _ty)))
    _spray_accuracy = (100 * (_direction / float(_final_direction)))

    entities.trigger_event(_weapon, 'get_actions', menu=_menu)
    ui_menu.add_selectable(
        _menu, 'Spray (Acc: %.2d)' % _spray_accuracy,
        lambda: entities.trigger_event(entity, 'shoot', target_id=target_id
                                       ) and settings.set_tick_mode('normal'))
    ui_menu.add_selectable(_menu, 'Snipe (Acc: %s)' % _accuracy, lambda: _)
Ejemplo n.º 21
0
def corpse(x, y, char, owner_id):
    _entity = _create(x, y, '', char, 4, 'corpse', fore_color=(130, 110, 110))
    _entity['owner_id'] = owner_id

    entities.register_event(_entity, 'seen', _corpse_seen)
    entities.register_event(
        _entity, 'get_interactions',
        lambda e, menu, target_id: ui_menu.add_selectable(
            menu, 'Examine', lambda: ui_dialog.create(x - camera.X, y - camera.
                                                      Y, 'Dead?')))

    return _entity
Ejemplo n.º 22
0
def corpse(x, y, char, owner_id):
	_entity = _create(x, y, '', char, 4, 'corpse', fore_color=(130, 110, 110))
	_entity['owner_id'] = owner_id
	
	entities.register_event(_entity, 'seen', _corpse_seen)
	entities.register_event(_entity, 'get_interactions', lambda e, menu, target_id: ui_menu.add_selectable(menu,
	                                                                                            'Examine',
	                                                                                            lambda: ui_dialog.create(x-camera.X,
	                                                                                                                     y-camera.Y,
	                                                                                                                     'Dead?')))
	
	return _entity
Ejemplo n.º 23
0
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))
Ejemplo n.º 24
0
def show_weapons(entity):
    global ACTIVE_MENU, REDRAW_TIMES

    _holder_menu = ui_menu.create(1,
                                  1,
                                  title='Weapons',
                                  surface='ui_inventory',
                                  click_offset=(constants.MAP_VIEW_WIDTH - 35,
                                                0))
    ACTIVE_MENU = _holder_menu
    REDRAW_TIMES = 3

    _equipped_weapon = items.get_items_in_holder(entity, 'weapon')
    _weapons = []

    if _equipped_weapon:
        _weapons.append(_equipped_weapon[0])

    for item_id in items.get_items_matching(entity, {'type': 'weapon'}):
        if item_id in _weapons:
            continue

        _weapons.add(item_id)

    for item_id in _weapons:
        _item = entities.get_entity(item_id)

        entities.trigger_event(_item, 'get_display_name')

        if item_id in _equipped_weapon:
            _fg = (245, 245, 245)
        else:
            _fg = (230, 230, 230)

        ui_menu.add_selectable(_holder_menu,
                               _item['stats']['display_name'],
                               show_weapon_menu,
                               fore_color=_fg,
                               item_id=item_id)
Ejemplo n.º 25
0
def create_item_menu(entity, item, x, y, on_path=False):
	_menu = ui_menu.create(ui_cursor.CURSOR['tile']['x']+2, ui_cursor.CURSOR['tile']['y']-1, title='Context')
	
	if items.get_list_of_free_holders(entity, item['_id']) and item['stats']['equip_to']:
		ui_menu.add_selectable(_menu, 'Equip', lambda: create_action_node(entity,
		                                                                  x,
		                                                                  y,
		                                                                  30,
		                                                                  lambda: entities.trigger_event(entity, 'get_and_hold_item', item_id=item['_id']),
		                                                                  name='Equip %s' % item['stats']['name'],
		                                                                  on_path=on_path))
	
	if items.get_list_of_free_containers(entity, item['_id']):
		ui_menu.add_selectable(_menu, 'Store', lambda: create_action_node(entity,
		                                                                  x,
		                                                                  y,
		                                                                  30,
		                                                                  lambda: entities.trigger_event(entity, 'get_and_store_item', item_id=item['_id']),
		                                                                  name='Store %s' % item['stats']['name'],
		                                                                  on_path=on_path))
	
	entities.trigger_event(item, 'get_interactions', menu=_menu, target_id=entity['_id'])
Ejemplo n.º 26
0
def _show_metas(entity):
    _keys = entity['ai']['meta'].keys()
    _keys.sort()

    for meta_key in _keys:
        print meta_key, entity['ai']['meta'][meta_key]
    return
    _menu = ui_menu.create(0, 0, title='Metas')
    _keys = entity['ai']['meta'].keys()
    _keys.sort()

    for meta_key in _keys:
        if entity['ai']['meta'][meta_key]:
            _color = (0, 200, 0)
        else:
            _color = (200, 0, 0)

        ui_menu.add_selectable(_menu,
                               '%s: %s' %
                               (meta_key, entity['ai']['meta'][meta_key]),
                               lambda: _show_metas(_entity),
                               fore_color=_color)
Ejemplo n.º 27
0
def create_life_interact_menu(entity, target_id):
	if not items.get_items_in_holder(entity, 'weapon'):
		return
	
	_target = entities.get_entity(target_id)
	_is_enemy = ai_factions.is_enemy(entity, target_id)
	_menu = ui_menu.create(ui_cursor.CURSOR['tile']['x']+2, ui_cursor.CURSOR['tile']['y']-4, title='Context')
	
	if not _is_enemy:
		if _target['missions']['inactive']:
			ui_menu.add_selectable(_menu, 'Talk', lambda: create_talk_menu(entity, target_id))
		
		ui_menu.add_selectable(_menu, 'Inquire', lambda: create_mission_menu(entity, target_id))
		ui_menu.add_selectable(_menu, 'Trade', lambda: create_mission_menu(entity, target_id))
	
	ui_menu.add_selectable(_menu, 'Shoot%s' % (' (Friendly fire)' * (not _is_enemy)), lambda: create_shoot_menu(entity, target_id))
Ejemplo n.º 28
0
def show_weapon_menu(item_id):
    global ACTIVE_MENU, REDRAW_TIMES

    _holder_menu = ui_menu.create(1,
                                  1,
                                  title='Actions',
                                  surface='ui_inventory',
                                  click_offset=(constants.MAP_VIEW_WIDTH - 35,
                                                0))
    ACTIVE_MENU = _holder_menu
    REDRAW_TIMES = 3

    _item = entities.get_entity(item_id)

    #entities.trigger_event(_item, 'get_actions', menu=_holder_menu)

    ui_menu.add_selectable(_holder_menu,
                           'Reload',
                           lambda: show_weapon_menu,
                           item_id=item_id)
    ui_menu.add_selectable(_holder_menu,
                           'Store',
                           lambda: show_weapon_menu,
                           item_id=item_id)
Ejemplo n.º 29
0
def create_life_interact_menu(entity, target_id):
    if not items.get_items_in_holder(entity, 'weapon'):
        return

    _target = entities.get_entity(target_id)
    _is_enemy = ai_factions.is_enemy(entity, target_id)
    _menu = ui_menu.create(ui_cursor.CURSOR['tile']['x'] + 2,
                           ui_cursor.CURSOR['tile']['y'] - 4,
                           title='Context')

    if not _is_enemy:
        if _target['missions']['inactive']:
            ui_menu.add_selectable(_menu, 'Talk',
                                   lambda: create_talk_menu(entity, target_id))

        ui_menu.add_selectable(_menu, 'Inquire',
                               lambda: create_mission_menu(entity, target_id))
        ui_menu.add_selectable(_menu, 'Trade',
                               lambda: create_mission_menu(entity, target_id))

    ui_menu.add_selectable(_menu,
                           'Shoot%s' % (' (Friendly fire)' * (not _is_enemy)),
                           lambda: create_shoot_menu(entity, target_id))
Ejemplo n.º 30
0
def _handle_mutated_wild_dog_corpse(entity, corpse_id):
	_corpse = entities.get_entity(corpse_id)
	
	entities.register_event(_corpse, 'get_interactions', lambda e, menu, target_id: ui_menu.add_selectable(menu,
	                                                                                            'Cut off tail',
	                                                                                            lambda: _handle_cut_tail(e, target_id)))
Ejemplo n.º 31
0
def handle_keyboard_input():
	if controls.get_input_char_pressed('\t'):
		if settings.TICK_MODE == 'strategy':
			if ui_panel.ACTIVE_MENU:
				ui_panel.close()
			else:
				ui_panel.show_inventory(entity)
		
		else:
			_x, _y = movement.get_position(entity)
			
			camera.set_pos(_x - constants.MAP_VIEW_WIDTH/2, _y - constants.MAP_VIEW_HEIGHT/2)
	
	if controls.get_input_char_pressed('O'):
		settings.toggle_show_node_grid()
	
	elif controls.get_input_char_pressed('o'):
		settings.toggle_observer_mode()
	
	if controls.get_input_char_pressed('d'):
		_mx, _my = ui_cursor.get_map_position()
		
		for entity_id in entities.get_entity_group('life'):
			_entity = entities.get_entity(entity_id)
			
			if not numbers.distance((_mx, _my), movement.get_position(_entity)):
				_x, _y = ui_cursor.get_screen_position()
				_menu = ui_menu.create(_x, _y, title='Debug')
				ui_menu.add_selectable(_menu, 'Show Metas', lambda: _show_metas(_entity))
				ui_menu.add_selectable(_menu, 'Kill', lambda: entities.trigger_event(_entity, 'kill'))
				ui_menu.add_selectable(_menu, 'Overwatch', lambda: ai_debugger.register(_entity))
				
				break
	
	if controls.get_input_char_pressed('l'):
		_x, _y = ui_cursor.get_screen_position()
		_mx, _my = ui_cursor.get_map_position()
		_weight = zones.get_active_weight_map()[_my, _mx]
		_menu = ui_menu.create(_x, _y, title='Tile Info')
		
		ui_menu.add_selectable(_menu, 'Warp', lambda: entities.trigger_event(entity, 'set_position', x=_mx, y=_my))
		ui_menu.add_selectable(_menu, 'Light', lambda: effects.light(_mx, _my, 15, r=random.uniform(1.0, 1.5), g=random.uniform(1.0, 1.5), light_map='static_lighting'))
		ui_menu.add_selectable(_menu, 'Weight: %s' % _weight, lambda: _)
Ejemplo n.º 32
0
def handle_keyboard_input():
    if controls.get_input_char_pressed('\t'):
        if settings.TICK_MODE == 'strategy':
            if ui_panel.ACTIVE_MENU:
                ui_panel.close()
            else:
                ui_panel.show_inventory(entity)

        else:
            _x, _y = movement.get_position(entity)

            camera.set_pos(_x - constants.MAP_VIEW_WIDTH / 2,
                           _y - constants.MAP_VIEW_HEIGHT / 2)

    if controls.get_input_char_pressed('O'):
        settings.toggle_show_node_grid()

    elif controls.get_input_char_pressed('o'):
        settings.toggle_observer_mode()

    if controls.get_input_char_pressed('d'):
        _mx, _my = ui_cursor.get_map_position()

        for entity_id in entities.get_entity_group('life'):
            _entity = entities.get_entity(entity_id)

            if not numbers.distance(
                (_mx, _my), movement.get_position(_entity)):
                _x, _y = ui_cursor.get_screen_position()
                _menu = ui_menu.create(_x, _y, title='Debug')
                ui_menu.add_selectable(_menu, 'Show Metas',
                                       lambda: _show_metas(_entity))
                ui_menu.add_selectable(
                    _menu, 'Kill',
                    lambda: entities.trigger_event(_entity, 'kill'))
                ui_menu.add_selectable(_menu, 'Overwatch',
                                       lambda: ai_debugger.register(_entity))

                break

    if controls.get_input_char_pressed('l'):
        _x, _y = ui_cursor.get_screen_position()
        _mx, _my = ui_cursor.get_map_position()
        _weight = zones.get_active_weight_map()[_my, _mx]
        _menu = ui_menu.create(_x, _y, title='Tile Info')

        ui_menu.add_selectable(
            _menu, 'Warp', lambda: entities.trigger_event(
                entity, 'set_position', x=_mx, y=_my))
        ui_menu.add_selectable(
            _menu, 'Light', lambda: effects.light(_mx,
                                                  _my,
                                                  15,
                                                  r=random.uniform(1.0, 1.5),
                                                  g=random.uniform(1.0, 1.5),
                                                  light_map='static_lighting'))
        ui_menu.add_selectable(_menu, 'Weight: %s' % _weight, lambda: _)