예제 #1
0
    def __init__(self, parent, new_button=True):
        super().__init__(parent)
        self.layout = fsui.VerticalLayout()
        hori_layout = fsui.HorizontalLayout()
        self.layout.add(hori_layout, fill=True)
        if new_button:
            label_stand_in = fsui.Panel(self)
            _, th = label_stand_in.measure_text(gettext("Configuration"))
            label_stand_in.set_min_height(th)
            hori_layout.add(label_stand_in, margin_top=10, margin_bottom=10)

            hori_layout.add(NewConfigButton(self),
                            margin_left=10,
                            margin_right=10)
        self.config_name_field = fsui.TextField(self)
        hori_layout.add(
            self.config_name_field,
            expand=True,
            margin=10,
            margin_top=0,
            margin_bottom=0,
        )
        hori_layout.add(SaveButton(self), margin_left=10, margin_right=10)
        self.config_name_field.on_changed = self.on_config_name_changed
        SettingsBehavior(self, ["config_name"])
 def add_option(self, layout, option, platforms=None, text=""):
     panel = fsui.Panel(self)
     panel.layout = fsui.VerticalLayout()
     panel.layout.add(OptionUI.create_group(panel,
                                            option,
                                            text,
                                            thin=False,
                                            help_button=True),
                      fill=True)
     layout.add(panel, fill=True, margin_bottom=10)
예제 #3
0
 def add_option(self, option, platforms=None, enable=None, text=""):
     panel = fsui.Panel(self)
     panel.layout = fsui.VerticalLayout()
     panel.layout.add(
         OptionUI.create_group(
             panel, option, text, thin=True, help_button=False),
         fill=True)
     self.layout.add(panel, fill=True, margin=10)
     if platforms:
         PlatformShowBehavior(panel, platforms)
     elif enable:
         PlatformEnableBehavior(panel, enable)
예제 #4
0
    def add_divider(parent, layout, top_margin=12, bottom_margin=12):
        # return
        import fsui

        panel = fsui.Panel(parent)
        panel.set_background_color(fsui.Color(0xA2A2A2))
        panel.set_min_height(1)
        layout.add(
            panel,
            fill=True,
            margin_top=top_margin,
            margin_bottom=bottom_margin,
        )
예제 #5
0
    def __init__(self, parent, new_button=True):
        fsui.Group.__init__(self, parent)
        self.layout = fsui.VerticalLayout()

        # heading_label = fsui.HeadingLabel(self, _("Configuration"))
        # self.layout.add(heading_label, margin=10)
        # self.layout.add_spacer(0)

        hori_layout = fsui.HorizontalLayout()
        self.layout.add(hori_layout, fill=True)

        # dummy label for sizing purposes
        # label = fsui.HeadingLabel(self, "")
        # hori_layout.add(label, margin_top=10, margin_bottom=10)

        if new_button:
            label_stand_in = fsui.Panel(self)
            tw, th = label_stand_in.measure_text(gettext("Configuration"))
            label_stand_in.set_min_height(th)
            hori_layout.add(label_stand_in, margin_top=10, margin_bottom=10)

            hori_layout.add(NewButton(self), margin_left=10, margin_right=10)

        # self.open_button = IconButton(self, "open_button.png")
        # self.open_button.set_tooltip(_("Open Configuration"))
        # self.open_button.disable()
        # self.open_button.activated.connect(self.on_open_button)
        # hori_layout.add(self.open_button, margin=10)

        self.config_name_field = fsui.TextField(self)
        hori_layout.add(self.config_name_field, expand=True, margin=10,
                        margin_top=0, margin_bottom=0)

        hori_layout.add(SaveButton(self), margin_left=10, margin_right=10)

        # self.save_button = IconButton(self, "save_button.png")
        # # self.save_button.disable()
        # self.save_button.set_tooltip(gettext("Save Configuration"))
        # self.save_button.activated.connect(self.on_save_button)
        # hori_layout.add(self.save_button, margin=10,
        #                 margin_top=0, margin_bottom=0)

        self.on_setting("config_name", LauncherSettings.get("config_name"))
        self.config_name_field.on_changed = self.on_config_name_changed

        # Config.add_listener(self)
        LauncherSettings.add_listener(self)
