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

View File

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