mirror of
https://github.com/spencershepard/RotorOps.git
synced 2025-11-10 15:45:30 +00:00
save and generate config files
This commit is contained in:
parent
538449f2f3
commit
65b5d3f773
@ -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()
|
||||
|
||||
|
||||
@ -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", "<br />")
|
||||
self.display_description = description.replace("\n", "<br />")
|
||||
|
||||
|
||||
|
||||
|
||||
@ -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__":
|
||||
|
||||
@ -80,7 +80,7 @@
|
||||
<rect>
|
||||
<x>510</x>
|
||||
<y>350</y>
|
||||
<width>241</width>
|
||||
<width>341</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -192,7 +192,7 @@ p, li { white-space: pre-wrap; }
|
||||
<rect>
|
||||
<x>980</x>
|
||||
<y>140</y>
|
||||
<width>156</width>
|
||||
<width>211</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -921,9 +921,9 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>750</x>
|
||||
<x>790</x>
|
||||
<y>600</y>
|
||||
<width>231</width>
|
||||
<width>191</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -1349,7 +1349,7 @@ p, li { white-space: pre-wrap; }
|
||||
<rect>
|
||||
<x>1020</x>
|
||||
<y>650</y>
|
||||
<width>121</width>
|
||||
<width>131</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -1369,6 +1369,38 @@ p, li { white-space: pre-wrap; }
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="saveConfigButton">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>660</x>
|
||||
<y>600</y>
|
||||
<width>121</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Save these mission options for next time.</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string> Save Config</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>resources/floppy-disk.png</normaloff>resources/floppy-disk.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
@ -1403,9 +1435,16 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
<addaction name="actionSave_Directory"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuTools">
|
||||
<property name="title">
|
||||
<string>Tools</string>
|
||||
</property>
|
||||
<addaction name="actionSave_Mission_Config"/>
|
||||
</widget>
|
||||
<addaction name="menuMap"/>
|
||||
<addaction name="menuFilter"/>
|
||||
<addaction name="menuPreferences"/>
|
||||
<addaction name="menuTools"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar">
|
||||
<property name="font">
|
||||
@ -1633,6 +1672,14 @@ p, li { white-space: pre-wrap; }
|
||||
<string>_rateButton5</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_Mission_Config">
|
||||
<property name="text">
|
||||
<string>Save Mission Config</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save Mission Config</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
@ -1812,6 +1859,22 @@ p, li { white-space: pre-wrap; }
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>saveConfigButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>actionSave_Mission_Config</receiver>
|
||||
<slot>trigger()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>795</x>
|
||||
<y>569</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<buttongroups>
|
||||
<buttongroup name="farp_buttonGroup"/>
|
||||
|
||||
BIN
Generator/resources/floppy-disk.png
Normal file
BIN
Generator/resources/floppy-disk.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
Loading…
x
Reference in New Issue
Block a user