RndName d154069877 Refactor ground objects and prepare template system
- completly refactored the way TGO handles groups and replaced the usage of the pydcs ground groups (vehicle, ship, static) with an own Group and Unit class.
- this allows us to only take care of dcs group generation during miz generation, where it should have always been.
- We can now have any type of unit (even statics) in the same logic ground group we handle in liberation. this is independent from the dcs group handling. the dcs group will only be genarted when takeoff is pressed.
- Refactored the unitmap and the scenery object handling to adopt to changes that now TGOs can hold all Units we want.
- Cleaned up many many many lines of uneeded hacks to build stuff around dcs groups.
- Removed IDs for TGOs as the names we generate are unique and for liberation to work we need no ids. Unique IDs for dcs will be generated for the units and groups only.
2022-02-21 20:45:41 +01:00

50 lines
1.6 KiB
Python

import os
from PySide2.QtGui import QPixmap
from PySide2.QtWidgets import QGroupBox, QHBoxLayout, QLabel, QVBoxLayout
from game.theater import GroundUnit
from game.config import REWARDS
class QBuildingInfo(QGroupBox):
def __init__(self, building, ground_object):
super(QBuildingInfo, self).__init__()
self.building: GroundUnit = building
self.ground_object = ground_object
self.init_ui()
def init_ui(self):
self.header = QLabel()
path = os.path.join(
"./resources/ui/units/buildings/" + self.building.type + ".png"
)
if not self.building.alive:
pixmap = QPixmap("./resources/ui/units/buildings/dead.png")
elif os.path.isfile(path):
pixmap = QPixmap(path)
else:
pixmap = QPixmap("./resources/ui/units/buildings/missing.png")
self.header.setPixmap(pixmap)
name = "<b>{}</b> {}".format(
self.building.type[0:18],
"[DEAD]" if not self.building.alive else "",
)
self.name = QLabel(name)
self.name.setProperty("style", "small")
layout = QVBoxLayout()
layout.addWidget(self.header)
layout.addWidget(self.name)
if self.ground_object.category in REWARDS.keys():
income_label_text = (
"Value: " + str(REWARDS[self.ground_object.category]) + "M"
)
if not self.building.alive:
income_label_text = "<s>" + income_label_text + "</s>"
self.reward = QLabel(income_label_text)
layout.addWidget(self.reward)
footer = QHBoxLayout()
self.setLayout(layout)