예제 #1
0
def capture_error(exc_info: Optional[ExceptionInfo], **error_context: Capturable):
    from skytemple.core.settings import SkyTempleSettingsStore
    try:
        settings = SkyTempleSettingsStore()
        if settings.get_allow_sentry():
            from skytemple.core import sentry
            sentry.capture(settings, exc_info, **error_context)
    except Exception as ex:
        logger.error("Failed capturing error", exc_info=ex)
예제 #2
0
def _load_theme(settings: SkyTempleSettingsStore):
    gtk_settings = Gtk.Settings.get_default()
    theme = settings.get_gtk_theme()
    if theme is None:
        theme = 'Arc-Dark'
        if sys.platform.startswith('win'):
            from skytemple_files.common.platform_utils.win import win_use_light_theme
            theme = 'ZorinBlue-Light'
            if not win_use_light_theme():
                theme = 'ZorinBlue-Dark'
        if sys.platform.startswith('darwin'):
            from skytemple_files.common.platform_utils.macos import macos_use_light_theme
            theme = 'ZorinBlue-Light'
            if not macos_use_light_theme():
                theme = 'ZorinBlue-Dark'
    gtk_settings.set_property("gtk-theme-name", theme)
예제 #3
0
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()
예제 #4
0
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with SkyTemple.  If not, see <https://www.gnu.org/licenses/>.
import logging
import os
import sys
import locale
import gettext
from skytemple.core.ui_utils import data_dir, APP, gdk_backend, GDK_BACKEND_BROADWAY

# Setup locale :(
from skytemple.core.settings import SkyTempleSettingsStore
LOCALE_DIR = os.path.abspath(os.path.join(data_dir(), 'locale'))
settings = SkyTempleSettingsStore()
if hasattr(locale, 'bindtextdomain'):
    libintl = locale
elif sys.platform.startswith('win'):
    import ctypes
    import ctypes.util
    if os.getenv('LANG') is None:
        lang, enc = locale.getdefaultlocale()
        os.environ['LANG'] = lang
        ctypes.cdll.msvcrt._putenv ("LANG=" + lang)
    libintl_loc = os.path.join(os.path.dirname(__file__), 'libintl-8.dll')
    if os.path.exists(libintl_loc):
        libintl = ctypes.cdll.LoadLibrary(libintl_loc)
    else:
        libintl = ctypes.cdll.LoadLibrary(ctypes.util.find_library('libintl-8'))
elif sys.platform == 'darwin':
예제 #5
0
def _load_theme(settings: SkyTempleSettingsStore):
    gtk_settings = Gtk.Settings.get_default()
    gtk_settings.set_property("gtk-theme-name", settings.get_gtk_theme(default='Arc-Dark'))
예제 #6
0
 def config_type(cls):
     if cls._config_type is None:
         from skytemple.core.settings import SkyTempleSettingsStore
         cls._config_type = SkyTempleSettingsStore(
         ).get_async_configuration()
     return cls._config_type
예제 #7
0
파일: main.py 프로젝트: SkyTemple/skytemple
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with SkyTemple.  If not, see <https://www.gnu.org/licenses/>.
import logging
import os
import sys
import locale
import gettext
from skytemple.core.ui_utils import data_dir, APP, gdk_backend, GDK_BACKEND_BROADWAY
from skytemple.core.settings import SkyTempleSettingsStore
from skytemple_files.common.impl_cfg import ENV_SKYTEMPLE_USE_NATIVE, change_implementation_type

settings = SkyTempleSettingsStore()

# Setup Sentry
if settings.get_allow_sentry():
    from skytemple.core import sentry
    sentry.init()

# Setup native library integration
if ENV_SKYTEMPLE_USE_NATIVE not in os.environ:
    change_implementation_type(settings.get_implementation_type())

# Setup locale :(
LOCALE_DIR = os.path.abspath(os.path.join(data_dir(), 'locale'))
if hasattr(locale, 'bindtextdomain'):
    libintl = locale
elif sys.platform.startswith('win'):