예제 #6
0
    def __init__(
        self,
        parent,
        *,
        title="",
        size=None,
        menu=False,
        maximizable=True,
        minimizable=True,
        escape=False
    ):
        self.theme = get_launcher_theme(self)
        window_parent = None
        # window_parent = parent
        border = self.theme.titlebar_system()
        super().__init__(
            window_parent,
            title,
            border=border,
            maximizable=maximizable,
            minimizable=minimizable,
            escape=escape,
        )
        if size is not None:
            self.set_size(size)
        self.layout = fsui.VerticalLayout()

        use_border = False
        if use_border:
            self.layout.set_padding(1, 1, 1, 1)
            self.borderwidget = fsui.Panel(self)
            self.borderwidget.set_background_color(fsui.Color(0xCCD6E4))
        else:
            self.borderwidget = None

        self.set_background_color(self.theme.window_bgcolor())
        if not self.theme.titlebar_system():
            self.__titlebar = TitleBar(
                self,
                title=title,
                menu=menu,
                minimizable=minimizable,
                maximizable=maximizable,
            )
            self.layout.add(self.__titlebar, fill=True)
예제 #7
0
    def __init__(self, parent):
        super().__init__(parent)
        hori_layout = fsui.HorizontalLayout()
        self.layout.add(hori_layout, fill=True)
        heading_label = fsui.HeadingLabel(self,
                                          gettext("Additional Configuration"))
        hori_layout.add(heading_label, margin=10)
        hori_layout.add_spacer(0, expand=True)
        hori_layout.add(CustomConfigButton(self), margin_right=10)
        self.layout.add_spacer(0)

        amiga_panel = fsui.Panel(self)
        amiga_panel.layout = fsui.VerticalLayout()
        self.layout.add(amiga_panel, fill=True)
        self.add_amiga_option(Option.CPU, parent=amiga_panel)
        self.add_amiga_option(Option.JIT_COMPILER, parent=amiga_panel)
        self.add_amiga_option(Option.FLOPPY_DRIVE_SPEED, parent=amiga_panel)
        self.add_amiga_option(Option.FLOPPY_DRIVE_VOLUME_EMPTY,
                              parent=amiga_panel)
        self.add_amiga_option(Option.FREEZER_CARTRIDGE, parent=amiga_panel)
        self.add_amiga_option(Option.DONGLE_TYPE, parent=amiga_panel)
예제 #8
0
    def __init__(self, parent, title):
        super().__init__(parent, title, minimizable=False, maximizable=False)
        # buttons, layout = fsui.DialogButtons.create_with_layout(self)
        # buttons.create_close_button()
        self.layout = fsui.VerticalLayout()
        # self.layout.set_padding(20)
        layout = self.layout

        hor_layout = fsui.HorizontalLayout()
        layout.add(hor_layout, fill=True, expand=True)

        layout_2 = fsui.VerticalLayout()
        # layout_2.padding_top = 20
        # layout_2.padding_bottom = 20
        # layout_2.padding_left = 20

        self.list_view = fsui.ListView(self, border=(not Skin.fws()))
        self.list_view.set_min_width(240)
        self.list_view.item_selected.connect(self.on_select_item)
        if Skin.fws():
            from workspace.ui.theme import Theme
            theme = Theme.instance()
            self.list_view.set_row_height(28)
            # self.list_view.set_background_color(fsui.Color(0xeb, 0xeb, 0xeb))
            self.list_view.setStyleSheet("""
            QListView {{
                padding-top: 20px;
                background-color: {0};
                outline: none;
            }}
            QListView::item {{
                padding-left: 20px;
                border: 0px;
            }}
            QListView::item:selected {{
                background-color: {1};
            }}
            """.format(theme.sidebar_background.to_hex(),
                       theme.selection_background.to_hex()))
            layout_2.add(self.list_view, fill=True, expand=True)
        else:
            layout_2.add(self.list_view,
                         fill=True,
                         expand=True,
                         margin=20,
                         margin_right=0)
        hor_layout.add(layout_2, fill=True)

        hor_layout.add_spacer(20)

        self.page_container = fsui.Panel(self)
        self.page_container.layout = fsui.VerticalLayout()
        hor_layout.add(self.page_container,
                       fill=True,
                       expand=True,
                       margin_top=20,
                       margin_right=20,
                       margin_bottom=20)

        # self.layout.add_spacer(20)

        hor_layout = fsui.HorizontalLayout()
        layout.add(hor_layout, fill=True)

        self.page_titles = []
        self.pages = []

        # self.add_page(_("Hardware"), HardwarePage)
        # self.add_page(_("Hard Drives"), HardDrivesPage)
        # elf.add_page(_("Custom Options"), CustomOptionsPage)

        self.current_page = None
        self.set_size((840, 640))
        self.center_on_parent()
