Merge pull request #525 from root0fall/fix_221

refresh budget after purchase from sub-dialog
This commit is contained in:
walterroach 2020-12-11 11:43:16 -06:00 committed by GitHub
commit f687a30c7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View File

@ -170,3 +170,10 @@ class QBaseMenu2(QDialog):
def new_package(self) -> None:
Dialog.open_new_package_dialog(self.cp, parent=self.window())
def update_dialogue_budget(self, budget: int):
GameUpdateSignal.get_instance().updateBudget(self.game_model.game)
for child in self.children():
if child.objectName() == "budgetField":
child.setText(
QRecruitBehaviour.BUDGET_FORMAT.format(budget))

View File

@ -125,10 +125,7 @@ class QRecruitBehaviour:
parent = self.parent()
while parent.objectName != "menuDialogue":
parent = parent.parent()
for child in parent.children():
if child.objectName() == "budgetField":
child.setText(
QRecruitBehaviour.BUDGET_FORMAT.format(self.budget))
parent.update_dialogue_budget(self.budget)
def buy(self, unit_type: Type[UnitType]):
price = db.PRICES[unit_type]

View File

@ -190,6 +190,7 @@ class QGroundObjectMenu(QDialog):
group.units_losts = [u for u in group.units_losts if u.id != unit.id]
group.units.append(unit)
GameUpdateSignal.get_instance().updateGame(self.game)
self.parent().update_dialogue_budget(self.game.budget)
# Remove destroyed units in the vicinity
destroyed_units = self.game.get_destroyed_units()
@ -209,6 +210,7 @@ class QGroundObjectMenu(QDialog):
self.ground_object.groups = []
self.do_refresh_layout()
GameUpdateSignal.get_instance().updateBudget(self.game)
self.parent().update_dialogue_budget(self.game.budget)
def buy_group(self):
self.subwindow = QBuyGroupForGroundObjectDialog(self, self.ground_object, self.cp, self.game, self.total_value)
@ -333,6 +335,7 @@ class QBuyGroupForGroundObjectDialog(QDialog):
self.ground_object.groups = [group]
GameUpdateSignal.get_instance().updateBudget(self.game)
self.parent().parent().update_dialogue_budget(self.game.budget)
self.changed.emit()
self.close()
@ -353,6 +356,7 @@ class QBuyGroupForGroundObjectDialog(QDialog):
self.ground_object.groups = [generated_group]
GameUpdateSignal.get_instance().updateBudget(self.game)
self.parent().parent().update_dialogue_budget(self.game.budget)
self.changed.emit()
self.close()