def __init__(self, parent): fsui.Panel.__init__(self, parent) self.layout = fsui.VerticalLayout() hori_layout = fsui.HorizontalLayout() self.layout.add(hori_layout, fill=True, margin=10) self.text_field = fsui.TextField(self, "") self.text_field.on_changed = self.on_text_changed self.text_field.disable() hori_layout.add(self.text_field, expand=True) # self.help_button = HelpButton( # self, "https://fs-uae.net/docs/options/nes-ines-header") # hori_layout.add(self.help_button, margin_left=10) ConfigBehavior(self, [Option.NES_INES_HEADER])
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)
def __init__(self, parent, import_type=0): fsui.Group.__init__(self, parent) self.type = import_type self.path = "" self.layout = fsui.VerticalLayout() if self.type == self.AMIGA_FOREVER: title = gettext("Import From Amiga Forever CD/DVD") else: title = gettext("Import Kickstarts and ROMs") label = fsui.HeadingLabel(self, title) self.layout.add(label, margin_bottom=10) icon_layout = fsui.HorizontalLayout() self.layout.add(icon_layout, fill=True) icon_layout.add_spacer(20) if self.type == self.AMIGA_FOREVER: image = fsui.Image("launcher:/data/amiga_forever_group.png") else: image = fsui.Image("launcher:/data/kickstart.png") self.image_view = fsui.ImageView(self, image) icon_layout.add(self.image_view, valign=0.0, margin_right=10) vert_layout = fsui.VerticalLayout() icon_layout.add(vert_layout, fill=True, expand=True) if self.type == self.AMIGA_FOREVER: text = gettext("If you own Amiga Forever, select the drive/folder " 'and click "{0}"').format(gettext("Import")) else: text = gettext("Select a folder containing Amiga kickstart files " 'and click "{0}"').format(gettext("Import")) label = fsui.Label(self, text) vert_layout.add(label, margin_bottom=10) hori_layout = fsui.HorizontalLayout() vert_layout.add(hori_layout, fill=True, margin=0) self.text_field = fsui.TextField(self, "", read_only=True) hori_layout.add(self.text_field, expand=True) self.browse_button = fsui.Button(self, gettext("Browse")) self.browse_button.activated.connect(self.on_browse) hori_layout.add(self.browse_button, margin_left=10) self.import_button = fsui.Button(self, gettext("Import")) self.import_button.activated.connect(self.on_import) self.import_button.set_enabled(False) hori_layout.add(self.import_button, margin_left=10)
def __init__(self, parent): fsui.Panel.__init__(self, parent) self.layout = fsui.VerticalLayout() hori_layout = fsui.HorizontalLayout() self.layout.add(hori_layout, fill=True, margin=10, margin_bottom=0) label = fsui.Label(self, gettext("Command:")) hori_layout.add(label, fill=True, margin_right=10) self.text_field = fsui.TextField(self, "") self.text_field.on_changed = self.on_text_changed # self.text_field.set_enabled(False) hori_layout.add(self.text_field, expand=True) # self.help_button = HelpButton( # self, "https://fs-uae.net/docs/options/nes-ines-header") # hori_layout.add(self.help_button, margin_left=10) ConfigBehavior(self, [Option.COMMAND])
def __init__(self, parent): fsui.Group.__init__(self, parent) self.layout = fsui.VerticalLayout() heading_label = fsui.HeadingLabel(self, gettext("WHDLoad Arguments")) self.layout.add(heading_label, margin=10) self.layout.add_spacer(0) self.text_field = fsui.TextField(self, "") hori_layout = fsui.HorizontalLayout() self.layout.add(hori_layout, fill=True, margin=10) hori_layout.add(self.text_field, expand=True) self.help_button = HelpButton( self, "https://fs-uae.net/whdload-support") hori_layout.add(self.help_button, margin_left=10) self.initialize_from_config() self.set_config_handlers()
def __init__(self, parent, new_button=True): fsui.Group.__init__(self, 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) 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.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 __init__(self, parent, index): fsui.Panel.__init__(self, parent) AmigaEnableBehavior(self) self.layout = fsui.VerticalLayout() self.index = index self.config_key = "hard_drive_{0}".format(index) self.config_key_sha1 = "x_hard_drive_{0}_sha1".format(index) # if index == 0: # # heading_label = fsui.HeadingLabel(self, # # _("Hard Drive {0}").format(index + 1)) # heading_label = fsui.HeadingLabel(self, gettext("Hard Drives")) # self.layout.add(heading_label, margin_bottom=20) # self.layout.add_spacer(0) hori_layout = fsui.HorizontalLayout() self.layout.add(hori_layout, fill=True) self.eject_button = IconButton(self, "eject_button.png") self.eject_button.set_tooltip(gettext("Eject")) self.eject_button.activated.connect(self.on_eject_button) hori_layout.add(self.eject_button) self.text_field = fsui.TextField(self, "", read_only=True) hori_layout.add(self.text_field, expand=True, margin_left=10) self.browse_button = IconButton(self, "browse_folder_16.png") self.browse_button.set_tooltip(gettext("Browse for Folder")) self.browse_button.activated.connect(self.on_browse_folder_button) hori_layout.add(self.browse_button, margin_left=10) self.browse_button = IconButton(self, "browse_file_16.png") self.browse_button.set_tooltip(gettext("Browse for File")) self.browse_button.activated.connect(self.on_browse_file_button) hori_layout.add(self.browse_button, margin_left=10) self.initialize_from_config() self.set_config_handlers()
def __init__(self, parent, drive, show_path=True): fsui.Panel.__init__(self, parent) self.mode = FloppySelector.FLOPPY_MODE self.show_path = show_path self.drive = drive self.config_key = "" self.config_key_sha1 = "" self.config_key_implicit = "" self.config_value_implicit = "" self.__platform = "" self.text_field = fsui.TextField(self, "", read_only=True) self.browse_button = IconButton(self, "browse_folder_16.png") self.browse_button.set_tooltip(gettext("Browse for file")) self.browse_button.activated.connect(self.on_browse) self.eject_button = IconButton(self, "eject_button.png") # AmigaEnableBehavior(self.eject_button) self.eject_button.set_tooltip(gettext("Eject")) self.eject_button.activated.connect(self.on_eject) self.layout = fsui.HorizontalLayout() self.layout.add(self.text_field, expand=True) self.layout.add_spacer(5) self.layout.add(self.eject_button, fill=True) self.layout.add_spacer(5) self.layout.add(self.browse_button, fill=True) # Config.add_listener(self) # fsgs.signal.connect(self.on_config, # "fsgs:config:floppy_drive_{0}".format(self.drive), # "fsgs:config:cdrom_drive_{0}".format(self.drive)) # fsgs.signal.connect("config", self.on_config) get_config(self).attach(self.__on_config) self.on_config(Option.PLATFORM, fsgs.config.get(Option.PLATFORM)) self.update_config_key()
def __init__(self, parent, header=True): fsui.Panel.__init__(self, parent) Skin.set_background_color(self) self.layout = fsui.VerticalLayout() if header: hori_layout = fsui.HorizontalLayout() self.layout.add(hori_layout, fill=True) self.layout.add_spacer(0) label = fsui.HeadingLabel(self, gettext("Net Play")) hori_layout.add(label, margin=10) hori_layout.add_spacer(0, expand=True) # label = fsui.Label(self, "Netplay is currently disabled in the " # "development versions.") # self.layout.add(label, margin=10) # label = fsui.Label(self, "Please use the stable FS-UAE series for " # "netplay in the meantime.") # self.layout.add(label, margin=10) # return # TODO gettext("Nick:") gettext("Connect") gettext("Disconnect") # self.nick_label = fsui.Label(self, _("Nick:")) # hori_layout.add(self.nick_label, # margin=10, margin_top=0, margin_bottom=0) # # self.nick_field = fsui.TextField(self, Settings.get("irc_nick")) # self.nick_field.set_min_width(130) # hori_layout.add(self.nick_field, margin_right=10) # #self.nick_field.on_changed = self.on_nick_change # # self.connect_button = fsui.Button(self, _("Connect")) # hori_layout.add(self.connect_button, margin_right=10) # #self.connect_button.activated.connect(self.on_connect_button) # # self.disconnect_button = fsui.Button(self, _("Disconnect")) # hori_layout.add(self.disconnect_button, margin_right=10) # #self.disconnect_button.activated.connect(self.on_disconnect_button) hori_layout = fsui.HorizontalLayout() self.layout.add(hori_layout, fill=True, expand=True) ver_layout = fsui.VerticalLayout() hori_layout.add(ver_layout, fill=True) self.channel_list = fsui.ListView(self) self.channel_list.set_min_width(212) self.channel_list.on_select_item = self.on_select_channel ver_layout.add(self.channel_list, fill=True, expand=True, margin=10) self.nick_list = fsui.ListView(self) ver_layout.add(self.nick_list, fill=True, expand=True, margin=10) self.text_area = fsui.TextArea(self, font_family="monospace") hori_layout.add(self.text_area, fill=True, expand=True, margin=10, margin_left=0) self.input_field = fsui.TextField(self) self.input_field.activated.connect(self.on_input) self.layout.add(self.input_field, fill=True, margin=10, margin_top=0) self.active_channel = LOBBY_CHANNEL self.input_field.focus() self.netplay = Netplay() IRCBroadcaster.add_listener(self)
def __init__(self, parent=None): title = gettext("ADF Disk Image Creator") super().__init__(parent, title=title, maximizable=False) buttons, layout = fsui.DialogButtons.create_with_layout(self) # buttons.create_close_button() self.dialog = None self.path = "" self.set_icon(fsui.Icon("floppy", "pkg:workspace")) layout.min_width = 500 self.icon_header = IconHeader( self, fsui.Icon("floppy", "pkg:workspace"), gettext("ADF Disk Image Creator"), gettext("Create a blank or formatted ADF floppy disk image")) layout.add(self.icon_header, fill=True, margin_bottom=20) label = fsui.Label(self, gettext("Create disk image of type:")) layout.add(label) layout.add_spacer(6) self.list_view = fsui.ListView(self) self.list_view.set_min_width(560) self.list_view.set_min_height(60) icon = fsui.Image("workspace:res/16/floppy.png") self.list_view.add_item(gettext("ADF - Standard Floppy Disk Image"), icon) self.list_view.add_item( gettext("ADF - Extended Floppy Disk Image (MFM Encoded)"), icon) layout.add(self.list_view, expand=True, fill=True) # self.list_view.on_select_item = self.on_select_item self.list_view.item_selected.connect(self.on_item_selected) layout.add_spacer(20) label = fsui.Label(self, gettext("Filename for the new disk image:")) layout.add(label) layout.add_spacer(6) hori_layout = fsui.HorizontalLayout() layout.add(hori_layout, fill=True) self.name_field = fsui.TextField(self, "", read_only=False) hori_layout.add(self.name_field, expand=True) text = gettext("Size:") label = fsui.Label(self, text) hori_layout.add(label, margin_left=20) self.size_field = fsui.TextField(self, "") self.size_field.set_min_width(60) hori_layout.add(self.size_field, expand=False, margin_left=10) text = gettext("MB") label = fsui.Label(self, text) hori_layout.add(label, margin_left=10) layout.add_spacer(20) label = fsui.Label(self, gettext("Save to directory:")) layout.add(label) layout.add_spacer(6) hori_layout = fsui.HorizontalLayout() layout.add(hori_layout, fill=True) self.dir_field = fsui.TextField(self, "", read_only=True) hori_layout.add(self.dir_field, expand=True) self.browse_button = fsui.Button(self, gettext("Browse")) self.browse_button.clicked.connect(self.on_browse_clicked) hori_layout.add(self.browse_button, margin_left=10) self.created_label = fsui.Label(self, "") layout.add(self.created_label, fill=True) # layout.add_spacer(20) # layout.add_spacer(20) # hori_layout = fsui.HorizontalLayout() # layout.add(hori_layout, fill=True) # self.created_label = fsui.Label(self, "") # hori_layout.add(self.created_label, expand=True) # hori_layout.add_spacer(20) self.create_button = fsui.Button(buttons, gettext("Create")) # self.create_button.activated.connect(self.on_create_clicked) self.create_button.clicked.connect(self.on_create_clicked) # hori_layout.add(self.create_button) buttons.add_button(self.create_button) self.list_view.select_item(0) self.update_name_suggestion()
def test_text_field_with_text(self): self.setup_dialog() text_field = fsui.TextField(self.dialog, "Hello World") self.assertEqual(text_field.get_text(), "Hello World") self.run_dialog()
def __init__(self, parent=None): title = gettext("HDF Disk Image Creator") super().__init__(parent, title=title) self.theme = WorkspaceTheme.instance() buttons, layout = fsui.DialogButtons.create_with_layout(self) if self.window.theme.has_close_buttons: buttons.create_close_button() self.dialog = None self.path = "" self.set_icon(fsui.Icon("hd-volume", "pkg:workspace")) layout.min_width = 500 self.icon_header = IconHeader( self, fsui.Icon("hd-volume", "pkg:workspace"), gettext("HDF Disk Image Creator"), gettext("Create a single-partition or partitionable hard " "drive image")) layout.add(self.icon_header, fill=True, margin_bottom=20) label = fsui.Label(self, gettext("Create disk image of type:")) layout.add(label) layout.add_spacer(6) self.list_view = fsui.ListView(self) self.list_view.set_min_width(560) self.list_view.set_min_height(60) icon = fsui.Image("workspace:res/16x16/hd-volume.png") self.list_view.add_item( gettext("HDF - Single Partition Hard Disk File"), icon) self.list_view.add_item( gettext("HDF - Partitionable Hard Drive Image (RDB)"), icon) layout.add(self.list_view, expand=True, fill=True) self.list_view.item_selected.connect(self.on_item_selected) layout.add_spacer(20) label = fsui.Label(self, gettext("Filename for the new disk image:")) layout.add(label) layout.add_spacer(6) hori_layout = fsui.HorizontalLayout() layout.add(hori_layout, fill=True) self.name_field = fsui.TextField( self, "", read_only=False) hori_layout.add(self.name_field, expand=True) text = gettext("Size:") label = fsui.Label(self, text) hori_layout.add(label, margin_left=20) self.size_field = fsui.TextField(self, "") self.size_field.set_min_width(60) hori_layout.add(self.size_field, expand=False, margin_left=10) text = gettext("MB") label = fsui.Label(self, text) hori_layout.add(label, margin_left=10) layout.add_spacer(20) label = fsui.Label(self, gettext("Save to directory:")) layout.add(label) layout.add_spacer(6) hori_layout = fsui.HorizontalLayout() layout.add(hori_layout, fill=True) self.dir_field = fsui.TextField(self, "", read_only=True) hori_layout.add(self.dir_field, expand=True) self.browse_button = fsui.Button(self, gettext("Browse")) self.browse_button.clicked.connect(self.on_browse_clicked) hori_layout.add(self.browse_button, margin_left=10) self.created_label = fsui.Label(self, "") layout.add(self.created_label, fill=True) # layout.add_spacer(20) # layout.add_spacer(20) # hori_layout = fsui.HorizontalLayout() # layout.add(hori_layout, fill=True) # self.created_label = fsui.Label(self, "") # hori_layout.add(self.created_label, expand=True) # hori_layout.add_spacer(20) self.create_button = fsui.Button(buttons, gettext("Create")) # self.create_button.activated.connect(self.on_create_clicked) self.create_button.clicked.connect(self.on_create_clicked) # hori_layout.add(self.create_button) buttons.add_button(self.create_button) self.list_view.select_item(0) self.update_name_suggestion()
def __init__(self, parent=None): print("LoginWindow, parent =", parent) super().__init__(parent, gettext("Log In to Your OAGD.net Account")) self.set_icon(fsui.Icon("password", "pkg:workspace")) self.theme = WorkspaceTheme.instance() self.layout = fsui.VerticalLayout() self.layout.set_padding(20, 20, 20, 20) heading_layout = fsui.HorizontalLayout() self.layout.add(heading_layout) heading_layout.add( fsui.ImageView(self, fsui.Image("workspace:res/48/password.png"))) heading_layout.add_spacer(20) heading_layout_2 = fsui.VerticalLayout() heading_layout.add(heading_layout_2, expand=True, fill=False, valign=0.5) heading_layout_2.add( fsui.HeadingLabel(self, gettext("Log In to Your OAGD.net Account"))) heading_layout_2.add_spacer(2) heading_layout_2.add( fsui.Label( self, gettext("Logging in will enable the online game database " "and more"))) self.username_field = fsui.TextField( self, app.settings["database_email"].strip()) self.password_field = fsui.PasswordField(self) if self.username_field.get_text(): self.password_field.focus() self.layout.add_spacer(20) hori_layout = fsui.HorizontalLayout() self.layout.add(hori_layout, fill=True) label = fsui.Label(self, gettext("E-mail:")) label.set_min_width(100) hori_layout.add(label) hori_layout.add_spacer(20) # self.username_field.select_all() self.username_field.changed.connect(self.on_text_field_changed) self.username_field.activated.connect(self.on_username_activated) hori_layout.add(self.username_field, expand=True) self.layout.add_spacer(10) hori_layout = fsui.HorizontalLayout() self.layout.add(hori_layout, fill=True) label = fsui.Label(self, gettext("Password:"******"Don't have an account already?")) hori_layout.add(label) hori_layout.add_spacer(20) label = fsui.URLLabel( self, gettext("Create an account now"), "https://oagd.net/user/register?referrer=fs-uae-launcher") hori_layout.add(label, expand=True) self.layout.add_spacer(6) hori_layout = fsui.HorizontalLayout() self.layout.add(hori_layout, fill=True) label = fsui.Label(self, gettext("Forgot your password?")) hori_layout.add(label) hori_layout.add_spacer(20) self.reset_label = fsui.URLLabel( self, gettext("Reset password via e-mail"), "https://oagd.net/user/reset?referrer=fs-uae-launcher") hori_layout.add(self.reset_label, expand=True) self.layout.add_spacer(20) hori_layout = fsui.HorizontalLayout() self.layout.add(hori_layout, fill=True) self.created_label = fsui.Label(self, "") hori_layout.add(self.created_label, expand=True) hori_layout.add_spacer(20) self.login_button = fsui.Button(self, gettext("Log In")) self.login_button.disable() self.login_button.activated.connect(self.on_login_activated) hori_layout.add(self.login_button) if self.window.theme.has_close_buttons: self.close_button = CloseButton(self) hori_layout.add(self.close_button, fill=True, margin_left=10) self.set_size(self.layout.get_min_size()) self.center_on_parent() if len(self.username_field.text()) == 0: self.username_field.focus() else: self.password_field.focus()
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()
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"))
def create_option_group(parent, options, option, key, option_type, option_text, use_checkbox, use_help_button, label_spacing, platforms=None, use_label=True): # group = fsui.Group(parent) group = OptionPanel(parent, platforms) group.layout = fsui.HorizontalLayout() if use_checkbox: group.layout.add(OptionCheckBox(group, option_text + ":", options, key), margin_right=label_spacing) elif use_label: group.layout.add(fsui.Label(group, option_text + ":"), margin_right=label_spacing) choice_values = [] if option_type == "boolean": group.layout.add_spacer(0, expand=True) group.layout.add( BooleanChoiceControl(group, options, key, use_checkbox=use_checkbox)) elif option_type == "choice": group.layout.add_spacer(0, expand=True) choices = option["values"] # if use_checkbox: # choices,insert(("", gettext("Auto"))) group.layout.add( ChoiceControl(group, options, key, choices, use_checkbox=use_checkbox)) elif option_type == "string": def on_changed(): val = text_field.get_text() LauncherConfig.set(key, val.strip()) text_field = fsui.TextField(group) # text_field.set_min_width(400) text_field.set_text(LauncherConfig.get(key)) text_field.on_changed = on_changed group.layout.add(text_field, expand=True) elif option["type"].lower() == "integer" and "min" in option \ and "max" in option: assert use_checkbox spin_ctrl = SpinValueControl(group, options, key, option["min"], option["max"]) # current = LauncherConfig.get(key) # current_int = int(option["default"]) # if current: # try: # current_int = int(current) # except ValueError: # pass # current_int = max(option["min"], min(option["max"], current_int)) # check_box = fsui.CheckBox(group, gettext("Default")) # spin_ctrl = fsui.SpinCtrl(group, option["min"], # option["max"], current_int) # if current == "": # check_box.check() # spin_ctrl.disable() # def on_checkbox(): # if check_box.is_checked(): # spin_ctrl.set_value(int(option["default"])) # spin_ctrl.disable() # LauncherConfig.set(key, "") # else: # spin_ctrl.enable() # # check_box.on_changed = on_checkbox # # def on_spin(): # val = spin_ctrl.get_value() # val = max(option["min"], min(option["max"], val)) # LauncherConfig.set(key, str(val)) # spin_ctrl.on_changed = on_spin # group.layout.add(check_box) group.layout.add_spacer(0, expand=True) group.layout.add(spin_ctrl, margin_left=10) if choice_values: def on_changed(): index = choice.get_index() LauncherConfig.set(key, choice_values[index][0]) choice_labels = [x[1] for x in choice_values] choice = fsui.Choice(group, choice_labels) current = LauncherConfig.get(key) for i, value in enumerate(choice_values): if current == value[0]: choice.set_index(i) break choice.on_changed = on_changed group.layout.add_spacer(0, expand=True) group.layout.add(choice) group.widget = choice if use_help_button: help_button = HelpButton(parent, "https://fs-uae.net/options#" + key) group.layout.add(help_button, margin_left=10) return group
def create_group(cls, parent, name, description=None, help_button=True, thin=False): group = fsui.Group(parent) group.layout = fsui.HorizontalLayout() if thin: thin_layout = fsui.VerticalLayout() thin_layout.add(group.layout, fill=True) option = Option.get(name) if description == "": description = gettext(option["description"]) if description: group.label = fsui.Label(group, description + ":") group.layout.add(group.label, margin_right=10) group.layout.add(OverrideWarning(group, name), margin_right=10) if thin: group.layout = fsui.HorizontalLayout() if description: thin_layout.add(group.layout, fill=True, margin_top=6) else: thin_layout.add(group.layout, fill=True, margin_top=0) choice_values = [] if description: default_tmpl = "{0} (*)" # default_tmpl = "Default - {0}" else: default_tmpl = "{0} (*)" # default_tmpl = "Default - {0}" if option["type"].lower() == "boolean": if option["default"] == "1": default_desc = gettext(default_tmpl).format(gettext("On")) elif option["default"] == "0": default_desc = gettext(default_tmpl).format(gettext("Off")) else: default_desc = gettext("Default") choice_values.append(("", default_desc)) choice_values.append(("1", gettext("On"))) choice_values.append(("0", gettext("Off"))) elif option["type"].lower() == "choice": for i, value in enumerate(option["values"]): if option["default"] == value[0]: default_desc = gettext(default_tmpl).format( gettext(value[1])) break else: default_desc = gettext("Default") choice_values.append(("", default_desc)) for option in option["values"]: choice_values.append((option[0], gettext(option[1]))) elif option["type"].lower() == "string": def on_changed(): val = text_field.get_text() LauncherSettings.set(name, val.strip()) text_field = fsui.TextField(group) # text_field.set_min_width(400) text_field.set_text(LauncherSettings.get(name)) text_field.on_changed = on_changed group.layout.add(text_field, expand=True) elif (option["type"].lower() == "integer" and "min" in option and "max" in option): current = LauncherSettings.get(name) if name == Option.LAUNCHER_FONT_SIZE: font = app.qapplication.font() Option.get( Option.LAUNCHER_FONT_SIZE)["default"] = font.pointSize() current_int = int(option["default"]) if current: try: current_int = int(current) except ValueError: pass current_int = max(option["min"], min(option["max"], current_int)) check_box = fsui.CheckBox(group, gettext("Default")) spin_ctrl = fsui.SpinCtrl(group, option["min"], option["max"], current_int) if current == "": check_box.check() spin_ctrl.disable() def on_checkbox(): if check_box.is_checked(): spin_ctrl.set_value(int(option["default"])) spin_ctrl.disable() LauncherSettings.set(name, "") else: spin_ctrl.enable() check_box.on_changed = on_checkbox def on_spin(): val = spin_ctrl.get_value() val = max(option["min"], min(option["max"], val)) LauncherSettings.set(name, str(val)) spin_ctrl.on_changed = on_spin group.layout.add_spacer(0, expand=True) group.layout.add(check_box) group.layout.add(spin_ctrl, margin_left=10) if choice_values: def on_changed(): index = choice.get_index() LauncherSettings.set(name, choice_values[index][0]) choice_labels = [x[1] for x in choice_values] choice = fsui.Choice(group, choice_labels) current = LauncherSettings.get(name) for i, value in enumerate(choice_values): if current == value[0]: choice.set_index(i) break choice.on_changed = on_changed if thin: group.layout.add(choice, expand=True) else: group.layout.add_spacer(0, expand=True) group.layout.add(choice) group.widget = choice if help_button: option_url = "https://fs-uae.net/docs/options/" + name.replace( "_", "-") group.help_button = HelpButton(parent, option_url) group.layout.add(group.help_button, margin_left=10) if thin: group.layout = thin_layout return group