Skip to content

Commit

Permalink
Merge pull request #381 from loathingKernel/next
Browse files Browse the repository at this point in the history
Merge a lot of WIP
  • Loading branch information
loathingKernel authored Feb 18, 2024
2 parents 9181641 + 5b217e0 commit 557189f
Show file tree
Hide file tree
Showing 128 changed files with 3,894 additions and 3,810 deletions.
37 changes: 16 additions & 21 deletions .github/workflows/job_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,34 @@ on:
type: string
name2:
type: string
default: ""
file2:
type: string
default: ""

jobs:
release:
name: Upload
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: ${{ inputs.name1 }}
file: ${{ inputs.file1 }}
- name: ${{ inputs.name2 }}
file: ${{ inputs.file2 }}
steps:

- name: Download ${{ inputs.name1 }} artifact
- name: Download ${{ matrix.name }} from artifact
uses: actions/download-artifact@v3
if: ${{ matrix.name != '' }}
with:
name: ${{ inputs.name1 }}
- name: Upload ${{ inputs.name1 }} to release
name: ${{ matrix.name }}
- name: Upload ${{ matrix.name }} to release
uses: svenstaro/upload-release-action@v2
if: ${{ matrix.name != '' }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ inputs.file1 }}
asset_name: ${{ inputs.name1 }}
file: ${{ matrix.file }}
asset_name: ${{ matrix.name }}
tag: ${{ inputs.version }}
overwrite: true

- name: Download ${{ inputs.name2 }} artifact
uses: actions/download-artifact@v3
if: ${{ inputs.name2 != '' }}
with:
name: ${{ inputs.name2 }}
- name: Upload ${{ inputs.name2 }} to release
uses: svenstaro/upload-release-action@v2
if: ${{ inputs.name2 != '' }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ inputs.file2 }}
asset_name: ${{ inputs.name2 }}
tag: ${{ inputs.version }}
overwrite: true
6 changes: 3 additions & 3 deletions .tx/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
host = https://www.transifex.com

[o:rare-1:p:rare:r:placeholder-ts]
file_filter = rare/resources/languages/<lang>.ts
source_file = rare/resources/languages/translation_source.ts
source_lang = en_US
file_filter = rare/resources/languages/rare_<lang>.ts
source_file = rare/resources/languages/source.ts
source_lang = en
type = QT
minimum_perc = 50

2 changes: 1 addition & 1 deletion misc/pip_upgrade_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from subprocess import call

for dist in pkg_resources.working_set:
call("python -m pip install --upgrade " + dist.project_name, shell=True)
call(f"python -m pip install --upgrade {dist.project_name}", shell=True)
5 changes: 4 additions & 1 deletion misc/py2ts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
cwd="$(pwd)"
cd "$(dirname "$0")"/.. || exit

pylupdate5 -noobsolete $(find rare/ -iname "*.py") -ts rare/resources/languages/translation_source.ts
#py_files=$(find rare -iname "*.py" -not -path rare/ui)
#ui_files=$(find rare/ui -iname "*.ui")

pylupdate5 -noobsolete $(find rare/ -iname "*.py") -ts rare/resources/languages/source.ts

cd "$cwd" || exit
13 changes: 7 additions & 6 deletions rare/launcher/__init__.py → rare/commands/launcher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from rare.lgndr.core import LegendaryCore
from rare.models.base_game import RareGameSlim
from rare.models.launcher import ErrorModel, Actions, FinishedModel, BaseModel, StateChangedModel
from rare.models.options import options
from rare.widgets.rare_app import RareApp, RareAppException
from .cloud_sync_dialog import CloudSyncDialog, CloudSyncDialogResult
from .console_dialog import ConsoleDialog
Expand Down Expand Up @@ -142,11 +143,11 @@ def __init__(self, args: InitArgs):
return
self.rgame = RareGameSlim(self.core, game)

lang = self.settings.value("language", self.core.language_code, type=str)
self.load_translator(lang)
language = self.settings.value(*options.language)
self.load_translator(language)

if QSettings().value("show_console", False, bool):
self.console = ConsoleDialog()
if QSettings(self).value(*options.log_games):
self.console = ConsoleDialog(game.app_title)
self.console.show()

