Automatically check configurations instead of user selection

Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
2023-10-23 14:56:29 +07:00
parent e7e4939882
commit a2d4f84877
3 changed files with 32 additions and 65 deletions

View File

@@ -3,10 +3,10 @@
from sys import argv, exit from sys import argv, exit
from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QApplication
from module_choice.script import ChoiceWindow from module_main.script import MainWindow
if __name__ == '__main__': if __name__ == '__main__':
app = QApplication(argv) app = QApplication(argv)
win = ChoiceWindow() win = MainWindow()
win.show() win.show()
exit(app.exec()) exit(app.exec())

View File

@@ -177,16 +177,16 @@
</property> </property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>130</x>
<y>310</y> <y>310</y>
<width>141</width> <width>111</width>
<height>31</height> <height>31</height>
</rect> </rect>
</property> </property>
<property name="font"> <property name="font">
<font> <font>
<family>Times New Roman</family> <family>Times New Roman</family>
<pointsize>12</pointsize> <pointsize>11</pointsize>
</font> </font>
</property> </property>
<property name="text"> <property name="text">
@@ -194,12 +194,15 @@
</property> </property>
</widget> </widget>
<widget class="QCheckBox" name="dont_change_all_inf"> <widget class="QCheckBox" name="dont_change_all_inf">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>80</x> <x>80</x>
<y>350</y> <y>350</y>
<width>211</width> <width>211</width>
<height>31</height> <height>21</height>
</rect> </rect>
</property> </property>
<property name="font"> <property name="font">
@@ -211,6 +214,9 @@
<property name="text"> <property name="text">
<string>Don't save all changes in this form</string> <string>Don't save all changes in this form</string>
</property> </property>
<property name="checkable">
<bool>false</bool>
</property>
</widget> </widget>
<widget class="QWidget" name="gridLayoutWidget_3"> <widget class="QWidget" name="gridLayoutWidget_3">
<property name="geometry"> <property name="geometry">
@@ -446,16 +452,16 @@
</property> </property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>210</x> <x>250</x>
<y>310</y> <y>310</y>
<width>141</width> <width>101</width>
<height>31</height> <height>31</height>
</rect> </rect>
</property> </property>
<property name="font"> <property name="font">
<font> <font>
<family>Times New Roman</family> <family>Times New Roman</family>
<pointsize>12</pointsize> <pointsize>11</pointsize>
</font> </font>
</property> </property>
<property name="text"> <property name="text">
@@ -468,49 +474,24 @@
</property> </property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>160</x> <x>10</x>
<y>320</y> <y>310</y>
<width>41</width> <width>111</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
<widget class="QLabel" name="chosen_cfgs">
<property name="geometry">
<rect>
<x>210</x>
<y>10</y>
<width>141</width>
<height>31</height> <height>31</height>
</rect> </rect>
</property> </property>
<property name="text"> <property name="font">
<string>Chosen configs:</string> <font>
</property> <pointsize>11</pointsize>
<property name="alignment"> </font>
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QPushButton" name="cfg_button">
<property name="geometry">
<rect>
<x>180</x>
<y>20</y>
<width>21</width>
<height>21</height>
</rect>
</property> </property>
<property name="text"> <property name="text">
<string>...</string> <string>Unlock garages</string>
</property> </property>
</widget> </widget>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>path_button</tabstop> <tabstop>path_button</tabstop>
<tabstop>cfg_button</tabstop>
<tabstop>money_edit</tabstop> <tabstop>money_edit</tabstop>
<tabstop>money_dont_change</tabstop> <tabstop>money_dont_change</tabstop>
<tabstop>xp_edit</tabstop> <tabstop>xp_edit</tabstop>
@@ -529,8 +510,8 @@
<tabstop>urgent_delivery_dont_change</tabstop> <tabstop>urgent_delivery_dont_change</tabstop>
<tabstop>ecodriving_edit</tabstop> <tabstop>ecodriving_edit</tabstop>
<tabstop>ecodriving_dont_change</tabstop> <tabstop>ecodriving_dont_change</tabstop>
<tabstop>backup</tabstop>
<tabstop>second_window</tabstop> <tabstop>second_window</tabstop>
<tabstop>backup</tabstop>
<tabstop>apply</tabstop> <tabstop>apply</tabstop>
<tabstop>dont_change_all_inf</tabstop> <tabstop>dont_change_all_inf</tabstop>
</tabstops> </tabstops>

