mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Fixes to Buy/Sell sam UI
This commit is contained in:
parent
4019da8ba9
commit
0e2a449553
@ -1,5 +1,5 @@
|
||||
from PySide2.QtCore import Qt
|
||||
from PySide2.QtWidgets import QGridLayout, QLabel, QGroupBox, QPushButton
|
||||
from PySide2.QtWidgets import QGridLayout, QLabel, QGroupBox, QPushButton, QVBoxLayout
|
||||
|
||||
from qt_ui.uiconstants import VEHICLES_ICONS
|
||||
from qt_ui.windows.groundobject.QGroundObjectMenu import QGroundObjectMenu
|
||||
@ -8,18 +8,40 @@ from theater import ControlPoint, TheaterGroundObject
|
||||
|
||||
class QBaseDefenseGroupInfo(QGroupBox):
|
||||
|
||||
def __init__(self, cp:ControlPoint, ground_object: TheaterGroundObject, game):
|
||||
def __init__(self, cp: ControlPoint, ground_object: TheaterGroundObject, game):
|
||||
super(QBaseDefenseGroupInfo, self).__init__("Group : " + ground_object.obj_name)
|
||||
self.ground_object = ground_object
|
||||
self.cp = cp
|
||||
self.game = game
|
||||
self.buildings = game.theater.find_ground_objects_by_obj_name(self.ground_object.obj_name)
|
||||
|
||||
self.main_layout = QVBoxLayout()
|
||||
self.unit_layout = QGridLayout()
|
||||
|
||||
self.init_ui()
|
||||
|
||||
|
||||
def init_ui(self):
|
||||
|
||||
self.buildLayout()
|
||||
manage_button = QPushButton("Manage")
|
||||
manage_button.setProperty("style", "btn-success")
|
||||
manage_button.setMaximumWidth(180)
|
||||
manage_button.clicked.connect(self.onManage)
|
||||
|
||||
self.main_layout.addLayout(self.unit_layout)
|
||||
self.main_layout.addWidget(manage_button, 0, Qt.AlignLeft)
|
||||
|
||||
self.setLayout(self.main_layout)
|
||||
|
||||
def buildLayout(self):
|
||||
unit_dict = {}
|
||||
layout = QGridLayout()
|
||||
for i in range(self.unit_layout.count()):
|
||||
item = self.unit_layout.itemAt(i)
|
||||
if item is not None and item.widget() is not None:
|
||||
self.unit_layout.removeItem(item)
|
||||
item.widget().setParent(None)
|
||||
item.widget().deleteLater()
|
||||
|
||||
for g in self.ground_object.groups:
|
||||
for u in g.units:
|
||||
if u.type in unit_dict.keys():
|
||||
@ -32,21 +54,18 @@ class QBaseDefenseGroupInfo(QGroupBox):
|
||||
if k in VEHICLES_ICONS.keys():
|
||||
icon.setPixmap(VEHICLES_ICONS[k])
|
||||
else:
|
||||
icon.setText("<b>" + k[:9] + "</b>")
|
||||
icon.setText("<b>" + k[:8] + "</b>")
|
||||
icon.setProperty("style", "icon-armor")
|
||||
layout.addWidget(icon, i, 0)
|
||||
layout.addWidget(QLabel(str(v) + " x " + "<strong>" + k + "</strong>"), i, 1)
|
||||
self.unit_layout.addWidget(icon, i, 0)
|
||||
self.unit_layout.addWidget(QLabel(str(v) + " x " + "<strong>" + k + "</strong>"), i, 1)
|
||||
i = i + 1
|
||||
|
||||
manage_button = QPushButton("Manage")
|
||||
manage_button.setProperty("style", "btn-success")
|
||||
manage_button.setMaximumWidth(180)
|
||||
manage_button.clicked.connect(self.onManage)
|
||||
layout.addWidget(manage_button, i, 0, Qt.AlignLeft)
|
||||
self.setLayout(layout)
|
||||
self.setLayout(self.main_layout)
|
||||
|
||||
def onManage(self):
|
||||
self.editionMenu = QGroundObjectMenu(self.window(), self.ground_object, self.buildings, self.cp, self.game)
|
||||
self.editionMenu.show()
|
||||
|
||||
self.edition_menu = QGroundObjectMenu(self.window(), self.ground_object, self.buildings, self.cp, self.game)
|
||||
self.edition_menu.show()
|
||||
self.edition_menu.changed.connect(self.onEdition)
|
||||
|
||||
def onEdition(self):
|
||||
self.buildLayout()
|
||||
@ -23,7 +23,6 @@ class QBaseInformation(QFrame):
|
||||
scroll_content = QWidget()
|
||||
task_box_layout = QGridLayout()
|
||||
scroll_content.setLayout(task_box_layout)
|
||||
row = 0
|
||||
|
||||
for g in self.cp.ground_objects:
|
||||
if g.airbase_group:
|
||||
|
||||
@ -20,6 +20,8 @@ from theater import ControlPoint, TheaterGroundObject
|
||||
|
||||
class QGroundObjectMenu(QDialog):
|
||||
|
||||
changed = QtCore.Signal()
|
||||
|
||||
def __init__(self, parent, ground_object: TheaterGroundObject, buildings:[], cp: ControlPoint, game: Game):
|
||||
super(QGroundObjectMenu, self).__init__(parent)
|
||||
self.setMinimumWidth(350)
|
||||
@ -64,7 +66,7 @@ class QGroundObjectMenu(QDialog):
|
||||
self.actionLayout.addWidget(self.sell_all_button)
|
||||
self.actionLayout.addWidget(self.buy_replace)
|
||||
|
||||
if self.cp.captured:
|
||||
if self.cp.captured and self.ground_object.dcs_identifier == "AA":
|
||||
self.mainLayout.addLayout(self.actionLayout)
|
||||
self.setLayout(self.mainLayout)
|
||||
|
||||
@ -132,12 +134,13 @@ class QGroundObjectMenu(QDialog):
|
||||
self.actionLayout.addWidget(self.sell_all_button)
|
||||
self.actionLayout.addWidget(self.buy_replace)
|
||||
|
||||
if self.cp.captured:
|
||||
if self.cp.captured and self.ground_object.dcs_identifier == "AA":
|
||||
self.mainLayout.addLayout(self.actionLayout)
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
self.update_total_value()
|
||||
self.changed.emit()
|
||||
|
||||
def update_total_value(self):
|
||||
total_value = 0
|
||||
@ -169,6 +172,7 @@ class QGroundObjectMenu(QDialog):
|
||||
logging.info("Repaired unit : " + str(unit.id) + " " + str(unit.type))
|
||||
|
||||
self.do_refresh_layout()
|
||||
self.changed.emit()
|
||||
|
||||
def sell_all(self):
|
||||
self.update_total_value()
|
||||
@ -183,9 +187,6 @@ class QGroundObjectMenu(QDialog):
|
||||
self.subwindow.show()
|
||||
|
||||
|
||||
def closeEvent(self, closeEvent: QCloseEvent):
|
||||
pass
|
||||
|
||||
|
||||
class QBuyGroupForGroundObjectDialog(QDialog):
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user