self.game_process.finished.connect(self.__process_finished)
Expand Down Expand Up @@ -294,10 +295,10 @@ def launch_game(self, args: LaunchArgs):
))
if self.rgame.app_name in DETACHED_APP_NAMES and platform.system() == "Windows":
self.game_process.deleteLater()
subprocess.Popen([args.executable] + args.arguments, cwd=args.working_directory,
env={i: args.environment.value(i) for i in args.environment.keys()})
if self.console:
self.console.log("Launching game as a detached process")
subprocess.Popen([args.executable] + args.arguments, cwd=args.working_directory,
env={i: args.environment.value(i) for i in args.environment.keys()})
self.stop()
return
if self.args.dry_run:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from rare.ui.components.tabs.games.game_info.cloud_sync_widget import Ui_CloudSyncWidget
from rare.utils.misc import icon
from rare.widgets.dialogs import ButtonDialog, dialog_title_game
from rare.widgets.dialogs import ButtonDialog, game_title

logger = getLogger("CloudSyncDialog")

Expand All @@ -28,9 +28,9 @@ class CloudSyncDialog(ButtonDialog):
def __init__(self, igame: InstalledGame, dt_local: datetime, dt_remote: datetime, parent=None):
super(CloudSyncDialog, self).__init__(parent=parent)
header = self.tr("Cloud saves for")
self.setWindowTitle(dialog_title_game(header, igame.title))
self.setWindowTitle(game_title(header, igame.title))

title_label = QLabel(f"<h4>{dialog_title_game(header, igame.title)}</h4>", self)
title_label = QLabel(f"<h4>{game_title(header, igame.title)}</h4>", self)

sync_widget = QWidget(self)
self.sync_ui = Ui_CloudSyncWidget()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import platform
from typing import Union

from PyQt5.QtCore import QProcessEnvironment, pyqtSignal, QSize, Qt
Expand All @@ -15,17 +14,20 @@
)

from rare.ui.launcher.console_env import Ui_ConsoleEnv
from rare.widgets.dialogs import dialog_title, game_title


class ConsoleDialog(QDialog):
term = pyqtSignal()
kill = pyqtSignal()
env: QProcessEnvironment

def __init__(self, parent=None):
def __init__(self, app_title: str, parent=None):
super(ConsoleDialog, self).__init__(parent=parent)
self.setAttribute(Qt.WA_DeleteOnClose, True)
self.setWindowTitle("Rare - Console")
self.setWindowTitle(
dialog_title(game_title(self.tr("Console"), app_title))
)
self.setGeometry(0, 0, 640, 480)
layout = QVBoxLayout()

Expand Down Expand Up @@ -62,7 +64,7 @@ def __init__(self, parent=None):

self.setLayout(layout)

self.env_variables = ConsoleEnv(self)
self.env_variables = ConsoleEnv(app_title, self)
self.env_variables.hide()

self.accept_close = False
Expand Down Expand Up @@ -140,11 +142,14 @@ def closeEvent(self, a0: QCloseEvent) -> None:

class ConsoleEnv(QDialog):

def __init__(self, parent=None):
def __init__(self, app_title: str, parent=None):
super(ConsoleEnv, self).__init__(parent=parent)
self.setAttribute(Qt.WA_DeleteOnClose, False)
self.ui = Ui_ConsoleEnv()
self.ui.setupUi(self)
self.setWindowTitle(
dialog_title(game_title(self.tr("Environment"), app_title))
)

def setTable(self, env: QProcessEnvironment):
self.ui.table.clearContents()
Expand All @@ -168,12 +173,12 @@ def __init__(self, parent=None):
self._cursor_output = self.textCursor()

def log(self, text):
html = f"<p style=\"color:#BBB;white-space:pre\">{text}</p>"
html = f"<p style=\"color:#aaa;white-space:pre\">{text}</p>"
self._cursor_output.insertHtml(html)
self.scroll_to_last_line()

def error(self, text):
html = f"<p style=\"color:#eee;white-space:pre\">{text}</p>"
html = f"<p style=\"color:#a33;white-space:pre\">{text}</p>"
self._cursor_output.insertHtml(html)
self.scroll_to_last_line()

