Exemplo n.º 1
0
    def __init__(self, parent, icon, title, subtitle="",
                 icon_position=ICON_RIGHT):
        unused(subtitle)
        fsui.Group.__init__(self, parent)
        self.layout = fsui.HorizontalLayout()

        image = icon.image(48)
        self.image_view = fsui.ImageView(self, image)
        if icon_position == self.ICON_LEFT:
            self.layout.add(self.image_view)
            self.layout.add_spacer(20)

        # vert_layout = fsui.VerticalLayout()
        # self.layout.add(
        #     vert_layout, expand=True, fill=False, valign=0.5)
        self.title_label = fsui.HeadingLabel(self, title)
        if Skin.fws():
            font = fsui.Font("Roboto", 26)
            self.title_label.set_font(font)
            self.layout.add(
                self.title_label, expand=True, fill=False, valign=0.0)
        else:
            font = self.title_label.get_font()
            font.increase_size(3)
            self.title_label.set_font(font)
            self.layout.add(
                self.title_label, expand=True, fill=False, valign=0.5)

        if icon_position == self.ICON_RIGHT:
            self.layout.add_spacer(20)
            self.layout.add(self.image_view)
Exemplo n.º 2
0
 def update_title(self):
     if Skin.fws():
         # Just want to keep "FS-UAE Launcher" in the title
         return
     auth = LauncherSettings.get(Option.DATABASE_AUTH)
     if auth:
         username = LauncherSettings.get(Option.DATABASE_USERNAME)
         login_info = username
     else:
         login_info = gettext("Not logged in")
     app_name = "{} Launcher".format(Product.base_name)
     title = "{} {} ({})".format(app_name,
                                 Application.instance().version, login_info)
     self.set_title(title)
    def __init__(self,
                 parent,
                 icon,
                 title,
                 subtitle="",
                 icon_position=ICON_RIGHT):
        unused(subtitle)
        fsui.Group.__init__(self, parent)
        self.layout = fsui.HorizontalLayout()

        image = icon.image(48)
        self.image_view = fsui.ImageView(self, image)
        if icon_position == self.ICON_LEFT:
            self.layout.add(self.image_view)
            self.layout.add_spacer(20)

        # vert_layout = fsui.VerticalLayout()
        # self.layout.add(
        #     vert_layout, expand=True, fill=False, valign=0.5)
        self.title_label = fsui.HeadingLabel(self, title)
        if Skin.fws() or True:
            font = fsui.Font("Roboto", 26)
            self.title_label.set_font(font)
            self.layout.add(self.title_label,
                            expand=True,
                            fill=False,
                            valign=0.0)
        else:
            font = self.title_label.get_font()
            font.increase_size(3)
            self.title_label.set_font(font)
            self.layout.add(self.title_label,
                            expand=True,
                            fill=False,
                            valign=0.5)

        if icon_position == self.ICON_RIGHT:
            self.layout.add_spacer(20)
            self.layout.add(self.image_view)
