Skip to content

Commit

Permalink
InstallDialog: Expose platforms in RareGame and use it
Browse files Browse the repository at this point in the history
to populate the combobox
  • Loading branch information
loathingKernel committed Sep 4, 2023
1 parent 5f0547e commit 3225e5a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
17 changes: 8 additions & 9 deletions rare/components/dialogs/install_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,8 @@ def __init__(self, rgame: RareGame, options: InstallOptionsModel, parent=None):

self.error_box()

platforms = ["Windows"]
if self.rgame.is_win32:
platforms.append("Win32")
if self.rgame.is_mac:
platforms.append("Mac")
self.ui.platform_combo.addItems(platforms)
platforms = self.rgame.platforms
self.ui.platform_combo.addItems(reversed(platforms))
self.ui.platform_combo.currentIndexChanged.connect(lambda: self.option_changed(None))
self.ui.platform_combo.currentIndexChanged.connect(lambda: self.error_box())
self.ui.platform_combo.currentIndexChanged.connect(
Expand All @@ -115,8 +111,11 @@ def __init__(self, rgame: RareGame, options: InstallOptionsModel, parent=None):
if (self.ui.platform_combo.currentText() == "Mac" and pf.system() != "Darwin")
else None
)
if pf.system() == "Darwin" and "Mac" in platforms:
self.ui.platform_combo.setCurrentIndex(platforms.index("Mac"))
self.ui.platform_combo.setCurrentIndex(
self.ui.platform_combo.findText(
"Mac" if (pf.system() == "Darwin" and "Mac" in platforms) else "Windows"
)
)
self.ui.platform_combo.currentTextChanged.connect(self.setup_sdl_list)

self.advanced.ui.max_workers_spin.setValue(self.core.lgd.config.getint("Legendary", "max_workers", fallback=0))
Expand All @@ -137,7 +136,7 @@ def __init__(self, rgame: RareGame, options: InstallOptionsModel, parent=None):

self.selectable_checks: List[TagCheckBox] = []
self.config_tags: Optional[List[str]] = None
self.setup_sdl_list("Mac" if pf.system() == "Darwin" and "Mac" in platforms else "Windows")
self.setup_sdl_list(self.ui.platform_combo.currentText())

self.ui.install_button.setEnabled(False)

Expand Down
9 changes: 9 additions & 0 deletions rare/models/base_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ def is_installed(self) -> bool:
def set_installed(self, installed: bool) -> None:
pass

@property
def platforms(self) -> Tuple:
"""!
@brief Property that holds the platforms a game is available for
@return Tuple
"""
return tuple(self.game.asset_infos.keys())

@property
def is_mac(self) -> bool:
"""!
Expand Down

0 comments on commit 3225e5a

Please sign in to comment.