예제 #9
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.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)

        # self.close_button = fsui.Button(panel, gettext("Close"))
        # self.close_button.activated.connect(self.on_close_button)
        # 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()
예제 #10
0
    def __init__(self, parent):
        fsui.Panel.__init__(self, parent)
        Skin.set_background_color(self)
        self.layout = fsui.HorizontalLayout()

        vert_layout = fsui.VerticalLayout()
        self.layout.add(vert_layout, fill=True, expand=True)

        hor_layout = fsui.HorizontalLayout()
        vert_layout.add(hor_layout, fill=True)

        label_stand_in = fsui.Panel(self)
        tw, th = label_stand_in.measure_text("Games")
        label_stand_in.set_min_height(th)
        hor_layout.add(label_stand_in, margin_top=10, margin_bottom=10)

        hor_layout.add(NewButton(self), margin_left=10, margin_right=10)

        game_list_selector = GameListSelector(self)
        game_list_selector.set_min_width(250)
        game_list_selector.setMaximumWidth(250)
        game_list_selector.changed.connect(self.on_game_list_changed)
        hor_layout.add(game_list_selector, expand=False, margin_left=10)

        self.text_field = fsui.TextField(self,
                                         LauncherSettings.get("config_search"))
        self.text_field.on_changed = self.on_search_changed
        if VariantsBrowser.use_horizontal_layout():
            # window is big enough to use fixed size
            # self.text_field.set_min_width(210)
            self.text_field.set_min_width(229)
            hor_layout.add(
                self.text_field,
                expand=False,
                margin=10,
                margin_top=0,
                margin_bottom=0,
            )
        else:
            hor_layout.add(
                self.text_field,
                expand=True,
                margin=10,
                margin_top=0,
                margin_bottom=0,
            )

        # self.refresh_button = IconButton(self, "refresh_button.png")
        # self.refresh_button.set_tooltip(
        #     gettext("Refresh Game Configurations from Online Database"))
        # self.refresh_button.activated.connect(self.on_refresh_button)
        # hor_layout.add(
        #     self.refresh_button, margin=10, margin_top=0, margin_bottom=0)

        self.configurations_browser = ConfigurationsBrowser(self)

        vert_layout.add(self.configurations_browser,
                        fill=True,
                        expand=3,
                        margin=10)

        self.variants_panel = fsui.Panel(self)
        vert_layout.add(
            self.variants_panel,
            fill=True,
            expand=False,
            margin=10,
            margin_top=20,
        )

        self.variants_panel.layout = fsui.HorizontalLayout()
        self.variants_browser = VariantsBrowser(self.variants_panel)
        # Do not use fill=True with the default OS X theme at least,
        # if you do the item will be rendered with the old Aqua look
        self.variants_panel.layout.add(self.variants_browser,
                                       fill=False,
                                       expand=True)

        # for rating in [1, 4, 5]:
        #     button = RatingButton(self.variants_panel, rating)
        #     self.variants_panel.layout.add(button, margin_left=5, fill=True)

        self.variants_panel.layout.add(RatingChoice(self.variants_panel),
                                       margin_left=5,
                                       fill=True)

        self.config_panel = fsui.Panel(self)
        vert_layout.add(
            self.config_panel,
            fill=True,
            expand=False,
            margin_bottom=10,
            margin_top=20,
        )

        self.config_panel.layout = fsui.VerticalLayout()
        self.config_group = ConfigGroup(self.config_panel, new_button=False)
        self.config_panel.layout.add(self.config_group, fill=True, expand=True)

        LauncherSettings.add_listener(self)
        self.on_setting("parent_uuid", LauncherSettings.get("parent_uuid"))