Exemplo n.º 4
0
    def __init__(self, fsgs=None):
        LauncherWindow._current = weakref.ref(self)
        # Old name
        if fsgs is not None:
            self.fsgs = fsgs
        else:
            self.fsgs = default_context()
        # New name
        self.gsc = self.fsgs

        from launcher.launcherapp import LauncherApp

        LauncherApp.pre_start()

        border = True
        maximize = None
        menu = False
        if launcher.ui.get_screen_size()[1] <= 768:
            if fstd.desktop.is_running_gnome_3():
                border = False
                if "--window-border" in sys.argv:
                    border = True
            maximize = True
        if Skin.fws():
            border = False
            menu = True
        if "--no-window-border" in sys.argv:
            border = False

        if fsgs_module.product == "OpenRetro":
            app_name = "OpenRetro Launcher"
        else:
            app_name = "FS-UAE Launcher"
        if Skin.fws():
            title = app_name
        else:
            title = "{} {}".format(app_name, Application.instance().version)

        WindowWithTabs.__init__(self, None, title, border=border, menu=menu)
        icon = self.find_icon()
        if icon:
            self.set_icon_from_path(icon)
        self.main_layout = fsui.VerticalLayout()

        self.books = []
        self.config_browser = None
        self.configurations_panel = None
        self.main_menu_close_time = 0
        self.main_panel = None
        self._menu = None
        self.menu_button = None
        self.quick_settings_panel = None
        self.tab_panels = []
        self.user_button = None
        self.user_menu_close_time = 0

        self.set_content(self.main_layout)
        self.column_layout = fsui.HorizontalLayout()
        self.main_layout.add(self.column_layout, fill=True, expand=True)

        # left border
        self.create_column(0,
                           min_width=Skin.get_window_padding_left(),
                           content=False)
        # left content
        # if fs_uae_launcher.ui.get_screen_size()[0] > 1024:
        #     left_width = 518
        # else:
        #     left_width = 400
        # FIXME: adjust
        left_width = 462
        self.create_column(1, min_width=left_width)

        # right content
        # right_width = Constants.SCREEN_SIZE[0] * 2 + 21 + 10 + 10
        extra_screenshot_width = Constants.SCREEN_SIZE[0] + 21
        need_width = 1280

        right_width = 518

        if self.is_editor_enabled():
            # need_width += extra_screen_width
            pass
        else:
            if launcher.ui.get_screen_size()[0] >= need_width:
                # make room for one more screenshot
                right_width += extra_screenshot_width
                pass

        # right_width = 518

        # if Skin.EXTRA_GROUP_MARGIN:
        #     self.main_layout.add_spacer(Skin.EXTRA_GROUP_MARGIN)

        self.create_column(2, min_width=right_width, expand=True)

        # right border
        self.create_column(3,
                           min_width=Skin.get_window_padding_right(),
                           content=False)

        # if self.is_editor_enabled():
        #     from ..editor.EditorGroup import EditorGroup
        #     editor = EditorGroup(self)
        #     self.main_layout.add(editor, fill=True, expand=True,
        #                          margin_right=20)

        # if fs_uae_launcher.ui.get_screen_size()[1] >= 768:
        #     right_margin = 0

        if launcher.ui.get_screen_size()[1] >= 720:
            self.bottom_layout = fsui.HorizontalLayout()
            self.main_layout.add(self.bottom_layout, fill=True)

            bottom_panel = BottomPanel(self)
            bottom_panel.set_min_width(10)
            bottom_panel.set_min_height(Skin.get_bottom_panel_height())
            self.bottom_layout.add(bottom_panel, fill=True)

            self.screenshots_panel = ScreenshotsPanel(self)
            self.bottom_layout.add(self.screenshots_panel, fill=True)

            self.game_info_panel = GameInfoPanel(self)
            self.game_info_panel.set_min_width(GAME_INFO_PANEL_MIN_WIDTH)
            self.bottom_layout.add(self.game_info_panel,
                                   fill=True,
                                   expand=True)

            bottom_panel = BottomPanel(self)
            bottom_panel.set_min_width(10)
            bottom_panel.set_min_height(Skin.get_bottom_panel_height())
            self.bottom_layout.add(bottom_panel, fill=True)
        else:
            self.bottom_layout = None
            self.screenshots_panel = None

        # right_margin = -10 - Skin.EXTRA_GROUP_MARGIN
        #     else:
        #         bottom_panel = None
        #     # FIXME:
        #     if bottom_panel is None:
        #         layout.add_spacer(0, Skin.get_bottom_panel_height())
        #     else:
        #         bottom_panel.set_min_height(Skin.get_bottom_panel_height())
        #         layout.add(bottom_panel, fill=True, margin_right=right_margin)
        # elif column == 1:
        #     group = LaunchGroup(self)
        #     layout.add(group, fill=True, margin=10, margin_top=0)
        #     layout.add_spacer(0, 10)

        self.realize_tabs()
        # self._menu = self.create_menu()
        if fsui.System.macosx and fsui.toolkit == "wx":
            # import wx
            # self.tools_menu = self.create_menu()
            # menu_bar = wx.MenuBar()
            # menu_bar.Append(self.tools_menu._menu, _("Tools"))
            # self.SetMenuBar(menu_bar)
            pass

        self.status_bar = StatusBar(self)
        self.layout.add(self.status_bar, fill=True)

        was_maximized = LauncherSettings.get("maximized") == "1"

        if LauncherSettings.get(Option.LAUNCHER_CONFIG_FEATURE) == "1":
            if launcher.ui.get_screen_size()[0] > 1300:
                if launcher.ui.get_screen_size()[1] > 1000:
                    self.layout.min_width = 1280
                    self.layout.min_height = 720

        self.set_size(self.layout.get_min_size())

        self.center_on_screen()
        if was_maximized or maximize:
            self.maximize()

        LauncherSignal.add_listener("scan_done", self)
        LauncherSignal.add_listener("setting", self)

        self.update_title()
        self.check_for_update_once()
        self.implicit_config_handler = ImplicitConfigHandler(self)
