diff --git a/rare/components/tabs/games/__init__.py b/rare/components/tabs/games/__init__.py
index f274eea5..419d0019 100644
--- a/rare/components/tabs/games/__init__.py
+++ b/rare/components/tabs/games/__init__.py
@@ -8,7 +8,7 @@ import rare.shared as shared
from legendary.models.game import InstalledGame
from rare.ui.components.tabs.games.games_tab import Ui_GamesTab
from rare.utils.extra_widgets import FlowLayout
-from rare.utils.utils import get_pixmap, download_image
+from rare.utils.utils import get_pixmap, download_image, get_uninstalled_pixmap
from .cloud_save_utils import CloudSaveUtils
from .cloud_save_utils import CloudSaveUtils
from .game_info import GameInfoTabs
@@ -110,7 +110,7 @@ class GamesTab(QStackedWidget, Ui_GamesTab):
game = self.core.get_game(app_name, False)
if game.is_dlc:
return
- self.installing_widget.set_game(game)
+ self.installing_widget.set_game(app_name)
self.installing_widget.setVisible(True)
def verification_finished(self, igame: InstalledGame):
@@ -197,10 +197,7 @@ class GamesTab(QStackedWidget, Ui_GamesTab):
return icon_widget, list_widget
def add_uninstalled_widget(self, game):
- pixmap = get_pixmap(game.app_name)
- img = pixmap.toImage()
- img = img.convertToFormat(QImage.Format_Grayscale8)
- pixmap = QPixmap.fromImage(img)
+ pixmap = get_uninstalled_pixmap(game.app_name)
if pixmap.isNull():
logger.warning(game.app_title + " has a corrupt image. Reloading...")
download_image(game, force=True)
diff --git a/rare/components/tabs/games/game_widgets/installing_game_widget.py b/rare/components/tabs/games/game_widgets/installing_game_widget.py
index 13f27112..e3712a6a 100644
--- a/rare/components/tabs/games/game_widgets/installing_game_widget.py
+++ b/rare/components/tabs/games/game_widgets/installing_game_widget.py
@@ -2,8 +2,8 @@ from PyQt5.QtCore import Qt, QRect
from PyQt5.QtGui import QPaintEvent, QPainter, QPixmap, QPen, QFont, QColor
from PyQt5.QtWidgets import QVBoxLayout, QLabel, QHBoxLayout, QWidget
-from legendary.models.game import Game
-from rare.utils.utils import get_pixmap, get_uninstalled_pixmap, optimal_text_background, text_color_for_background
+from rare import shared
+from rare.utils.utils import get_pixmap, optimal_text_background, text_color_for_background, get_uninstalled_pixmap
class InstallingGameWidget(QWidget):
@@ -30,43 +30,52 @@ class InstallingGameWidget(QWidget):
minilayout.addWidget(self.title_label)
self.layout().addLayout(minilayout)
- def set_game(self, game: Game):
+ def set_game(self, app_name):
+ game = shared.core.get_game(app_name)
self.title_label.setText(f"
{game.app_title}
")
- self.pixmap = get_pixmap(game.app_name)
- w = 200
- self.pixmap = self.pixmap.scaled(w, int(w * 4 / 3), transformMode=Qt.SmoothTransformation)
- self.image_widget.set_game(self.pixmap, game.app_name)
+
+ self.image_widget.set_game(game.app_name)
def set_status(self, s: int):
- self.image_widget.status = s
+ self.image_widget.progress = s
self.image_widget.repaint()
class PaintWidget(QWidget):
+ color_image: QPixmap
+ bw_image: QPixmap
+ progress: int = 0
+
def __init__(self):
super(PaintWidget, self).__init__()
- def set_game(self, pixmap: QPixmap, app_name):
- self.image = pixmap
- self.setFixedSize(self.image.size())
- self.new_image = get_uninstalled_pixmap(app_name)
- self.status = 0
+ def set_game(self, app_name: str):
+ game = shared.core.get_game(app_name, False)
+ self.color_image = get_pixmap(game.app_name)
+ w = 200
+ self.color_image = self.color_image.scaled(w, int(w * 4 // 3), transformMode=Qt.SmoothTransformation)
+ self.setFixedSize(self.color_image.size())
+ self.bw_image = get_uninstalled_pixmap(app_name)
+ self.bw_image = self.bw_image.scaled(w, int(w * 4 // 3), transformMode=Qt.SmoothTransformation)
+ self.progress = 0
+
pixel_list = []
- for x in range(self.image.width()):
- for y in range(self.image.height()):
+ for x in range(self.color_image.width()):
+ for y in range(self.color_image.height()):
# convert pixmap to qimage, get pixel and remove alpha channel
- pixel_list.append(self.image.toImage().pixelColor(x, y).getRgb()[:-1])
+ pixel_list.append(self.color_image.toImage().pixelColor(x, y).getRgb()[:-1])
self.rgb_tuple = optimal_text_background(pixel_list)
def paintEvent(self, a0: QPaintEvent) -> None:
painter = QPainter()
painter.begin(self)
- painter.drawPixmap(self.rect(), self.image)
+ painter.drawPixmap(self.rect(), self.bw_image)
- w = self.image.width() * (1 - self.status // 100)
- painter.drawPixmap(self.image.width() - w, 0, w, self.image.height(),
- self.new_image.copy(QRect(self.image.width() - w, 0, w, self.image.height())))
+ w = self.bw_image.width() * self.progress // 100
+
+ painter.drawPixmap(0, 0, w, self.color_image.height(),
+ self.color_image.copy(QRect(0, 0, w, self.color_image.height())))
# Draw Circle
pen = QPen(QColor(*self.rgb_tuple), 3)
@@ -77,5 +86,5 @@ class PaintWidget(QWidget):
# draw text
painter.setPen(QColor(*text_color_for_background(self.rgb_tuple)))
painter.setFont(QFont(None, 16))
- painter.drawText(a0.rect(), Qt.AlignCenter, str(self.status) + "%")
+ painter.drawText(a0.rect(), Qt.AlignCenter, str(self.progress) + "%")
painter.end()
diff --git a/rare/utils/utils.py b/rare/utils/utils.py
index 64afc08a..4772c889 100644
--- a/rare/utils/utils.py
+++ b/rare/utils/utils.py
@@ -363,11 +363,9 @@ def get_pixmap(app_name: str) -> QPixmap:
def get_uninstalled_pixmap(app_name: str) -> QPixmap:
- if os.path.exists(image := os.path.join(image_dir, app_name, "UninstalledArt.png")):
- pixmap = QPixmap(image)
- else:
- pixmap = QPixmap()
- return pixmap
+ pm = get_pixmap(app_name)
+ grey_image = pm.toImage().convertToFormat(QImage.Format_Grayscale8)
+ return QPixmap.fromImage(grey_image)
def optimal_text_background(image: list) -> Tuple[int, int, int]: