mirror of
https://github.com/JDM170/SaveWizard
synced 2025-04-20 22:30:42 +07:00
Update
* Added .gitignore * Added build.spec for compiling project with PyInstaller * Updated font on all window elements * Recoded functions: ** purchased_garages ** add_garage ** add_all_garages * Typo fixes Signed-off-by: JDM170 <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
16
.gitignore
vendored
Normal file
16
.gitignore
vendored
Normal file
@@ -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
|
||||
@@ -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())
|
||||
|
||||
35
build.spec
Normal file
35
build.spec
Normal file
@@ -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')
|
||||
1
compile_cx-freeze.bat
Normal file
1
compile_cx-freeze.bat
Normal file
@@ -0,0 +1 @@
|
||||
pythonqt setup.py build
|
||||
1
compile_pyinstaller.bat
Normal file
1
compile_pyinstaller.bat
Normal file
@@ -0,0 +1 @@
|
||||
pyinstaller build.spec
|
||||
@@ -1 +0,0 @@
|
||||
python setup.py build
|
||||
@@ -1,2 +1 @@
|
||||
# initialize module 'main' for compile program
|
||||
import main.script
|
||||
|
||||
155
main/form.ui
155
main/form.ui
@@ -95,18 +95,31 @@
|
||||
<widget class="QWidget" name="gridLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>14</x>
|
||||
<x>10</x>
|
||||
<y>50</y>
|
||||
<width>331</width>
|
||||
<width>341</width>
|
||||
<height>81</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="basic_inf_layout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="money_edit"/>
|
||||
<widget class="QLineEdit" name="money_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="money_dont_change">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't change</string>
|
||||
</property>
|
||||
@@ -126,10 +139,23 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="xp_edit"/>
|
||||
<widget class="QLineEdit" name="xp_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="xp_dont_change">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't change</string>
|
||||
</property>
|
||||
@@ -149,10 +175,23 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="loan_limit_edit"/>
|
||||
<widget class="QLineEdit" name="loan_limit_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QCheckBox" name="loan_limit_dont_change">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't change</string>
|
||||
</property>
|
||||
@@ -176,15 +215,22 @@
|
||||
<widget class="QWidget" name="gridLayoutWidget_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>14</x>
|
||||
<y>138</y>
|
||||
<width>331</width>
|
||||
<x>10</x>
|
||||
<y>140</y>
|
||||
<width>341</width>
|
||||
<height>161</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="skills_layout">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="long_distance_edit"/>
|
||||
<widget class="QLineEdit" name="long_distance_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="urgent_delivery_label">
|
||||
@@ -201,39 +247,91 @@
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QCheckBox" name="ecodriving_dont_change">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="adr_edit"/>
|
||||
<widget class="QLineEdit" name="adr_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="urgent_delivery_edit"/>
|
||||
<widget class="QLineEdit" name="urgent_delivery_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QCheckBox" name="fragile_cargo_dont_change">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="ecodriving_edit"/>
|
||||
<widget class="QLineEdit" name="ecodriving_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QCheckBox" name="high_value_cargo_dont_change">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="fragile_cargo_edit"/>
|
||||
<widget class="QLineEdit" name="fragile_cargo_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="adr_dont_change">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't change</string>
|
||||
</property>
|
||||
@@ -241,13 +339,26 @@
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="long_distance_dont_change">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="high_value_cargo_edit"/>
|
||||
<widget class="QLineEdit" name="high_value_cargo_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="high_value_cargo_label">
|
||||
@@ -290,6 +401,12 @@
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QCheckBox" name="urgent_delivery_dont_change">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't change</string>
|
||||
</property>
|
||||
@@ -342,12 +459,18 @@
|
||||
<widget class="QCheckBox" name="dont_change_all_inf">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<x>80</x>
|
||||
<y>300</y>
|
||||
<width>181</width>
|
||||
<width>211</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't save all changes in this form</string>
|
||||
</property>
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
# initialize module 'second' for compile program
|
||||
from second import script
|
||||
|
||||
@@ -43,6 +43,12 @@
|
||||
<layout class="QGridLayout" name="garages_layout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QTextBrowser" name="garages_text">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@@ -65,6 +71,9 @@
|
||||
<property name="text">
|
||||
<string>Owned garages:</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
@@ -113,6 +122,12 @@
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTextBrowser" name="cities_text">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@@ -154,6 +169,12 @@
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTextBrowser" name="dealerships_text">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@@ -195,6 +216,12 @@
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTextBrowser" name="agencies_text">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@@ -240,7 +267,7 @@
|
||||
<x>150</x>
|
||||
<y>10</y>
|
||||
<width>171</width>
|
||||
<height>133</height>
|
||||
<height>135</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="add_garage">
|
||||
@@ -258,7 +285,14 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="garage_edit"/>
|
||||
<widget class="QLineEdit" name="garage_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="garage_add_all">
|
||||
@@ -290,7 +324,14 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QComboBox" name="garage_size"/>
|
||||
<widget class="QComboBox" name="garage_size">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -300,7 +341,7 @@
|
||||
<x>480</x>
|
||||
<y>60</y>
|
||||
<width>171</width>
|
||||
<height>107</height>
|
||||
<height>110</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="add_city">
|
||||
@@ -318,7 +359,14 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="city_edit"/>
|
||||
<widget class="QLineEdit" name="city_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="city_label">
|
||||
@@ -357,7 +405,7 @@
|
||||
<x>150</x>
|
||||
<y>290</y>
|
||||
<width>171</width>
|
||||
<height>107</height>
|
||||
<height>108</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="add_dealer">
|
||||
@@ -375,7 +423,14 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="dealer_edit"/>
|
||||
<widget class="QLineEdit" name="dealer_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="dealer_label">
|
||||
@@ -414,7 +469,7 @@
|
||||
<x>480</x>
|
||||
<y>290</y>
|
||||
<width>171</width>
|
||||
<height>107</height>
|
||||
<height>108</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="add_agency">
|
||||
@@ -461,7 +516,14 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="agency_edit"/>
|
||||
<widget class="QLineEdit" name="agency_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -492,7 +554,14 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="headquarter_edit"/>
|
||||
<widget class="QLineEdit" name="headquarter_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="headquarter_change">
|
||||
|
||||
185
second/script.py
185
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()
|
||||
|
||||
2
setup.py
2
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,
|
||||
|
||||
31
util.py
31
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
|
||||
|
||||
Reference in New Issue
Block a user