Skip to content

Commit

Permalink
Merge pull request #312 from loathingKernel/fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
loathingKernel authored Dec 3, 2023
2 parents 6017dcf + 842bd27 commit c7efe36
Show file tree
Hide file tree
Showing 49 changed files with 40,913 additions and 1,244 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/release-tests.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

name: "Development Snapshot"
name: "Snapshot"


on:
workflow_dispatch:

jobs:
version:
name: "Describe version"
name: "Version"
runs-on: ubuntu-latest
outputs:
tag_abbrev: ${{ steps.version.outputs.tag_abbrev }}
Expand Down Expand Up @@ -239,7 +239,8 @@ jobs:
git clone https://github.com/create-dmg/create-dmg
create-dmg/create-dmg Rare.dmg dist/Rare.App --volname Rare --volicon rare/resources/images/Rare.icns
- uses: actions/upload-artifact@v3
- name: Upload to Artifacts
uses: actions/upload-artifact@v3
with:
name: Rare-${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}.dmg
path: Rare.dmg
14 changes: 1 addition & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: "release"
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -65,8 +63,6 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
ref: "release"
- name: Install build dependencies
run: |
sudo apt update
Expand Down Expand Up @@ -105,8 +101,6 @@ jobs:
runs-on: "windows-latest"
steps:
- uses: actions/checkout@v3
with:
ref: "release"
- uses: actions/setup-python@v4
with:
cache: pip
Expand Down Expand Up @@ -170,8 +164,6 @@ jobs:
runs-on: "windows-latest"
steps:
- uses: actions/checkout@v3
with:
ref: "release"
- uses: actions/setup-python@v4
with:
cache: pip
Expand Down Expand Up @@ -202,8 +194,6 @@ jobs:
runs-on: "windows-latest"
steps:
- uses: actions/checkout@v3
with:
ref: "release"
- uses: actions/setup-python@v4
with:
cache: pip
Expand Down Expand Up @@ -236,8 +226,6 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
ref: "release"
- uses: actions/setup-python@v4
with:
cache: pip
Expand All @@ -264,7 +252,7 @@ jobs:
git clone https://github.com/create-dmg/create-dmg
create-dmg/create-dmg Rare.dmg dist/Rare.App --volname Rare --volicon rare/resources/images/Rare.icns
- name: upload to GitHub
- name: Upload to Releases
uses: svenstaro/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion rare/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "1.10.3"
__version__ = "1.10.4"
__codename__ = "Garlic Crab"
28 changes: 17 additions & 11 deletions rare/components/dialogs/install_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from PyQt5.QtCore import Qt, QThreadPool, QSettings, QCoreApplication
from PyQt5.QtCore import pyqtSignal, pyqtSlot
from PyQt5.QtGui import QCloseEvent, QKeyEvent
from PyQt5.QtGui import QCloseEvent, QKeyEvent, QShowEvent
from PyQt5.QtWidgets import QDialog, QFileDialog, QCheckBox, QLayout, QWidget, QVBoxLayout
from legendary.utils.selective_dl import get_sdl_appname

Expand Down Expand Up @@ -66,6 +66,8 @@ def __init__(self, rgame: RareGame, options: InstallOptionsModel, parent=None):
header = self.tr("Repair and update")
elif options.update:
header = self.tr("Update")
elif options.reset_sdl:
header = self.tr("Modify")
else:
header = self.tr("Install")
self.ui.install_dialog_label.setText(f'<h3>{header} "{self.rgame.app_title}"</h3>')
Expand Down Expand Up @@ -95,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 @@ -113,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 @@ -135,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 Expand Up @@ -171,6 +172,12 @@ def __init__(self, rgame: RareGame, options: InstallOptionsModel, parent=None):

self.ui.install_dialog_layout.setSizeConstraint(QLayout.SetFixedSize)

def showEvent(self, a0: QShowEvent) -> None:
if a0.spontaneous():
return super().showEvent(a0)
self.save_install_edit(self.install_dir_edit.text())
super().showEvent(a0)

def execute(self):
if self.options.silent:
self.reject_close = False
Expand All @@ -192,7 +199,6 @@ def setup_sdl_list(self, platform="Windows"):
config_disable_sdl = self.core.lgd.config.getboolean(self.rgame.app_name, 'disable_sdl', fallback=False)
sdl_name = get_sdl_appname(self.rgame.app_name)
if not config_disable_sdl and sdl_name is not None:
# FIXME: this should be updated whenever platform changes
sdl_data = self.core.get_sdl_data(sdl_name, platform=platform)
if sdl_data:
widget = QWidget(self.selectable)
Expand Down
9 changes: 0 additions & 9 deletions rare/components/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,6 @@ def center_window(self):
self.resize(window_size)
self.move(screen_rect.center() - self.rect().adjusted(0, 0, decor_width, decor_height).center())

