mirror of
https://github.com/JDM170/SaveWizard
synced 2025-04-20 22:30:42 +07:00
Update
* Improved game checking mechanism * Some code refactor * Updated .gitignore Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -14,7 +14,7 @@
|
||||
/upx
|
||||
|
||||
## Ignore build from cx_Freeze
|
||||
/prog_build
|
||||
/app_build
|
||||
|
||||
## Ignore build files from PyInstaller
|
||||
/build
|
||||
|
||||
@@ -109,6 +109,9 @@ class MainWindow(QDialog, Ui_MainWindow):
|
||||
return adr_list
|
||||
|
||||
def check_config(self):
|
||||
if self.selected_game is None:
|
||||
self.owns = False
|
||||
return
|
||||
cfg_path = "configs/{}/dlc.json".format(self.selected_game)
|
||||
if dataIO.is_valid_json(cfg_path) is False:
|
||||
self.owns = False
|
||||
@@ -152,10 +155,12 @@ class MainWindow(QDialog, Ui_MainWindow):
|
||||
self.old_file = f.read()
|
||||
util.set_lines(self.old_file.split("\n"))
|
||||
|
||||
if util.search_line("company.volatile.eurogoodies.magdeburg"):
|
||||
if util.search_line("company.volatile.eurogoodies.dortmund"):
|
||||
self.selected_game = "ets2"
|
||||
else:
|
||||
elif util.search_line("company.volatile.ed_mkt.elko"):
|
||||
self.selected_game = "ats"
|
||||
else:
|
||||
self.selected_game = None
|
||||
self.check_config()
|
||||
|
||||
if self.owns is not False:
|
||||
@@ -186,11 +191,10 @@ class MainWindow(QDialog, Ui_MainWindow):
|
||||
caption=self.tr("Choose your save file..."),
|
||||
filter=self.tr("game.sii"))
|
||||
self.clear_form_data()
|
||||
if file_path != "":
|
||||
if file_path == "":
|
||||
return
|
||||
self.file_path = file_path
|
||||
self.get_file_data(file_path)
|
||||
else:
|
||||
return
|
||||
|
||||
def update_on_startup(self):
|
||||
with open(update_config_name, "w") as f:
|
||||
|
||||
@@ -54,7 +54,7 @@ def update_configs():
|
||||
update_list = check_remote_hashes()
|
||||
if not update_list or len(update_list) == 0:
|
||||
return
|
||||
progress_bar = util.show_progress_bar("Download progress", "Downloading configs...", len(update_list))
|
||||
progress_bar = util.show_progress_bar("Download progress", "Downloading configs", len(update_list))
|
||||
for cfg in update_list:
|
||||
check_path(cfg)
|
||||
response_status, response = get_response_result(github_link + cfg)
|
||||
|
||||
@@ -21,9 +21,8 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
self.ui = Ui_SecondWindow()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
self.owns = owns_list # From main window
|
||||
|
||||
# Checking config files
|
||||
if selected_game is not None:
|
||||
cfg_path = "configs/{}".format(selected_game)
|
||||
dealers_path = "{}/dealers.json".format(cfg_path)
|
||||
if dataIO.is_valid_json(dealers_path) is False:
|
||||
@@ -101,9 +100,9 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
self.ui.dealer_add_all.clicked.connect(self.add_all_da_clicked)
|
||||
self.ui.agency_add_all.clicked.connect(self.add_all_da_clicked)
|
||||
|
||||
if self.owns:
|
||||
self.fill_list(self.owns, self.dealers, self.dealers_file)
|
||||
self.fill_list(self.owns, self.agencies, self.agencies_file)
|
||||
if isinstance(owns_list, dict):
|
||||
self.fill_list(owns_list, self.dealers, self.dealers_file)
|
||||
self.fill_list(owns_list, self.agencies, self.agencies_file)
|
||||
|
||||
# Checking save-file
|
||||
self.check_cities()
|
||||
@@ -228,7 +227,7 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
def add_all_cities(self):
|
||||
all_cities = self.all_cities()
|
||||
visited_cities = util.get_array_items(util.search_line("visited_cities:"))
|
||||
progress = util.show_progress_bar("Visiting cities", "Visiting cities...", len(all_cities)-len(visited_cities))
|
||||
progress = util.show_progress_bar("Visiting cities", "Visiting cities", len(all_cities)-len(visited_cities))
|
||||
for city in all_cities:
|
||||
if city not in visited_cities:
|
||||
util.add_array_value(util.search_line("visited_cities:"), city)
|
||||
@@ -284,13 +283,13 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
if da_arr is None:
|
||||
return
|
||||
static_key, success_message, progress_message = da_arr
|
||||
city_list, line_to_search, check_func = self.da_statics.get(static_key)
|
||||
cities_to_unlock, line_to_search, check_func = self.da_statics.get(static_key)
|
||||
all_cities = self.all_cities()
|
||||
array_line = util.search_line(line_to_search)
|
||||
visited_cities = util.get_array_items(array_line)
|
||||
progress = util.show_progress_bar(progress_message, progress_message+"...", len(all_cities)-len(visited_cities))
|
||||
for element in city_list:
|
||||
if (element in all_cities) and (element not in visited_cities):
|
||||
unlocked_cities = util.get_array_items(array_line)
|
||||
progress = util.show_progress_bar(progress_message, progress_message, len(all_cities)-len(unlocked_cities))
|
||||
for element in cities_to_unlock:
|
||||
if (element not in unlocked_cities) and (element in all_cities):
|
||||
util.add_array_value(array_line, element)
|
||||
util.update_progress_bar(progress)
|
||||
QMessageBox.information(self, "Success", success_message)
|
||||
|
||||
2
util.py
2
util.py
@@ -39,7 +39,7 @@ class CustomFuncs:
|
||||
def show_progress_bar(title, text, length):
|
||||
if (not title) or (not text) or (not length) or (length <= 0):
|
||||
return
|
||||
progress_bar = QProgressDialog(text, None, 0, length, flags=Qt.Window | Qt.WindowTitleHint)
|
||||
progress_bar = QProgressDialog(text + "...", None, 0, length, flags=Qt.Window | Qt.WindowTitleHint)
|
||||
progress_bar.setWindowTitle(title)
|
||||
progress_bar.setWindowModality(Qt.WindowModal)
|
||||
progress_bar.show()
|
||||
|
||||
Reference in New Issue
Block a user