Expand Down
File renamed without changes.
Empty file added rare/commands/reaper.py
Empty file.
13 changes: 13 additions & 0 deletions rare/commands/webview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import sys
from argparse import Namespace

from legendary.utils import webview_login


def launch(args: Namespace) -> int:
if webview_login.do_webview_login(
callback_code=sys.stdout.write, user_agent=f'EpicGamesLauncher/{args.egl_version}'
):
return 0
else:
return 1
5 changes: 3 additions & 2 deletions rare/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from PyQt5.QtWidgets import QApplication, QMessageBox
from requests import HTTPError

from rare.models.options import options
from rare.components.dialogs.launch_dialog import LaunchDialog
from rare.components.main_window import MainWindow
from rare.shared import RareCore
Expand Down Expand Up @@ -45,8 +46,8 @@ def __init__(self, args: Namespace):
self.signals = RareCore.instance().signals()
self.core = RareCore.instance().core()

lang = self.settings.value("language", self.core.language_code, type=str)
self.load_translator(lang)
language = self.settings.value(*options.language)
self.load_translator(language)

# set Application name for settings
self.main_window: Optional[MainWindow] = None
Expand Down
6 changes: 3 additions & 3 deletions rare/components/dialogs/install_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from rare.ui.components.dialogs.install_dialog_advanced import Ui_InstallDialogAdvanced
from rare.utils.misc import format_size, icon
from rare.widgets.collapsible_widget import CollapsibleFrame
from rare.widgets.dialogs import ActionDialog, dialog_title_game
from rare.widgets.dialogs import ActionDialog, game_title
from rare.widgets.indicator_edit import PathEdit, IndicatorReasonsCommon
from rare.widgets.selective_widget import SelectiveWidget

Expand Down Expand Up @@ -74,8 +74,8 @@ def __init__(self, rgame: RareGame, options: InstallOptionsModel, parent=None):
elif options.reset_sdl:
header = self.tr("Modify")
bicon = icon("fa.gear")
self.setWindowTitle(dialog_title_game(header, rgame.app_title))
self.setSubtitle(dialog_title_game(header, rgame.app_title))
self.setWindowTitle(game_title(header, rgame.app_title))
self.setSubtitle(game_title(header, rgame.app_title))

install_widget = QWidget(self)
self.ui = Ui_InstallDialog()
Expand Down
20 changes: 17 additions & 3 deletions rare/components/dialogs/login/browser_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
from logging import getLogger
from typing import Tuple

from PyQt5.QtCore import pyqtSignal, QUrl
from PyQt5.QtCore import pyqtSignal, QUrl, QProcess, pyqtSlot
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWidgets import QFrame, qApp, QFormLayout, QLineEdit
from legendary.core import LegendaryCore
from legendary.utils import webview_login

from rare.lgndr.core import LegendaryCore
from rare.ui.components.dialogs.login.browser_login import Ui_BrowserLogin
from rare.utils.misc import icon
from rare.utils.paths import get_rare_executable
from rare.widgets.indicator_edit import IndicatorLineEdit, IndicatorReasonsCommon

logger = getLogger("BrowserLogin")
Expand Down Expand Up @@ -43,6 +44,7 @@ def __init__(self, core: LegendaryCore, parent=None):
self.ui.open_button.clicked.connect(self.open_browser)
self.sid_edit.textChanged.connect(self.changed.emit)

@pyqtSlot()
def copy_link(self):
clipboard = qApp.clipboard()
clipboard.setText(self.login_url)
Expand Down Expand Up @@ -79,12 +81,24 @@ def do_login(self):
except Exception as e:
logger.warning(e)

@pyqtSlot()
def open_browser(self):
if not webview_login.webview_available:
logger.warning("You don't have webengine installed, you will need to manually copy the authorizationCode.")
QDesktopServices.openUrl(QUrl(self.login_url))
else:
if webview_login.do_webview_login(callback_code=self.core.auth_ex_token):
cmd = get_rare_executable() + ["login", self.core.get_egl_version()]
proc = QProcess(self)
proc.start(cmd[0], cmd[1:])
proc.waitForFinished(-1)
out, err = (
proc.readAllStandardOutput().data().decode("utf-8", "ignore"),
proc.readAllStandardError().data().decode("utf-8", "ignore")
)
proc.deleteLater()