Exemplo n.º 5
0
    def add_column_content(self, column):
        default_page_index = 0
        default_tab_index_offset = 0
        if column == 1:
            if Skin.fws():
                self.add_tab_spacer(5)
                self.add_tab_spacer(64)
            else:
                # if USE_MAIN_MENU:
                icon = fsui.Image("launcher:res/32/main-menu.png")
                self.menu_button = self.add_tab_button(
                    None,
                    icon,
                    gettext("Main Menu"),
                    menu_function=self.open_main_menu,
                    left_padding=5,
                )
            # default_tab_index_offset = 1
            # self.add_tab_spacer(60)
            # else:
            #    self.add_tab_spacer(10)

            # page_index = 0
            self.configurations_panel = self.add_page(
                column,
                ConfigurationsPanel,
                "",
                gettext("Configurations"),
                gettext("Configuration Browser"),
            )

            self.add_tab_spacer(0, expand=True)

        elif column == 2:
            self.new_tab_group()

            self.add_tab_spacer(10)
            self.add_page(
                column,
                MainPanel,
                "32x32/go-home",
                gettext("Config"),
                gettext("Main Configuration Options"),
            )
            self.add_page(
                column,
                FloppiesPanel,
                "32x32/media-floppy",
                gettext("Floppies"),
                gettext("Floppy Drives"),
            )
            self.add_page(
                column,
                CDPanel,
                "32x32/media-optical",
                gettext("CD-ROMs"),
                gettext("CD-ROM Drives"),
            )
            # noinspection SpellCheckingInspection
            self.add_page(
                column,
                HardDrivesPanel,
                "32x32/drive-harddisk",
                gettext("Hard Drives"),
            )
            self.add_scroll_page(
                column,
                RomRamPanel,
                "32x32/application-x-firmware",
                gettext("Hardware"),
                gettext("ROM and RAM"),
            )
            self.add_page(
                column,
                InputPanel,
                "32x32/applications-games",
                gettext("Input"),
                gettext("Input Options"),
            )
            self.add_scroll_page(
                column,
                ExpansionsPanel,
                "32x32/audio-card",
                gettext("Expansions"),
                gettext("Expansions"),
            )
            self.add_scroll_page(
                column,
                AdditionalConfigPanel,
                "32x32/system-shutdown",
                gettext("Additional Configuration"),
                gettext("Additional Configuration"),
            )

            self.add_tab_spacer(0, expand=True)
            self.add_tab_spacer(10)
            self.add_tab_button(
                self.toggle_quick_settings_sidebar,
                fsui.Image("launcher:res/32/quick-settings-sidebar.png"),
                gettext("Toggle quick settings sidebar"),
                right_padding=5,
            )

            # column - 1 is the group id of the tab group
            self.select_tab(default_page_index + default_tab_index_offset,
                            column - 1)
        self.books[column].set_page(default_page_index)
Exemplo n.º 6
0
    def __init__(self, parent, device_name):
        title = gettext("Configure {device_name}").format(
            device_name=device_name
        )
        super().__init__(
            parent,
            title=title,
            minimizable=False,
            maximizable=False,
            separator=False,
        )
        self.theme = WorkspaceTheme.instance()
        self.layout = fsui.VerticalLayout()

        self.image = fsui.Image("workspace:res/gamepad-config.png")
        self.joystick_panel = fsui.ImageView(self, self.image)
        self.layout.add(self.joystick_panel)

        if Skin.fws():
            from workspace.ui import TitleSeparator

            separator = TitleSeparator(self)
            self.layout.add(separator, fill=True)

        self.mapping_field = fsui.TextArea(
            self, read_only=True, line_wrap=False
        )
        self.layout.add(
            self.mapping_field,
            fill=True,
            margin_left=20,
            margin_top=20,
            margin_right=20,
        )

        panel = fsui.Panel(self)
        self.layout.add(panel, fill=True)

        panel.layout = fsui.HorizontalLayout()
        panel.layout.padding = 20

        self.device_type_ids = [
            "",
            "gamepad",
            "joystick",
            # "flightstick",
            "other",
        ]
        self.device_type_labels = [
            gettext("Choose Type"),
            gettext("Gamepad"),
            gettext("Digital Joystick"),
            # gettext("Flight Stick"),
            gettext("Other Device"),
        ]

        self.reset_button = fsui.Button(panel, gettext("Reset"))
        self.reset_button.activated.connect(self.on_reset_button)
        panel.layout.add(self.reset_button)

        self.priority_type_ids = [
            "axis,hat,button",
            "hat,button,axis",
        ]
        self.priority_type_labels = [
            gettext("Axes, hats, buttons"),
            gettext("Hats, buttons, axes"),
        ]
        self.priority_choice = fsui.Choice(panel, self.priority_type_labels)
        panel.layout.add(self.priority_choice, margin_left=20)

        self.type_field = fsui.Choice(panel, self.device_type_labels)
        panel.layout.add(self.type_field, margin_left=20)

        # panel.layout.add(
        #     fsui.PlainLabel(panel, gettext("Make:")), margin_left=20
        # )
        # self.make_field = fsui.TextField(panel)
        # self.make_field.set_min_width(140)
        # panel.layout.add(self.make_field, margin_left=10)

        panel.layout.add(
            fsui.PlainLabel(panel, gettext("Model:")), margin_left=20
        )
        self.model_field = fsui.TextField(panel)
        panel.layout.add(self.model_field, expand=True, margin_left=10)

        self.save_button = fsui.Button(panel, gettext("Save"))
        self.save_button.activated.connect(self.on_save_button)
        panel.layout.add(self.save_button, margin_left=20)

        if self.window.theme.has_close_buttons:
            self.close_button = CloseButton(panel)
            panel.layout.add(self.close_button, margin_left=10)

        self.device_name = device_name
        existing_config = self.read_existing_config()

        self.button_panels = []
        for x, y, direction, name in BUTTONS:
            b = MappingButton(self.joystick_panel, (x, y + 4), direction, name)
            self.button_panels.append(b)
            if name in existing_config:
                b.event_name = existing_config[name]

        self.type_field.changed.connect(self.on_change)
        # self.make_field.changed.connect(self.on_change)
        self.model_field.changed.connect(self.on_change)

        self.save_button.disable()
        self.set_size(self.layout.get_min_size())
        self.center_on_parent()

        self.stopped = False
        self.previous_timer_state = {}
        self.current_state = {}
        self.initial_state = {}
        self.map_key_name = None

        fsui.call_later(100, self.on_timer_callback)
        thread = threading.Thread(
            target=event_thread,
            name="JoystickConfigEventThread",
            args=(self.device_name, weakref.ref(self)),
        )
        thread.start()
