From 65b5d3f77357d6661d419d2e7d8e4ec43f90f8a8 Mon Sep 17 00:00:00 2001 From: spencershepard Date: Sat, 3 Feb 2024 17:05:10 -0800 Subject: [PATCH] save and generate config files --- Generator/MissionGenerator.py | 65 +++++++++++++++++++++- Generator/MissionGeneratorTemplates.py | 3 +- Generator/MissionGeneratorUI.py | 30 +++++++++- Generator/MissionGeneratorUI.ui | 73 +++++++++++++++++++++++-- Generator/resources/floppy-disk.png | Bin 0 -> 6860 bytes 5 files changed, 161 insertions(+), 10 deletions(-) create mode 100644 Generator/resources/floppy-disk.png 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 + + @@ -1403,9 +1435,16 @@ p, li { white-space: pre-wrap; } + + + Tools + + + + @@ -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 0000000000000000000000000000000000000000..5349f6a4fa5ac6d170236760593757fcf28025e6 GIT binary patch literal 6860 zcmeHMc~n!^y5AXOr~;y|ii+THfL0Muii`mjtQ?VWZ#4{IilU$mA`s><#M(MxK@U|> zWVqD|9*71ZXpkXFm76j|r38d96atY5K|qL%c^lt)|G)RoTkGES&RSV}_=f%M@%w#W zF8z&qKy`qF*NO6P@v+d8?jo`on? zYHcq|EFaIY&$`;ZklMq_W;=`L7E;CbZS+R`K3;=T9c57p4Rx)pNGS*<_wg2YiHyx= z7}y3Zpq)PVu6k=!G5se{j0d7d*JaOeYl-&zP9gWBznDOYiv=!ry3SruHuB zI_gV)^KN>=q`5jY|22KCTcEkF`!0bukE%tD4a-n!es~n{7H!XRddPi#>fK(?HGnqt zBVy?lEkTwOd5WMsnf(@qQ8%d&Z$T$6Bl6flEl!?0x#_siLy}M1Fl}lGX>S7X?ab=!tKbmSPqEt@xfzs_^MAJ$xG)itNa7u4ikc4F`39CCRJ>X~+ z$XI%_F^3yv&)CgU^dFW@J@&`i8n7&S0SolD?K2+ZcW%|*t(80 zXrta9GO5XMXd%Z${s~v%dEHLx9Lb8J&uh*YTp{%6k4OVUTZxsg|K3gFC1(}bP8n;0 zjDJ!HU40h`ykvH->P7B6;5oPnqa4D4xl4!qUIIH9cxP(a=^m)k?Au>9L*m_%u8uU^ zO(Fe_R%ABgo_yC5lr-P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