if out:
self.core.auth_ex_token(out)
logger.info("Successfully logged in as %s", {self.core.lgd.userdata['displayName']})
self.success.emit()
else:
Expand Down
8 changes: 4 additions & 4 deletions rare/components/dialogs/move_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from rare.models.game import RareGame
from rare.shared import RareCore
from rare.utils.misc import path_size, format_size, icon
from rare.widgets.dialogs import ActionDialog, dialog_title_game
from rare.widgets.dialogs import ActionDialog, game_title
from rare.widgets.elide_label import ElideLabel
from rare.widgets.indicator_edit import PathEdit, IndicatorReasons, IndicatorReasonsCommon

Expand All @@ -33,8 +33,8 @@ class MoveDialog(ActionDialog):
def __init__(self, rgame: RareGame, parent=None):
super(MoveDialog, self).__init__(parent=parent)
header = self.tr("Move")
self.setWindowTitle(dialog_title_game(header, rgame.app_title))
self.setSubtitle(dialog_title_game(header, rgame.app_title))
self.setWindowTitle(game_title(header, rgame.app_title))
self.setSubtitle(game_title(header, rgame.app_title))

self.rcore = RareCore.instance()
self.core = RareCore.instance().core()
Expand Down Expand Up @@ -135,7 +135,7 @@ def helper_func(reason: int) -> Tuple[bool, str, int]:
if not os.access(path, os.W_OK) or not os.access(self.rgame.install_path, os.W_OK):
return helper_func(MovePathEditReasons.NO_WRITE_PERM)

if src_path == dst_path or src_path == dst_install_path:
if src_path in {dst_path, dst_install_path}:
return helper_func(MovePathEditReasons.SAME_DIR)

if str(src_path) in str(dst_path):
Expand Down
8 changes: 4 additions & 4 deletions rare/components/dialogs/selective_dialog.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QLabel, QVBoxLayout, QLayout, QGroupBox
from PyQt5.QtWidgets import QVBoxLayout, QGroupBox

from rare.models.game import RareGame
from rare.models.install import SelectiveDownloadsModel
from rare.utils.misc import icon
from rare.widgets.dialogs import ButtonDialog, dialog_title_game
from rare.widgets.dialogs import ButtonDialog, game_title
from rare.widgets.selective_widget import SelectiveWidget


Expand All @@ -14,8 +14,8 @@ class SelectiveDialog(ButtonDialog):
def __init__(self, rgame: RareGame, parent=None):
super(SelectiveDialog, self).__init__(parent=parent)
header = self.tr("Optional downloads for")
self.setWindowTitle(dialog_title_game(header, rgame.app_title))
self.setSubtitle(dialog_title_game(header, rgame.app_title))
self.setWindowTitle(game_title(header, rgame.app_title))
self.setSubtitle(game_title(header, rgame.app_title))

self.rgame = rgame
self.selective_widget = SelectiveWidget(rgame, rgame.igame.platform, self)
Expand Down
6 changes: 3 additions & 3 deletions rare/components/dialogs/uninstall_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from rare.models.game import RareGame
from rare.models.install import UninstallOptionsModel
from rare.utils.misc import icon
from rare.widgets.dialogs import ButtonDialog, dialog_title_game
from rare.widgets.dialogs import ButtonDialog, game_title


class UninstallDialog(ButtonDialog):
Expand All @@ -16,8 +16,8 @@ class UninstallDialog(ButtonDialog):
def __init__(self, rgame: RareGame, options: UninstallOptionsModel, parent=None):
super(UninstallDialog, self).__init__(parent=parent)
header = self.tr("Uninstall")
self.setWindowTitle(dialog_title_game(header, rgame.app_title))
self.setSubtitle(dialog_title_game(header, rgame.app_title))
self.setWindowTitle(game_title(header, rgame.app_title))
self.setSubtitle(game_title(header, rgame.app_title))

self.keep_files = QCheckBox(self.tr("Keep files"))
self.keep_files.setChecked(bool(options.keep_files))
Expand Down
Loading

0 comments on commit 557189f

Please sign in to comment.