Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ImageSize location and enable "Import Game" button in game information #277

Merged
merged 9 commits into from
May 3, 2023
82 changes: 30 additions & 52 deletions .github/workflows/release-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
id: version
shell: bash
run: |
tag_abbrev=$(git tag | sort -h | grep -oE "(^[0-9]+\.[0-9]+(.[0-9]+)?)$" | tail -1)
echo "::set-output name=tag_abbrev::$tag_abbrev"
echo "::set-output name=tag_offset::$(git rev-list $tag_abbrev..HEAD --count)"
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
echo "::set-output name=full_desc::$(git describe --long --tags)"
tag_abbrev=$(git tag --sort=v:refname | grep -oE "(^[0-9]+\.[0-9]+(.[0-9]+)?)$" | tail -1)
echo "tag_abbrev=$tag_abbrev" >> $GITHUB_OUTPUT
echo "tag_offset=$(git rev-list $tag_abbrev..HEAD --count)" >> $GITHUB_OUTPUT
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "full_desc=$(git describe --long --tags)" >> $GITHUB_OUTPUT

deb-package:
needs: version
Expand All @@ -48,13 +48,13 @@ jobs:
run: |
cd build
makedeb -d
mv *.deb Rare.deb
mv *.deb ../Rare.deb

- name: Upload to Artifacts
uses: actions/upload-artifact@v3
with:
name: Rare.deb
path: build/Rare.deb
name: Rare-${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}.deb
path: Rare.deb

appimage:
needs: version
Expand All @@ -75,44 +75,18 @@ jobs:
cp rare/__main__.py .
appimage-builder --skip-test
mv Rare-*.AppImage Rare.AppImage
mv Rare-*.AppImage.zsync Rare.AppImage.zsync

- name: Upload to Artifacts
uses: actions/upload-artifact@v3
with:
name: Rare.AppImage
name: Rare-${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}.AppImage
path: Rare.AppImage

cx_freeze_zip:
needs: version
runs-on: "windows-latest"
steps:
- uses: actions/checkout@v3
with:
ref: "release"
- uses: actions/setup-python@v4
with:
cache: pip
python-version: '3.11'
check-latest: true
architecture: x64
- name: Install build dependencies
run: pip3 install cx_freeze
- name: Install target dependencies
run: |
pip3 install -r requirements.txt
pip3 install -r requirements-presence.txt
pip3 install .
- name: Build
run: cxfreeze -c rare/__main__.py --target-dir dist --target-name rare --icon rare/resources/images/Rare.ico -OO --base-name Win32GUI
- name: Compress
run: |
python -c "import shutil; shutil.make_archive('Rare-Windows', 'zip', 'dist')"

- name: Upload to Artifacts
- name: Upload to Artifacts (zsync)
uses: actions/upload-artifact@v3
with:
name: Rare-Windows-${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}.zip
path: Rare-Windows.zip
name: Rare-${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}.AppImage.zsync
path: Rare.AppImage.zsync

nuitka:
if: ${{ false }}
Expand All @@ -124,8 +98,8 @@ jobs:
with:
cache: pip
python-version: '3.9'
architecture: x64
check-latest: true
architecture: x64
- name: Install build dependencies
run: pip3 install nuitka ordered-set
- name: Install target dependencies
Expand Down Expand Up @@ -166,14 +140,17 @@ jobs:
run: |
Copy-Item -Path "rare.dist\libcrypto-1_1.dll" -Destination "rare.dist\libcrypto-1_1-x64.dll"
Copy-Item -Path "rare.dist\libssl-1_1.dll" -Destination "rare.dist\libssl-1_1-x64.dll"
- name: Compress
run: |
python -c "import shutil; shutil.make_archive('Rare-Windows', 'zip', 'rare.dist')"

- name: Upload to Artifacts
uses: actions/upload-artifact@v3
with:
name: Rare-Windows-${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}
path: rare.dist
path: Rare-Windows.zip

