2021-09-12 23:23:40 +12:00
|
|
|
from PyQt5.QtCore import Qt
|
2021-08-17 09:08:15 +12:00
|
|
|
from PyQt5.QtGui import QKeyEvent
|
2021-10-12 06:09:20 +13:00
|
|
|
|
2022-02-26 06:43:27 +13:00
|
|
|
from rare.shared import LegendaryCoreSingleton, GlobalSignalsSingleton
|
2021-10-12 06:09:20 +13:00
|
|
|
from rare.utils.extra_widgets import SideTabWidget
|
|
|
|
from .game_dlc import GameDlc
|
|
|
|
from .game_info import GameInfo
|
|
|
|
from .game_settings import GameSettings
|
2021-11-02 10:53:04 +13:00
|
|
|
from ..game_utils import GameUtils
|
2021-02-28 03:54:26 +13:00
|
|
|
|
|
|
|
|
2021-10-12 06:09:20 +13:00
|
|
|
class GameInfoTabs(SideTabWidget):
|
2021-12-10 08:03:34 +13:00
|
|
|
def __init__(self, dlcs: dict, game_utils: GameUtils, parent=None):
|
2021-10-12 06:09:20 +13:00
|
|
|
super(GameInfoTabs, self).__init__(show_back=True, parent=parent)
|
2022-02-26 06:43:27 +13:00
|
|
|
self.core = LegendaryCoreSingleton()
|
|
|
|
self.signals = GlobalSignalsSingleton()
|
2021-03-12 00:24:54 +13:00
|
|
|
|
2021-11-17 10:54:23 +13:00
|
|
|
self.info = GameInfo(self, game_utils)
|
2021-09-11 02:36:26 +12:00
|
|
|
self.addTab(self.info, self.tr("Information"))
|
2021-04-17 03:48:24 +12:00
|
|
|
|
2022-03-21 10:18:36 +13:00
|
|
|
self.settings = GameSettings(self)
|
2021-03-10 09:57:54 +13:00
|
|
|
self.addTab(self.settings, self.tr("Settings"))
|
|
|
|
|
2021-10-11 08:52:11 +13:00
|
|
|
self.dlc_list = dlcs
|
2021-11-02 10:53:04 +13:00
|
|
|
self.dlc = GameDlc(self.dlc_list, game_utils, self)
|
2021-09-11 02:36:26 +12:00
|
|
|
self.addTab(self.dlc, self.tr("Downloadable Content"))
|
2021-04-17 03:48:24 +12:00
|
|
|
|
2021-10-12 06:09:20 +13:00
|
|
|
self.tabBar().setCurrentIndex(1)
|
|
|
|
|
2021-12-06 08:11:11 +13:00
|
|
|
def update_game(self, app_name: str):
|
2021-09-27 03:43:56 +13:00
|
|
|
self.setCurrentIndex(1)
|
2021-12-06 08:11:11 +13:00
|
|
|
self.info.update_game(app_name)
|
2022-03-21 10:18:36 +13:00
|
|
|
self.settings.load_settings(app_name)
|
2021-02-28 03:54:26 +13:00
|
|
|
|
2021-04-17 03:48:24 +12:00
|
|
|
# DLC Tab: Disable if no dlcs available
|
2021-12-24 22:09:50 +13:00
|
|
|
if (
|
2022-03-21 10:18:36 +13:00
|
|
|
len(self.dlc_list.get(self.core.get_game(app_name).catalog_item_id, []))
|
|
|
|
== 0
|
2021-12-24 22:09:50 +13:00
|
|
|
):
|
2021-06-12 10:29:55 +12:00
|
|
|
self.setTabEnabled(3, False)
|
2021-10-11 08:52:11 +13:00
|
|
|
else:
|
|
|
|
self.setTabEnabled(3, True)
|
2021-12-06 08:11:11 +13:00
|
|
|
self.dlc.update_dlcs(app_name)
|
2021-04-17 03:48:24 +12:00
|
|
|
|
2021-03-12 00:24:54 +13:00
|
|
|
def keyPressEvent(self, e: QKeyEvent):
|
|
|
|
if e.key() == Qt.Key_Escape:
|
2021-09-16 08:16:50 +12:00
|
|
|
self.parent().layout().setCurrentIndex(0)
|