Exemplo n.º 1
0
    def __on_save_as_cancel(self, event):
        pf.unregister_event_handler(EVENT_FILE_CHOOSER_OKAY, MenuVC.__on_save_as_confirm)
        pf.unregister_event_handler(EVENT_FILE_CHOOSER_CANCEL, MenuVC.__on_save_as_cancel)

        assert self.fc is not None
        self.fc.hide()
        self.fc = None
        self.activate()
Exemplo n.º 2
0
 def deactivate(self):
     pf.unregister_event_handler(EVENT_DIPLO_FAC_SELECTION_CHANGED,
                                 DiplomacyVC.__on_fac_sel_changed)
     pf.unregister_event_handler(EVENT_DIPLO_FAC_REMOVED,
                                 DiplomacyVC.__on_fac_removed)
     pf.unregister_event_handler(EVENT_DIPLO_FAC_CHANGED,
                                 DiplomacyVC.__on_fac_changed)
     pf.unregister_event_handler(EVENT_DIPLO_FAC_NEW,
                                 DiplomacyVC.__on_fac_new)
     pf.unregister_event_handler(pf.EVENT_NEW_GAME,
                                 DiplomacyVC.__on_new_game)
Exemplo n.º 3
0
    def __on_load_confirm(self, event):
        pf.unregister_event_handler(EVENT_FILE_CHOOSER_OKAY, MenuVC.__on_load_confirm)
        pf.unregister_event_handler(EVENT_FILE_CHOOSER_CANCEL, MenuVC.__on_load_cancel)

        assert self.fc is not None
        self.fc.hide()
        self.fc = None
        self.activate()

        args = event if event[1] is not None else (event[0],)
        pf.exec_(sys.argv[0], args)
Exemplo n.º 4
0
 def deactivate(self):
     pf.unregister_event_handler(EVENT_SELECTED_TILE_CHANGED,
                                 TerrainTabVC.__on_selected_tile_changed)
     pf.unregister_event_handler(EVENT_SDL_MOUSEBUTTONDOWN,
                                 TerrainTabVC.__on_mouse_pressed)
     pf.unregister_event_handler(EVENT_SDL_MOUSEBUTTONUP,
                                 TerrainTabVC.__on_mouse_released)
     pf.unregister_event_handler(EVENT_TERRAIN_BRUSH_SIZE_CHANGED,
                                 TerrainTabVC.__on_brush_size_changed)
Exemplo n.º 5
0
    def __on_load_confirm(self, event):
        pf.unregister_event_handler(EVENT_FILE_CHOOSER_OKAY,
                                    MenuVC.__on_load_confirm)
        pf.unregister_event_handler(EVENT_FILE_CHOOSER_CANCEL,
                                    MenuVC.__on_load_cancel)

        assert self.fc is not None
        self.fc.hide()
        self.fc = None
        self.activate()

        try:
            new_map = map.Map.from_filepath(event[0])
        except:
            print("Failed to load map! [{0}]".format(event[0]))
        else:
            pf.global_event(EVENT_OLD_GAME_TEARDOWN_BEGIN, (new_map, event[1]))
Exemplo n.º 6
0
    def on_save_as_confirm(self, event):
        pf.unregister_event_handler(EVENT_FILE_CHOOSER_OKAY,
                                    MenuVC.on_save_as_confirm)
        pf.unregister_event_handler(EVENT_FILE_CHOOSER_CANCEL,
                                    MenuVC.on_save_as_cancel)

        assert self.fc is not None
        self.fc.hide()
        self.fc = None
        self.activate()

        globals.active_map.filename = event
        try:
            globals.active_map.write_to_file()
        except:
            pass
        else:
            self.view.hide()
Exemplo n.º 7
0
    def __on_save_as_confirm(self, event):
        pf.unregister_event_handler(EVENT_FILE_CHOOSER_OKAY, MenuVC.__on_save_as_confirm)
        pf.unregister_event_handler(EVENT_FILE_CHOOSER_CANCEL, MenuVC.__on_save_as_cancel)

        assert self.fc is not None
        self.fc.hide()
        self.fc = None
        self.activate()

        old_filename = globals.active_map.filename
        globals.active_map.filename = event[0]
        try: 
            globals.active_map.write_to_file()
            if event[1] is not None:
                scene.save_scene(event[1])
                globals.scene_filename = event[1]
        except:
            globals.active_map.filename = old_filename
            print("Failed to save map/scene!")
            traceback.print_exc() 
        else: 
            self.view.hide()
