diff --git a/Generator/MissionGenerator.py b/Generator/MissionGenerator.py
index 9cd86a3..2b1cfb8 100644
--- a/Generator/MissionGenerator.py
+++ b/Generator/MissionGenerator.py
@@ -188,6 +188,7 @@ class Window(QMainWindow, Ui_MainWindow):
self.action_rateButton3.triggered.connect(self.rateButtonActionThree)
self.action_rateButton4.triggered.connect(self.rateButtonActionFour)
self.action_rateButton5.triggered.connect(self.rateButtonActionFive)
+ self.actionSave_Mission_Config.triggered.connect(self.saveScenarioConfig)
# Find the selected dropdown menu options and make a list of tags to filter for
def tagsFromMenuOptions(self):
@@ -248,6 +249,7 @@ class Window(QMainWindow, Ui_MainWindow):
s.rating_qty = module["rating_count"]
config_file_path = os.path.join(path, folder, basename + '.yaml')
+ s.config_file_path = config_file_path
if os.path.exists(config_file_path):
config = self.loadScenarioConfig(config_file_path)
if config:
@@ -444,6 +446,67 @@ class Window(QMainWindow, Ui_MainWindow):
except Exception as e:
logger.error("Error loading config file: " + str(e))
+ def saveScenarioConfig(self):
+
+ ## 'are you sure' popup
+ msg = QMessageBox()
+ msg.setWindowTitle("Save Mission Config")
+ msg.setText("This will overwrite the current mission config file. Are you sure?")
+ msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
+ msg.setDefaultButton(QMessageBox.No)
+ x = msg.exec_()
+ if x == QMessageBox.No:
+ return
+
+ config = {}
+
+ # get the author, version, map, tags, name, and description from the scenario
+ config['author'] = self.scenario.author
+ config['map'] = self.scenario.map_name
+ config['tags'] = self.scenario.tags
+ config['name'] = self.scenario.name
+ config['description'] = self.scenario.description
+
+
+ config['checkboxes'] = {}
+ config['spinboxes'] = {}
+ config['radiobuttons'] = {}
+ config['disable_checkboxes'] = []
+ config['disable_spinboxes'] = []
+
+ for box in QObject.findChildren(self, QCheckBox):
+ config['checkboxes'][box.objectName()] = box.isChecked()
+
+ for box in QObject.findChildren(self, QSpinBox):
+ config['spinboxes'][box.objectName()] = box.value()
+
+ for button in QObject.findChildren(self, QRadioButton):
+ if button.isChecked():
+ config['radiobuttons'][button.objectName()] = True
+
+ for box in QObject.findChildren(self, QCheckBox):
+ if not box.isEnabled():
+ config['disable_checkboxes'].append(box.objectName())
+
+ for box in QObject.findChildren(self, QSpinBox):
+ if not box.isEnabled():
+ config['disable_spinboxes'].append(box.objectName())
+
+
+ config['blue_forces'] = self.forces_list[self.blueforces_comboBox.currentIndex()].basename
+
+ config['red_forces'] = self.forces_list[self.redforces_comboBox.currentIndex()].basename
+
+ if self.slot_template_comboBox.currentIndex() > 0:
+ config['player_spawn'] = "fixed"
+
+ config_file_path = os.path.join(self.scenario.config_file_path)
+ with open(config_file_path, 'w') as outfile:
+ yaml.dump(config, outfile)
+
+
+
+
def loadUserData(self):
prefs = {}
if os.path.exists(directories.user_datafile_path):
@@ -507,7 +570,7 @@ class Window(QMainWindow, Ui_MainWindow):
self.missionImage.setPixmap(QtGui.QPixmap(directories.assets + "/briefing1.png"))
self.scenario.evaluateMiz()
- self.description_textBrowser.setText(self.scenario.description)
+ self.description_textBrowser.setText(self.scenario.display_description)
QApplication.restoreOverrideCursor()
diff --git a/Generator/MissionGeneratorTemplates.py b/Generator/MissionGeneratorTemplates.py
index a7cdf17..7a192b6 100644
--- a/Generator/MissionGeneratorTemplates.py
+++ b/Generator/MissionGeneratorTemplates.py
@@ -20,6 +20,7 @@ class Scenario:
self.packageID = None
self.local_rating = None
self.author = "unknown"
+ self.display_description = ""
def applyConfig(self, config):
@@ -122,7 +123,7 @@ class Scenario:
)
if self.packageID:
description = description + "\n\nScenario module ID: " + self.packageID
- self.description = description.replace("\n", "
")
+ self.display_description = description.replace("\n", "
")
diff --git a/Generator/MissionGeneratorUI.py b/Generator/MissionGeneratorUI.py
index 6e9d512..955df52 100644
--- a/Generator/MissionGeneratorUI.py
+++ b/Generator/MissionGeneratorUI.py
@@ -42,7 +42,7 @@ class Ui_MainWindow(object):
self.logistics_crates_checkBox.setChecked(True)
self.logistics_crates_checkBox.setObjectName("logistics_crates_checkBox")
self.advanced_defenses_checkBox = QtWidgets.QCheckBox(self.centralwidget)
- self.advanced_defenses_checkBox.setGeometry(QtCore.QRect(510, 350, 241, 28))
+ self.advanced_defenses_checkBox.setGeometry(QtCore.QRect(510, 350, 341, 28))
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(False)
@@ -79,7 +79,7 @@ class Ui_MainWindow(object):
self.description_textBrowser.setObjectName("description_textBrowser")
self.defense_checkBox = QtWidgets.QCheckBox(self.centralwidget)
self.defense_checkBox.setEnabled(True)
- self.defense_checkBox.setGeometry(QtCore.QRect(980, 140, 156, 28))
+ self.defense_checkBox.setGeometry(QtCore.QRect(980, 140, 211, 28))
font = QtGui.QFont()
font.setPointSize(11)
font.setBold(False)
@@ -467,13 +467,25 @@ class Ui_MainWindow(object):
self.perks_checkBox.setObjectName("perks_checkBox")
self.rotorops_server_checkBox = QtWidgets.QCheckBox(self.centralwidget)
self.rotorops_server_checkBox.setEnabled(True)
- self.rotorops_server_checkBox.setGeometry(QtCore.QRect(1020, 650, 121, 21))
+ self.rotorops_server_checkBox.setGeometry(QtCore.QRect(1020, 650, 131, 21))
font = QtGui.QFont()
font.setPointSize(7)
font.setBold(False)
self.rotorops_server_checkBox.setFont(font)
self.rotorops_server_checkBox.setChecked(False)
self.rotorops_server_checkBox.setObjectName("rotorops_server_checkBox")
+ self.saveConfigButton = QtWidgets.QPushButton(self.centralwidget)
+ self.saveConfigButton.setEnabled(True)
+ self.saveConfigButton.setGeometry(QtCore.QRect(620, 600, 121, 51))
+ font = QtGui.QFont()
+ font.setPointSize(8)
+ font.setBold(True)
+ self.saveConfigButton.setFont(font)
+ self.saveConfigButton.setStyleSheet("")
+ icon1 = QtGui.QIcon()
+ icon1.addPixmap(QtGui.QPixmap("resources/floppy-disk.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
+ self.saveConfigButton.setIcon(icon1)
+ self.saveConfigButton.setObjectName("saveConfigButton")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 1280, 24))
@@ -484,6 +496,8 @@ class Ui_MainWindow(object):
self.menuFilter.setObjectName("menuFilter")
self.menuPreferences = QtWidgets.QMenu(self.menubar)
self.menuPreferences.setObjectName("menuPreferences")
+ self.menuTools = QtWidgets.QMenu(self.menubar)
+ self.menuTools.setObjectName("menuTools")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
font = QtGui.QFont()
@@ -568,6 +582,8 @@ class Ui_MainWindow(object):
self.action_rateButton4.setObjectName("action_rateButton4")
self.action_rateButton5 = QtWidgets.QAction(MainWindow)
self.action_rateButton5.setObjectName("action_rateButton5")
+ self.actionSave_Mission_Config = QtWidgets.QAction(MainWindow)
+ self.actionSave_Mission_Config.setObjectName("actionSave_Mission_Config")
self.menuMap.addAction(self.actionCaucasus)
self.menuMap.addAction(self.actionPersian_Gulf)
self.menuMap.addAction(self.actionMarianas)
@@ -577,9 +593,11 @@ class Ui_MainWindow(object):
self.menuFilter.addAction(self.actionSingle_Player)
self.menuFilter.addAction(self.actionCo_Op)
self.menuPreferences.addAction(self.actionSave_Directory)
+ self.menuTools.addAction(self.actionSave_Mission_Config)
self.menubar.addAction(self.menuMap.menuAction())
self.menubar.addAction(self.menuFilter.menuAction())
self.menubar.addAction(self.menuPreferences.menuAction())
+ self.menubar.addAction(self.menuTools.menuAction())
self.retranslateUi(MainWindow)
self.generateButton.clicked.connect(self.action_generateMission.trigger) # type: ignore
@@ -593,6 +611,7 @@ class Ui_MainWindow(object):
self.rateButton3.clicked.connect(self.action_rateButton3.trigger) # type: ignore
self.rateButton4.clicked.connect(self.action_rateButton4.trigger) # type: ignore
self.rateButton5.clicked.connect(self.action_rateButton5.trigger) # type: ignore
+ self.saveConfigButton.clicked.connect(self.actionSave_Mission_Config.trigger) # type: ignore
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
@@ -675,9 +694,12 @@ class Ui_MainWindow(object):
self.perks_checkBox.setText(_translate("MainWindow", "Perks"))
self.rotorops_server_checkBox.setStatusTip(_translate("MainWindow", "Generate missions for RotorOps public servers."))
self.rotorops_server_checkBox.setText(_translate("MainWindow", "RotorOps Server Mission"))
+ self.saveConfigButton.setStatusTip(_translate("MainWindow", "Save these mission options for next time."))
+ self.saveConfigButton.setText(_translate("MainWindow", " Save Config"))
self.menuMap.setTitle(_translate("MainWindow", "Map"))
self.menuFilter.setTitle(_translate("MainWindow", "Filter"))
self.menuPreferences.setTitle(_translate("MainWindow", "Preferences"))
+ self.menuTools.setTitle(_translate("MainWindow", "Tools"))
self.action_generateMission.setText(_translate("MainWindow", "_generateMission"))
self.action_scenarioSelected.setText(_translate("MainWindow", "_scenarioSelected"))
self.action_blueforcesSelected.setText(_translate("MainWindow", "_blueforcesSelected"))
@@ -712,6 +734,8 @@ class Ui_MainWindow(object):
self.action_rateButton4.setToolTip(_translate("MainWindow", "_rateButton4"))
self.action_rateButton5.setText(_translate("MainWindow", "_rateButton5"))
self.action_rateButton5.setToolTip(_translate("MainWindow", "_rateButton5"))
+ self.actionSave_Mission_Config.setText(_translate("MainWindow", "Save Mission Config"))
+ self.actionSave_Mission_Config.setToolTip(_translate("MainWindow", "Save Mission Config"))
if __name__ == "__main__":
diff --git a/Generator/MissionGeneratorUI.ui b/Generator/MissionGeneratorUI.ui
index 1f99d0c..b788ce3 100644
--- a/Generator/MissionGeneratorUI.ui
+++ b/Generator/MissionGeneratorUI.ui
@@ -80,7 +80,7 @@
510
350
- 241
+ 341
28
@@ -192,7 +192,7 @@ p, li { white-space: pre-wrap; }
980
140
- 156
+ 211
28
@@ -921,9 +921,9 @@ p, li { white-space: pre-wrap; }
- 750
+ 790
600
- 231
+ 191
51
@@ -1349,7 +1349,7 @@ p, li { white-space: pre-wrap; }
1020
650
- 121
+ 131
21
@@ -1369,6 +1369,38 @@ p, li { white-space: pre-wrap; }
false
+
+
+ true
+
+
+
+ 660
+ 600
+ 121
+ 51
+
+
+
+
+ 8
+ true
+
+
+
+ Save these mission options for next time.
+
+
+
+
+
+ Save Config
+
+
+
+ resources/floppy-disk.pngresources/floppy-disk.png
+
+
+
+
@@ -1633,6 +1672,14 @@ p, li { white-space: pre-wrap; }
_rateButton5
+
+
+ Save Mission Config
+
+
+ Save Mission Config
+
+
@@ -1812,6 +1859,22 @@ p, li { white-space: pre-wrap; }
+
+ saveConfigButton
+ clicked()
+ actionSave_Mission_Config
+ trigger()
+
+
+ 795
+ 569
+
+
+ -1
+ -1
+
+
+
diff --git a/Generator/resources/floppy-disk.png b/Generator/resources/floppy-disk.png
new file mode 100644
index 0000000..5349f6a
Binary files /dev/null and b/Generator/resources/floppy-disk.png differ