mirror of
https://github.com/JDM170/SaveWizard
synced 2025-04-20 22:30:42 +07:00
Typo fixes
Signed-off-by: JDM170 <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<author>JDM170</author>
|
||||
<class>Choice</class>
|
||||
<widget class="QDialog" name="Choice">
|
||||
<property name="geometry">
|
||||
|
||||
@@ -34,7 +34,7 @@ class ChoiceWindow(QDialog, Ui_Choice):
|
||||
answer = remember_data.get("answer_updates")
|
||||
if answer:
|
||||
box = QMessageBox(QMessageBox.Information, "Info",
|
||||
"Some configs get updated, do you want update your local configs?")
|
||||
"Some configs have been updated. Do you want to update the local configs?")
|
||||
box.addButton("Yes", QMessageBox.YesRole) # 0
|
||||
box.addButton("Yes, remember that", QMessageBox.YesRole) # 1
|
||||
box.addButton("No", QMessageBox.NoRole) # 2
|
||||
|
||||
15
dataIO.py
15
dataIO.py
@@ -7,10 +7,6 @@ from os.path import splitext
|
||||
from random import randint
|
||||
|
||||
|
||||
class InvalidFileIO(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class DataIO:
|
||||
@staticmethod
|
||||
def _read_json(filename):
|
||||
@@ -18,12 +14,6 @@ class DataIO:
|
||||
data = load(f)
|
||||
return data
|
||||
|
||||
@staticmethod
|
||||
def _save_json(filename, data):
|
||||
with open(filename, encoding="utf-8", mode="w") as f:
|
||||
dump(data, f, indent=4, sort_keys=True, separators=(",", " : "))
|
||||
return data
|
||||
|
||||
def is_valid_json(self, filename):
|
||||
"""Verifies if json file exists / is readable"""
|
||||
try:
|
||||
@@ -43,7 +33,10 @@ class DataIO:
|
||||
rnd = randint(1000, 9999)
|
||||
path, ext = splitext(filename)
|
||||
tmp_file = "{}-{}.tmp".format(path, rnd)
|
||||
self._save_json(tmp_file, data)
|
||||
# self._save_json(filename, data)
|
||||
with open(filename, encoding="utf-8", mode="w") as f:
|
||||
dump(data, f, indent=4, sort_keys=True, separators=(",", " : "))
|
||||
# return data (?)
|
||||
try:
|
||||
self._read_json(tmp_file)
|
||||
except decoder.JSONDecodeError:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<author>JDM170</author>
|
||||
<class>MainWindow</class>
|
||||
<widget class="QDialog" name="MainWindow">
|
||||
<property name="geometry">
|
||||
|
||||
@@ -99,8 +99,8 @@ class MainWindow(QDialog, Ui_MainWindow):
|
||||
cfg_path = "configs/{}/dlc.json".format(self.selected_game)
|
||||
if dataIO.is_valid_json(cfg_path) is False:
|
||||
self.owns = False
|
||||
show_message(QMessageBox.Warning, "Warning", "'dlc.json' from '{}' not found, functionality "
|
||||
"has been limited".format(self.selected_game))
|
||||
show_message(QMessageBox.Warning, "Warning", "'dlc.json' from '{}' have errors or not found, "
|
||||
"functionality has been limited".format(self.selected_game))
|
||||
else:
|
||||
self.owns = {}
|
||||
self.dlc = dataIO.load_json(cfg_path)
|
||||
@@ -138,7 +138,10 @@ class MainWindow(QDialog, Ui_MainWindow):
|
||||
self.old_file = f.read()
|
||||
show_message(QMessageBox.Information, "Success", "File successfully decrypted.")
|
||||
except UnicodeDecodeError:
|
||||
show_message(QMessageBox.Critical, "Error", "Error to decrypt and open file. Try again.")
|
||||
show_message(QMessageBox.Critical, "Error", "Error to decrypt and open file. "
|
||||
"Try again.\nIf you still get error on this step,"
|
||||
"try to change \"uset g_save_format\" to 2, resave game "
|
||||
"and try again.")
|
||||
return
|
||||
set_lines(self.old_file.split("\n"))
|
||||
|
||||
@@ -177,8 +180,8 @@ class MainWindow(QDialog, Ui_MainWindow):
|
||||
return
|
||||
|
||||
def change_configs(self):
|
||||
box = QMessageBox(QMessageBox.Warning, "Warning", "Do you really change configs? "
|
||||
"Your changes has been lost!")
|
||||
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:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<author>JDM170</author>
|
||||
<class>SecondWindow</class>
|
||||
<widget class="QDialog" name="SecondWindow">
|
||||
<property name="geometry">
|
||||
|
||||
@@ -33,7 +33,7 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
self.ui.dealer_edit.setEnabled(False)
|
||||
self.ui.dealer_add.setEnabled(False)
|
||||
self.ui.dealer_add_all.setEnabled(False)
|
||||
show_message(QMessageBox.Warning, "Warning", "'dealers.json' from '{}' not found, dealers "
|
||||
show_message(QMessageBox.Warning, "Warning", "'dealers.json' from '{}' have errors or not found, dealers "
|
||||
"editing has been disabled".format(selected_game))
|
||||
else:
|
||||
self.dealers = []
|
||||
@@ -44,7 +44,7 @@ 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(QMessageBox.Warning, "Warning", "'agencies.json' from '{}' not found, agencies "
|
||||
show_message(QMessageBox.Warning, "Warning", "'agencies.json' from '{}' have errors or not found, agencies "
|
||||
"editing has been disabled".format(selected_game))
|
||||
else:
|
||||
self.agencies = []
|
||||
@@ -121,7 +121,7 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
def add_garage(self):
|
||||
garage = self.ui.garage_edit.text().lower()
|
||||
if garage is "":
|
||||
show_message(QMessageBox.Critical, "Error", "Enter a name for the city.")
|
||||
show_message(QMessageBox.Critical, "Error", "Enter city name!")
|
||||
return
|
||||
self.ui.garage_edit.setText("")
|
||||
reg_garage = "garage." + garage
|
||||
@@ -156,12 +156,12 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
def change_headquarter(self):
|
||||
hq = self.ui.headquarter_edit.text().lower()
|
||||
if hq is "":
|
||||
show_message(QMessageBox.Critical, "Error", "Enter a name for the city.")
|
||||
show_message(QMessageBox.Critical, "Error", "Enter city name!")
|
||||
return
|
||||
if get_value(search_line("hq_city:")) == hq:
|
||||
show_message(QMessageBox.Information, "Info", "Your headquarter is already in this city")
|
||||
show_message(QMessageBox.Information, "Info", "Your headquarter is already in this city.")
|
||||
elif hq not in self.purchased_garages():
|
||||
show_message(QMessageBox.Critical, "Error", "You need to own the garage in this city.")
|
||||
show_message(QMessageBox.Critical, "Error", "You need a garage in \"{}\" to set headquarter.".format(hq))
|
||||
else:
|
||||
set_value(search_line("hq_city:"), hq)
|
||||
show_message(QMessageBox.Information, "Success", "Headquarter successfully set to \"{}\".".format(hq))
|
||||
@@ -179,7 +179,7 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
def add_city(self):
|
||||
city = self.ui.city_edit.text().lower()
|
||||
if city is "":
|
||||
show_message(QMessageBox.Critical, "Error", "Enter a name for the city.")
|
||||
show_message(QMessageBox.Critical, "Error", "Enter city name!")
|
||||
return
|
||||
self.ui.city_edit.setText("")
|
||||
if city not in get_array_items(search_line("visited_cities:")):
|
||||
@@ -188,7 +188,7 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
show_message(QMessageBox.Information, "Success", "City \"{}\" successfully visited.".format(city))
|
||||
self.check_cities()
|
||||
else:
|
||||
show_message(QMessageBox.Critical, "Error", "You already visited \"{}\".".format(city))
|
||||
show_message(QMessageBox.Critical, "Error", "You've already visited \"{}\".".format(city))
|
||||
|
||||
def add_all_cities(self):
|
||||
visited_cities = get_array_items(search_line("visited_cities:"))
|
||||
@@ -242,15 +242,16 @@ class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
edit, file_var, message_var = da_arr[0], da_arr[1], da_arr[2]
|
||||
city_element = edit.text().lower()
|
||||
if not city_element:
|
||||
show_message(QMessageBox.Critical, "Error", "Enter a name for the city.")
|
||||
show_message(QMessageBox.Critical, "Error", "Enter city name!")
|
||||
return
|
||||
edit.setText("")
|
||||
if city_element not in da_arr[3]:
|
||||
show_message(QMessageBox.Critical, "Error", "There is no {} in that city.".format(message_var.lower()))
|
||||
elif city_element in get_array_items(search_line(file_var)):
|
||||
show_message(QMessageBox.Information, "Info", "{} is already unlocked.".format(message_var))
|
||||
show_message(QMessageBox.Information, "Info",
|
||||
"{} in \"{}\" is already unlocked.".format(message_var, city_element))
|
||||
else:
|
||||
add_array_value(search_line(file_var), city_element)
|
||||
show_message(QMessageBox.Information, "Success", "{} in \"{}\" successfully unlocked."
|
||||
"".format(message_var, city_element))
|
||||
show_message(QMessageBox.Information, "Success",
|
||||
"{} in \"{}\" successfully unlocked.".format(message_var, city_element))
|
||||
da_arr[4]()
|
||||
|
||||
63
util.py
63
util.py
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from re import search, match, sub
|
||||
# from re import search, match, sub
|
||||
from re import search, match
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
|
||||
github_link = "https://raw.githubusercontent.com/JDM170/SaveWizard/master/"
|
||||
@@ -71,9 +72,9 @@ def set_value(line, value):
|
||||
lines[line] = name + ": " + value
|
||||
|
||||
|
||||
def get_unit_name(line):
|
||||
global lines
|
||||
return search(r" : (.+) {$", lines[line]).group(1)
|
||||
# def get_unit_name(line):
|
||||
# global lines
|
||||
# return search(r" : (.+) {$", lines[line]).group(1)
|
||||
|
||||
|
||||
def get_array_length(line):
|
||||
@@ -81,19 +82,19 @@ def get_array_length(line):
|
||||
return int(search(r": ([0-9]+)$", lines[line]).group(1))
|
||||
|
||||
|
||||
def get_array_value_by_index(line, index):
|
||||
global lines
|
||||
return search(r": (.+)$", lines[line + index + 1]).group(1)
|
||||
|
||||
|
||||
def get_array_index_by_value(line, value):
|
||||
global lines
|
||||
count = 0
|
||||
for i in range(get_array_length(line)):
|
||||
if get_value(line + count + 1) == value:
|
||||
return count
|
||||
count += 1
|
||||
return None
|
||||
# def get_array_value_by_index(line, index):
|
||||
# global lines
|
||||
# return search(r": (.+)$", lines[line + index + 1]).group(1)
|
||||
#
|
||||
#
|
||||
# def get_array_index_by_value(line, value):
|
||||
# global lines
|
||||
# count = 0
|
||||
# for i in range(get_array_length(line)):
|
||||
# if get_value(line + count + 1) == value:
|
||||
# return count
|
||||
# count += 1
|
||||
# return None
|
||||
|
||||
|
||||
def get_array_items(line):
|
||||
@@ -114,17 +115,17 @@ def add_array_value(line, value):
|
||||
lines.insert(line + count + 1, name + "[" + str(count) + "]: " + value)
|
||||
|
||||
|
||||
def remove_array_value(line, value):
|
||||
global lines
|
||||
name = match(r"(.+):", lines[line]).group(1)
|
||||
del lines[line + 1 + get_array_index_by_value(line, value)]
|
||||
count = get_array_length(line)
|
||||
lines[line] = name + ": " + str(count - 1)
|
||||
for i in range(count):
|
||||
lines[line + i + 1] = sub(r"\[[0-9]+\]", "[" + str(i) + "]", lines[line + i + 1])
|
||||
|
||||
|
||||
def change_array_value(line, index, value):
|
||||
global lines
|
||||
line += index + 1
|
||||
set_value(line, value)
|
||||
# def remove_array_value(line, value):
|
||||
# global lines
|
||||
# name = match(r"(.+):", lines[line]).group(1)
|
||||
# del lines[line + 1 + get_array_index_by_value(line, value)]
|
||||
# count = get_array_length(line)
|
||||
# lines[line] = name + ": " + str(count - 1)
|
||||
# for i in range(count):
|
||||
# lines[line + i + 1] = sub(r"\[[0-9]+]", "[" + str(i) + "]", lines[line + i + 1])
|
||||
#
|
||||
#
|
||||
# def change_array_value(line, index, value):
|
||||
# global lines
|
||||
# line += index + 1
|
||||
# set_value(line, value)
|
||||
|
||||
Reference in New Issue
Block a user