mirror of
https://github.com/JDM170/SaveWizard
synced 2025-04-20 22:30:42 +07:00
Compare commits
4 Commits
e9eef9f785
...
1ad1f536de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ad1f536de | ||
|
89f56be8b2
|
|||
|
2b14be3832
|
|||
|
6330a0dfa8
|
@@ -8,7 +8,7 @@
|
||||
|
||||
Features:
|
||||
1. Decrypt file, if save file crypted
|
||||
2. Check for DLC to the save file (available DLC listed at [DLC_TABLE.md](https://github.com/JDM170/SaveWizard/blob/dev/DLC_TABLE.md))
|
||||
2. Check for DLC to the save file (available DLC listed at [DLC_TABLE.md](https://github.com/JDM170/SaveWizard/blob/configs/DLC_TABLE.md))
|
||||
3. Edit money, experience and loan limit
|
||||
4. Edit skills
|
||||
5. Visit cities, unlock garages, dealers and agencies
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QResizeEvent, QCloseEvent, QClipboard
|
||||
from PyQt5.QtWidgets import QMainWindow, QFileDialog, QMessageBox, QApplication
|
||||
from ast import literal_eval
|
||||
|
||||
@@ -5,7 +5,7 @@ from ast import literal_eval
|
||||
from ctypes import CDLL
|
||||
from os import getcwd, remove
|
||||
|
||||
from PyQt5.QtCore import Qt, QRegExp
|
||||
from PyQt5.QtCore import QRegExp
|
||||
from PyQt5.QtGui import QRegExpValidator
|
||||
from PyQt5.QtWidgets import QDialog, QFileDialog
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
import os
|
||||
from ast import literal_eval
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QProgressDialog, QApplication
|
||||
from requests import get
|
||||
|
||||
from dataIO import dataIO
|
||||
@@ -56,10 +54,7 @@ def update_configs():
|
||||
update_list = check_remote_hashes()
|
||||
if not update_list or len(update_list) == 0:
|
||||
return
|
||||
progress = QProgressDialog("Downloading configs...", None, 0, len(update_list), flags=Qt.Window | Qt.WindowTitleHint)
|
||||
progress.setWindowTitle("Download progress")
|
||||
progress.setWindowModality(Qt.WindowModal)
|
||||
progress.show()
|
||||
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)
|
||||
@@ -67,7 +62,5 @@ def update_configs():
|
||||
remote_cfg = literal_eval(response.text)
|
||||
if dataIO.is_valid_json(cfg) or os.path.exists(cfg):
|
||||
dataIO.save_json(cfg, remote_cfg)
|
||||
progress.setValue(progress.value()+1)
|
||||
QApplication.processEvents()
|
||||
progress.setValue(len(update_list))
|
||||
QApplication.processEvents()
|
||||
util.update_progress_bar(progress_bar)
|
||||
util.update_progress_bar(progress_bar, len(update_list))
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QDialog
|
||||
from .form import Ui_SecondWindow
|
||||
from util import *
|
||||
@@ -24,10 +23,9 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
|
||||
self.owns = owns_list # From main window
|
||||
|
||||
# Checking files
|
||||
# Checking config files
|
||||
cfg_path = "configs/{}".format(selected_game)
|
||||
dealers_path = "{}/dealers.json".format(cfg_path)
|
||||
agencies_path = "{}/agencies.json".format(cfg_path)
|
||||
if dataIO.is_valid_json(dealers_path) is False:
|
||||
self.dealers = False
|
||||
self.ui.dealer_edit.setEnabled(False)
|
||||
@@ -39,6 +37,7 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
self.dealers = []
|
||||
self.dealers_file = dataIO.load_json(dealers_path)
|
||||
|
||||
agencies_path = "{}/agencies.json".format(cfg_path)
|
||||
if dataIO.is_valid_json(agencies_path) is False:
|
||||
self.agencies = False
|
||||
self.ui.agency_edit.setEnabled(False)
|
||||
@@ -54,36 +53,39 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
self.ui.garage_size.addItem("Medium")
|
||||
self.ui.garage_size.addItem("Big")
|
||||
|
||||
# Dealers and agencies properties for 'ADD' button
|
||||
self.add_da_dict = {
|
||||
self.ui.dealer_add: [
|
||||
self.ui.dealer_edit,
|
||||
"unlocked_dealers:",
|
||||
self.dealers,
|
||||
"Dealership",
|
||||
self.check_dealers
|
||||
self.da_statics = {
|
||||
"dealer": [
|
||||
self.dealers, # city_list
|
||||
"unlocked_dealers:", # line_to_search
|
||||
self.check_dealers, # check_func
|
||||
],
|
||||
self.ui.agency_add: [
|
||||
self.ui.agency_edit,
|
||||
"unlocked_recruitments:",
|
||||
self.agencies,
|
||||
"Recruitment agency",
|
||||
self.check_agencies
|
||||
"agency": [
|
||||
self.agencies, # city_list
|
||||
"unlocked_recruitments:", # line_to_search
|
||||
self.check_agencies, # check_func
|
||||
],
|
||||
}
|
||||
# Dealers and agencies properties for 'ADD ALL' button
|
||||
self.add_all_da_dict = {
|
||||
|
||||
self.add_da_handlers = {
|
||||
self.ui.dealer_add: [
|
||||
"dealer",
|
||||
self.ui.dealer_edit, # city_to_add
|
||||
"Dealership", # message_variable
|
||||
],
|
||||
self.ui.dealer_add_all: [
|
||||
self.dealers,
|
||||
"unlocked_dealers:",
|
||||
"All dealerships unlocked.",
|
||||
self.check_dealers
|
||||
"dealer",
|
||||
"All dealerships unlocked.", # success_message
|
||||
"Visiting dealers", # progress_message
|
||||
],
|
||||
self.ui.agency_add: [
|
||||
"agency",
|
||||
self.ui.agency_edit, # city_to_add
|
||||
"Recruitment agency", # message_variable
|
||||
],
|
||||
self.ui.agency_add_all: [
|
||||
self.agencies,
|
||||
"unlocked_recruitments:",
|
||||
"All recruitment agencies unlocked.",
|
||||
self.check_agencies
|
||||
"agency",
|
||||
"All recruitment agencies unlocked.", # success_message
|
||||
"Visiting agencies", # progress_message
|
||||
],
|
||||
}
|
||||
|
||||
@@ -96,14 +98,13 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
self.ui.city_add_all.clicked.connect(self.add_all_cities)
|
||||
self.ui.dealer_add.clicked.connect(self.add_da_clicked)
|
||||
self.ui.agency_add.clicked.connect(self.add_da_clicked)
|
||||
# self.ui.dealer_add_all.clicked.connect(self.add_all_dealers)
|
||||
# self.ui.agency_add_all.clicked.connect(self.add_all_agencies)
|
||||
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)
|
||||
|
||||
# Checking save-file
|
||||
self.check_cities()
|
||||
self.check_dealers()
|
||||
@@ -146,8 +147,8 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
array.append(value)
|
||||
|
||||
def check_garage_size(self):
|
||||
stat = garages_stat[self.ui.garage_size.currentText()]
|
||||
return str(stat[0]), stat[1]
|
||||
status_id, size = garages_stat[self.ui.garage_size.currentText()]
|
||||
return str(status_id), size
|
||||
|
||||
def check_garages(self):
|
||||
self.ui.garages_text.clear()
|
||||
@@ -225,11 +226,14 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
QMessageBox.critical(self, "Error", "You've already visited \"{}\".".format(city))
|
||||
|
||||
def add_all_cities(self):
|
||||
all_cities = self.all_cities()
|
||||
visited_cities = util.get_array_items(util.search_line("visited_cities:"))
|
||||
for city in self.all_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)
|
||||
util.add_array_value(util.search_line("visited_cities_count:"), "1")
|
||||
util.update_progress_bar(progress)
|
||||
QMessageBox.information(self, "Success", "All cities successfully visited.")
|
||||
self.check_cities()
|
||||
|
||||
@@ -243,15 +247,6 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
self.ui.dealerships_text.append(dealer)
|
||||
self.ui.dealerships_text.scrollToAnchor(visited_dealers[0])
|
||||
|
||||
# def add_all_dealers(self):
|
||||
# all_cities = self.all_cities()
|
||||
# visited_dealers = util.get_array_items(util.search_line("unlocked_dealers:"))
|
||||
# for dealer in self.dealers:
|
||||
# if dealer in all_cities and dealer not in visited_dealers:
|
||||
# util.add_array_value(util.search_line("unlocked_dealers:"), dealer)
|
||||
# QMessageBox.information(self, "Success", "All dealerships unlocked.")
|
||||
# self.check_dealers()
|
||||
|
||||
def check_agencies(self):
|
||||
self.ui.agencies_text.clear()
|
||||
visited_agencies = util.get_array_items(util.search_line("unlocked_recruitments:"))
|
||||
@@ -262,25 +257,17 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
self.ui.agencies_text.append(agency)
|
||||
self.ui.agencies_text.scrollToAnchor(visited_agencies[0])
|
||||
|
||||
# def add_all_agencies(self):
|
||||
# all_cities = self.all_cities()
|
||||
# visited_agencies = util.get_array_items(util.search_line("unlocked_recruitments:"))
|
||||
# for agency in self.agencies:
|
||||
# if agency in all_cities and agency not in visited_agencies:
|
||||
# util.add_array_value(util.search_line("unlocked_recruitments:"), agency)
|
||||
# QMessageBox.information(self, "Success", "All recruitment agencies unlocked.")
|
||||
# self.check_agencies()
|
||||
|
||||
def add_da_clicked(self):
|
||||
da_arr = self.add_da_dict.get(self.sender())
|
||||
da_arr = self.add_da_handlers.get(self.sender())
|
||||
if da_arr is None:
|
||||
return
|
||||
edit, line_to_search, city_list, message_variable, check_func = da_arr
|
||||
city_element = edit.text().lower()
|
||||
static_key, city_to_add, message_variable = da_arr
|
||||
city_list, line_to_search, check_func = self.da_statics.get(static_key)
|
||||
city_element = city_to_add.text().lower()
|
||||
if not city_element:
|
||||
QMessageBox.critical(self, "Error", "Enter city name!")
|
||||
return
|
||||
edit.setText("")
|
||||
city_to_add.setText("")
|
||||
if city_element not in city_list:
|
||||
QMessageBox.critical(self, "Error", "There is no {} in that city.".format(message_variable.lower()))
|
||||
elif city_element in util.get_array_items(util.search_line(line_to_search)):
|
||||
@@ -293,15 +280,18 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
check_func()
|
||||
|
||||
def add_all_da_clicked(self):
|
||||
da_arr = self.add_all_da_dict.get(self.sender())
|
||||
da_arr = self.add_da_handlers.get(self.sender())
|
||||
if da_arr is None:
|
||||
return
|
||||
city_list, line_to_search, success_message, check_func = da_arr
|
||||
static_key, success_message, progress_message = da_arr
|
||||
city_list, 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 = util.get_array_items(array_line)
|
||||
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):
|
||||
if (element in all_cities) and (element not in visited_cities):
|
||||
util.add_array_value(array_line, element)
|
||||
util.update_progress_bar(progress)
|
||||
QMessageBox.information(self, "Success", success_message)
|
||||
check_func()
|
||||
|
||||
@@ -14,4 +14,4 @@ PyQt5-Qt5==5.15.2
|
||||
PyQt5-sip==12.13.0
|
||||
pywin32-ctypes==0.2.2
|
||||
requests==2.32.0
|
||||
urllib3==2.1.0
|
||||
urllib3==2.2.2
|
||||
|
||||
22
util.py
22
util.py
@@ -4,7 +4,10 @@
|
||||
from os.path import isfile
|
||||
from re import search, match
|
||||
# from re import search, match, sub
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import (
|
||||
QMessageBox, QProgressDialog, QApplication
|
||||
)
|
||||
from hashlib import md5
|
||||
from statics import hash_chunk_size
|
||||
|
||||
@@ -32,6 +35,23 @@ class CustomFuncs:
|
||||
hash_md5.update(chunk)
|
||||
return hash_md5.hexdigest()
|
||||
|
||||
@staticmethod
|
||||
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.setWindowTitle(title)
|
||||
progress_bar.setWindowModality(Qt.WindowModal)
|
||||
progress_bar.show()
|
||||
return progress_bar
|
||||
|
||||
@staticmethod
|
||||
def update_progress_bar(progress_bar, value=1):
|
||||
if not progress_bar:
|
||||
return
|
||||
progress_bar.setValue(progress_bar.value() + value)
|
||||
QApplication.processEvents()
|
||||
|
||||
# Stock functions
|
||||
def search_line(self, term, start=0, cancel=r"this_string_must_not_exist"):
|
||||
if search(term, self.lines[start]):
|
||||
|
||||
Reference in New Issue
Block a user