mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
from PySide2.QtWidgets import QLabel, QHBoxLayout, QGroupBox, QPushButton
|
|
|
|
import qt_ui.uiconstants as CONST
|
|
from qt_ui.windows.finances.QFinancesMenu import QFinancesMenu
|
|
|
|
|
|
class QBudgetBox(QGroupBox):
|
|
"""
|
|
UI Component to display current budget and player's money
|
|
"""
|
|
|
|
def __init__(self, game):
|
|
super(QBudgetBox, self).__init__("Budget")
|
|
|
|
self.game = game
|
|
self.money_icon = QLabel()
|
|
self.money_icon.setPixmap(CONST.ICONS["Money"])
|
|
self.money_amount = QLabel()
|
|
|
|
self.finances = QPushButton("Details")
|
|
self.finances.setProperty("style", "btn-primary")
|
|
self.finances.clicked.connect(self.openFinances)
|
|
|
|
self.layout = QHBoxLayout()
|
|
self.layout.addWidget(self.money_icon)
|
|
self.layout.addWidget(self.money_amount)
|
|
self.layout.addWidget(self.finances)
|
|
self.setLayout(self.layout)
|
|
|
|
def setBudget(self, budget, reward):
|
|
"""
|
|
Set the money amount to display
|
|
:param budget: Current money available
|
|
:param reward: Planned reward for next turn
|
|
"""
|
|
self.money_amount.setText(str(budget) + "M (+" + str(reward) + "M)")
|
|
|
|
def setGame(self, game):
|
|
self.game = game
|
|
self.setBudget(self.game.budget, self.game.budget_reward_amount)
|
|
|
|
def openFinances(self):
|
|
self.subwindow = QFinancesMenu(self.game)
|
|
self.subwindow.show() |