Exemplo n.º 8
0
    def on_load_confirm(self, event):
        pf.unregister_event_handler(EVENT_FILE_CHOOSER_OKAY,
                                    MenuVC.on_load_confirm)
        pf.unregister_event_handler(EVENT_FILE_CHOOSER_CANCEL,
                                    MenuVC.on_load_cancel)

        assert self.fc is not None
        self.fc.hide()
        self.fc = None
        self.activate()

        import os.path
        if os.path.isfile(event):
            new_map = map.Map.from_filepath(event)
            if new_map is not None:
                globals.active_map = new_map
                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()
Exemplo n.º 9
0
 def deactivate(self):
     pf.unregister_event_handler(pf.SDL_MOUSEMOTION,
                                 ObjectsVC.__on_mousemove)
     pf.unregister_event_handler(pf.SDL_MOUSEBUTTONDOWN,
                                 ObjectsVC.__on_click)
     pf.unregister_event_handler(pf.SDL_MOUSEBUTTONUP,
                                 ObjectsVC.__on_release)
     pf.unregister_event_handler(pf.SDL_MOUSEWHEEL,
                                 ObjectsVC.__on_mousewheel)
     pf.unregister_event_handler(pf.EVENT_NEW_GAME, ObjectsVC.__on_new_game)
     pf.unregister_event_handler(EVENT_OBJECT_SELECTION_CHANGED,
                                 ObjectsVC.__on_selected_object_changed)
     pf.unregister_event_handler(EVENT_MOUSE_ENTERED_MAP,
                                 ObjectsVC.__on_mouse_enter_map)
     pf.unregister_event_handler(EVENT_MOUSE_EXITED_MAP,
                                 ObjectsVC.__on_mouse_exit_map)
     pf.unregister_event_handler(EVENT_OBJECTS_TAB_MODE_CHANGED,
                                 ObjectsVC.__on_mode_changed)
     pf.unregister_event_handler(EVENT_OBJECT_SELECTED_UNIT_PICKED,
                                 ObjectsVC.__on_selected_unit_picked)
     pf.unregister_event_handler(EVENT_OBJECT_DELETE_SELECTION,
                                 ObjectsVC.__on_delete_selection)
     pf.unregister_event_handler(EVENT_OLD_GAME_TEARDOWN_BEGIN,
                                 ObjectsVC.__on_old_game_teardown_begin)
     pf.clear_unit_selection()
     pf.disable_unit_selection()
     self.current_object = None
Exemplo n.º 10
0
 def deactivate(self):
     pf.unregister_event_handler(pf.SDL_MOUSEMOTION, ObjectsVC.__on_mousemove)
     pf.unregister_event_handler(pf.SDL_MOUSEBUTTONDOWN, ObjectsVC.__on_click)
     pf.unregister_event_handler(pf.SDL_MOUSEBUTTONUP, ObjectsVC.__on_release)
     pf.unregister_event_handler(pf.SDL_MOUSEWHEEL, ObjectsVC.__on_mousewheel)
     pf.unregister_event_handler(EVENT_OBJECT_SELECTION_CHANGED, ObjectsVC.__on_selected_object_changed)
     pf.unregister_event_handler(EVENT_OBJECTS_TAB_MODE_CHANGED, ObjectsVC.__on_mode_changed)
     pf.unregister_event_handler(EVENT_OBJECT_SELECTED_UNIT_PICKED, ObjectsVC.__on_selected_unit_picked)
     pf.unregister_event_handler(EVENT_OBJECT_DELETE_SELECTION, ObjectsVC.__on_delete_selection)
     pf.clear_unit_selection()
     pf.disable_unit_selection()
     self.current_object = None
