mirror of
https://github.com/spencershepard/RotorOps.git
synced 2025-11-10 15:45:30 +00:00
Allow skill level selection
This commit is contained in:
parent
2b108d7746
commit
b898b4dbdd
@ -1,6 +1,7 @@
|
||||
import json
|
||||
|
||||
import dcs.installation
|
||||
import dcs.unit
|
||||
import yaml
|
||||
import sys
|
||||
import os
|
||||
@ -14,7 +15,6 @@ import logging
|
||||
import requests
|
||||
from packaging import version as ver
|
||||
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QApplication, QDialog, QMainWindow, QMessageBox, QCheckBox, QSpinBox, QSplashScreen, QFileDialog, QRadioButton,
|
||||
QInputDialog, QDialogButtonBox, QVBoxLayout, QLabel, QComboBox
|
||||
@ -104,6 +104,10 @@ defenders_text = "Defending Forces:"
|
||||
attackers_text = "Attacking Forces:"
|
||||
ratings_json = None
|
||||
|
||||
skillNameList = ["From Template", "Average", "Good", "High", "Excellent", "Random"]
|
||||
skillValueList = [None, dcs.unit.Skill.Average, dcs.unit.Skill.Good, dcs.unit.Skill.High, dcs.unit.Skill.Excellent, dcs.unit.Skill.Random]
|
||||
|
||||
|
||||
logger.info("RotorOps v" + version.version_string)
|
||||
logger.info("pydcs DCS installation directory: " + dcs.installation.get_dcs_install_directory())
|
||||
logger.info("pydcs DCS saved games directory: " + dcs.installation.get_dcs_saved_games_directory())
|
||||
@ -323,6 +327,9 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
for forces in self.forces_list:
|
||||
self.redforces_comboBox.addItem(forces.name)
|
||||
self.blueforces_comboBox.addItem(forces.name)
|
||||
for skill in skillNameList:
|
||||
self.redforces_skill_comboBox.addItem(skill)
|
||||
self.blueforces_skill_comboBox.addItem(skill)
|
||||
|
||||
def getImports(self):
|
||||
self.imports_list = []
|
||||
@ -617,6 +624,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
|
||||
red_forces = self.forces_list[self.redforces_comboBox.currentIndex()]
|
||||
blue_forces = self.forces_list[self.blueforces_comboBox.currentIndex()]
|
||||
red_forces_skill = skillValueList[self.redforces_skill_comboBox.currentIndex()]
|
||||
blue_forces_skill = skillValueList[self.blueforces_skill_comboBox.currentIndex()]
|
||||
scenario_name = self.scenario.name
|
||||
scenario_path = self.scenario.path
|
||||
|
||||
@ -637,6 +646,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
"scenario_name": scenario_name,
|
||||
"red_forces_path": red_forces.path,
|
||||
"blue_forces_path": blue_forces.path,
|
||||
"red_forces_skill": red_forces_skill,
|
||||
"blue_forces_skill": blue_forces_skill,
|
||||
"red_quantity": self.redqty_spinBox.value(),
|
||||
"blue_quantity": self.blueqty_spinBox.value(),
|
||||
"inf_spawn_qty": self.inf_spawn_spinBox.value(),
|
||||
|
||||
@ -49,7 +49,7 @@ class Ui_MainWindow(object):
|
||||
self.advanced_defenses_checkBox.setFont(font)
|
||||
self.advanced_defenses_checkBox.setObjectName("advanced_defenses_checkBox")
|
||||
self.red_forces_label = QtWidgets.QLabel(self.centralwidget)
|
||||
self.red_forces_label.setGeometry(QtCore.QRect(470, 80, 171, 27))
|
||||
self.red_forces_label.setGeometry(QtCore.QRect(470, 80, 81, 27))
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(10)
|
||||
font.setBold(False)
|
||||
@ -87,7 +87,7 @@ class Ui_MainWindow(object):
|
||||
self.defense_checkBox.setCheckable(True)
|
||||
self.defense_checkBox.setObjectName("defense_checkBox")
|
||||
self.redqty_spinBox = QtWidgets.QSpinBox(self.centralwidget)
|
||||
self.redqty_spinBox.setGeometry(QtCore.QRect(1070, 80, 51, 31))
|
||||
self.redqty_spinBox.setGeometry(QtCore.QRect(1090, 80, 51, 31))
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(12)
|
||||
self.redqty_spinBox.setFont(font)
|
||||
@ -97,7 +97,7 @@ class Ui_MainWindow(object):
|
||||
self.redqty_spinBox.setProperty("value", 2)
|
||||
self.redqty_spinBox.setObjectName("redqty_spinBox")
|
||||
self.redforces_comboBox = QtWidgets.QComboBox(self.centralwidget)
|
||||
self.redforces_comboBox.setGeometry(QtCore.QRect(660, 80, 391, 33))
|
||||
self.redforces_comboBox.setGeometry(QtCore.QRect(560, 80, 391, 33))
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
@ -130,14 +130,14 @@ class Ui_MainWindow(object):
|
||||
self.scenario_label_5.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.scenario_label_5.setObjectName("scenario_label_5")
|
||||
self.blue_forces_label = QtWidgets.QLabel(self.centralwidget)
|
||||
self.blue_forces_label.setGeometry(QtCore.QRect(470, 30, 161, 27))
|
||||
self.blue_forces_label.setGeometry(QtCore.QRect(470, 30, 81, 27))
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(10)
|
||||
font.setBold(False)
|
||||
self.blue_forces_label.setFont(font)
|
||||
self.blue_forces_label.setObjectName("blue_forces_label")
|
||||
self.blueqty_spinBox = QtWidgets.QSpinBox(self.centralwidget)
|
||||
self.blueqty_spinBox.setGeometry(QtCore.QRect(1070, 30, 51, 31))
|
||||
self.blueqty_spinBox.setGeometry(QtCore.QRect(1090, 30, 51, 31))
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(12)
|
||||
self.blueqty_spinBox.setFont(font)
|
||||
@ -147,7 +147,7 @@ class Ui_MainWindow(object):
|
||||
self.blueqty_spinBox.setProperty("value", 3)
|
||||
self.blueqty_spinBox.setObjectName("blueqty_spinBox")
|
||||
self.blueforces_comboBox = QtWidgets.QComboBox(self.centralwidget)
|
||||
self.blueforces_comboBox.setGeometry(QtCore.QRect(660, 30, 391, 33))
|
||||
self.blueforces_comboBox.setGeometry(QtCore.QRect(560, 30, 391, 33))
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(9)
|
||||
font.setBold(False)
|
||||
@ -486,9 +486,25 @@ class Ui_MainWindow(object):
|
||||
icon1.addPixmap(QtGui.QPixmap("resources/floppy-disk.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.saveConfigButton.setIcon(icon1)
|
||||
self.saveConfigButton.setObjectName("saveConfigButton")
|
||||
self.blueforces_skill_comboBox = QtWidgets.QComboBox(self.centralwidget)
|
||||
self.blueforces_skill_comboBox.setGeometry(QtCore.QRect(960, 31, 120, 33))
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(9)
|
||||
font.setBold(False)
|
||||
font.setWeight(50)
|
||||
self.blueforces_skill_comboBox.setFont(font)
|
||||
self.blueforces_skill_comboBox.setObjectName("blueforces_skill_comboBox")
|
||||
self.redforces_skill_comboBox = QtWidgets.QComboBox(self.centralwidget)
|
||||
self.redforces_skill_comboBox.setGeometry(QtCore.QRect(960, 80, 120, 33))
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(9)
|
||||
font.setBold(False)
|
||||
font.setWeight(50)
|
||||
self.redforces_skill_comboBox.setFont(font)
|
||||
self.redforces_skill_comboBox.setObjectName("redforces_skill_comboBox")
|
||||
MainWindow.setCentralWidget(self.centralwidget)
|
||||
self.menubar = QtWidgets.QMenuBar(MainWindow)
|
||||
self.menubar.setGeometry(QtCore.QRect(0, 0, 1280, 24))
|
||||
self.menubar.setGeometry(QtCore.QRect(0, 0, 1280, 21))
|
||||
self.menubar.setObjectName("menubar")
|
||||
self.menuMap = QtWidgets.QMenu(self.menubar)
|
||||
self.menuMap.setObjectName("menuMap")
|
||||
|
||||
@ -102,7 +102,7 @@
|
||||
<rect>
|
||||
<x>470</x>
|
||||
<y>80</y>
|
||||
<width>171</width>
|
||||
<width>81</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -215,7 +215,7 @@ p, li { white-space: pre-wrap; }
|
||||
<widget class="QSpinBox" name="redqty_spinBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1070</x>
|
||||
<x>1090</x>
|
||||
<y>80</y>
|
||||
<width>51</width>
|
||||
<height>31</height>
|
||||
@ -245,7 +245,7 @@ p, li { white-space: pre-wrap; }
|
||||
<widget class="QComboBox" name="redforces_comboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>660</x>
|
||||
<x>560</x>
|
||||
<y>80</y>
|
||||
<width>391</width>
|
||||
<height>33</height>
|
||||
@ -334,7 +334,7 @@ p, li { white-space: pre-wrap; }
|
||||
<rect>
|
||||
<x>470</x>
|
||||
<y>30</y>
|
||||
<width>161</width>
|
||||
<width>81</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -351,7 +351,7 @@ p, li { white-space: pre-wrap; }
|
||||
<widget class="QSpinBox" name="blueqty_spinBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1070</x>
|
||||
<x>1090</x>
|
||||
<y>30</y>
|
||||
<width>51</width>
|
||||
<height>31</height>
|
||||
@ -381,7 +381,7 @@ p, li { white-space: pre-wrap; }
|
||||
<widget class="QComboBox" name="blueforces_comboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>660</x>
|
||||
<x>560</x>
|
||||
<y>30</y>
|
||||
<width>391</width>
|
||||
<height>33</height>
|
||||
@ -1401,6 +1401,40 @@ p, li { white-space: pre-wrap; }
|
||||
<normaloff>resources/floppy-disk.png</normaloff>resources/floppy-disk.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="blueforces_skill_comboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>960</x>
|
||||
<y>31</y>
|
||||
<width>120</width>
|
||||
<height>33</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="redforces_skill_comboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>960</x>
|
||||
<y>80</y>
|
||||
<width>120</width>
|
||||
<height>33</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
@ -1408,7 +1442,7 @@ p, li { white-space: pre-wrap; }
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1280</width>
|
||||
<height>24</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuMap">
|
||||
|
||||
@ -32,9 +32,9 @@ class ImportObjects:
|
||||
def getHelicopters(self):
|
||||
return self.helicopters
|
||||
|
||||
def copyAll(self, mission, dest_country_name, dest_name, dest_point=None, dest_heading=0, start_type=None):
|
||||
def copyAll(self, mission, dest_country_name, dest_name, dest_point=None, dest_heading=0, start_type=None, skill=None):
|
||||
return self.copyStatics(mission, dest_country_name, dest_name, dest_point, dest_heading), \
|
||||
self.copyVehicles(mission, dest_country_name, dest_name, dest_point, dest_heading), \
|
||||
self.copyVehicles(mission, dest_country_name, dest_name, dest_point, dest_heading, skill), \
|
||||
self.copyHelicopters(mission, dest_country_name, dest_name, dest_point, dest_heading, start_type)
|
||||
|
||||
def anchorByGroupName(self, group_name):
|
||||
@ -107,7 +107,7 @@ class ImportObjects:
|
||||
|
||||
return new_groups
|
||||
|
||||
def copyVehicles(self, mission, dest_country_name, dest_name, dest_point=None, dest_heading=0):
|
||||
def copyVehicles(self, mission, dest_country_name, dest_name, dest_point=None, dest_heading=0, skill=None):
|
||||
logger.info("Copying " + str(len(self.vehicles)) + " vehicle groups as " + dest_name)
|
||||
new_groups = []
|
||||
|
||||
@ -129,6 +129,8 @@ class ImportObjects:
|
||||
|
||||
# ng.units[0].livery_id = group.units[0].livery_id
|
||||
ng.units[0].name = dest_name + " " + group.units[i].name
|
||||
if skill:
|
||||
ng.units[0].skill = skill
|
||||
new_groups.append(ng)
|
||||
|
||||
else:
|
||||
@ -138,6 +140,8 @@ class ImportObjects:
|
||||
u.position = group.units[i].position
|
||||
u.heading = group.units[i].heading
|
||||
# u.livery_id = group.units[i].livery_id
|
||||
if skill:
|
||||
u.skill = skill
|
||||
ng.add_unit(u)
|
||||
|
||||
return new_groups
|
||||
@ -196,7 +200,7 @@ class ImportObjects:
|
||||
|
||||
return new_groups
|
||||
|
||||
def copyVehiclesAsGroup(self, mission, dest_country_name, dest_name, dest_point, dest_heading=0):
|
||||
def copyVehiclesAsGroup(self, mission, dest_country_name, dest_name, dest_point, dest_heading=0, skill=None):
|
||||
logger.info("Copying " + str(len(self.vehicles)) + " vehicle groups as single group name: " + dest_name)
|
||||
new_group = None
|
||||
|
||||
@ -216,6 +220,8 @@ class ImportObjects:
|
||||
unit_count = unit_count + 1
|
||||
# new_group.units[0].livery_id = group.units[0].livery_id
|
||||
new_group.units[0].name = dest_name + " " + group.units[i].name
|
||||
if skill:
|
||||
new_group.units[0].skill = skill
|
||||
|
||||
else:
|
||||
|
||||
@ -226,6 +232,8 @@ class ImportObjects:
|
||||
u.heading = group.units[i].heading
|
||||
|
||||
# u.livery_id = group.units[i].livery_id
|
||||
if skill:
|
||||
u.skill = skill
|
||||
new_group.add_unit(u)
|
||||
|
||||
unit_count = unit_count + 1
|
||||
|
||||
@ -194,7 +194,7 @@ class RotorOpsMission:
|
||||
for zone_name in self.red_zones:
|
||||
if red_forces["vehicles"]:
|
||||
self.addGroundGroups(self.red_zones[zone_name], self.m.country(jtf_red), red_forces["vehicles"],
|
||||
options["red_quantity"])
|
||||
options["red_quantity"], options["red_forces_skill"])
|
||||
|
||||
if options["zone_farps"] != "farp_never" and not options["defending"]:
|
||||
helicopters = False
|
||||
@ -238,7 +238,7 @@ class RotorOpsMission:
|
||||
for i, zone_name in enumerate(self.blue_zones):
|
||||
if blue_forces["vehicles"]:
|
||||
self.addGroundGroups(self.blue_zones[zone_name], self.m.country(jtf_blue), blue_forces["vehicles"],
|
||||
options["blue_quantity"])
|
||||
options["blue_quantity"], options["blue_forces_skill"])
|
||||
|
||||
# Add blue zone FARPS (not late activated) for defensive mode
|
||||
if options["zone_farps"] != "farp_never" and options["defending"]:
|
||||
@ -447,10 +447,10 @@ class RotorOpsMission:
|
||||
if copy_vehicles:
|
||||
if vehicles_single_group:
|
||||
vehicle_group = i.copyVehiclesAsGroup(self.m, country, vehicles_name, position,
|
||||
heading)
|
||||
heading, options["blue_forces_skill"] if country == jtf_blue else options["red_forces_skill"] )
|
||||
else:
|
||||
i.copyVehicles(self.m, country, vehicles_name,
|
||||
position, heading)
|
||||
position, heading, options["blue_forces_skill"] if country == jtf_blue else options["red_forces_skill"] )
|
||||
|
||||
# Add client helicopters and farp objects
|
||||
if copy_helicopters:
|
||||
@ -461,7 +461,7 @@ class RotorOpsMission:
|
||||
|
||||
return vehicle_group # for setting properties such as late activation
|
||||
|
||||
def addGroundGroups(self, zone, _country, groups, quantity):
|
||||
def addGroundGroups(self, zone, _country, groups, quantity, skill):
|
||||
for a in range(0, quantity):
|
||||
|
||||
group = random.choice(groups)
|
||||
@ -470,7 +470,7 @@ class RotorOpsMission:
|
||||
if dcs.vehicles.vehicle_map[unit.type]:
|
||||
unit_types.append(dcs.vehicles.vehicle_map[unit.type])
|
||||
country = self.m.country(_country.name)
|
||||
self.m.vehicle_group_platoon(
|
||||
ng = self.m.vehicle_group_platoon(
|
||||
country,
|
||||
zone.name + '-GND ' + str(a + 1),
|
||||
unit_types,
|
||||
@ -478,6 +478,9 @@ class RotorOpsMission:
|
||||
heading=random.randint(0, 359),
|
||||
formation=dcs.unitgroup.VehicleGroup.Formation.Scattered,
|
||||
)
|
||||
if skill:
|
||||
for unit in ng.units:
|
||||
unit.skill = skill
|
||||
|
||||
def getCoalitionAirports(self, side: str):
|
||||
coalition_airports = []
|
||||
|
||||
@ -110,7 +110,8 @@ def getUnitsFromMiz(file, side='both'):
|
||||
|
||||
source_mission = dcs.mission.Mission()
|
||||
|
||||
try:
|
||||
#try:
|
||||
if True:
|
||||
source_mission.load_file(file)
|
||||
if side == 'both':
|
||||
sides = ['red', 'blue']
|
||||
@ -144,8 +145,8 @@ def getUnitsFromMiz(file, side='both'):
|
||||
|
||||
return forces
|
||||
|
||||
except:
|
||||
logger.error("Failed to load units from " + file)
|
||||
#except:
|
||||
# logger.error("Failed to load units from " + file)
|
||||
|
||||
def getDefaultLoadouts():
|
||||
print("Getting default loadouts")
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user