Exemplo n.º 7
0
    def __init__(self, parent, device_name):
        title = gettext("Configure {device_name}").format(
            device_name=device_name
        )
        super().__init__(
            parent,
            title=title,
            minimizable=False,
            maximizable=False,
            separator=False,
        )
        self.theme = WorkspaceTheme.instance()
        self.layout = fsui.VerticalLayout()

        self.image = fsui.Image("workspace:res/gamepad-config.png")
        self.joystick_panel = fsui.ImageView(self, self.image)
        self.layout.add(self.joystick_panel)

        if Skin.fws():
            from workspace.ui import TitleSeparator

            separator = TitleSeparator(self)
            self.layout.add(separator, fill=True)

        panel = fsui.Panel(self)
        self.layout.add(panel, fill=True)

        panel.layout = fsui.HorizontalLayout()
        panel.layout.padding = 20

        self.device_type_ids = [
            "",
            "gamepad",
            "joystick",
            # "flightstick",
            "other",
        ]
        self.device_type_labels = [
            gettext("Choose Type"),
            gettext("Gamepad"),
            gettext("Digital Joystick"),
            # gettext("Flight Stick"),
            gettext("Other Device"),
        ]

        self.type_field = fsui.Choice(panel, self.device_type_labels)
        self.type_field.changed.connect(self.on_change)
        panel.layout.add(self.type_field)

        panel.layout.add(
            fsui.PlainLabel(panel, gettext("Make:")), margin_left=20
        )
        self.make_field = fsui.TextField(panel)
        self.make_field.set_min_width(140)
        self.make_field.changed.connect(self.on_change)
        panel.layout.add(self.make_field, margin_left=10)

        panel.layout.add(
            fsui.PlainLabel(panel, gettext("Model:")), margin_left=20
        )
        self.model_field = fsui.TextField(panel)
        self.model_field.changed.connect(self.on_change)
        panel.layout.add(self.model_field, expand=True, margin_left=10)

        self.save_button = fsui.Button(panel, gettext("Save"))
        self.save_button.activated.connect(self.on_save_button)
        panel.layout.add(self.save_button, margin_left=20)

        if self.window.theme.has_close_buttons:
            self.close_button = CloseButton(panel)
            panel.layout.add(self.close_button, margin_left=10)

        self.device_name = device_name
        existing_config = self.read_existing_config()

        self.button_panels = []
        for x, y, direction, name in BUTTONS:
            b = MappingButton(self.joystick_panel, (x, y + 4), direction, name)
            self.button_panels.append(b)
            if name in existing_config:
                b.event_name = existing_config[name]

        self.save_button.disable()
        self.set_size(self.layout.get_min_size())
        self.center_on_parent()

        self.stopped = False
        self.current_state = {}
        self.initial_state = {}
        self.map_key_name = None

        fsui.call_later(100, self.on_timer_callback)
        thread = threading.Thread(
            target=event_thread,
            name="JoystickConfigEventThread",
            args=(self.device_name, weakref.ref(self)),
        )
        thread.start()