mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Fix budget update for non-base SAMs.
Just emit the signal to update the budget rather than trying to figure out the heirarchy of the UI. Fixes https://github.com/Khopa/dcs_liberation/issues/581 (cherry picked from commit 7d907aac0f644f55bda42ec916eb2be054aefcf5)
This commit is contained in:
parent
4b0d2f7abc
commit
edba923f2f
@ -10,7 +10,7 @@ from PySide2.QtWidgets import (
|
|||||||
QWidget,
|
QWidget,
|
||||||
)
|
)
|
||||||
|
|
||||||
from game import db
|
from game import Game, db
|
||||||
from game.theater import ControlPoint, ControlPointType
|
from game.theater import ControlPoint, ControlPointType
|
||||||
from gen.flights.flight import FlightType
|
from gen.flights.flight import FlightType
|
||||||
from qt_ui.dialogs import Dialog
|
from qt_ui.dialogs import Dialog
|
||||||
@ -89,13 +89,14 @@ class QBaseMenu2(QDialog):
|
|||||||
runway_attack_button.setProperty("style", "btn-danger")
|
runway_attack_button.setProperty("style", "btn-danger")
|
||||||
runway_attack_button.clicked.connect(self.new_package)
|
runway_attack_button.clicked.connect(self.new_package)
|
||||||
|
|
||||||
budget_display = QLabel(
|
self.budget_display = QLabel(
|
||||||
QRecruitBehaviour.BUDGET_FORMAT.format(self.game_model.game.budget)
|
QRecruitBehaviour.BUDGET_FORMAT.format(self.game_model.game.budget)
|
||||||
)
|
)
|
||||||
budget_display.setObjectName("budgetField")
|
self.budget_display.setAlignment(Qt.AlignRight | Qt.AlignBottom)
|
||||||
budget_display.setAlignment(Qt.AlignRight | Qt.AlignBottom)
|
self.budget_display.setProperty("style", "budget-label")
|
||||||
budget_display.setProperty("style", "budget-label")
|
bottom_row.addWidget(self.budget_display)
|
||||||
bottom_row.addWidget(budget_display)
|
GameUpdateSignal.get_instance().budgetupdated.connect(
|
||||||
|
self.update_budget)
|
||||||
self.setLayout(main_layout)
|
self.setLayout(main_layout)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -171,9 +172,6 @@ class QBaseMenu2(QDialog):
|
|||||||
def new_package(self) -> None:
|
def new_package(self) -> None:
|
||||||
Dialog.open_new_package_dialog(self.cp, parent=self.window())
|
Dialog.open_new_package_dialog(self.cp, parent=self.window())
|
||||||
|
|
||||||
def update_dialogue_budget(self, budget: int):
|
def update_budget(self, game: Game) -> None:
|
||||||
GameUpdateSignal.get_instance().updateBudget(self.game_model.game)
|
self.budget_display.setText(
|
||||||
for child in self.children():
|
QRecruitBehaviour.BUDGET_FORMAT.format(game.budget))
|
||||||
if child.objectName() == "budgetField":
|
|
||||||
child.setText(
|
|
||||||
QRecruitBehaviour.BUDGET_FORMAT.format(budget))
|
|
||||||
|
|||||||
@ -16,6 +16,7 @@ from game import db
|
|||||||
from game.event import UnitsDeliveryEvent
|
from game.event import UnitsDeliveryEvent
|
||||||
from game.theater import ControlPoint
|
from game.theater import ControlPoint
|
||||||
from qt_ui.models import GameModel
|
from qt_ui.models import GameModel
|
||||||
|
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
||||||
|
|
||||||
|
|
||||||
class QRecruitBehaviour:
|
class QRecruitBehaviour:
|
||||||
@ -121,11 +122,8 @@ class QRecruitBehaviour:
|
|||||||
self.cp.base.total_units_of_type(unit_type)
|
self.cp.base.total_units_of_type(unit_type)
|
||||||
))
|
))
|
||||||
|
|
||||||
def update_available_budget(self):
|
def update_available_budget(self) -> None:
|
||||||
parent = self.parent()
|
GameUpdateSignal.get_instance().updateBudget(self.game_model.game)
|
||||||
while parent.objectName != "menuDialogue":
|
|
||||||
parent = parent.parent()
|
|
||||||
parent.update_dialogue_budget(self.budget)
|
|
||||||
|
|
||||||
def buy(self, unit_type: Type[UnitType]):
|
def buy(self, unit_type: Type[UnitType]):
|
||||||
price = db.PRICES[unit_type]
|
price = db.PRICES[unit_type]
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
from typing import List, Optional
|
||||||
|
|
||||||
from PySide2 import QtCore
|
from PySide2 import QtCore
|
||||||
from PySide2.QtGui import Qt
|
from PySide2.QtGui import Qt
|
||||||
@ -33,11 +34,16 @@ class QGroundObjectMenu(QDialog):
|
|||||||
|
|
||||||
changed = QtCore.Signal()
|
changed = QtCore.Signal()
|
||||||
|
|
||||||
def __init__(self, parent, ground_object: TheaterGroundObject, buildings:[], cp: ControlPoint, game: Game):
|
def __init__(self, parent, ground_object: TheaterGroundObject,
|
||||||
super(QGroundObjectMenu, self).__init__(parent)
|
buildings: Optional[List[TheaterGroundObject]],
|
||||||
|
cp: ControlPoint, game: Game):
|
||||||
|
super().__init__(parent)
|
||||||
self.setMinimumWidth(350)
|
self.setMinimumWidth(350)
|
||||||
self.ground_object = ground_object
|
self.ground_object = ground_object
|
||||||
self.buildings = buildings
|
if buildings is None:
|
||||||
|
self.buildings = []
|
||||||
|
else:
|
||||||
|
self.buildings = buildings
|
||||||
self.cp = cp
|
self.cp = cp
|
||||||
self.game = game
|
self.game = game
|
||||||
self.setWindowTitle("Location " + self.ground_object.obj_name)
|
self.setWindowTitle("Location " + self.ground_object.obj_name)
|
||||||
@ -190,7 +196,6 @@ class QGroundObjectMenu(QDialog):
|
|||||||
group.units_losts = [u for u in group.units_losts if u.id != unit.id]
|
group.units_losts = [u for u in group.units_losts if u.id != unit.id]
|
||||||
group.units.append(unit)
|
group.units.append(unit)
|
||||||
GameUpdateSignal.get_instance().updateGame(self.game)
|
GameUpdateSignal.get_instance().updateGame(self.game)
|
||||||
self.parent().update_dialogue_budget(self.game.budget)
|
|
||||||
|
|
||||||
# Remove destroyed units in the vicinity
|
# Remove destroyed units in the vicinity
|
||||||
destroyed_units = self.game.get_destroyed_units()
|
destroyed_units = self.game.get_destroyed_units()
|
||||||
@ -210,7 +215,6 @@ class QGroundObjectMenu(QDialog):
|
|||||||
self.ground_object.groups = []
|
self.ground_object.groups = []
|
||||||
self.do_refresh_layout()
|
self.do_refresh_layout()
|
||||||
GameUpdateSignal.get_instance().updateBudget(self.game)
|
GameUpdateSignal.get_instance().updateBudget(self.game)
|
||||||
self.parent().update_dialogue_budget(self.game.budget)
|
|
||||||
|
|
||||||
def buy_group(self):
|
def buy_group(self):
|
||||||
self.subwindow = QBuyGroupForGroundObjectDialog(self, self.ground_object, self.cp, self.game, self.total_value)
|
self.subwindow = QBuyGroupForGroundObjectDialog(self, self.ground_object, self.cp, self.game, self.total_value)
|
||||||
@ -335,7 +339,6 @@ class QBuyGroupForGroundObjectDialog(QDialog):
|
|||||||
self.ground_object.groups = [group]
|
self.ground_object.groups = [group]
|
||||||
|
|
||||||
GameUpdateSignal.get_instance().updateBudget(self.game)
|
GameUpdateSignal.get_instance().updateBudget(self.game)
|
||||||
self.parent().parent().update_dialogue_budget(self.game.budget)
|
|
||||||
|
|
||||||
self.changed.emit()
|
self.changed.emit()
|
||||||
self.close()
|
self.close()
|
||||||
@ -356,7 +359,6 @@ class QBuyGroupForGroundObjectDialog(QDialog):
|
|||||||
self.ground_object.groups = [generated_group]
|
self.ground_object.groups = [generated_group]
|
||||||
|
|
||||||
GameUpdateSignal.get_instance().updateBudget(self.game)
|
GameUpdateSignal.get_instance().updateBudget(self.game)
|
||||||
self.parent().parent().update_dialogue_budget(self.game.budget)
|
|
||||||
|
|
||||||
self.changed.emit()
|
self.changed.emit()
|
||||||
self.close()
|
self.close()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user