def __on_old_game_teardown_end(self, event): assert isinstance(event[0], map.Map) del globals.active_objects_list[:] globals.active_map = event[0] pf.new_game_string(globals.active_map.pfmap_str(), update_navgrid=False) minimap_pos = pf.get_minimap_position() pf.set_minimap_position(UI_LEFT_PANE_WIDTH + minimap_pos[0], minimap_pos[1]) self.view.hide() if event[1] is not None: assert len(globals.active_objects_list) == 0 try: globals.active_objects_list = pf.load_scene( event[1], update_navgrid=False) globals.scene_filename = event[1] for obj in globals.active_objects_list: obj.selectable = True faction_descs = pf.get_factions_list() except: print("Failed to load scene! [{0}]".format(event[1])) if len(pf.get_factions_list()) == 0: pf.add_faction(DEFAULT_FACTION_NAME, DEFAULT_FACTION_COLOR)
def __on_old_game_teardown_end(self, event): assert isinstance(event[0], map.Map) del globals.active_objects_list[:] globals.active_map = event[0] pf.new_game_string(globals.active_map.pfmap_str()) pf.set_minimap_position(UI_LEFT_PANE_WIDTH + MINIMAP_PX_WIDTH/cos(pi/4)/2 + 10, pf.get_resolution()[1] - MINIMAP_PX_WIDTH/cos(pi/4)/2 - 10) self.view.hide() import os if event[1] is not None and os.path.isfile(event[1]): assert len(globals.active_objects_list) == 0 try: globals.active_objects_list = pf.load_scene(event[1]) globals.scene_filename = event[1] for obj in globals.active_objects_list: obj.selectable = True except: print("Failed to load scene! [{0}]".format(event[1]))
############################################################ # Global configs # ############################################################ pf.set_ambient_light_color((1.0, 1.0, 1.0)) pf.set_emit_light_color((1.0, 1.0, 1.0)) pf.set_emit_light_pos((1664.0, 1024.0, 384.0)) pf.set_active_font("OptimusPrinceps.ttf") ############################################################ # Setup map/scene # ############################################################ pf.load_map("assets/maps", "demo.pfmap") globals.scene_objs = pf.load_scene("assets/maps/demo.pfscene") pf.set_diplomacy_state(1, 2, pf.DIPLOMACY_STATE_WAR) pf.set_diplomacy_state(1, 3, pf.DIPLOMACY_STATE_WAR) pf.set_diplomacy_state(2, 3, pf.DIPLOMACY_STATE_WAR) pf.set_faction_controllable(0, False) pf.set_faction_controllable(2, False) pf.set_faction_controllable(3, False) ############################################################ # Setup global events # ############################################################ main_cam = pf.get_active_camera() debug_cam = pf.Camera(mode=pf.CAM_MODE_FPS,
mouse_events.install() ############################################################ # Setup Map, Scene # ############################################################ if len(sys.argv) > 1: pf.load_map(pf.get_basedir(), sys.argv[1], update_navgrid=False) globals.active_map = map.Map.from_filepath(pf.get_basedir() + "/" + sys.argv[1]) else: pf.load_map_string(globals.active_map.pfmap_str(), update_navgrid=False) if len(sys.argv) > 2: globals.active_objects_list = pf.load_scene(sys.argv[2], update_navgrid=False) globals.scene_filename = sys.argv[2] for obj in globals.active_objects_list: obj.selectable = True else: pf.add_faction(DEFAULT_FACTION_NAME, DEFAULT_FACTION_COLOR) ############################################################ # Setup UI # ############################################################ minimap_pos = pf.get_minimap_position() pf.set_minimap_position(UI_LEFT_PANE_WIDTH + minimap_pos[0], minimap_pos[1]) terrain_tab_vc = ttvc.TerrainTabVC(ttw.TerrainTabWindow()) objects_tab_vc = otvc.ObjectsVC(otw.ObjectsTabWindow())