Exemplo n.º 11
0
 def deactivate(self):
     pf.unregister_event_handler(EVENT_WATER_REF_SETTING_CHANGED, VideoSettingsVC.__update_dirty)
     pf.unregister_event_handler(EVENT_SHADOWS_SETTING_CHANGED, VideoSettingsVC.__update_dirty)
     pf.unregister_event_handler(EVENT_VSYNC_SETTING_CHANGED, VideoSettingsVC.__update_dirty)
     pf.unregister_event_handler(EVENT_WIN_TOP_SETTING_CHANGED, VideoSettingsVC.__update_dirty)
     pf.unregister_event_handler(EVENT_AR_SETTING_CHANGED, VideoSettingsVC.__update_dirty)
     pf.unregister_event_handler(EVENT_WINMODE_SETTING_CHANGED, VideoSettingsVC.__update_dirty)
     pf.unregister_event_handler(EVENT_RES_SETTING_CHANGED, VideoSettingsVC.__update_dirty)
     pf.unregister_event_handler(EVENT_SETTINGS_APPLY, VideoSettingsVC.__on_settings_apply)
Exemplo n.º 12
0
 def deactivate(self):
     self.__view.hide()
     pf.unregister_event_handler(
         common.constants.EVENT_SESSION_SAVE_REQUESTED,
         DemoVC.__on_session_save)
     pf.unregister_event_handler(
         common.constants.EVENT_SESSION_LOAD_REQUESTED,
         DemoVC.__on_session_load)
     pf.unregister_event_handler(EVENT_SESSION_SHOW,
                                 DemoVC.__on_session_show)
     pf.unregister_event_handler(EVENT_SIMSTATE_CHANGE,
                                 DemoVC.__on_ss_change)
     pf.unregister_event_handler(common.constants.EVENT_SETTINGS_HIDE,
                                 DemoVC.__on_settings_hide)
     pf.unregister_event_handler(EVENT_PERF_SHOW, DemoVC.__on_perf_show,
                                 self)
     pf.unregister_event_handler(EVENT_SETTINGS_SHOW,
                                 DemoVC.__on_settings_show)
     pf.unregister_event_handler(EVENT_CONTROLLED_FACTION_CHANGED,
                                 DemoVC.__on_controlled_faction_chagned)
Exemplo n.º 13
0
 def deactivate(self):
     self.__view.hide()
     pf.unregister_event_handler(common.constants.EVENT_SETTINGS_HIDE, DemoVC.__on_settings_hide)
     pf.unregister_event_handler(EVENT_PERF_SHOW, DemoVC.__on_perf_show, self)
     pf.unregister_event_handler(EVENT_SETTINGS_SHOW, DemoVC.__on_settings_show)
     pf.unregister_event_handler(EVENT_CONTROLLED_FACTION_CHANGED, DemoVC.__on_controlled_faction_chagned)
Exemplo n.º 14
0
 def deactivate(self):
     pf.unregister_event_handler(EVENT_MENU_NEW, MenuVC.on_new)
     pf.unregister_event_handler(EVENT_MENU_LOAD, MenuVC.on_load)
     pf.unregister_event_handler(EVENT_MENU_SAVE, MenuVC.on_save)
     pf.unregister_event_handler(EVENT_MENU_SAVE_AS, MenuVC.on_save_as)
     pf.unregister_event_handler(EVENT_MENU_EXIT, MenuVC.on_exit)
     pf.unregister_event_handler(EVENT_MENU_CANCEL, MenuVC.on_cancel)