View File

@@ -14,7 +14,7 @@ from module_second.script import SecondWindow
class MainWindow(QDialog, Ui_MainWindow): class MainWindow(QDialog, Ui_MainWindow):
def __init__(self, selected_game, parent=None): def __init__(self, parent=None):
# Setup UI # Setup UI
QDialog.__init__(self, parent, flags=Qt.Window) QDialog.__init__(self, parent, flags=Qt.Window)
Ui_MainWindow.__init__(self) Ui_MainWindow.__init__(self)
@@ -24,14 +24,10 @@ class MainWindow(QDialog, Ui_MainWindow):
self.file_path = "" self.file_path = ""
self.old_file = "" self.old_file = ""
self.selected_game = selected_game self.selected_game = ""
self.owns = {} self.owns = {}
self.dlc = {} self.dlc = {}
# Editing label to show what configs chosen
self.chosen_cfg_text = self.ui.chosen_cfgs.text()
self.ui.chosen_cfgs.setText("{} {}".format(self.chosen_cfg_text, selected_game.upper()))
# Storing edits with his checkboxes and file-lines # Storing edits with his checkboxes and file-lines
self.basic_edits = { self.basic_edits = {
self.ui.money_edit: [self.ui.money_dont_change, "money_account:"], self.ui.money_edit: [self.ui.money_dont_change, "money_account:"],
@@ -64,12 +60,10 @@ class MainWindow(QDialog, Ui_MainWindow):
# Connecting buttons # Connecting buttons
self.ui.path_button.clicked.connect(self.open_file_dialog) self.ui.path_button.clicked.connect(self.open_file_dialog)
self.ui.cfg_button.clicked.connect(self.change_configs)
self.ui.backup.clicked.connect(self.recover_backup) self.ui.backup.clicked.connect(self.recover_backup)
self.ui.second_window.clicked.connect(self.open_second_win) self.ui.second_window.clicked.connect(self.open_second_win)
self.ui.apply.clicked.connect(self.apply_changes) self.ui.apply.clicked.connect(self.apply_changes)
self.check_config()
self.clear_form_data() self.clear_form_data()
def text_edited(self): def text_edited(self):
@@ -112,9 +106,6 @@ class MainWindow(QDialog, Ui_MainWindow):
self.old_file = "" self.old_file = ""
util.set_lines([]) util.set_lines([])
if self.owns is not False:
self.owns = {}
for key, value in self.basic_edits.items(): for key, value in self.basic_edits.items():
key.setText("") key.setText("")
value[0].setChecked(True) value[0].setChecked(True)
@@ -141,6 +132,12 @@ class MainWindow(QDialog, Ui_MainWindow):
self.old_file = f.read() self.old_file = f.read()
util.set_lines(self.old_file.split("\n")) util.set_lines(self.old_file.split("\n"))
if util.search_line("company.volatile.eurogoodies.magdeburg"):
self.selected_game = "ets2"
else:
self.selected_game = "ats"
self.check_config()
if self.owns is not False: if self.owns is not False:
self.owns["base"] = True self.owns["base"] = True
companies = util.get_array_items(util.search_line("companies:")) companies = util.get_array_items(util.search_line("companies:"))
@@ -175,17 +172,6 @@ class MainWindow(QDialog, Ui_MainWindow):
else: else:
return return
def change_configs(self):
box = QMessageBox(QMessageBox.Warning, "Warning", "Do you really want to load other configs?\n"
"Your current changes won't be saved.")
box.addButton("Yes", QMessageBox.YesRole)
box.addButton("No", QMessageBox.NoRole)
if box.exec() == 0:
self.clear_form_data()
self.selected_game = "ets2" if self.selected_game == "ats" else "ats"
self.ui.chosen_cfgs.setText("{} {}".format(self.chosen_cfg_text, self.selected_game.upper()))
self.check_config()
def recover_backup(self): def recover_backup(self):
backup_path = self.file_path + ".swbak" backup_path = self.file_path + ".swbak"
if not isfile(backup_path): if not isfile(backup_path):