# lk: For the gritty details see `RareCore.load_pixmaps()` method
# Just before the window is shown, fire a timer to load game icons
# This is by nature a little iffy because we don't really know if the
# has been shown, and it might make the window delay as widgets being are updated.
# Still better than showing a hanged window frame for a few seconds.
def showEvent(self, a0: QShowEvent) -> None:
if not self._window_launched:
QTimer.singleShot(100, self.rcore.load_pixmaps)

@pyqtSlot()
def show(self) -> None:
super(MainWindow, self).show()
Expand Down
14 changes: 7 additions & 7 deletions rare/components/tabs/downloads/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __check_updates(self):

@pyqtSlot(str)
@pyqtSlot(RareGame)
def __add_update(self, update: Union[str,RareGame]):
def __add_update(self, update: Union[str, RareGame]):
if isinstance(update, str):
update = self.rcore.get_game(update)
if update.metadata.auto_update or QSettings().value("auto_update", False, bool):
Expand Down Expand Up @@ -192,12 +192,12 @@ def __start_download(self, item: InstallQueueItemModel):
if item.expired:
self.__refresh_download(item)
return
thread = DlThread(item, self.rcore.get_game(item.options.app_name), self.core, self.args.debug)
thread.result.connect(self.__on_download_result)
thread.progress.connect(self.__on_download_progress)
thread.finished.connect(thread.deleteLater)
thread.start()
self.__thread = thread
dl_thread = DlThread(item, self.rcore.get_game(item.options.app_name), self.core, self.args.debug)
dl_thread.result.connect(self.__on_download_result)
dl_thread.progress.connect(self.__on_download_progress)
dl_thread.finished.connect(dl_thread.deleteLater)
dl_thread.start()
self.__thread = dl_thread
self.download_widget.ui.kill_button.setDisabled(False)
self.download_widget.ui.dl_name.setText(item.download.game.app_title)
self.download_widget.setPixmap(
Expand Down
5 changes: 4 additions & 1 deletion rare/components/tabs/games/game_info/game_dlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from rare.ui.components.tabs.games.game_info.game_dlc_widget import Ui_GameDlcWidget
from rare.widgets.image_widget import ImageWidget, ImageSize
from rare.widgets.side_tab import SideTabContents
from rare.utils.misc import widget_object_name
from rare.utils.misc import widget_object_name, icon


class GameDlcWidget(QFrame):
Expand Down Expand Up @@ -48,6 +48,7 @@ def __init__(self, rgame: RareGame, rdlc: RareGame, parent=None):
self.ui.action_button.setObjectName("UninstallButton")
self.ui.action_button.clicked.connect(self.uninstall_dlc)
self.ui.action_button.setText(self.tr("Uninstall DLC"))
self.ui.action_button.setIcon(icon("ri.uninstall-line"))
# lk: don't reference `self.rdlc` here because the object has been deleted
rdlc.signals.game.uninstalled.connect(self.__uninstalled)

Expand All @@ -68,6 +69,8 @@ def __init__(self, rgame: RareGame, rdlc: RareGame, parent=None):
self.ui.action_button.setObjectName("InstallButton")
self.ui.action_button.clicked.connect(self.install_dlc)
self.ui.action_button.setText(self.tr("Install DLC"))
self.ui.action_button.setIcon(icon("ri.install-line"))

# lk: don't reference `self.rdlc` here because the object has been deleted
rdlc.signals.game.installed.connect(self.__installed)

Expand Down
27 changes: 25 additions & 2 deletions rare/components/tabs/games/game_info/game_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from rare.shared import RareCore
from rare.shared.workers import VerifyWorker, MoveWorker
from rare.ui.components.tabs.games.game_info.game_info import Ui_GameInfo
from rare.utils.misc import format_size
from rare.utils.misc import format_size, icon
from rare.widgets.image_widget import ImageWidget, ImageSize
from rare.widgets.side_tab import SideTabContents
from .move_game import MoveGamePopUp, is_game_dir
Expand All @@ -38,8 +38,18 @@ def __init__(self, parent=None):
self.ui.setupUi(self)
# lk: set object names for CSS properties
self.ui.install_button.setObjectName("InstallButton")
self.ui.modify_button.setObjectName("InstallButton")
self.ui.uninstall_button.setObjectName("UninstallButton")

self.ui.install_button.setIcon(icon("ri.install-line"))
self.ui.import_button.setIcon(icon("mdi.file-import"))

self.ui.modify_button.setIcon(icon("fa.gear"))
self.ui.verify_button.setIcon(icon("fa.check"))
self.ui.repair_button.setIcon(icon("fa.wrench"))
self.ui.move_button.setIcon(icon("mdi.folder-move"))
self.ui.uninstall_button.setIcon(icon("ri.uninstall-line"))

self.rcore = RareCore.instance()
self.core = RareCore.instance().core()
self.args = RareCore.instance().args()
Expand All @@ -53,6 +63,7 @@ def __init__(self, parent=None):

self.ui.install_button.clicked.connect(self.__on_install)
self.ui.import_button.clicked.connect(self.__on_import)
self.ui.modify_button.clicked.connect(self.__on_modify)
self.ui.verify_button.clicked.connect(self.__on_verify)
self.ui.repair_button.clicked.connect(self.__on_repair)
self.ui.uninstall_button.clicked.connect(self.__on_uninstall)
Expand All @@ -78,7 +89,7 @@ def __init__(self, parent=None):
"na": self.tr("Not applicable"),
}