cx_freeze:
cx_freeze_msi:
needs: version
runs-on: "windows-latest"
steps:
Expand All @@ -193,31 +170,32 @@ jobs:
- name: Build
run: |
python freeze.py bdist_msi
mv dist/*.msi dist/Rare-Windows.msi
mv dist/*.msi Rare.msi

- name: Upload to Artifacts
uses: actions/upload-artifact@v3
with:
name: Rare-Windows-${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}.msi
path: dist/*.msi
name: Rare-${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}.msi
path: Rare.msi

win-zip:
cx_freeze_zip:
needs: version
runs-on: "windows-latest"
steps:
- uses: actions/checkout@v3
with:
ref: "release"
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: pip
python-version: '3.11'
check-latest: true
architecture: x64
- name: Install build dependencies
run: pip3 install cx_freeze
- name: Install target dependencies
run: |
pip3 install -r requirements.txt
pip3 install -r requirements-presence.txt
pip3 install .
- name: Build
run: cxfreeze -c rare/__main__.py --target-dir dist --target-name rare --icon rare/resources/images/Rare.ico -OO --base-name Win32GUI
- name: Compress
Expand Down Expand Up @@ -259,9 +237,9 @@ jobs:
- name: Create dmg
run: |
git clone https://github.com/create-dmg/create-dmg
create-dmg/create-dmg Rare-${{github.ref}}.dmg dist/Rare.App --volname Rare --volicon rare/resources/images/Rare.icns
create-dmg/create-dmg Rare.dmg dist/Rare.App --volname Rare --volicon rare/resources/images/Rare.icns

- uses: actions/upload-artifact@v3
with:
name: Rare-MacOS.dmg
path: ./*.dmg
name: Rare-${{ needs.version.outputs.tag_abbrev }}.${{ needs.version.outputs.tag_offset }}.dmg
path: Rare.dmg
80 changes: 40 additions & 40 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ jobs:
run: |
cd build
makedeb -d
mv *.deb Rare.deb
mv *.deb ../Rare.deb

- name: Upload to Releases
uses: svenstaro/upload-release-action@2.2.1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: build/Rare.deb
file: Rare.deb
asset_name: Rare-${{ github.event.release.tag_name }}.deb
tag: ${{ github.ref }}
overwrite: true
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
asset_name: Rare-${{ github.event.release.tag_name }}.AppImage
tag: ${{ github.ref }}
overwrite: true
- name: Upload zsync file to GitHub
- name: Upload to Releases (zsync)
uses: svenstaro/upload-release-action@2.2.1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -100,40 +100,6 @@ jobs:
tag: ${{ github.ref }}
overwrite: true

cx_freeze_zip:
runs-on: "windows-latest"
steps:
- uses: actions/checkout@v3
with:
ref: "release"
- uses: actions/setup-python@v4
with:
cache: pip
python-version: '3.11'
check-latest: true
architecture: x64
- name: Install build dependencies
run: pip3 install cx_freeze
- name: Install target dependencies
run: |
pip3 install -r requirements.txt
pip3 install -r requirements-presence.txt
pip3 install .
- name: Build
run: cxfreeze -c rare/__main__.py --target-dir dist --target-name rare --icon rare/resources/images/Rare.ico -OO --base-name Win32GUI
- name: Compress
run: |
python -c "import shutil; shutil.make_archive('Rare-Windows', 'zip', 'dist')"

- name: Upload to Releases
uses: svenstaro/upload-release-action@2.2.1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: Rare-Windows.zip
asset_name: Rare-Windows-${{ github.event.release.tag_name }}.zip
tag: ${{ github.ref }}
overwrite: true

nuitka:
if: ${{ false }}
runs-on: "windows-latest"
Expand Down Expand Up @@ -221,14 +187,48 @@ jobs:
- name: Build
run: |
python freeze.py bdist_msi
mv dist/*.msi dist/Rare-Windows.msi
mv dist/*.msi Rare.msi

- name: Upload to Releases
uses: svenstaro/upload-release-action@2.2.1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/Rare-Windows.msi
asset_name: Rare-Windows-${{ github.event.release.tag_name }}.msi
file: Rare.msi
asset_name: Rare-${{ github.event.release.tag_name }}.msi
tag: ${{ github.ref }}
overwrite: true

cx_freeze_zip:
runs-on: "windows-latest"
steps:
- uses: actions/checkout@v3
with:
ref: "release"
- uses: actions/setup-python@v4
with:
cache: pip
python-version: '3.11'
check-latest: true
architecture: x64
- name: Install build dependencies
run: pip3 install cx_freeze
- name: Install target dependencies
run: |
pip3 install -r requirements.txt
pip3 install -r requirements-presence.txt
pip3 install .
- name: Build
run: cxfreeze -c rare/__main__.py --target-dir dist --target-name rare --icon rare/resources/images/Rare.ico -OO --base-name Win32GUI
- name: Compress
run: |
python -c "import shutil; shutil.make_archive('Rare-Windows', 'zip', 'dist')"

- name: Upload to Releases
uses: svenstaro/upload-release-action@2.2.1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: Rare-Windows.zip
asset_name: Rare-Windows-${{ github.event.release.tag_name }}.zip
tag: ${{ github.ref }}
overwrite: true

Expand Down
6 changes: 3 additions & 3 deletions rare/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys
import traceback
from argparse import Namespace
from datetime import datetime
from datetime import datetime, timezone
from typing import Optional

import requests.exceptions
Expand Down Expand Up @@ -70,8 +70,8 @@ def __init__(self, args: Namespace):
self.launch_dialog.login()

def poke_timer(self):
dt_exp = datetime.fromisoformat(self.core.lgd.userdata['expires_at'][:-1])
dt_now = datetime.utcnow()
dt_exp = datetime.fromisoformat(self.core.lgd.userdata['expires_at'][:-1]).replace(tzinfo=timezone.utc)
dt_now = datetime.utcnow().replace(tzinfo=timezone.utc)
td = abs(dt_exp - dt_now)
self.timer.start(int(td.total_seconds() - 60) * 1000)
logger.info(f"Renewed session expires at {self.core.lgd.userdata['expires_at']}")
Expand Down
6 changes: 4 additions & 2 deletions rare/components/tabs/games/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self, parent=None):

self.game_info_page = GameInfoTabs(self)
self.game_info_page.back_clicked.connect(lambda: self.setCurrentWidget(self.games_page))
self.game_info_page.import_clicked.connect(self.show_import)
self.addWidget(self.game_info_page)

self.integrations_page = IntegrationsTabs(self)
Expand Down Expand Up @@ -117,9 +118,10 @@ def scroll_to_top(self):
)

@pyqtSlot()
def show_import(self):
@pyqtSlot(str)
def show_import(self, app_name: str = None):
self.setCurrentWidget(self.integrations_page)
self.integrations_page.show_import()
self.integrations_page.show_import(app_name)

@pyqtSlot()
def show_egl_sync(self):
Expand Down
6 changes: 5 additions & 1 deletion rare/components/tabs/games/game_info/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from PyQt5.QtCore import Qt
from PyQt5.QtCore import Qt, pyqtSignal, pyqtSlot
from PyQt5.QtGui import QKeyEvent
from PyQt5.QtWidgets import QTreeView

Expand All @@ -15,13 +15,17 @@


class GameInfoTabs(SideTabWidget):
# str: app_name
import_clicked = pyqtSignal(str)

def __init__(self, parent=None):
super(GameInfoTabs, self).__init__(show_back=True, parent=parent)
self.core = LegendaryCoreSingleton()
self.signals = GlobalSignalsSingleton()
self.args = ArgumentsSingleton()

self.info_tab = GameInfo(self)
self.info_tab.import_clicked.connect(self.import_clicked)
self.info_index = self.addTab(self.info_tab, self.tr("Information"))

self.settings_tab = GameSettings(self)
Expand Down
7 changes: 3 additions & 4 deletions rare/components/tabs/games/game_info/game_dlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

from rare.models.game import RareGame
from rare.shared import LegendaryCoreSingleton, GlobalSignalsSingleton
from rare.shared.image_manager import ImageSize
from rare.ui.components.tabs.games.game_info.game_dlc import Ui_GameDlc
from rare.ui.components.tabs.games.game_info.game_dlc_widget import Ui_GameDlcWidget
from rare.widgets.image_widget import ImageWidget
from rare.widgets.image_widget import ImageWidget, ImageSize
from rare.widgets.side_tab import SideTabContents
from rare.utils.misc import widget_object_name

Expand Down Expand Up @@ -76,6 +75,7 @@ class GameDlc(QToolBox, SideTabContents):

def __init__(self, parent=None):
super(GameDlc, self).__init__(parent=parent)
self.implements_scrollarea = True
self.ui = Ui_GameDlc()
self.ui.setupUi(self)
self.core = LegendaryCoreSingleton()
Expand All @@ -93,7 +93,7 @@ def get_installed(self, app_name: str) -> Optional[InstalledGameDlcWidget]:
return self.ui.installed_dlc_container.findChild(
InstalledGameDlcWidget,
name=widget_object_name(InstalledGameDlcWidget, app_name),
options = Qt.FindDirectChildrenOnly
options=Qt.FindDirectChildrenOnly
)

def get_available(self, app_name: str) -> Optional[AvailableGameDlcWidget]:
Expand Down Expand Up @@ -131,7 +131,6 @@ def append_installed(self, rdlc: RareGame):
i_widget.uninstalled.connect(self.append_available)
self.ui.installed_dlc_container.layout().addWidget(i_widget)


def append_available(self, rdlc: RareGame):
self.ui.available_dlc_label.setVisible(False)
self.ui.available_dlc_container.setVisible(True)
Expand Down
Loading
Loading