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-09-12 23:23:40 +12:00
|
|
|
from PyQt5.QtWidgets import QWidget, QTabWidget
|
2021-03-12 00:24:54 +13:00
|
|
|
from qtawesome import icon
|
2021-04-17 03:48:24 +12:00
|
|
|
|
2021-09-30 10:22:47 +13:00
|
|
|
from legendary.models.game import Game
|
2021-10-11 08:52:11 +13:00
|
|
|
from rare import shared
|
2021-09-11 02:36:26 +12:00
|
|
|
from rare.components.tabs.games.game_info.game_dlc import GameDlc
|
2021-09-12 23:23:40 +12:00
|
|
|
from rare.components.tabs.games.game_info.game_info import GameInfo
|
2021-04-08 08:42:30 +12:00
|
|
|
from rare.components.tabs.games.game_info.game_settings import GameSettings
|
2021-04-08 08:39:23 +12:00
|
|
|
from rare.utils.extra_widgets import SideTabBar
|
2021-02-28 03:54:26 +13:00
|
|
|
|
|
|
|
|
|
|
|
class InfoTabs(QTabWidget):
|
2021-10-11 08:52:11 +13:00
|
|
|
def __init__(self, dlcs: list, parent):
|
2021-04-18 04:58:18 +12:00
|
|
|
super(InfoTabs, self).__init__(parent=parent)
|
2021-03-10 09:57:54 +13:00
|
|
|
self.app_name = ""
|
2021-10-11 08:52:11 +13:00
|
|
|
self.core = shared.legendary_core
|
|
|
|
self.signals = shared.signals
|
2021-02-28 03:54:26 +13:00
|
|
|
self.setTabBar(SideTabBar())
|
|
|
|
self.setTabPosition(QTabWidget.West)
|
|
|
|
|
2021-08-29 06:03:25 +12:00
|
|
|
self.addTab(QWidget(), icon("mdi.keyboard-backspace"), self.tr("Back"))
|
2021-09-27 03:43:56 +13:00
|
|
|
self.tabBarClicked.connect(lambda x: self.parent().setCurrentIndex(0) if x == 0 else None)
|
2021-03-12 00:24:54 +13:00
|
|
|
|
2021-09-30 10:22:47 +13:00
|
|
|
self.info = GameInfo(self.core, self.signals, self)
|
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-03-12 00:24:54 +13:00
|
|
|
self.tabBar().setCurrentIndex(1)
|
2021-03-10 09:57:54 +13:00
|
|
|
|
2021-10-11 08:52:11 +13:00
|
|
|
self.dlc_list = dlcs
|
|
|
|
self.dlc = GameDlc(self.dlc_list, 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-09-16 08:16:50 +12:00
|
|
|
def update_game(self, game: Game, dlcs: list):
|
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)
|