1
0
Fork 0
mirror of synced 2024-07-02 21:20:54 +12:00
Rare/rare/components/tabs/games/game_info/__init__.py

48 lines
1.6 KiB
Python
Raw Normal View History

from PyQt5.QtCore import Qt
2021-08-17 09:08:15 +12:00
from PyQt5.QtGui import QKeyEvent
from rare.shared import LegendaryCoreSingleton, GlobalSignalsSingleton
from rare.utils.extra_widgets import SideTabWidget
from .game_dlc import GameDlc
from .game_info import GameInfo
from .game_settings import GameSettings
from ..game_utils import GameUtils
2021-02-28 03:54:26 +13:00
class GameInfoTabs(SideTabWidget):
def __init__(self, dlcs: dict, game_utils: GameUtils, parent=None):
super(GameInfoTabs, self).__init__(show_back=True, parent=parent)
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
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
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
self.tabBar().setCurrentIndex(1)
def update_game(self, app_name: str):
2021-09-27 03:43:56 +13:00
self.setCurrentIndex(1)
self.info.update_game(app_name)
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 (
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)
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:
self.parent().layout().setCurrentIndex(0)