コード例 #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
     AsyncTaskRunner.instance().run_task(load_controller(
         self._current_view_module, self._current_view_controller_class, self._current_view_item_id,
         self
     ))
     # 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
コード例 #2
0
ファイル: gfxcrunch.py プロジェクト: marius851000/skytemple
 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)
         AsyncTaskRunner.instance().run_task(self._run_gfxcrunch([tmp_path, dir_fn]))
         self._run_window()
         if self.status != GfxcrunchStatus.SUCCESS:
             raise RuntimeError(_("The gfxcrunch process failed."))
コード例 #3
0
ファイル: gfxcrunch.py プロジェクト: marius851000/skytemple
 def import_sprite(self, dir_fn: str) -> bytes:
     with tempfile.TemporaryDirectory() as tmp_path:
         tmp_path = os.path.join(tmp_path, 'tmp.wan')
         AsyncTaskRunner.instance().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 RuntimeError(_("The gfxcrunch process failed."))
コード例 #4
0
ファイル: delegator.py プロジェクト: SkyTemple/skytemple
 def run_task(cls, coro: Coroutine):
     """
     This runs the coroutine, depending on the current configuration for async tasks.
     """
     if cls.config_type(
     ).async_task_runner_type == AsyncTaskRunnerType.THREAD_BASED:
         AsyncTaskRunner.instance().run_task(coro)
     elif cls.config_type(
     ).async_task_runner_type == AsyncTaskRunnerType.EVENT_LOOP_BLOCKING:
         Now.instance().run_task(coro)
     elif cls.config_type(
     ).async_task_runner_type == AsyncTaskRunnerType.EVENT_LOOP_BLOCKING_SOON:
         GLib.idle_add(lambda: Now.instance().run_task(coro))
     elif cls.config_type(
     ).async_task_runner_type == AsyncTaskRunnerType.EVENT_LOOP_CONCURRENT:
         asyncio.create_task(coro)
     else:
         raise RuntimeError("Invalid async configuration")
コード例 #5
0
ファイル: main.py プロジェクト: marius851000/skytemple
def main():
    # TODO: Gtk.Application: https://python-gtk-3-tutorial.readthedocs.io/en/latest/application.html
    path = os.path.abspath(os.path.dirname(__file__))

    # Load settings
    settings = SkyTempleSettingsStore()

    if sys.platform.startswith('win'):
        # Load theming under Windows
        _load_theme(settings)
        # Solve issue #12
        try:
            from skytemple_files.common.platform_utils.win import win_set_error_mode
            win_set_error_mode()
        except BaseException:
            # This really shouldn't fail, but it's not important enough to crash over
            pass

    if sys.platform.startswith('darwin'):
        # Load theming under macOS
        _load_theme(settings)

        # The search path is wrong if SkyTemple is executed as an .app bundle
        if getattr(sys, 'frozen', False):
            path = os.path.dirname(sys.executable)

    if sys.platform.startswith('linux') and gdk_backend() == GDK_BACKEND_BROADWAY:
        gtk_settings = Gtk.Settings.get_default()
        gtk_settings.set_property("gtk-theme-name", 'Arc-Dark')
        gtk_settings.set_property("gtk-application-prefer-dark-theme", True)

    itheme: Gtk.IconTheme = Gtk.IconTheme.get_default()
    itheme.append_search_path(os.path.abspath(icons()))
    itheme.append_search_path(os.path.abspath(os.path.join(data_dir(), "icons")))
    itheme.append_search_path(os.path.abspath(os.path.join(get_debugger_data_dir(), "icons")))
    itheme.rescan_if_needed()

    # Load Builder and Window
    builder = make_builder(os.path.join(path, "skytemple.glade"))
    main_window: Window = builder.get_object("main_window")
    main_window.set_role("SkyTemple")
    GLib.set_application_name("SkyTemple")
    GLib.set_prgname("skytemple")
    # TODO: Deprecated but the only way to set the app title on GNOME...?
    main_window.set_wmclass("SkyTemple", "SkyTemple")

    # Load CSS
    style_provider = Gtk.CssProvider()
    with open(os.path.join(path, "skytemple.css"), 'rb') as f:
        css = f.read()
    style_provider.load_from_data(css)
    Gtk.StyleContext.add_provider_for_screen(
        Gdk.Screen.get_default(), style_provider,
        Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
    )

    # Load async task runner thread
    AsyncTaskRunner.instance()

    # Init. core events
    event_manager = EventManager.instance()
    if settings.get_integration_discord_enabled():
        try:
            from skytemple.core.events.impl.discord import DiscordPresence
            discord_listener = DiscordPresence()
            event_manager.register_listener(discord_listener)
        except BaseException:
            pass

    # Load modules
    Modules.load()

    # Load main window + controller
    MainController(builder, main_window, settings)

    main_window.present()
    main_window.set_icon_name('skytemple')
    try:
        Gtk.main()
    except (KeyboardInterrupt, SystemExit):
        AsyncTaskRunner.end()
コード例 #6
0
 def _load_object(self, name, after_load_cb):
     AsyncTaskRunner.instance().run_task(
         self._load_object__impl(name, after_load_cb))
コード例 #7
0
 def _load_monster_outline(self, md_index, direction_id: int,
                           after_load_cb):
     AsyncTaskRunner.instance().run_task(
         self._load_monster_outline__impl(md_index, direction_id,
                                          after_load_cb))
コード例 #8
0
 def _load_actor_placeholder(self, actor_id, direction_id: int,
                             after_load_cb):
     AsyncTaskRunner.instance().run_task(
         self._load_actor_placeholder__impl(actor_id, direction_id,
                                            after_load_cb))
コード例 #9
0
ファイル: portrait_provider.py プロジェクト: riiswa/skytemple
 def _load(self, entry_id, sub_id, after_load_cb, allow_fallback):
     AsyncTaskRunner.instance().run_task(self._load__impl(entry_id, sub_id, after_load_cb, allow_fallback))
コード例 #10
0
 def _load_item(self, itm: ItemPEntry, after_load_cb):
     AsyncTaskRunner.instance().run_task(
         self._load_item__impl(itm, after_load_cb))
コード例 #11
0
 def _load_trap(self, trp: int, after_load_cb):
     AsyncTaskRunner.instance().run_task(
         self._load_trap__impl(trp, after_load_cb))