# lk: requirements is unused so hide it
# lk: hide unfinished things
self.ui.requirements_group.setVisible(False)

@pyqtSlot()
Expand All @@ -97,6 +108,11 @@ def __on_uninstall(self):
""" This method is to be called from the button only """
self.rgame.uninstall()

@pyqtSlot()
def __on_modify(self):
""" This method is to be called from the button only """
self.rgame.modify()

@pyqtSlot()
def __on_repair(self):
""" This method is to be called from the button only """
Expand Down Expand Up @@ -286,6 +302,13 @@ def __update_widget(self):
(not self.rgame.is_installed or self.rgame.is_non_asset) and self.rgame.is_idle
)

self.ui.modify_button.setEnabled(
self.rgame.is_installed
and (not self.rgame.is_non_asset)
and self.rgame.is_idle
and self.rgame.sdl_name is not None
)

self.ui.verify_button.setEnabled(
self.rgame.is_installed and (not self.rgame.is_non_asset) and self.rgame.is_idle
)
Expand Down
38 changes: 10 additions & 28 deletions rare/components/tabs/games/game_widgets/game_widget.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import platform
import random
from logging import getLogger

from PyQt5.QtCore import pyqtSignal, Qt, pyqtSlot, QObject, QEvent
from PyQt5.QtGui import QMouseEvent
from PyQt5.QtCore import pyqtSignal, Qt, pyqtSlot, QObject, QEvent, QTimer
from PyQt5.QtGui import QMouseEvent, QShowEvent
from PyQt5.QtWidgets import QMessageBox, QAction

from rare.models.game import RareGame
Expand Down Expand Up @@ -38,9 +39,6 @@ def __init__(self, rgame: RareGame, parent=None):
self.install_action = QAction(self.tr("Install"), self)
self.install_action.triggered.connect(self._install)

# self.sync_action = QAction(self.tr("Sync with cloud"), self)
# self.sync_action.triggered.connect(self.sync_saves)

self.desktop_link_action = QAction(self)
self.desktop_link_action.triggered.connect(
lambda: self._create_link(self.rgame.folder_name, "desktop")
Expand Down Expand Up @@ -108,6 +106,13 @@ def __init__(self, rgame: RareGame, parent=None):
# lk: attributes as `GameWidgetUi` class
__slots__ = "ui"

def showEvent(self, a0: QShowEvent) -> None:
if a0.spontaneous():
return super().showEvent(a0)
if self.rgame.pixmap.isNull():
QTimer.singleShot(random.randrange(42, 361, 7), self.rgame.load_pixmap)
super().showEvent(a0)

@pyqtSlot()
def update_state(self):
if self.rgame.is_idle:
Expand Down Expand Up @@ -144,9 +149,6 @@ def update_actions(self):
else:
self.addAction(self.install_action)

# if self.rgame.game.supports_cloud_saves:
# self.addAction(self.sync_action)

if desktop_links_supported() and self.rgame.is_installed:
if desktop_link_path(self.rgame.folder_name, "desktop").exists():
self.desktop_link_action.setText(self.tr("Remove Desktop link"))
Expand Down Expand Up @@ -209,8 +211,6 @@ def _on_reload_image(self) -> None:
def _launch(self, offline=False, skip_version_check=False):
if offline or (self.rgame.is_foreign and self.rgame.can_run_offline):
offline = True
# if self.rgame.game.supports_cloud_saves and not offline:
# self.syncing_cloud_saves = True
if self.rgame.has_update:
skip_version_check = True
self.rgame.launch(
Expand Down Expand Up @@ -261,21 +261,3 @@ def _create_link(self, name, link_type):
self.desktop_link_action.setText(self.tr("Create Desktop link"))
elif link_type == "start_menu":
self.menu_link_action.setText(self.tr("Create Start Menu link"))

# def sync_finished(self, app_name):
# self.syncing_cloud_saves = False

# def sync_game(self):
# try:
# sync = self.game_utils.cloud_save_utils.sync_before_launch_game(
# self.rgame.app_name, True
# )
# except Exception:
# sync = False
# if sync:
# self.syncing_cloud_saves = True

# def game_finished(self, app_name, error):
# if error:
# QMessageBox.warning(self, "Error", error)
# self.game_running = False
3 changes: 3 additions & 0 deletions rare/components/tabs/games/game_widgets/library_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ def event(self, e: QEvent) -> bool:
return super().event(e)

def showEvent(self, a0: QShowEvent) -> None:
if a0.spontaneous():
return super().showEvent(a0)
self.__center_on_parent()
super().showEvent(a0)

def eventFilter(self, a0: QObject, a1: QEvent) -> bool:
if a0 is self.parent() and a1.type() == QEvent.Resize:
Expand Down
Loading

0 comments on commit c7efe36

Please sign in to comment.