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
|
|
|
|
|
|
|
import rare.shared as shared
|
2021-10-15 10:05:00 +13:00
|
|
|
from legendary.models.game import Game
|
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-11-02 10:53:04 +13:00
|
|
|
def __init__(self, dlcs: list, game_utils: GameUtils, parent=None):
|
2021-10-12 06:09:20 +13:00
|
|
|
super(GameInfoTabs, self).__init__(show_back=True, parent=parent)
|
2021-10-15 10:18:13 +13:00
|
|
|
self.core = shared.core
|
2021-10-11 08:52:11 +13:00
|
|
|
self.signals = shared.signals
|
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
|
|
|
|
2021-10-11 08:52:11 +13:00
|
|
|
self.settings = GameSettings(self.core, 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-10-24 12:47:49 +13:00
|
|
|
def update_game(self, game: Game):
|
2021-09-27 03:43:56 +13:00
|
|
|
self.setCurrentIndex(1)
|
2021-09-16 08:16:50 +12:00
|
|
|
self.info.update_game(game)
|
|
|
|
self.settings.update_game(game)
|
2021-02-28 03:54:26 +13:00
|
|
|
|
2021-04-17 03:48:24 +12:00
|
|
|
# DLC Tab: Disable if no dlcs available
|
2021-10-11 08:52:11 +13:00
|
|
|
if len(self.dlc_list[game.asset_info.catalog_item_id]) == 0:
|
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(game.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)
|