예제 #11
0
    def __init__(self, parent, title):
        super().__init__(parent, title, minimizable=False, maximizable=False)
        self.theme = LauncherTheme.get()
        self.layout = fsui.VerticalLayout()

        # self.layout.set_padding(20)
        layout = self.layout

        h_layout = fsui.HorizontalLayout()
        layout.add(h_layout, fill=True, expand=True)

        layout_2 = fsui.VerticalLayout()
        # layout_2.padding_top = 20
        # layout_2.padding_bottom = 20
        # layout_2.padding_left = 20

        self.list_view = fsui.ListView(self, border=False)
        self.list_view.set_min_width(240)
        self.list_view.item_selected.connect(self.on_select_item)

        self.list_view.set_row_height(
            self.window.theme.sidebar_list_row_height)
        self.list_view.setStyleSheet("""
        QListView {{
            padding-top: 20px;
            background-color: {base};
            outline: none;
        }}
        QListView::item {{
            padding-left: 20px;
            border: 0px;
        }}
        QListView::item:selected {{
            background-color: {row_bg};
            color: {row_fg};
        }}
        """.format(
            row_fg=self.window.theme.sidebar_list_row_text.to_hex(),
            row_bg=self.window.theme.sidebar_list_row_background.to_hex(),
            base=self.window.theme.sidebar_list_background.to_hex()))
        layout_2.add(self.list_view, fill=True, expand=True)
        h_layout.add(layout_2, fill=True)

        # h_layout.add_spacer(20)

        v_layout = fsui.VerticalLayout()
        h_layout.add(v_layout, fill=True, expand=True)

        use_scrolling = False
        if use_scrolling:
            # FIXME: Problems with page height
            scroll_area = fsui.VerticalScrollArea(self)
            self.page_container = fsui.Panel(scroll_area)
            self.page_container.layout = fsui.VerticalLayout()
            scroll_area.set_widget(self.page_container)
            v_layout.add(scroll_area, fill=True, expand=True)
        else:
            self.page_container = fsui.Panel(self)
            self.page_container.layout = fsui.VerticalLayout()
            v_layout.add(self.page_container, fill=True, expand=True)

        # self.layout.add_spacer(20)

        # h_layout = fsui.HorizontalLayout()
        # layout.add(h_layout, fill=True)

        self.page_titles = []
        self.pages = []

        # self.add_page(_("Hardware"), HardwarePage)
        # self.add_page(_("Hard Drives"), HardDrivesPage)
        # elf.add_page(_("Custom Options"), CustomOptionsPage)

        self.button_layout = fsui.HorizontalLayout()
        v_layout.add(self.button_layout, fill=True, margin=20, margin_top=0)
        if self.window.theme.has_close_buttons:
            self.button_layout.add_spacer(expand=True)
            self.close_button = CloseButton(self)
            self.button_layout.add(
                self.close_button, fill=True, margin_left=10)

        self.current_page = None

        # self.page_container.set_min_width(600)
        # self.page_container.set_min_height(640)
        # self.set_size_from_layout()
        self.set_size((840, 640))
        self.center_on_parent()