Exemplo n.º 15
0
 def deactivate(self):
     pf.unregister_event_handler(EVENT_MENU_NEW, MenuVC.__on_new)
     pf.unregister_event_handler(EVENT_MENU_LOAD, MenuVC.__on_load)
     pf.unregister_event_handler(EVENT_MENU_SAVE, MenuVC.__on_save)
     pf.unregister_event_handler(EVENT_MENU_SAVE_AS, MenuVC.__on_save_as)
     pf.unregister_event_handler(EVENT_MENU_EXIT, MenuVC.__on_exit)
     pf.unregister_event_handler(EVENT_MENU_CANCEL, MenuVC.__on_cancel)
     pf.unregister_event_handler(EVENT_MENU_SETTINGS_SHOW,
                                 MenuVC.__on_settings_show)
     pf.unregister_event_handler(common.constants.EVENT_SETTINGS_HIDE,
                                 MenuVC.__on_settings_hide)
     pf.unregister_event_handler(EVENT_MENU_PERF_SHOW,
                                 MenuVC.__on_perf_show)
     pf.unregister_event_handler(EVENT_MENU_SESSION_SHOW,
                                 MenuVC.__on_session_show)
     pf.unregister_event_handler(EVENT_OLD_GAME_TEARDOWN_BEGIN,
                                 MenuVC.__on_old_game_teardown_begin)
     pf.unregister_event_handler(EVENT_OLD_GAME_TEARDOWN_END,
                                 MenuVC.__on_old_game_teardown_end)
     pf.unregister_event_handler(
         common.constants.EVENT_SESSION_SAVE_REQUESTED,
         MenuVC.__on_session_save)
     pf.unregister_event_handler(
         common.constants.EVENT_SESSION_LOAD_REQUESTED,
         MenuVC.__on_session_load)
Exemplo n.º 16
0
 def deactivate(self):
     self.__view.hide()
     pf.unregister_event_handler(pf.SDL_KEYDOWN, ActionPadVC.__on_keydown)
     pf.unregister_event_handler(pf.EVENT_UNIT_SELECTION_CHANGED,
                                 ActionPadVC.__on_selection_changed)
Exemplo n.º 17
0
 def deactivate(self):
     pf.unregister_event_handler(EVENT_SETTINGS_APPLY, GameSettingsVC.__on_settings_apply)
     pf.unregister_event_handler(EVENT_SETTINGS_HB_MODE_CHANGED, GameSettingsVC.__on_hb_mode_changed)
Exemplo n.º 18
0
 def deactivate(self):
     self.view.hide()
     if len(self.__children) > 0:
         self.__children[self.__active_idx].deactivate()
     pf.unregister_event_handler(self.__tce, TabBarVC.__on_tab_changed)
Exemplo n.º 19
0
 def deactivate(self):
     pf.unregister_event_handler(EVENT_MENU_NEW, MenuVC.__on_new)
     pf.unregister_event_handler(EVENT_MENU_LOAD, MenuVC.__on_load)
     pf.unregister_event_handler(EVENT_MENU_SAVE, MenuVC.__on_save)
     pf.unregister_event_handler(EVENT_MENU_SAVE_AS, MenuVC.__on_save_as)
     pf.unregister_event_handler(EVENT_MENU_EXIT, MenuVC.__on_exit)
     pf.unregister_event_handler(EVENT_MENU_CANCEL, MenuVC.__on_cancel)
     pf.unregister_event_handler(EVENT_OLD_GAME_TEARDOWN_BEGIN,
                                 MenuVC.__on_old_game_teardown_begin)
     pf.unregister_event_handler(EVENT_OLD_GAME_TEARDOWN_END,
                                 MenuVC.__on_old_game_teardown_end)
Exemplo n.º 20
0
 def deactivate(self):
     self.children[self.active_idx].deactivate()
     pf.unregister_event_handler(EVENT_TOP_TAB_SELECTION_CHANGED,
                                 TabBarVC.__on_tab_changed)
 def deactivate(self):
     pf.unregister_event_handler(EVENT_SHADOWS_SETTING_CHANGED,
                                 VideoSettingsVC.__on_vsync_changed)
     pf.unregister_event_handler(EVENT_VSYNC_SETTING_CHANGED,
                                 VideoSettingsVC.__on_vsync_changed)
     pf.unregister_event_handler(EVENT_WIN_TOP_SETTING_CHANGED,
                                 VideoSettingsVC.__on_win_ontop_changed)
     pf.unregister_event_handler(EVENT_AR_SETTING_CHANGED,
                                 VideoSettingsVC.__on_aspect_ratio_changed)
     pf.unregister_event_handler(EVENT_WINMODE_SETTING_CHANGED,
                                 VideoSettingsVC.__on_winmode_changed)
     pf.unregister_event_handler(EVENT_RES_SETTING_CHANGED,
                                 VideoSettingsVC.__on_resolution_changed)
     pf.unregister_event_handler(EVENT_SETTINGS_APPLY,
                                 VideoSettingsVC.__on_settings_apply)