diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ff3eb5b --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +## Ignoring PyCharm settings +/.idea + +## Ignoring Python complied files +/__pycache__ +/main/__pycache__ +/second/__pycache__ +/main/form.py +/second/form.py + +## Ignoring build from cx_Freeze +/stable_build + +## Ignoring build files from PyInstaller +/build +/dist diff --git a/__init__.py b/__init__.py index cf8ba66..fb967b8 100644 --- a/__init__.py +++ b/__init__.py @@ -1,11 +1,12 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- +from sys import argv, exit +from PyQt5.QtWidgets import QApplication +from main.script import MainWindow + if __name__ == '__main__': - from sys import argv, exit - from PyQt5.QtWidgets import QApplication - from main.script import MainWindow app = QApplication(argv) win = MainWindow() win.show() - exit(app.exec_()) + exit(app.exec()) diff --git a/build.spec b/build.spec new file mode 100644 index 0000000..876b2fe --- /dev/null +++ b/build.spec @@ -0,0 +1,35 @@ +# -*- mode: python ; coding: utf-8 -*- + +block_cipher = None + +a = Analysis(['__init__.py'], + pathex=['.'], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False) +pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) +exe = EXE(pyz, + a.scripts, + [], + exclude_binaries=True, + name='SaveWizard', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + console=False ) +coll = COLLECT(exe, + a.binaries, + a.zipfiles, + a.datas, + strip=False, + upx=True, + upx_exclude=[], + name='build') diff --git a/compile_cx-freeze.bat b/compile_cx-freeze.bat new file mode 100644 index 0000000..32dfd93 --- /dev/null +++ b/compile_cx-freeze.bat @@ -0,0 +1 @@ +pythonqt setup.py build diff --git a/compile_pyinstaller.bat b/compile_pyinstaller.bat new file mode 100644 index 0000000..c3d2dfc --- /dev/null +++ b/compile_pyinstaller.bat @@ -0,0 +1 @@ +pyinstaller build.spec diff --git a/compile_python_code.bat b/compile_python_code.bat deleted file mode 100644 index 7d7d354..0000000 --- a/compile_python_code.bat +++ /dev/null @@ -1 +0,0 @@ -python setup.py build \ No newline at end of file diff --git a/main/__init__.py b/main/__init__.py index 43d4a57..a015801 100644 --- a/main/__init__.py +++ b/main/__init__.py @@ -1,2 +1 @@ # initialize module 'main' for compile program -import main.script diff --git a/main/form.ui b/main/form.ui index 8e2434e..7770540 100644 --- a/main/form.ui +++ b/main/form.ui @@ -95,18 +95,31 @@ - 14 + 10 50 - 331 + 341 81 - + + + + Times New Roman + 10 + + + + + + Times New Roman + 10 + + Don't change @@ -126,10 +139,23 @@ - + + + + Times New Roman + 10 + + + + + + Times New Roman + 10 + + Don't change @@ -149,10 +175,23 @@ - + + + + Times New Roman + 10 + + + + + + Times New Roman + 10 + + Don't change @@ -176,15 +215,22 @@ - 14 - 138 - 331 + 10 + 140 + 341 161 - + + + + Times New Roman + 10 + + + @@ -201,39 +247,91 @@ + + + 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 + + + + + + Times New Roman + 10 + + Don't change - + + + + Times New Roman + 10 + + + + + + Times New Roman + 10 + + Don't change @@ -241,13 +339,26 @@ + + + Times New Roman + 10 + + Don't change - + + + + Times New Roman + 10 + + + @@ -290,6 +401,12 @@ + + + Times New Roman + 10 + + Don't change @@ -342,12 +459,18 @@ - 90 + 80 300 - 181 + 211 31 + + + Times New Roman + 10 + + Don't save all changes in this form diff --git a/main/script.py b/main/script.py index 1c21af4..089bb4f 100644 --- a/main/script.py +++ b/main/script.py @@ -1,15 +1,20 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -from PyQt5.QtWidgets import QMainWindow +from os import system, remove +from PyQt5.QtCore import Qt, QRegExp +from PyQt5.QtGui import QRegExpValidator +from PyQt5.QtWidgets import QMainWindow, QFileDialog + from .form import Ui_MainWindow from util import * from dataIO import dataIO +from second.script import SecondWindow class MainWindow(QMainWindow, Ui_MainWindow): def __init__(self, parent=None): - from PyQt5.QtCore import Qt + # Setup UI QMainWindow.__init__(self, parent, flags=Qt.Window) Ui_MainWindow.__init__(self) self.ui = Ui_MainWindow() @@ -18,13 +23,15 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.file_path = "" self.old_file = "" + # Checking DLC file if dataIO.is_valid_json("dlc.json") is False: self.owns = False - show_message("Error", "'dlc.json' not found, functionality has been limited") + show_message(QMessageBox.Warning, "Warning", "'dlc.json' not found, functionality has been limited") else: self.owns = {} self.dlc = dataIO.load_json("dlc.json") + # Storing edits with his checkboxes and file-lines self.basic_edits = { self.ui.money_edit: [self.ui.money_dont_change, "money_account:"], self.ui.xp_edit: [self.ui.xp_dont_change, "experience_points:"], @@ -38,9 +45,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.ui.ecodriving_edit: [self.ui.ecodriving_dont_change, "mechanical:"], } - from PyQt5.QtCore import QRegExp - from PyQt5.QtGui import QRegExpValidator - + # Setting up validators for edits basic_validator = QRegExpValidator(QRegExp("[0-9]{1,9}")) for key in self.basic_edits.keys(): key.setValidator(basic_validator) @@ -52,6 +57,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): key.setValidator(skills_validator) key.textEdited.connect(self.text_edited) + # Connecting buttons self.ui.path_button.clicked.connect(self.open_file_dialog) self.ui.apply.clicked.connect(self.apply_changes) self.ui.backup.clicked.connect(self.recover_backup) @@ -85,7 +91,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): def clear_fields(self): self.file_path = "" self.old_file = "" - set_lines("") + set_lines([]) if self.owns is not False: self.owns = {} @@ -110,13 +116,12 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.old_file = f.read() except UnicodeDecodeError: try: - from os import system system("SII_Decrypt.exe --on_file -i \"{}\"".format(file)) with open(file, "r") as f: self.old_file = f.read() - show_message("Success", "File successfully decrypted.") + show_message(QMessageBox.Information, "Success", "File successfully decrypted.") except UnicodeDecodeError: - show_message("Error", "Error to decrypt and open file. Try again.") + show_message(QMessageBox.Critical, "Error", "Error to decrypt and open file. Try again.") return set_lines(self.old_file.split("\n")) @@ -144,7 +149,6 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.ui.second_window.setEnabled(True) def open_file_dialog(self): - from PyQt5.QtWidgets import QFileDialog file, _ = QFileDialog.getOpenFileName(parent=self, caption=self.tr("Choose your save file..."), filter=self.tr("game.sii")) @@ -164,9 +168,9 @@ class MainWindow(QMainWindow, Ui_MainWindow): if self.ui.adr_dont_change.isChecked() is False: adr_set = self.get_adr_from_line() if len(adr_set) < 6: - show_message("Error", "ADR can't have less than 6 elements.") + show_message(QMessageBox.Critical, "Error", "ADR can't have less than 6 elements.") elif len(adr_set) > 6: - show_message("Error", "ADR can't have more than 6 elements.") + show_message(QMessageBox.Critical, "Error", "ADR can't have more than 6 elements.") else: adr_new = int("".join(adr_set), 2) set_value(search_line("adr:"), str(adr_new)) @@ -179,7 +183,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): f.write(self.old_file) with open(self.file_path, "w") as f: f.write("\n".join(get_lines())) - show_message("Success", "Changes successfully applied!") + show_message(QMessageBox.Information, "Success", "Changes successfully applied!") self.get_file_data(self.file_path) return @@ -190,15 +194,13 @@ class MainWindow(QMainWindow, Ui_MainWindow): with open(self.file_path, "w") as g: g.write(f.read()) f.close() - from os import remove remove(backup) - show_message("Success", "Backup successfully recovered.") + show_message(QMessageBox.Information, "Success", "Backup successfully recovered.") self.get_file_data(self.file_path) except IOError: - show_message("Error", "Backup not found.") + show_message(QMessageBox.Critical, "Error", "Backup not found.") return def open_second_win(self): - from second.script import SecondWindow second_win = SecondWindow(self.owns, self) second_win.show() diff --git a/second/__init__.py b/second/__init__.py index bbb504c..280c358 100644 --- a/second/__init__.py +++ b/second/__init__.py @@ -1,2 +1 @@ # initialize module 'second' for compile program -from second import script diff --git a/second/form.ui b/second/form.ui index 9471c99..ff3eb24 100644 --- a/second/form.ui +++ b/second/form.ui @@ -43,6 +43,12 @@ + + + Times New Roman + 11 + + false @@ -65,6 +71,9 @@ Owned garages: + + Qt::PlainText + Qt::AlignCenter @@ -113,6 +122,12 @@ + + + Times New Roman + 11 + + false @@ -154,6 +169,12 @@ + + + Times New Roman + 11 + + false @@ -195,6 +216,12 @@ + + + Times New Roman + 11 + + false @@ -240,7 +267,7 @@ 150 10 171 - 133 + 135 @@ -258,7 +285,14 @@ - + + + + Times New Roman + 10 + + + @@ -290,7 +324,14 @@ - + + + + Times New Roman + 10 + + + @@ -300,7 +341,7 @@ 480 60 171 - 107 + 110 @@ -318,7 +359,14 @@ - + + + + Times New Roman + 10 + + + @@ -357,7 +405,7 @@ 150 290 171 - 107 + 108 @@ -375,7 +423,14 @@ - + + + + Times New Roman + 10 + + + @@ -414,7 +469,7 @@ 480 290 171 - 107 + 108 @@ -461,7 +516,14 @@ - + + + + Times New Roman + 10 + + + @@ -492,7 +554,14 @@ - + + + + Times New Roman + 10 + + + diff --git a/second/script.py b/second/script.py index 66d6fae..eba73d9 100644 --- a/second/script.py +++ b/second/script.py @@ -1,7 +1,9 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- +from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QDialog + from .form import Ui_SecondWindow from util import * from dataIO import dataIO @@ -9,7 +11,7 @@ from dataIO import dataIO class SecondWindow(QDialog, Ui_SecondWindow): def __init__(self, owns_list, parent=None): - from PyQt5.QtCore import Qt + # Setup UI QDialog.__init__(self, parent, flags=Qt.Window) Ui_SecondWindow.__init__(self) self.ui = Ui_SecondWindow() @@ -17,12 +19,13 @@ class SecondWindow(QDialog, Ui_SecondWindow): self.owns = owns_list # From main window + # Checking files if dataIO.is_valid_json("dealers.json") is False: self.dealers = False self.ui.dealer_edit.setEnabled(False) self.ui.dealer_add.setEnabled(False) self.ui.dealer_add_all.setEnabled(False) - show_message("Error", "'dealers.json' not found, dealers editing has been disabled") + show_message(QMessageBox.Warning, "Warning", "'dealers.json' not found, dealers editing has been disabled") else: self.dealers = [] self.dealers_file = dataIO.load_json("dealers.json") @@ -32,7 +35,8 @@ class SecondWindow(QDialog, Ui_SecondWindow): self.ui.agency_edit.setEnabled(False) self.ui.agency_add.setEnabled(False) self.ui.agency_add_all.setEnabled(False) - show_message("Error", "'agencies.json' not found, agencies editing has been disabled") + show_message(QMessageBox.Warning, "Warning", "'agencies.json' not found, agencies editing has been" + "disabled") else: self.agencies = [] self.agencies_file = dataIO.load_json("agencies.json") @@ -41,6 +45,7 @@ class SecondWindow(QDialog, Ui_SecondWindow): self.ui.garage_size.addItem("Medium") self.ui.garage_size.addItem("Big") + # Connecting buttons self.ui.garages_analyze.clicked.connect(self.check_garages) self.ui.garage_add.clicked.connect(self.add_garage) self.ui.garage_add_all.clicked.connect(self.add_all_garages) @@ -52,6 +57,7 @@ class SecondWindow(QDialog, Ui_SecondWindow): self.ui.agency_add.clicked.connect(self.add_agency) self.ui.agency_add_all.clicked.connect(self.add_all_agencies) + # Checking save-file self.initialize_arrays() self.check_cities() self.check_dealers() @@ -60,31 +66,19 @@ class SecondWindow(QDialog, Ui_SecondWindow): @staticmethod def purchased_garages(): garages = [] - i = 0 - try: - local_lines = get_lines() - while True: - while "garage : " not in local_lines[i]: - i += 1 - city = match(r"garage : garage.(.+) {$", local_lines[i]).group(1) - while "status:" not in local_lines[i]: - i += 1 - if "0" not in local_lines[i]: - garages.append(city) - except: - pass + for index in search_all_lines("garage : garage."): + city = match(r"garage : garage.(.+) {$", get_lines(index)).group(1) + if get_value(search_line("status:", start=index)) != "0": + garages.append(city) return garages @staticmethod - def cities(): + def all_cities(): cities = [] - line = search_line(r"companies\[") - local_lines = get_lines() - while "companies[" in local_lines[line]: - city = match(r" companies\[[0-9]+\]: company.volatile.[a-z0-9_]+[.]([a-z_]+)", local_lines[line]).group(1) + for line in get_array_items(search_line("companies:")): + city = match(r"company.volatile.[a-z0-9_]+[.]([a-z_]+)", line).group(1) if city not in cities: cities.append(city) - line += 1 return cities def initialize_arrays(self): @@ -100,156 +94,169 @@ class SecondWindow(QDialog, Ui_SecondWindow): def check_garage_size(self): text = self.ui.garage_size.currentText() - garage_size = 0 - garage_status = 0 + status = 0 + size = 0 if text == "Small": - garage_size = 1 - garage_status = 1 + status = 1 + size = 1 elif text == "Medium": - garage_size = 3 - garage_status = 2 + status = 2 + size = 3 elif text == "Big": - garage_size = 5 - garage_status = 3 - return garage_size, str(garage_status) + status = 3 + size = 5 + return str(status), size def check_garages(self): self.ui.garages_text.clear() for garage in self.purchased_garages(): self.ui.garages_text.append(garage) - hq = get_value(search_line("hq_city:")) - self.ui.headquarter_edit.setText(hq) def add_garage(self): garage = self.ui.garage_edit.text().lower() if garage is "": - show_message("Error", "Enter a name for the city.") + show_message(QMessageBox.Critical, "Error", "Enter a name for the city.") return - garage_size, garage_status = self.check_garage_size() self.ui.garage_edit.setText("") - if get_value(search_line_in_unit("status:", "garage." + garage)) != "0": - show_message("Error", "Garage in \"{}\" already unlocked.".format(garage)) + reg_garage = "garage." + garage + current_status = search_line_in_unit("status:", reg_garage) + if get_value(current_status) == "0": + new_status, size = self.check_garage_size() + set_value(current_status, new_status) + vehicles_array = search_line_in_unit("vehicles:", reg_garage) + drivers_array = search_line_in_unit("drivers:", reg_garage) + for i in range(1, size+1): + add_array_value(vehicles_array, "null") + add_array_value(drivers_array+i, "null") + show_message(QMessageBox.Information, "Success", "Garage in \"{}\" successfully unlocked.".format(garage)) else: - set_value(search_line_in_unit("status:", "garage." + garage), garage_status) - for i in range(garage_size): - add_array_value(search_line_in_unit("vehicles:", "garage." + garage), "null") - add_array_value(search_line_in_unit("drivers:", "garage." + garage), "null") - show_message("Success", "Garage in \"{}\" successfully unlocked.".format(garage)) - self.check_garages() + show_message(QMessageBox.Warning, "Warning", "Garage in \"{}\" already unlocked.".format(garage)) def add_all_garages(self): - garage_size, garage_status = self.check_garage_size() - line = 0 - try: - while True: - line = search_line("garage : garage.", start=line) - if get_value(search_line_in_unit("status:", get_unit_name(line))) == "0": - set_value(search_line_in_unit("status:", get_unit_name(line)), garage_status) - for i in range(garage_size): - add_array_value(search_line_in_unit("vehicles:", get_unit_name(line)), "null") - add_array_value(search_line_in_unit("drivers:", get_unit_name(line)), "null") - line += 1 - except: - pass - show_message("Success", "All garages successfully unlocked.") - self.check_garages() + new_status, size = self.check_garage_size() + for item in get_array_items(search_line("garages:")): + item = match(r"garage.(.+)$", item).group(1) + current_garage = search_line("garage : garage."+item+" {") + current_status = search_line("status:", start=current_garage) + if get_value(current_status) == "0": + set_value(current_status, new_status) + vehicles_array = search_line("vehicles:", start=current_garage) + drivers_array = search_line("drivers:", start=current_garage) + for i in range(1, size+1): + add_array_value(vehicles_array, "null") + add_array_value(drivers_array+i, "null") + show_message(QMessageBox.Information, "Success", "All garages successfully unlocked.") def change_headquarter(self): hq = self.ui.headquarter_edit.text().lower() if hq is "": - show_message("Error", "Enter a name for the city.") + show_message(QMessageBox.Critical, "Error", "Enter a name for the city.") return if get_value(search_line("hq_city:")) == hq: - show_message("Error", "Your headquarter is already in this city") + show_message(QMessageBox.Critical, "Error", "Your headquarter is already in this city") elif hq not in self.purchased_garages(): - show_message("Error", "You need to own the garage in this city.") + show_message(QMessageBox.Critical, "Error", "You need to own the garage in this city.") else: set_value(search_line("hq_city:"), hq) - show_message("Success", "Headquarter successfully set to \"{}\".".format(hq)) + show_message(QMessageBox.Information, "Success", "Headquarter successfully set to \"{}\".".format(hq)) def check_cities(self): + self.ui.headquarter_edit.setText(get_value(search_line("hq_city:"))) self.ui.cities_text.clear() - for city in get_array_items(search_line("visited_cities:")): - self.ui.cities_text.append(city) - if not get_array_items(search_line("visited_cities:")): + visited_cities = get_array_items(search_line("visited_cities:")) + if not visited_cities: self.ui.cities_text.append("No cities visited yet.") + return + for city in visited_cities: + self.ui.cities_text.append(city) def add_city(self): city = self.ui.city_edit.text().lower() if city is "": - show_message("Error", "Enter a name for the city.") + show_message(QMessageBox.Critical, "Error", "Enter a name for the city.") return self.ui.city_edit.setText("") if city not in get_array_items(search_line("visited_cities:")): add_array_value(search_line("visited_cities:"), city) add_array_value(search_line("visited_cities_count:"), "1") - show_message("Success", "City \"{}\" successfully visited.".format(city)) + show_message(QMessageBox.Warning, "Success", "City \"{}\" successfully visited.".format(city)) self.check_cities() else: - show_message("Error", "You already visited \"{}\".".format(city)) + show_message(QMessageBox.Critical, "Error", "You already visited \"{}\".".format(city)) def add_all_cities(self): - for city in self.cities(): - if city not in get_array_items(search_line("visited_cities:")): + visited_cities = get_array_items(search_line("visited_cities:")) + for city in self.all_cities(): + if city not in visited_cities: add_array_value(search_line("visited_cities:"), city) add_array_value(search_line("visited_cities_count:"), "1") - show_message("Success", "All cities successfully visited.") + show_message(QMessageBox.Information, "Success", "All cities successfully visited.") self.check_cities() def check_dealers(self): self.ui.dealerships_text.clear() - for dealer in get_array_items(search_line("unlocked_dealers:")): - self.ui.dealerships_text.append(dealer) - if not get_array_items(search_line("unlocked_dealers:")): + visited_dealers = get_array_items(search_line("unlocked_dealers:")) + if not visited_dealers: self.ui.dealerships_text.append("No dealerships unlocked yet.") + return + for dealer in visited_dealers: + self.ui.dealerships_text.append(dealer) def add_dealer(self): dealer = self.ui.dealer_edit.text().lower() if dealer is "": - show_message("Error", "Enter a name for the city.") + show_message(QMessageBox.Critical, "Error", "Enter a name for the city.") return self.ui.dealer_edit.setText("") if dealer not in self.dealers: - show_message("Error", "There is no dealership in that city.") + show_message(QMessageBox.Critical, "Error", "There is no dealership in that city.") elif dealer in get_array_items(search_line("unlocked_dealers:")): - show_message("Error", "This dealership already unlocked.") + show_message(QMessageBox.Critical, "Error", "This dealership already unlocked.") else: add_array_value(search_line("unlocked_dealers:"), dealer) - show_message("Success", "Dealership in \"{}\" successfully unlocked.".format(dealer)) + show_message(QMessageBox.Information, "Success", "Dealership in \"{}\" successfully unlocked." + "".format(dealer)) self.check_dealers() def add_all_dealers(self): + all_cities = self.all_cities() + visited_dealers = get_array_items(search_line("unlocked_dealers:")) for dealer in self.dealers: - if dealer in self.cities() and dealer not in get_array_items(search_line("unlocked_dealers:")): + if dealer in all_cities and dealer not in visited_dealers: add_array_value(search_line("unlocked_dealers:"), dealer) - show_message("Success", "All dealerships unlocked.") + show_message(QMessageBox.Information, "Success", "All dealerships unlocked.") self.check_dealers() def check_agencies(self): self.ui.agencies_text.clear() - for agency in get_array_items(search_line("unlocked_recruitments:")): - self.ui.agencies_text.append(agency) - if not get_array_items(search_line("unlocked_recruitments:")): + visited_agencies = get_array_items(search_line("unlocked_recruitments:")) + if not visited_agencies: self.ui.agencies_text.append("No recruitment agencies unlocked yet.") + return + for agency in visited_agencies: + self.ui.agencies_text.append(agency) def add_agency(self): agency = self.ui.agency_edit.text().lower() if agency is "": - show_message("Error", "Enter a name for the city.") + show_message(QMessageBox.Critical, "Error", "Enter a name for the city.") return self.ui.agency_edit.setText("") if agency not in self.agencies: - show_message("Error", "There is no recruitment agency in that city.") + show_message(QMessageBox.Critical, "Error", "There is no recruitment agency in that city.") elif agency in get_array_items(search_line("unlocked_recruitments:")): - show_message("Error", "Recruitment agency is already unlocked.") + show_message(QMessageBox.Critical, "Error", "Recruitment agency is already unlocked.") else: add_array_value(search_line("unlocked_recruitments:"), agency) - show_message("Success", "Recruitment agency in \"{}\" successfully unlocked.".format(agency)) + show_message(QMessageBox.Information, "Success", "Recruitment agency in \"{}\" successfully unlocked." + "".format(agency)) self.check_agencies() def add_all_agencies(self): + all_cities = self.all_cities() + visited_agencies = get_array_items(search_line("unlocked_recruitments:")) for agency in self.agencies: - if agency in self.cities() and agency not in get_array_items(search_line("unlocked_recruitments:")): + if agency in all_cities and agency not in visited_agencies: add_array_value(search_line("unlocked_recruitments:"), agency) - show_message("Success", "All recruitment agencies unlocked.") + show_message(QMessageBox.Information, "Success", "All recruitment agencies unlocked.") self.check_agencies() diff --git a/setup.py b/setup.py index 3c677a0..05a0b6c 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ excludes = ['email', 'html', 'http', 'logging', 'pydoc_data', 'unittest', 'urlli 'doctest', 'plistlib', 'calendar', 'subprocess', 'copy', 'bz2', 'stringprep', 'posixpath', '_strptime', 'dummy_threading'] zip_include_packages = ['collections', 'encodings', 'importlib', 'json', 'hashlib', 'PyQt5', 'sip', 'main', 'second'] -include_files = ['SII_Decrypt.exe', 'dlc.json', 'dealers.json', 'agencies.json'] +include_files = ['SII_Decrypt.exe', 'ats_configs', 'ets2_configs'] options = { 'build_exe': { 'excludes': excludes, diff --git a/util.py b/util.py index e64450f..01304c7 100644 --- a/util.py +++ b/util.py @@ -1,28 +1,31 @@ #!/usr/bin/python3 # -*- coding: utf-8 -*- -from PyQt5.QtWidgets import QMessageBox from re import search, match, sub -lines = '' +from PyQt5.QtWidgets import QMessageBox + +lines = [] -def set_lines(from_other): +# Custom functions +def set_lines(new_lines): global lines - lines = from_other + lines = new_lines -def get_lines(): +def get_lines(index=None): global lines + if index is not None: + return lines[index] return lines -def show_message(title, text): - box = QMessageBox() - box.setWindowTitle(title) - box.setText(text) - box.exec_() +def show_message(icon, title, text): + box = QMessageBox(icon, title, text, QMessageBox.Ok) + box.exec() +# Stock functions def search_line(term, start=0, cancel=r"this_string_must_not_exist"): global lines if search(term, lines[start]): @@ -46,10 +49,10 @@ def search_line_in_unit(term, unit): def search_all_lines(term): global lines matches = [] - start = 0 - while search_line(term, start=start + 1): - start = search_line(term, start=start + 1) - matches.append(start) + line = 0 + while search_line(term, start=line + 1): + line = search_line(term, start=line + 1) + matches.append(line) if matches is None: return None return matches