diff --git a/README.md b/README.md index fb248a6..a6d6dc7 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,4 @@ Commands to build project: *** -#### Since the program is in development, I won't give up help and guidance on my errors in the code. +#### If you've found a bug - please open an issue diff --git a/init_config_editor.py b/init_config_editor.py index 880ead2..b954581 100644 --- a/init_config_editor.py +++ b/init_config_editor.py @@ -9,4 +9,4 @@ if __name__ == '__main__': app = QApplication(argv) win = EditorWindow() win.show() - exit(app.exec()) + exit(app.exec_()) diff --git a/init_main_program.py b/init_main_program.py index 136df37..0caa3af 100644 --- a/init_main_program.py +++ b/init_main_program.py @@ -9,4 +9,4 @@ if __name__ == '__main__': app = QApplication(argv) win = MainWindow() win.show() - exit(app.exec()) + exit(app.exec_()) diff --git a/module_main/form.ui b/module_main/form.ui index 989d979..1913e9d 100644 --- a/module_main/form.ui +++ b/module_main/form.ui @@ -8,19 +8,19 @@ 0 0 360 - 350 + 400 360 - 350 + 400 360 - 350 + 400 @@ -38,21 +38,11 @@ 10 50 341 - 81 + 104 - - - - - Times New Roman - 10 - - - - - + @@ -65,7 +55,7 @@ - + @@ -78,7 +68,7 @@ - + @@ -88,7 +78,17 @@ - + + + + + Times New Roman + 10 + + + + + @@ -101,20 +101,7 @@ - - - - - Times New Roman - 14 - - - - Loan limit: - - - - + @@ -124,7 +111,7 @@ - + @@ -137,7 +124,7 @@ - + @@ -150,6 +137,34 @@ + + + + + Times New Roman + 14 + + + + Loan limit: + + + + + + + + 14 + + + + Basic info + + + Qt::AlignCenter + + + @@ -178,7 +193,7 @@ 130 - 310 + 360 111 31 @@ -200,7 +215,7 @@ 80 - 350 + 400 211 21 @@ -222,92 +237,13 @@ 10 - 140 + 160 341 - 161 + 191 - - - - - Times New Roman - 10 - - - - - - - - - Times New Roman - 13 - - - - Urgent delivery: - - - - - - - - Times New Roman - 10 - - - - Don't change - - - - - - - - Times New Roman - 10 - - - - - - - - - Times New Roman - 10 - - - - - - - - Times New Roman - 10 - - - - Don't change - - - - - - - - Times New Roman - 10 - - - - - @@ -320,30 +256,7 @@ - - - - - Times New Roman - 10 - - - - - - - - - Times New Roman - 10 - - - - Don't change - - - - + @@ -356,8 +269,8 @@ - - + + Times New Roman @@ -366,33 +279,30 @@ - - + + Times New Roman - 13 + 10 - High value cargo: + Don't change - - + + Times New Roman - 13 + 10 - - Fragile cargo: - - + @@ -405,7 +315,30 @@ - + + + + + Times New Roman + 13 + + + + High value cargo: + + + + + + + + Times New Roman + 10 + + + + + @@ -418,7 +351,20 @@ - + + + + + Times New Roman + 13 + + + + Fragile cargo: + + + + @@ -431,7 +377,7 @@ - + @@ -444,6 +390,90 @@ + + + + + Times New Roman + 13 + + + + Urgent delivery: + + + + + + + + Times New Roman + 10 + + + + + + + + + Times New Roman + 10 + + + + + + + + + Times New Roman + 10 + + + + Don't change + + + + + + + + Times New Roman + 10 + + + + Don't change + + + + + + + + Times New Roman + 10 + + + + + + + + + 14 + + + + Skills + + + Qt::AlignCenter + + + @@ -453,7 +483,7 @@ 250 - 310 + 360 101 31 @@ -475,7 +505,7 @@ 10 - 310 + 360 111 31 @@ -489,6 +519,19 @@ Unlock garages + + + + 180 + 10 + 181 + 31 + + + + Check updates on startup + + path_button diff --git a/module_main/script.py b/module_main/script.py index ac02a0c..c6128ec 100644 --- a/module_main/script.py +++ b/module_main/script.py @@ -7,13 +7,16 @@ from ctypes import CDLL from PyQt5.QtCore import Qt, QRegExp from PyQt5.QtGui import QRegExpValidator from PyQt5.QtWidgets import QDialog, QFileDialog +from ast import literal_eval from .form import Ui_MainWindow from util import * from dataIO import dataIO from module_second.script import SecondWindow +from module_parsing.script import check_remote_hashes, update_configs +from statics import update_config_name -libdecrypt = CDLL("{}\SII_Decrypt.dll".format(getcwd())) +libdecrypt = CDLL("{}\\SII_Decrypt.dll".format(getcwd())) class MainWindow(QDialog, Ui_MainWindow): @@ -24,6 +27,18 @@ class MainWindow(QDialog, Ui_MainWindow): self.ui = Ui_MainWindow() self.ui.setupUi(self) + update_cfg = {"update_on_start": False} + if isfile(update_config_name): + with open(update_config_name, "r") as f: + update_cfg = literal_eval(f.read()) + + update_bool = update_cfg.get("update_on_start") + if update_bool: + self.ui.updates_checkbox.setChecked(update_bool) + update_list = check_remote_hashes() + if update_list and len(update_list) > 0: + update_configs(update_list) + self.file_path = "" self.old_file = "" @@ -63,6 +78,7 @@ class MainWindow(QDialog, Ui_MainWindow): # Connecting buttons self.ui.path_button.clicked.connect(self.open_file_dialog) + self.ui.updates_checkbox.clicked.connect(self.update_on_startup) self.ui.second_window.clicked.connect(self.open_second_win) self.ui.backup.clicked.connect(self.recover_backup) self.ui.apply.clicked.connect(self.apply_changes) @@ -174,9 +190,13 @@ class MainWindow(QDialog, Ui_MainWindow): else: return + def update_on_startup(self): + with open(update_config_name, "w") as f: + f.write(str({"update_on_start": self.ui.updates_checkbox.isChecked()})) + def open_second_win(self): second_win = SecondWindow(self.selected_game, self.owns, self) - second_win.exec() + second_win.exec_() def recover_backup(self): backup_path = self.file_path + ".swbak" @@ -191,24 +211,25 @@ class MainWindow(QDialog, Ui_MainWindow): self.get_file_data(self.file_path) def apply_changes(self): - if not self.ui.dont_change_all_inf.isChecked(): - for key, value in self.basic_edits.items(): - if value[0].isChecked() is False: - util.set_value(util.search_line(value[1]), key.text()) - value[0].setChecked(True) - if self.ui.adr_dont_change.isChecked() is False: - adr_set = self.get_adr_from_line() - if len(adr_set) < 6: - QMessageBox.critical(self, "Error", "ADR can't have less than 6 elements.") - elif len(adr_set) > 6: - QMessageBox.critical(self, "Error", "ADR can't have more than 6 elements.") - else: - adr_new = int("".join(adr_set), 2) - util.set_value(util.search_line("adr:"), str(adr_new)) - for key, value in self.skill_edits.items(): - if value[0].isChecked() is False: - util.set_value(util.search_line(value[1]), key.text()) - value[0].setChecked(True) + if self.ui.dont_change_all_inf.isChecked(): + return + for key, value in self.basic_edits.items(): + if value[0].isChecked() is False: + util.set_value(util.search_line(value[1]), key.text()) + value[0].setChecked(True) + if self.ui.adr_dont_change.isChecked() is False: + adr_set = self.get_adr_from_line() + if len(adr_set) < 6: + QMessageBox.critical(self, "Error", "ADR can't have less than 6 elements.") + elif len(adr_set) > 6: + QMessageBox.critical(self, "Error", "ADR can't have more than 6 elements.") + else: + adr_new = int("".join(adr_set), 2) + util.set_value(util.search_line("adr:"), str(adr_new)) + for key, value in self.skill_edits.items(): + if value[0].isChecked() is False: + util.set_value(util.search_line(value[1]), key.text()) + value[0].setChecked(True) backup = self.file_path + ".swbak" with open(backup, "w") as f: f.write(self.old_file) diff --git a/module_parsing/script.py b/module_parsing/script.py index d4a893b..2779772 100644 --- a/module_parsing/script.py +++ b/module_parsing/script.py @@ -48,19 +48,14 @@ def check_remote_hashes(): return False -def update_configs(cfg_list, ans_upd=0): +def update_configs(cfg_list): """ :param cfg_list: config list to update - :param ans_upd: ask user to update configs, update or not, remember answer or not """ - if ans_upd in (0, 1): - for cfg in cfg_list: - check_path(cfg) - response_status, response = get_response_result(github_link + cfg) - if response_status: - remote_cfg = literal_eval(response.text) - if dataIO.is_valid_json(cfg) or os.path.exists(cfg): - dataIO.save_json(cfg, remote_cfg) - if ans_upd in (1, 3): - with open(update_config_name, "w") as f: - f.write(str({"answer_updates": ans_upd == 3, "update_on_start": ans_upd == 1})) + for cfg in cfg_list: + check_path(cfg) + response_status, response = get_response_result(github_link + cfg) + if response_status: + remote_cfg = literal_eval(response.text) + if dataIO.is_valid_json(cfg) or os.path.exists(cfg): + dataIO.save_json(cfg, remote_cfg) diff --git a/requirements.txt b/requirements.txt index 047a51e..2ebff10 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,10 @@ altgraph==0.17.4 certifi==2023.11.17 charset-normalizer==3.3.2 -cx-Freeze==6.15.12 +cx-Freeze==7.0.0 cx-Logging==3.1.0 idna==3.6 -lief==0.13.2 +lief==0.14.0 packaging==23.2 pefile==2023.2.7 pyinstaller==6.3.0 diff --git a/setup.py b/setup.py index 2460d09..ad4f3cb 100644 --- a/setup.py +++ b/setup.py @@ -13,8 +13,8 @@ executables = [ Executable('init_config_editor.py', target_name='SaveWizard_Config_Editor.exe', base=base) ] -excludes = ['html', 'pydoc_data', 'unittest', 'xml', 'pwd', 'shlex', 'platform', 'webbrowser', 'pydoc', 'tty', - 'inspect', 'doctest', 'plistlib', 'subprocess', 'bz2', '_strptime', 'dummy_threading'] +excludes = ['html', 'pydoc_data', 'unittest', 'xml', 'pwd', 'shlex', 'platform', 'webbrowser', 'pydoc', + 'tty', 'doctest', 'plistlib', 'subprocess', 'bz2', '_strptime', 'dummy_threading'] includes = ['pkgutil', 'enum', 'queue'] @@ -25,7 +25,7 @@ zip_include_packages = [ # PyQt5 'PyQt5', # Modules for parsing cfg's - 'requests', 'logging', 'certifi', 'chardet', 'idna', 'urllib3', + 'requests', 'logging', 'certifi', 'chardet', 'idna', 'urllib3', 'inspect', # Self-written modules 'module_parsing', 'module_main', 'module_second', 'module_config_editor' ] @@ -49,7 +49,7 @@ options = { setup( name='SaveWizard', - version='1.4', + version='1.4.1', description='For editing ETS2 sii files', executables=executables, options=options,