mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Show objective value per turn in the tooltip.
This commit is contained in:
parent
3d41eb1ab4
commit
2269cf0f08
@ -7,6 +7,7 @@ from PySide2.QtWidgets import QGraphicsItem
|
|||||||
import qt_ui.uiconstants as const
|
import qt_ui.uiconstants as const
|
||||||
from game import Game
|
from game import Game
|
||||||
from game.data.building_data import FORTIFICATION_BUILDINGS
|
from game.data.building_data import FORTIFICATION_BUILDINGS
|
||||||
|
from game.db import REWARDS
|
||||||
from qt_ui.windows.groundobject.QGroundObjectMenu import QGroundObjectMenu
|
from qt_ui.windows.groundobject.QGroundObjectMenu import QGroundObjectMenu
|
||||||
from theater import ControlPoint, TheaterGroundObject
|
from theater import ControlPoint, TheaterGroundObject
|
||||||
from .QMapObject import QMapObject
|
from .QMapObject import QMapObject
|
||||||
@ -27,7 +28,14 @@ class QMapGroundObject(QMapObject):
|
|||||||
self.buildings = buildings if buildings is not None else []
|
self.buildings = buildings if buildings is not None else []
|
||||||
self.setFlag(QGraphicsItem.ItemIgnoresTransformations, False)
|
self.setFlag(QGraphicsItem.ItemIgnoresTransformations, False)
|
||||||
self.ground_object_dialog: Optional[QGroundObjectMenu] = None
|
self.ground_object_dialog: Optional[QGroundObjectMenu] = None
|
||||||
|
self.setToolTip(self.tooltip)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tooltip(self) -> str:
|
||||||
|
lines = [
|
||||||
|
f"[{self.ground_object.obj_name}]",
|
||||||
|
f"${self.production_per_turn} per turn",
|
||||||
|
]
|
||||||
if self.ground_object.groups:
|
if self.ground_object.groups:
|
||||||
units = {}
|
units = {}
|
||||||
for g in self.ground_object.groups:
|
for g in self.ground_object.groups:
|
||||||
@ -36,16 +44,23 @@ class QMapGroundObject(QMapObject):
|
|||||||
units[u.type] = units[u.type]+1
|
units[u.type] = units[u.type]+1
|
||||||
else:
|
else:
|
||||||
units[u.type] = 1
|
units[u.type] = 1
|
||||||
tooltip = "[" + self.ground_object.obj_name + "]" + "\n"
|
|
||||||
for unit in units.keys():
|
for unit in units.keys():
|
||||||
tooltip = tooltip + str(unit) + "x" + str(units[unit]) + "\n"
|
lines.append(f"{unit} x {units[unit]}")
|
||||||
self.setToolTip(tooltip[:-1])
|
|
||||||
else:
|
else:
|
||||||
tooltip = "[" + self.ground_object.obj_name + "]" + "\n"
|
for building in self.buildings:
|
||||||
for building in buildings:
|
|
||||||
if not building.is_dead:
|
if not building.is_dead:
|
||||||
tooltip = tooltip + str(building.dcs_identifier) + "\n"
|
lines.append(f"{building.dcs_identifier}")
|
||||||
self.setToolTip(tooltip[:-1])
|
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def production_per_turn(self) -> int:
|
||||||
|
production = 0
|
||||||
|
for g in self.control_point.ground_objects:
|
||||||
|
if g.category in REWARDS.keys():
|
||||||
|
production += REWARDS[g.category]
|
||||||
|
return production
|
||||||
|
|
||||||
def paint(self, painter, option, widget=None) -> None:
|
def paint(self, painter, option, widget=None) -> None:
|
||||||
player_icons = "_blue"
|
player_icons = "_blue"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user