Shows total at top for economic intel

This commit is contained in:
jsjlewis96 2021-06-19 01:20:49 +01:00 committed by Dan Albert
parent c68e583c20
commit fe227e02b8
2 changed files with 10 additions and 5 deletions

View File

@ -26,12 +26,16 @@ class QHorizontalSeparationLine(QFrame):
class FinancesLayout(QGridLayout): class FinancesLayout(QGridLayout):
def __init__(self, game: Game, player: bool) -> None: def __init__(self, game: Game, player: bool, total_at_top: bool = False) -> None:
super().__init__() super().__init__()
self.row = itertools.count(0) self.row = itertools.count(0)
income = Income(game, player) income = Income(game, player)
if total_at_top:
self.add_total(game, income, player)
self.add_line()
control_points = reversed( control_points = reversed(
sorted(income.control_points, key=lambda c: c.income_per_turn) sorted(income.control_points, key=lambda c: c.income_per_turn)
) )
@ -44,18 +48,19 @@ class FinancesLayout(QGridLayout):
for building in buildings: for building in buildings:
self.add_building(building) self.add_building(building)
self.add_line() if not total_at_top:
self.add_line()
self.add_total(game, income, player)
def add_total(self, game, income, player):
self.add_row( self.add_row(
middle=f"Income multiplier: {income.multiplier:.1f}", middle=f"Income multiplier: {income.multiplier:.1f}",
right=f"<b>{income.total}M</b>", right=f"<b>{income.total}M</b>",
) )
if player: if player:
budget = game.budget budget = game.budget
else: else:
budget = game.enemy_budget budget = game.enemy_budget
self.add_row(middle="Balance", right=f"<b>{budget}M</b>") self.add_row(middle="Balance", right=f"<b>{budget}M</b>")
self.setRowStretch(next(self.row), 1) self.setRowStretch(next(self.row), 1)

View File

@ -45,7 +45,7 @@ class ScrollingFrame(QFrame):
class EconomyIntelTab(ScrollingFrame): class EconomyIntelTab(ScrollingFrame):
def __init__(self, game: Game, player: bool) -> None: def __init__(self, game: Game, player: bool) -> None:
super().__init__() super().__init__()
self.addLayout(FinancesLayout(game, player=player)) self.addLayout(FinancesLayout(game, player=player, total_at_top=True))
class IntelTableLayout(QGridLayout): class IntelTableLayout(QGridLayout):