Beispiel #1
0
 def load_view(self,
               model: Gtk.TreeModel,
               treeiter: Gtk.TreeIter,
               tree: Gtk.TreeView,
               scroll_into_view=True):
     logger.debug('View selected. Locking and showing Loader.')
     path = model.get_path(treeiter)
     self._lock_trees()
     selected_node = model[treeiter]
     self._init_window_before_view_load(model[treeiter])
     # Show loading stack page in editor stack
     self._editor_stack.set_visible_child(
         self.builder.get_object('es_loading'))
     # Set current view values for later check (if race conditions between fast switching)
     self._current_view_module = selected_node[2]
     self._current_view_controller_class = selected_node[3]
     self._current_view_item_id = selected_node[4]
     # Fully load the view and the controller
     AsyncTaskDelegator.run_task(
         load_controller(
             self._current_view_module,
             self._current_view_controller_class,
             self._current_view_item_id,  # type: ignore
             self  # type: ignore
         ))
     # Expand the node
     tree.expand_to_path(path)
     # Select node
     tree.get_selection().select_path(path)
     # Scroll node into view
     if scroll_into_view:
         tree.scroll_to_cell(path, None, True, 0.5, 0.5)
     self._last_selected_view_model = model
     self._last_selected_view_iter = treeiter
Beispiel #2
0
 def open(cls,
          filename,
          main_controller: Optional['MainController'] = None):
     """
     Open a file (in a new thread).
     If the main controller is set, it will be informed about this.
     """
     AsyncTaskDelegator.run_task(cls._open_impl(
         filename, main_controller))  # type: ignore
Beispiel #3
0
 def export_sprite(self, wan: bytes, dir_fn: str):
     with tempfile.TemporaryDirectory() as tmp_path:
         tmp_path = os.path.join(tmp_path, 'tmp.wan')
         with open(tmp_path, 'wb') as f:
             f.write(wan)
         AsyncTaskDelegator.run_task(self._run_gfxcrunch([tmp_path, dir_fn]))
         self._run_window()
         if self.status != GfxcrunchStatus.SUCCESS:
             raise make_user_err(RuntimeError, _("The gfxcrunch process failed."))
Beispiel #4
0
 def import_sprite(self, dir_fn: str) -> bytes:
     with tempfile.TemporaryDirectory() as tmp_path:
         tmp_path = os.path.join(tmp_path, 'tmp.wan')
         AsyncTaskDelegator.run_task(self._run_gfxcrunch([dir_fn, tmp_path]))
         self._run_window()
         if self.status == GfxcrunchStatus.SUCCESS:
             with open(tmp_path, 'rb') as f:
                 return f.read()
         else:
             raise make_user_err(RuntimeError, _("The gfxcrunch process failed."))
Beispiel #5
0
    def __init__(self):
        """
        Tries to initialize the connection with Discord.
        :raises: ConnectionRefusedError
        """
        self.rpc: BaseClient
        if AsyncTaskDelegator.support_aio():
            self.rpc = AioPresence(CLIENT_ID)
        else:
            self.rpc = Presence(CLIENT_ID)
            self.rpc.connect()
        self._idle_timeout_id = None

        self.start = None
        self._reset_playtime()
        self.current_presence = 'main'
        self.module_info = None
        self.module_state = None
        self.rom_name = None
        self.debugger_script_name = None
        self.project: Optional[RomProject] = None
Beispiel #6
0
 def _load_item(self, itm: ItemPEntry, after_load_cb):
     AsyncTaskDelegator.run_task(self._load_item__impl(itm, after_load_cb))
Beispiel #7
0
 def _load_trap(self, trp: int, after_load_cb):
     AsyncTaskDelegator.run_task(self._load_trap__impl(trp, after_load_cb))
Beispiel #8
0
 def _load_object(self, name, after_load_cb):
     AsyncTaskDelegator.run_task(
         self._load_object__impl(name, after_load_cb))
Beispiel #9
0
 def _load_monster_outline(self, md_index, direction_id: int,
                           after_load_cb):
     AsyncTaskDelegator.run_task(
         self._load_monster_outline__impl(md_index, direction_id,
                                          after_load_cb))
Beispiel #10
0
 def _load_actor_placeholder(self, actor_id, direction_id: int,
                             after_load_cb):
     AsyncTaskDelegator.run_task(
         self._load_actor_placeholder__impl(actor_id, direction_id,
                                            after_load_cb))
Beispiel #11
0
 def save(self, main_controller: Optional['MainController']):
     """Save the rom. The main controller will be informed about this, if given."""
     AsyncTaskDelegator.run_task(self._save_impl(main_controller))
 def _load(self, entry_id, sub_id, after_load_cb, allow_fallback):
     AsyncTaskDelegator.run_task(
         self._load__impl(entry_id, sub_id, after_load_cb, allow_fallback))
Beispiel #13
0
def main():
    # TODO: At the moment doesn't support any cli arguments.
    logging.basicConfig()
    logging.getLogger().setLevel(SKYTEMPLE_LOGLEVEL)
    from skytemple.core.async_tasks.delegator import AsyncTaskDelegator
    AsyncTaskDelegator.run_main(run_main, settings)