def update(): global X global Y global LAST_X global LAST_Y X = numbers.clip(X, X_MIN, X_MAX) Y = numbers.clip(Y, Y_MIN, Y_MAX) _zone = zones.ZONES[zones.ACTIVE_ZONE] display.set_surface_camera("tiles", X, Y) display.reset_surface_shaders("tiles") if world_action.FADE_VALUE < 255: display.apply_surface_shader( "tiles", zones.get_active_fader(), constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT ) for shader in _zone["shaders"]: display.apply_surface_shader("tiles", shader, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT) display.blit_surface_viewport("tiles", X, Y, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT) LAST_X = X LAST_Y = Y
def draw(): _entity = entities.get_entity(HAS_FOCUS) _x, _y = movement.get_position(_entity) _char = tile.get_char(_entity) for y in range(12): display.write_char('ui', 4, 4 + y + 1, ' ', back_color=(20, 20, 20)) display.write_char('ui', 4 + 12, 4 + y, ' ', back_color=(40, 40, 40)) display.write_char('ui', 4 + y, 4, ' ', back_color=(20, 20, 20)) display.write_char('ui', 4 + y + 1, 4 + 12, ' ', back_color=(40, 40, 40)) display.blit_surface_viewport('tiles', _x-5, _y-5, 11, 11, dx=5, dy=5) display.write_char('ui', 10, 10, _char, fore_color=_entity['tile']['fore_color'])
def draw(): if SELECTED_SQUAD: _x, _y = movement.get_position(entities.get_entity(SELECTED_SQUAD)) _selected_grid = _x, _y else: _selected_grid = None ui_strategy.draw_map_grid(selected_grid=_selected_grid, fade=FADE_VALUE / 255.0) ui_strategy.draw_squads(selected_squad=SELECTED_SQUAD) ui_strategy.draw_time() ui_strategy.draw_money() if DRAW_MODE == 'squad_info': ui_strategy.draw_squad_info(SELECTED_SQUAD) elif DRAW_MODE == 'camp_info': ui_strategy.draw_camp_info(SELECTED_CAMP) elif DRAW_MODE == 'news': ui_strategy.draw_news(NEWS) elif DRAW_MODE == 'raid': ui_strategy.draw_raid_info(SELECTED_SQUAD, SELECTED_CAMP) ui_strategy.draw_raid_path(MAP_PATH) display.blit_surface('map_path') display.blit_surface('map_markers') display.blit_surface('map_squads') display.blit_surface_viewport('ui_bar', 0, 0, constants.WINDOW_WIDTH, constants.WINDOW_HEIGHT - constants.STRAT_MAP_HEIGHT, dy=constants.STRAT_MAP_HEIGHT) events.trigger_event('draw') display.reset_surface_shaders('map')
def draw(): _entity = entities.get_entity(HAS_FOCUS) _x, _y = movement.get_position(_entity) _char = tile.get_char(_entity) for y in range(12): display.write_char('ui', 4, 4 + y + 1, ' ', back_color=(20, 20, 20)) display.write_char('ui', 4 + 12, 4 + y, ' ', back_color=(40, 40, 40)) display.write_char('ui', 4 + y, 4, ' ', back_color=(20, 20, 20)) display.write_char('ui', 4 + y + 1, 4 + 12, ' ', back_color=(40, 40, 40)) display.blit_surface_viewport('tiles', _x - 5, _y - 5, 11, 11, dx=5, dy=5) display.write_char('ui', 10, 10, _char, fore_color=_entity['tile']['fore_color'])
def draw(): if SELECTED_SQUAD: _x, _y = movement.get_position(entities.get_entity(SELECTED_SQUAD)) _selected_grid = _x, _y else: _selected_grid = None ui_strategy.draw_map_grid(selected_grid=_selected_grid, fade=FADE_VALUE/255.0) ui_strategy.draw_squads(selected_squad=SELECTED_SQUAD) ui_strategy.draw_time() ui_strategy.draw_money() if DRAW_MODE == 'squad_info': ui_strategy.draw_squad_info(SELECTED_SQUAD) elif DRAW_MODE == 'camp_info': ui_strategy.draw_camp_info(SELECTED_CAMP) elif DRAW_MODE == 'news': ui_strategy.draw_news(NEWS) elif DRAW_MODE == 'raid': ui_strategy.draw_raid_info(SELECTED_SQUAD, SELECTED_CAMP) ui_strategy.draw_raid_path(MAP_PATH) display.blit_surface('map_path') display.blit_surface('map_markers') display.blit_surface('map_squads') display.blit_surface_viewport('ui_bar', 0, 0, constants.WINDOW_WIDTH, constants.WINDOW_HEIGHT-constants.STRAT_MAP_HEIGHT, dy=constants.STRAT_MAP_HEIGHT) events.trigger_event('draw') display.reset_surface_shaders('map')
def update(): global X global Y global LAST_X global LAST_Y X = numbers.clip(X, X_MIN, X_MAX) Y = numbers.clip(Y, Y_MIN, Y_MAX) _zone = zones.ZONES[zones.ACTIVE_ZONE] display.set_surface_camera('tiles', X, Y) display.reset_surface_shaders('tiles') if world_action.FADE_VALUE < 255: display.apply_surface_shader('tiles', zones.get_active_fader(), constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT) for shader in _zone['shaders']: display.apply_surface_shader('tiles', shader, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT) display.blit_surface_viewport('tiles', X, Y, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT) LAST_X = X LAST_Y = Y
def draw_map_grid(selected_grid=None, fade=1.0): _shader = [] _shader.append(numpy.zeros((constants.STRAT_MAP_HEIGHT, constants.STRAT_MAP_WIDTH), dtype=numpy.float)) _shader.append(numpy.zeros((constants.STRAT_MAP_HEIGHT, constants.STRAT_MAP_WIDTH), dtype=numpy.float)) _shader.append(numpy.zeros((constants.STRAT_MAP_HEIGHT, constants.STRAT_MAP_WIDTH), dtype=numpy.float)) _shader[0] += 1.35 * fade _shader[1] += 1.35 * fade _shader[2] += 1.25 * fade display.apply_surface_shader("map", _shader, constants.STRAT_MAP_WIDTH, constants.STRAT_MAP_HEIGHT) display.blit_surface_viewport("map", 0, 0, constants.STRAT_MAP_WIDTH, constants.STRAT_MAP_HEIGHT) for x in range(constants.STRAT_MAP_WIDTH / constants.MAP_CELL_SPACE): for y in range(constants.STRAT_MAP_HEIGHT / constants.MAP_CELL_SPACE): _tile = world_strategy.MAP["grid"][x, y] if ( x == controls.get_mouse_pos()[0] / constants.MAP_CELL_SPACE and y == controls.get_mouse_pos()[1] / constants.MAP_CELL_SPACE ): _hover = True else: _hover = False for _x in range(constants.MAP_CELL_SPACE): for _y in range(constants.MAP_CELL_SPACE): _d_x = (x * constants.MAP_CELL_SPACE) + _x _d_y = (y * constants.MAP_CELL_SPACE) + _y _back_color = None if _tile["is_ownable"]: if _tile["owned_by"] == "Terrorists": _fore_color = (200, 0, 0) _back_color = (125, 0, 0) elif _tile["owned_by"] == "Rogues": _fore_color = (0, 200, 0) _back_color = (0, 125, 0) else: _fore_color = (180, 180, 180) _back_color = (100, 100, 100) if (x, y) == selected_grid: _fore_color = ( int(round(_fore_color[0] * 1.2)), int(round(_fore_color[1] * 1.2)), int(round(_fore_color[2] * 1.2)), ) _back_color = ( int(round(_back_color[0] * 1.2)), int(round(_back_color[1] * 1.2)), int(round(_back_color[2] * 1.2)), ) if not _x + _y: if _hover or (x, y) == selected_grid: _char = chr(201) _fore_color = (255, 255, 255) else: _char = chr(218) elif _x == constants.MAP_CELL_SPACE - 1 and not _y: if _hover or (x, y) == selected_grid: _char = chr(187) _fore_color = (255, 255, 255) else: _char = chr(191) elif not _x and _y == constants.MAP_CELL_SPACE - 1: if _hover or (x, y) == selected_grid: _char = chr(200) _fore_color = (255, 255, 255) else: _char = chr(192) elif _x + _y == (constants.MAP_CELL_SPACE - 1) * 2: if _hover or (x, y) == selected_grid: _char = chr(188) _fore_color = (255, 255, 255) else: _char = chr(217) elif ( _y > 0 and _y < constants.MAP_CELL_SPACE - 1 and (not _x or _x == constants.MAP_CELL_SPACE - 1) ): _char = chr(179) elif ( _x > 0 and _x < constants.MAP_CELL_SPACE - 1 and (not _y or _y == constants.MAP_CELL_SPACE - 1) ): _char = chr(196) else: _char = "." display.write_char( "map_markers", _d_x, _d_y, _char, fore_color=_fore_color, back_color=_back_color ) else: if _hover or (x, y) == selected_grid: if not _x + _y: _char = chr(201) elif _x == constants.MAP_CELL_SPACE - 1 and not _y: _char = chr(187) elif not _x and _y == constants.MAP_CELL_SPACE - 1: _char = chr(200) elif _x + _y == (constants.MAP_CELL_SPACE - 1) * 2: _char = chr(188) else: _char = " " _color = display.get_color_at("map", _d_x, _d_y)[1] display.write_char( "map_markers", _d_x, _d_y, _char, back_color=( int(round(_color[0] * 1.4)), int(round(_color[1] * 1.4)), int(round(_color[2] * 1.4)), ), )
def draw(): #Title _i = 0 _dst_x = 9999 for c in TEXT[0]: _alpha = numbers.clip( FADE_ALPHA * numbers.clip(16 - _i, 7, 16) / SPARK_SIZE, 0, 1) _dx = ((constants.WINDOW_WIDTH / 2) - (len(''.join(TEXT)) / 2)) + _i if _dx < _dst_x: _dst_x = _dx _batch = display.create_batch(len(TEXT[0]), 1, _dst_x, 12) _i = 0 for c in TEXT[0]: _alpha = numbers.clip( FADE_ALPHA * numbers.clip(16 - _i, 7, 16) / SPARK_SIZE, 0, 1) display.write_char_batch( _batch, ((constants.WINDOW_WIDTH / 2) - (len(''.join(TEXT)) / 2)) + _i, 12, c, fore_color=(200 * _alpha, 200 * _alpha, 200 * _alpha)) _i += 1 display.draw_batch(_batch, 'text') _i = 0 for c in TEXT[1]: _alpha = numbers.clip( FADE_ALPHA * numbers.clip(18 - _i, 0, 18) / SPARK_SIZE, 0, 1) display.write_char('text', ((constants.WINDOW_WIDTH / 2) - (len(TEXT[1]) / 2)) + _i, 13, c.upper(), fore_color=(200 * _alpha, 60 * _alpha, 80 * _alpha)) _i += 1 #Menu _i = 0 for item in [('Continue', False), ('New', True), ('Quit', True)]: if item[1]: _fore_color = (200 * FADE_ALPHA, 200 * FADE_ALPHA, 200 * FADE_ALPHA) else: _fore_color = (100 * FADE_ALPHA, 100 * FADE_ALPHA, 100 * FADE_ALPHA) if MENU_ITEM_SELECTED == _i: _text = '> %s <' % item[0] else: _text = item[0] display.write_string('text', (constants.WINDOW_WIDTH / 2) - (len(_text) / 2), 18 + _i, _text, fore_color=_fore_color) _i += 1 paint_map() display.blit_surface_viewport('background', 0, 0, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT) display.blit_surface('text')
def draw(): _x = 3 _y_mod = 0 _total_money = 0 display.write_string('text', (SIDEBAR_WIDTH / 2) - (len(TITLE) / 2), 3, TITLE, fore_color=(255, 255, 255)) for squad_member in HIRED_MEMBERS: _y = 10 + _y_mod _name = squad_member['name'] display.write_string('text', _x, _y - 2, _name, fore_color=(255, 255, 255)) display.write_string('text', _x, _y - 1, squad_member['skill_focus'].title() + ' ' * (len(_name) - len(squad_member['skill_focus'])), fore_color=(180, 180, 180), back_color=(40, 40, 40)) for stat in SKILL_NAMES: _r = int(round(220 * (1 - (squad_member[stat] / 75.0)))) _g = int(round(250 * (squad_member[stat] / 75.0))) display.write_string('text', _x, _y + 1, '%s' % stat.upper()) display.write_string('text', _x + len(stat), _y + 1, '.' * (15 - len(stat)), fore_color=(80, 80, 80)) display.write_string('text', _x + 15, _y + 1, '%s' % squad_member[stat], fore_color=(_r, _g, 0)) _y += 1 display.write_string('text', _x, _y + 2, 'Pay: ') display.write_string('text', _x + 6, _y + 2, '$%.2f' % squad_member['pay'], fore_color=(0, 200, 0), back_color=(0, 40, 0)) display.write_string('text', _x + 6 + len('$%.2f' % squad_member['pay']) + 0, _y + 2, '/week', fore_color=(150, 150, 150), back_color=(0, 0, 0)) _x += 20 if _x > 40: _x = 3 _y_mod += 12 _total_money += squad_member['pay'] #for y in range(12, 14): #for x in range(SIDEBAR_WIDTH + 10, constants.WINDOW_WIDTH - 14): display.write_string('text', SIDEBAR_WIDTH + 10, 12, 'Operation', fore_color=(255, 255, 255)) display.write_string('text', SIDEBAR_WIDTH + 10, 13, 'Dark Wing', fore_color=(255, 255, 255)) for y in range(20, 28): for x in range(SIDEBAR_WIDTH + 10, constants.WINDOW_WIDTH - 14): display.write_char('text', x, y, '#', fore_color=(255, 255, 255)) display.write_string('text', SIDEBAR_WIDTH + 5, 29, 'No contact outside the town.', fore_color=(255, 255, 255)) _i = 0 for feat in FEATS: display.write_string('text', 3, _y + 5 + _i, feat[0][0], fore_color=feat[0][1]) display.write_string('text', 3 + len(feat[0][0]), _y + 5 + _i, '- ' + feat[1], fore_color=(255, 255, 255)) _i += 1 display.write_string('text', 3, constants.WINDOW_HEIGHT - 4, '<Space>', fore_color=(255, 255, 255)) display.write_string('text', 10, constants.WINDOW_HEIGHT - 4, ' - Reroll', fore_color=(200, 200, 200)) display.write_string('text', 3, constants.WINDOW_HEIGHT - 5, '<Enter>', fore_color=(255, 255, 255)) display.write_string('text', 10, constants.WINDOW_HEIGHT - 5, ' - Accept', fore_color=(200, 200, 200)) display.write_string('text', 3, constants.WINDOW_HEIGHT - 2, 'Total Cost: ') display.write_string('text', 15, constants.WINDOW_HEIGHT - 2, '$%.2f' % _total_money, fore_color=(0, 200, 0), back_color=(0, 40, 0)) display.blit_surface_viewport('background', 0, 0, constants.WINDOW_WIDTH, constants.WINDOW_HEIGHT) display.blit_surface('text')
def draw(): global MOVIE_TIME, MOVIE_TIME_MAX if settings.OBSERVER_MODE: _draw_life = entities.get_entity_group('life') _draw_items = entities.get_entity_group('items') else: _draw_life = set() _draw_items = set() for squad_id in entities.get_entity_group('squads'): _squad = entities.get_entity(squad_id) if not _squad['faction'] == 'Rogues': continue for member_id in _squad['members']: _member = entities.get_entity(member_id) _draw_life.add(member_id) _draw_life.update([i for i in _member['ai']['life_memory'] if _member['ai']['life_memory'][i]['can_see'] and i in entities.ENTITIES]) _draw_life = list(_draw_life) for entity_id in _draw_life: entities.trigger_event(entities.get_entity(entity_id), 'draw', x_mod=camera.X, y_mod=camera.Y) for entity_id in entities.get_entity_group('nodes'): entities.trigger_event(entities.get_entity(entity_id), 'draw', x_mod=camera.X, y_mod=camera.Y) if settings.SHOW_NODE_GRID: for entity_id in zones.get_active_node_grid().values(): entities.trigger_event(entities.get_entity(entity_id), 'draw', x_mod=camera.X, y_mod=camera.Y) for entity_id in entities.get_entity_groups(['ui_effects', 'ui_effects_freetick']): entities.trigger_event(entities.get_entity(entity_id), 'draw') for entity_id in entities.get_entity_groups(['effects', 'effects_freetick']): entities.trigger_event(entities.get_entity(entity_id), 'draw', x_mod=camera.X, y_mod=camera.Y) for entity_id in entities.get_entity_group('contexts'): entities.trigger_event(entities.get_entity(entity_id), 'draw', x_mod=camera.X, y_mod=camera.Y) for entity_id in _draw_items: if not entity_id in entities.ENTITIES: continue _entity = entities.get_entity(entity_id) if _entity['stats']['owner']: continue entities.trigger_event(entities.get_entity(entity_id), 'draw', x_mod=camera.X, y_mod=camera.Y) ui_draw.draw_status_bar(planning=settings.TICK_MODE == 'strategy', executing=not settings.TICK_MODE == 'strategy', execute_speed=settings.PLAN_TICK_RATE_STRING, selecting=nodes.SELECTING_TARGET_CALLBACK) #if settings.TICK_MODE == 'strategy': # ui_draw.draw_item_labels() if '--labels' in sys.argv: ui_draw.draw_life_labels() ui_draw.draw_long_range_life() ui_draw.draw_life_memory() ui_draw.draw_walk_path() #ui_draw.draw_mission_details() ui_draw.draw_turn_bar() if '--fps' in sys.argv: ui_draw.draw_fps() events.trigger_event('post_process') #display.reset_surface_shaders('tiles') #_zone = zones.ZONES[zones.ACTIVE_ZONE] #for shader in _zone['shaders']: # display.apply_surface_shader('tiles', shader, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT) if ui_director.HAS_FOCUS: ui_director.draw() display.blit_surface('effects') display.blit_surface('nodes') display.blit_surface('items') display.blit_surface('life') display.blit_surface('ui') display.blit_surface('ui_menus') display.blit_surface('ui_dialogs') if ui_panel.ACTIVE_MENU: display.blit_surface_viewport('ui_inventory', 0, 0, 35, constants.MAP_VIEW_HEIGHT, dx=constants.MAP_VIEW_WIDTH-35) if settings.SHOW_NODE_GRID: display.blit_surface('node_grid') events.trigger_event('draw') if '--record' in sys.argv: MOVIE_TIME += 1 if MOVIE_TIME == MOVIE_TIME_MAX: display.screenshot('screenshot-%s.bmp' % time.time()) MOVIE_TIME = 0
def draw(): # Title _i = 0 _dst_x = 9999 for c in TEXT[0]: _alpha = numbers.clip(FADE_ALPHA * numbers.clip(16 - _i, 7, 16) / SPARK_SIZE, 0, 1) _dx = ((constants.WINDOW_WIDTH / 2) - (len("".join(TEXT)) / 2)) + _i if _dx < _dst_x: _dst_x = _dx _batch = display.create_batch(len(TEXT[0]), 1, _dst_x, 12) _i = 0 for c in TEXT[0]: _alpha = numbers.clip(FADE_ALPHA * numbers.clip(16 - _i, 7, 16) / SPARK_SIZE, 0, 1) display.write_char_batch( _batch, ((constants.WINDOW_WIDTH / 2) - (len("".join(TEXT)) / 2)) + _i, 12, c, fore_color=(200 * _alpha, 200 * _alpha, 200 * _alpha), ) _i += 1 display.draw_batch(_batch, "text") _i = 0 for c in TEXT[1]: _alpha = numbers.clip(FADE_ALPHA * numbers.clip(18 - _i, 0, 18) / SPARK_SIZE, 0, 1) display.write_char( "text", ((constants.WINDOW_WIDTH / 2) - (len(TEXT[1]) / 2)) + _i, 13, c.upper(), fore_color=(200 * _alpha, 60 * _alpha, 80 * _alpha), ) _i += 1 # Menu _i = 0 for item in [("Continue", False), ("New", True), ("Quit", True)]: if item[1]: _fore_color = (200 * FADE_ALPHA, 200 * FADE_ALPHA, 200 * FADE_ALPHA) else: _fore_color = (100 * FADE_ALPHA, 100 * FADE_ALPHA, 100 * FADE_ALPHA) if MENU_ITEM_SELECTED == _i: _text = "> %s <" % item[0] else: _text = item[0] display.write_string( "text", (constants.WINDOW_WIDTH / 2) - (len(_text) / 2), 18 + _i, _text, fore_color=_fore_color ) _i += 1 paint_map() display.blit_surface_viewport("background", 0, 0, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT) display.blit_surface("text")
def draw(): _x = 3 _y_mod = 0 _total_money = 0 display.write_string('text', (SIDEBAR_WIDTH / 2) - (len(TITLE) / 2), 3, TITLE, fore_color=(255, 255, 255)) for squad_member in HIRED_MEMBERS: _y = 10 + _y_mod _name = squad_member['name'] display.write_string('text', _x, _y - 2, _name, fore_color=(255, 255, 255)) display.write_string('text', _x, _y - 1, squad_member['skill_focus'].title() + ' ' * (len(_name) - len(squad_member['skill_focus'])), fore_color=(180, 180, 180), back_color=(40, 40, 40)) for stat in SKILL_NAMES: _r = int(round(220 * (1 - (squad_member[stat] / 75.0)))) _g = int(round(250 * (squad_member[stat] / 75.0))) display.write_string('text', _x, _y + 1, '%s' % stat.upper()) display.write_string('text', _x + len(stat), _y + 1, '.' * (15 - len(stat)), fore_color=(80, 80, 80)) display.write_string('text', _x + 15, _y + 1, '%s' % squad_member[stat], fore_color=(_r, _g, 0)) _y += 1 display.write_string('text', _x, _y + 2, 'Pay: ') display.write_string('text', _x + 6, _y + 2, '$%.2f' % squad_member['pay'], fore_color=(0, 200, 0), back_color=(0, 40, 0)) display.write_string('text', _x + 6 + len('$%.2f' % squad_member['pay']) + 0, _y + 2, '/week', fore_color=(150, 150, 150), back_color=(0, 0, 0)) _x += 20 if _x > 40: _x = 3 _y_mod += 12 _total_money += squad_member['pay'] #for y in range(12, 14): #for x in range(SIDEBAR_WIDTH + 10, constants.WINDOW_WIDTH - 14): display.write_string('text', SIDEBAR_WIDTH + 10, 12, 'Operation', fore_color=(255, 255, 255)) display.write_string('text', SIDEBAR_WIDTH + 10, 13, 'Dark Wing', fore_color=(255, 255, 255)) for y in range(20, 28): for x in range(SIDEBAR_WIDTH + 10, constants.WINDOW_WIDTH - 14): display.write_char('text', x, y, '#', fore_color=(255, 255, 255)) display.write_string('text', SIDEBAR_WIDTH + 5, 29, 'No contact outside the town.', fore_color=(255, 255, 255)) _i = 0 for feat in FEATS: display.write_string('text', 3, _y + 5 + _i, feat[0][0], fore_color=feat[0][1]) display.write_string('text', 3 + len(feat[0][0]), _y + 5 + _i, '- ' + feat[1], fore_color=(255, 255, 255)) _i += 1 display.write_string('text', 3, constants.WINDOW_HEIGHT - 4, '<Space>', fore_color=(255, 255, 255)) display.write_string('text', 10, constants.WINDOW_HEIGHT - 4, ' - Reroll', fore_color=(200, 200, 200)) display.write_string('text', 3, constants.WINDOW_HEIGHT - 5, '<Enter>', fore_color=(255, 255, 255)) display.write_string('text', 10, constants.WINDOW_HEIGHT - 5, ' - Accept', fore_color=(200, 200, 200)) display.write_string('text', 3, constants.WINDOW_HEIGHT - 2, 'Total Cost: ') display.write_string('text', 15, constants.WINDOW_HEIGHT - 2, '$%.2f' % _total_money, fore_color=(0, 200, 0), back_color=(0, 40, 0)) display.blit_surface_viewport('background', 0, 0, constants.WINDOW_WIDTH, constants.WINDOW_HEIGHT) display.blit_surface('text')
def draw(): global MOVIE_TIME, MOVIE_TIME_MAX if settings.OBSERVER_MODE: _draw_life = entities.get_entity_group('life') _draw_items = entities.get_entity_group('items') else: _draw_life = set() _draw_items = set() for squad_id in entities.get_entity_group('squads'): _squad = entities.get_entity(squad_id) if not _squad['faction'] == 'Rogues': continue for member_id in _squad['members']: _member = entities.get_entity(member_id) _draw_life.add(member_id) _draw_life.update([ i for i in _member['ai']['life_memory'] if _member['ai']['life_memory'][i]['can_see'] and i in entities.ENTITIES ]) _draw_life = list(_draw_life) for entity_id in _draw_life: entities.trigger_event(entities.get_entity(entity_id), 'draw', x_mod=camera.X, y_mod=camera.Y) for entity_id in entities.get_entity_group('nodes'): entities.trigger_event(entities.get_entity(entity_id), 'draw', x_mod=camera.X, y_mod=camera.Y) if settings.SHOW_NODE_GRID: for entity_id in zones.get_active_node_grid().values(): entities.trigger_event(entities.get_entity(entity_id), 'draw', x_mod=camera.X, y_mod=camera.Y) for entity_id in entities.get_entity_groups( ['ui_effects', 'ui_effects_freetick']): entities.trigger_event(entities.get_entity(entity_id), 'draw') for entity_id in entities.get_entity_groups( ['effects', 'effects_freetick']): entities.trigger_event(entities.get_entity(entity_id), 'draw', x_mod=camera.X, y_mod=camera.Y) for entity_id in entities.get_entity_group('contexts'): entities.trigger_event(entities.get_entity(entity_id), 'draw', x_mod=camera.X, y_mod=camera.Y) for entity_id in _draw_items: if not entity_id in entities.ENTITIES: continue _entity = entities.get_entity(entity_id) if _entity['stats']['owner']: continue entities.trigger_event(entities.get_entity(entity_id), 'draw', x_mod=camera.X, y_mod=camera.Y) ui_draw.draw_status_bar(planning=settings.TICK_MODE == 'strategy', executing=not settings.TICK_MODE == 'strategy', execute_speed=settings.PLAN_TICK_RATE_STRING, selecting=nodes.SELECTING_TARGET_CALLBACK) #if settings.TICK_MODE == 'strategy': # ui_draw.draw_item_labels() if '--labels' in sys.argv: ui_draw.draw_life_labels() ui_draw.draw_long_range_life() ui_draw.draw_life_memory() ui_draw.draw_walk_path() #ui_draw.draw_mission_details() ui_draw.draw_turn_bar() if '--fps' in sys.argv: ui_draw.draw_fps() events.trigger_event('post_process') #display.reset_surface_shaders('tiles') #_zone = zones.ZONES[zones.ACTIVE_ZONE] #for shader in _zone['shaders']: # display.apply_surface_shader('tiles', shader, constants.MAP_VIEW_WIDTH, constants.MAP_VIEW_HEIGHT) if ui_director.HAS_FOCUS: ui_director.draw() display.blit_surface('effects') display.blit_surface('nodes') display.blit_surface('items') display.blit_surface('life') display.blit_surface('ui') display.blit_surface('ui_menus') display.blit_surface('ui_dialogs') if ui_panel.ACTIVE_MENU: display.blit_surface_viewport('ui_inventory', 0, 0, 35, constants.MAP_VIEW_HEIGHT, dx=constants.MAP_VIEW_WIDTH - 35) if settings.SHOW_NODE_GRID: display.blit_surface('node_grid') events.trigger_event('draw') if '--record' in sys.argv: MOVIE_TIME += 1 if MOVIE_TIME == MOVIE_TIME_MAX: display.screenshot('screenshot-%s.bmp' % time.time()) MOVIE_TIME = 0
def draw_map_grid(selected_grid=None, fade=1.0): _shader = [] _shader.append( numpy.zeros((constants.STRAT_MAP_HEIGHT, constants.STRAT_MAP_WIDTH), dtype=numpy.float)) _shader.append( numpy.zeros((constants.STRAT_MAP_HEIGHT, constants.STRAT_MAP_WIDTH), dtype=numpy.float)) _shader.append( numpy.zeros((constants.STRAT_MAP_HEIGHT, constants.STRAT_MAP_WIDTH), dtype=numpy.float)) _shader[0] += 1.35 * fade _shader[1] += 1.35 * fade _shader[2] += 1.25 * fade display.apply_surface_shader('map', _shader, constants.STRAT_MAP_WIDTH, constants.STRAT_MAP_HEIGHT) display.blit_surface_viewport('map', 0, 0, constants.STRAT_MAP_WIDTH, constants.STRAT_MAP_HEIGHT) for x in range(constants.STRAT_MAP_WIDTH / constants.MAP_CELL_SPACE): for y in range(constants.STRAT_MAP_HEIGHT / constants.MAP_CELL_SPACE): _tile = world_strategy.MAP['grid'][x, y] if x == controls.get_mouse_pos( )[0] / constants.MAP_CELL_SPACE and y == controls.get_mouse_pos( )[1] / constants.MAP_CELL_SPACE: _hover = True else: _hover = False for _x in range(constants.MAP_CELL_SPACE): for _y in range(constants.MAP_CELL_SPACE): _d_x = (x * constants.MAP_CELL_SPACE) + _x _d_y = (y * constants.MAP_CELL_SPACE) + _y _back_color = None if _tile['is_ownable']: if _tile['owned_by'] == 'Terrorists': _fore_color = (200, 0, 0) _back_color = (125, 0, 0) elif _tile['owned_by'] == 'Rogues': _fore_color = (0, 200, 0) _back_color = (0, 125, 0) else: _fore_color = (180, 180, 180) _back_color = (100, 100, 100) if (x, y) == selected_grid: _fore_color = int(round( _fore_color[0] * 1.2)), int( round(_fore_color[1] * 1.2)), int( round(_fore_color[2] * 1.2)) _back_color = int(round( _back_color[0] * 1.2)), int( round(_back_color[1] * 1.2)), int( round(_back_color[2] * 1.2)) if not _x + _y: if _hover or (x, y) == selected_grid: _char = chr(201) _fore_color = (255, 255, 255) else: _char = chr(218) elif _x == constants.MAP_CELL_SPACE - 1 and not _y: if _hover or (x, y) == selected_grid: _char = chr(187) _fore_color = (255, 255, 255) else: _char = chr(191) elif not _x and _y == constants.MAP_CELL_SPACE - 1: if _hover or (x, y) == selected_grid: _char = chr(200) _fore_color = (255, 255, 255) else: _char = chr(192) elif _x + _y == (constants.MAP_CELL_SPACE - 1) * 2: if _hover or (x, y) == selected_grid: _char = chr(188) _fore_color = (255, 255, 255) else: _char = chr(217) elif _y > 0 and _y < constants.MAP_CELL_SPACE - 1 and ( not _x or _x == constants.MAP_CELL_SPACE - 1): _char = chr(179) elif _x > 0 and _x < constants.MAP_CELL_SPACE - 1 and ( not _y or _y == constants.MAP_CELL_SPACE - 1): _char = chr(196) else: _char = '.' display.write_char('map_markers', _d_x, _d_y, _char, fore_color=_fore_color, back_color=_back_color) else: if _hover or (x, y) == selected_grid: if not _x + _y: _char = chr(201) elif _x == constants.MAP_CELL_SPACE - 1 and not _y: _char = chr(187) elif not _x and _y == constants.MAP_CELL_SPACE - 1: _char = chr(200) elif _x + _y == (constants.MAP_CELL_SPACE - 1) * 2: _char = chr(188) else: _char = ' ' _color = display.get_color_at('map', _d_x, _d_y)[1] display.write_char( 'map_markers', _d_x, _d_y, _char, back_color=(int(round(_color[0] * 1.4)), int(round(_color[1] * 1.4)), int(round(_color[2] * 1.4))))