mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Merge branch 'develop_mission_planner' into ato
This commit is contained in:
@@ -8,7 +8,7 @@ from game.event import UnitsDeliveryEvent, FrontlineAttackEvent
|
||||
from theater.theatergroundobject import CATEGORY_MAP
|
||||
from userdata.liberation_theme import get_theme_icons
|
||||
|
||||
VERSION_STRING = "2.1.0"
|
||||
VERSION_STRING = "2.1.3"
|
||||
|
||||
URLS : Dict[str, str] = {
|
||||
"Manual": "https://github.com/khopa/dcs_liberation/wiki",
|
||||
@@ -82,6 +82,7 @@ def load_icons():
|
||||
ICONS["New"] = QPixmap("./resources/ui/misc/"+get_theme_icons()+"/new.png")
|
||||
ICONS["Open"] = QPixmap("./resources/ui/misc/"+get_theme_icons()+"/open.png")
|
||||
ICONS["Save"] = QPixmap("./resources/ui/misc/"+get_theme_icons()+"/save.png")
|
||||
ICONS["Hangar"] = QPixmap("./resources/ui/misc/hangar.png")
|
||||
|
||||
ICONS["Terrain_Caucasus"] = QPixmap("./resources/ui/terrain_caucasus.gif")
|
||||
ICONS["Terrain_Persian_Gulf"] = QPixmap("./resources/ui/terrain_pg.gif")
|
||||
@@ -138,6 +139,7 @@ def load_aircraft_icons():
|
||||
AIRCRAFT_ICONS[aircraft[:-7]] = QPixmap(os.path.join("./resources/ui/units/aircrafts/", aircraft))
|
||||
AIRCRAFT_ICONS["F-16C_50"] = AIRCRAFT_ICONS["F-16C"]
|
||||
AIRCRAFT_ICONS["FA-18C_hornet"] = AIRCRAFT_ICONS["FA-18C"]
|
||||
AIRCRAFT_ICONS["A-10C_2"] = AIRCRAFT_ICONS["A-10C"]
|
||||
|
||||
|
||||
def load_vehicle_icons():
|
||||
|
||||
@@ -243,7 +243,7 @@ class QLiberationWindow(QMainWindow):
|
||||
"<h4>Authors</h4>" + \
|
||||
"<p>DCS Liberation was originally developed by <b>shdwp</b>, DCS Liberation 2.0 is a partial rewrite based on this work by <b>Khopa</b>." \
|
||||
"<h4>Contributors</h4>" + \
|
||||
"shdwp, Khopa, Wrycu, calvinmorrow, JohanAberg, Deus, root0fall, Captain Cody" + \
|
||||
"shdwp, Khopa, ColonelPanic, Wrycu, calvinmorrow, JohanAberg, Deus, root0fall, Captain Cody, steveveepee, pedromagueija, parithon, bwRavencl, davidp57" + \
|
||||
"<h4>Special Thanks :</h4>" \
|
||||
"<b>rp-</b> <i>for the pydcs framework</i><br/>"\
|
||||
"<b>Grimes (mrSkortch)</b> & <b>Speed</b> <i>for the MIST framework</i><br/>"\
|
||||
|
||||
@@ -6,18 +6,28 @@ from PySide2.QtWidgets import (
|
||||
QSizePolicy,
|
||||
QSpacerItem,
|
||||
)
|
||||
import logging
|
||||
from dcs.unittype import UnitType
|
||||
|
||||
from theater import db
|
||||
|
||||
|
||||
|
||||
class QRecruitBehaviour:
|
||||
game = None
|
||||
cp = None
|
||||
deliveryEvent = None
|
||||
existing_units_labels = None
|
||||
bought_amount_labels = None
|
||||
maximum_units = -1
|
||||
recruitable_types = []
|
||||
BUDGET_FORMAT = "Available Budget: <b>${}M</b>"
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.deliveryEvent = None
|
||||
self.bought_amount_labels = {}
|
||||
self.existing_units_labels = {}
|
||||
self.recruitable_types = []
|
||||
self.update_available_budget()
|
||||
|
||||
@property
|
||||
@@ -75,7 +85,6 @@ class QRecruitBehaviour:
|
||||
sell.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
|
||||
sell.clicked.connect(lambda: self.sell(unit_type))
|
||||
|
||||
|
||||
existLayout.addWidget(unitName)
|
||||
existLayout.addItem(QSpacerItem(20, 0, QSizePolicy.Minimum, QSizePolicy.Minimum))
|
||||
existLayout.addWidget(existing_units)
|
||||
@@ -112,10 +121,19 @@ class QRecruitBehaviour:
|
||||
|
||||
def buy(self, unit_type):
|
||||
|
||||
if self.maximum_units > 0:
|
||||
if self.total_units + 1 > self.maximum_units:
|
||||
logging.info("Not enough space left !")
|
||||
# TODO : display modal warning
|
||||
return
|
||||
|
||||
price = db.PRICES[unit_type]
|
||||
if self.budget >= price:
|
||||
self.deliveryEvent.deliver({unit_type: 1})
|
||||
self.budget -= price
|
||||
else:
|
||||
# TODO : display modal warning
|
||||
logging.info("Not enough money !")
|
||||
self._update_count_label(unit_type)
|
||||
self.update_available_budget()
|
||||
|
||||
@@ -133,3 +151,34 @@ class QRecruitBehaviour:
|
||||
|
||||
self._update_count_label(unit_type)
|
||||
self.update_available_budget()
|
||||
|
||||
@property
|
||||
def total_units(self):
|
||||
|
||||
total = 0
|
||||
for unit_type in self.recruitables_types:
|
||||
total += self.cp.base.total_units(unit_type)
|
||||
print(unit_type, total, self.cp.base.total_units(unit_type))
|
||||
print("--------------------------------")
|
||||
|
||||
if self.deliveryEvent:
|
||||
for unit_bought in self.deliveryEvent.units:
|
||||
if db.unit_task(unit_bought) in self.recruitables_types:
|
||||
total += self.deliveryEvent.units[unit_bought]
|
||||
print(unit_bought, total, self.deliveryEvent.units[unit_bought])
|
||||
|
||||
print("=============================")
|
||||
|
||||
return total
|
||||
|
||||
def set_maximum_units(self, maximum_units):
|
||||
"""
|
||||
Set the maximum number of units that can be bought
|
||||
"""
|
||||
self.maximum_units = maximum_units
|
||||
|
||||
def set_recruitable_types(self, recruitables_types):
|
||||
"""
|
||||
Set the maximum number of units that can be bought
|
||||
"""
|
||||
self.recruitables_types = recruitables_types
|
||||
@@ -31,6 +31,15 @@ class QAircraftRecruitmentMenu(QFrame, QRecruitBehaviour):
|
||||
if not self.deliveryEvent:
|
||||
self.deliveryEvent = self.game_model.game.units_delivery_event(self.cp)
|
||||
|
||||
# Determine maximum number of aircrafts that can be bought
|
||||
self.set_maximum_units(self.cp.available_aircraft_slots)
|
||||
self.set_recruitable_types([CAP, CAS])
|
||||
|
||||
self.bought_amount_labels = {}
|
||||
self.existing_units_labels = {}
|
||||
|
||||
self.hangar_status = QHangarStatus(self.total_units, self.cp.available_aircraft_slots)
|
||||
|
||||
self.init_ui()
|
||||
|
||||
def init_ui(self):
|
||||
@@ -66,5 +75,32 @@ class QAircraftRecruitmentMenu(QFrame, QRecruitBehaviour):
|
||||
scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
|
||||
scroll.setWidgetResizable(True)
|
||||
scroll.setWidget(scroll_content)
|
||||
main_layout.addLayout(self.hangar_status)
|
||||
main_layout.addWidget(scroll)
|
||||
self.setLayout(main_layout)
|
||||
|
||||
def buy(self, unit_type):
|
||||
super().buy(unit_type)
|
||||
self.hangar_status.update_label(self.total_units, self.cp.available_aircraft_slots)
|
||||
|
||||
def sell(self, unit_type):
|
||||
super().sell(unit_type)
|
||||
self.hangar_status.update_label(self.total_units, self.cp.available_aircraft_slots)
|
||||
|
||||
|
||||
class QHangarStatus(QHBoxLayout):
|
||||
|
||||
def __init__(self, current_amount: int, max_amount: int):
|
||||
super(QHangarStatus, self).__init__()
|
||||
self.icon = QLabel()
|
||||
self.icon.setPixmap(ICONS["Hangar"])
|
||||
self.text = QLabel("")
|
||||
|
||||
self.update_label(current_amount, max_amount)
|
||||
self.addWidget(self.icon, Qt.AlignLeft)
|
||||
self.addWidget(self.text, Qt.AlignLeft)
|
||||
self.addStretch(50)
|
||||
self.setAlignment(Qt.AlignLeft)
|
||||
|
||||
def update_label(self, current_amount: int, max_amount: int):
|
||||
self.text.setText("<strong>{}/{}</strong>".format(current_amount, max_amount))
|
||||
|
||||
@@ -35,12 +35,12 @@ class QBaseDefenseGroupInfo(QGroupBox):
|
||||
|
||||
def buildLayout(self):
|
||||
unit_dict = {}
|
||||
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 i in range(self.unit_layout.rowCount()):
|
||||
for j in range(self.unit_layout.columnCount()):
|
||||
item = self.unit_layout.itemAtPosition(i, j)
|
||||
if item is not None and item.widget() is not None:
|
||||
item.widget().setParent(None)
|
||||
print("Remove " + str(i) + ", " + str(j))
|
||||
|
||||
for g in self.ground_object.groups:
|
||||
for u in g.units:
|
||||
@@ -60,6 +60,11 @@ class QBaseDefenseGroupInfo(QGroupBox):
|
||||
self.unit_layout.addWidget(QLabel(str(v) + " x " + "<strong>" + k + "</strong>"), i, 1)
|
||||
i = i + 1
|
||||
|
||||
if len(unit_dict.items()) == 0:
|
||||
self.unit_layout.addWidget(QLabel("/"), 0, 0)
|
||||
|
||||
|
||||
|
||||
self.setLayout(self.main_layout)
|
||||
|
||||
def onManage(self):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import logging
|
||||
|
||||
from PySide2 import QtCore
|
||||
from PySide2.QtGui import QCloseEvent, Qt
|
||||
from PySide2.QtGui import Qt
|
||||
from PySide2.QtWidgets import QHBoxLayout, QDialog, QGridLayout, QLabel, QGroupBox, QVBoxLayout, QPushButton, \
|
||||
QComboBox, QSpinBox, QMessageBox
|
||||
from dcs import Point
|
||||
@@ -9,7 +9,7 @@ from dcs import Point
|
||||
from game import Game, db
|
||||
from game.data.building_data import FORTIFICATION_BUILDINGS
|
||||
from game.db import PRICES, unit_type_of, PinpointStrike
|
||||
from gen.defenses.armor_group_generator import generate_armor_group
|
||||
from gen.defenses.armor_group_generator import generate_armor_group_of_type_and_size
|
||||
from gen.sam.sam_group_generator import get_faction_possible_sams_generator
|
||||
from qt_ui.uiconstants import EVENT_ICONS
|
||||
from qt_ui.widgets.QBudgetBox import QBudgetBox
|
||||
@@ -288,7 +288,9 @@ class QBuyGroupForGroundObjectDialog(QDialog):
|
||||
self.buyArmorButton.setText("Buy [$" + str(db.PRICES[self.buyArmorCombo.itemData(self.buyArmorCombo.currentIndex())] * self.amount.value()) + "M][-$" + str(self.current_group_value) + "M]")
|
||||
|
||||
def buyArmor(self):
|
||||
print("Buy Armor ")
|
||||
utype = self.buyArmorCombo.itemData(self.buyArmorCombo.currentIndex())
|
||||
print(utype)
|
||||
price = db.PRICES[utype] * self.amount.value() - self.current_group_value
|
||||
if price > self.game.budget:
|
||||
self.error_money()
|
||||
@@ -298,7 +300,7 @@ class QBuyGroupForGroundObjectDialog(QDialog):
|
||||
self.game.budget -= price
|
||||
|
||||
# Generate Armor
|
||||
group = generate_armor_group(self.game.player_name, self.game, self.ground_object)
|
||||
group = generate_armor_group_of_type_and_size(self.game, self.ground_object, utype, int(self.amount.value()))
|
||||
self.ground_object.groups = [group]
|
||||
|
||||
GameUpdateSignal.get_instance().updateBudget(self.game)
|
||||
|
||||
Reference in New Issue
Block a user