mirror of
https://github.com/JDM170/SaveWizard
synced 2025-04-20 22:30:42 +07:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 950ed7678f | |||
| ba0c03f051 | |||
|
|
d7b1e4322e | ||
|
|
d58996bd2f | ||
|
|
e3e91d9665 | ||
|
|
6094f785a5 | ||
|
|
5b5bc9f9d6 | ||
|
|
0d769cd254 | ||
|
|
9ae9b59f70 | ||
|
|
6ea831e87f | ||
|
|
4c2d7967e7 | ||
|
|
c9214aa17c | ||
|
|
4763f43a3d | ||
|
|
db6d09e7b3 |
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
|
||||
20
README.md
20
README.md
@@ -1,20 +1,30 @@
|
||||
# SaveWizard
|
||||
|
||||
* Author of original "SaveWizard" script: DrEGZo
|
||||
* The original script is taken from here: <https://forum.truckersmp.com/index.php?/topic/55773-savewizard/>
|
||||
* To decrypt the file the utility is used: <https://github.com/ncs-sniper/SII_Decrypt/>
|
||||
* Original script is taken from here: <https://forum.truckersmp.com/index.php?/topic/55773-savewizard/> (access to the topic has been closed)
|
||||
* Utility to decrypt file: <https://github.com/ncs-sniper/SII_Decrypt/> (repo has been removed)
|
||||
|
||||
***
|
||||
|
||||
This program allows:
|
||||
The program allows you to edit ETS2 and ATS saves, just place 'dlc.json', 'dealers.json' and 'agencies.json' files next to the executable SaveWizard.exe.
|
||||
|
||||
***
|
||||
|
||||
Features:
|
||||
1. Decrypt file, if save file crypted
|
||||
2. Check for DLC to the save file
|
||||
3. Edit money, experience and loan limit
|
||||
4. Edit skills
|
||||
5. Unlock garages, visit cities, unlock dealers and agencies
|
||||
|
||||
**This functionality of the program is not final!**
|
||||
**This functionality of the program isn't final!**
|
||||
|
||||
***
|
||||
|
||||
#### Since the program is in development, I will not give up help and guidance on my errors in the code.
|
||||
Requirments:
|
||||
* Python 3.5.4 or higher
|
||||
* PyQt 5.6.0 or higher
|
||||
|
||||
***
|
||||
|
||||
#### Since the program is in development, I won't give up help and guidance on my errors in the code.
|
||||
|
||||
BIN
SII_Decrypt.exe
Normal file
BIN
SII_Decrypt.exe
Normal file
Binary file not shown.
12
__init__.py
Normal file
12
__init__.py
Normal file
@@ -0,0 +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__':
|
||||
app = QApplication(argv)
|
||||
win = MainWindow()
|
||||
win.show()
|
||||
exit(app.exec())
|
||||
9
ats_configs/agencies.json
Normal file
9
ats_configs/agencies.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"base": ["bakersfield", "fresno", "los_angeles", "oxnard", "redding", "san_diego",
|
||||
"san_rafael", "santa_cruz", "stockton", "carson_city", "las_vegas"],
|
||||
"arizona": ["phoenix", "sierra_vista", "tucson"],
|
||||
"new_mexico": ["carlsbad_nm", "farmington", "roswell", "santa_fe"],
|
||||
"oregon": ["bend", "eugene", "ontario", "salem"],
|
||||
"washington": ["bellingham", "olympia", "seattle", "wenatchee", "yakima"],
|
||||
"utah": ["moab", "salt_lake_city", "st_george"]
|
||||
}
|
||||
8
ats_configs/dealers.json
Normal file
8
ats_configs/dealers.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"base": ["bakersfield", "los_angeles", "sacramento", "santa_cruz", "san_diego", "san_francisco"],
|
||||
"arizona": ["flagstaff", "phoenix", "tucson", "yuma"],
|
||||
"new_mexico": ["alamogordo", "albuquerque", "farmington", "hobbs"],
|
||||
"oregon": ["eugene", "medford", "pendleton", "portland", "salem"],
|
||||
"washington": ["bellingham", "seattle", "spokane", "tacoma", "yakima"],
|
||||
"utah": ["ogden", "price", "provo", "salina", "salt_lake_city", "vernal"]
|
||||
}
|
||||
7
ats_configs/dlc.json
Normal file
7
ats_configs/dlc.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"arizona": "company.volatile.aport_phx.phoenix",
|
||||
"new_mexico": "company.volatile.aport_abq.albuquerque",
|
||||
"oregon": "company.volatile.aport_pcc.portland",
|
||||
"washington": "company.volatile.port_sea.seattle",
|
||||
"utah": "company.volatile.gal_oil_sit.price"
|
||||
}
|
||||
38
build.spec
Normal file
38
build.spec
Normal file
@@ -0,0 +1,38 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
block_cipher = None
|
||||
|
||||
a = Analysis(['__init__.py'],
|
||||
pathex=['.'],
|
||||
binaries=[],
|
||||
datas=[
|
||||
('ats_configs', 'ats_configs'),
|
||||
('ets2_configs', 'ets2_configs')
|
||||
],
|
||||
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 @@
|
||||
python setup.py build
|
||||
1
compile_pyinstaller.bat
Normal file
1
compile_pyinstaller.bat
Normal file
@@ -0,0 +1 @@
|
||||
pyinstaller build.spec
|
||||
13
convert_ui_to_py.bat
Normal file
13
convert_ui_to_py.bat
Normal file
@@ -0,0 +1,13 @@
|
||||
cls
|
||||
@echo off
|
||||
title Form converter
|
||||
|
||||
:SETUP
|
||||
echo Enter form name to convert into .py (without .ui):
|
||||
echo Type 'exit' to exit
|
||||
set/p "name=> "
|
||||
if %name%==exit goto EXIT
|
||||
pyuic5 %name%.ui -o %name%.py
|
||||
goto SETUP
|
||||
|
||||
:EXIT
|
||||
52
dataIO.py
Normal file
52
dataIO.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from json import decoder, load, dump
|
||||
from os import replace
|
||||
from os.path import splitext
|
||||
from random import randint
|
||||
|
||||
|
||||
class InvalidFileIO(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class DataIO:
|
||||
@staticmethod
|
||||
def _read_json(filename):
|
||||
with open(filename, encoding="utf-8", mode="r") as f:
|
||||
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:
|
||||
self._read_json(filename)
|
||||
return True
|
||||
except FileNotFoundError:
|
||||
return False
|
||||
except decoder.JSONDecodeError:
|
||||
return False
|
||||
|
||||
def load_json(self, filename):
|
||||
"""Loads json file"""
|
||||
return self._read_json(filename)
|
||||
|
||||
def save_json(self, filename, data):
|
||||
"""Atomically saves json file"""
|
||||
rnd = randint(1000, 9999)
|
||||
path, ext = splitext(filename)
|
||||
tmp_file = "{}-{}.tmp".format(path, rnd)
|
||||
self._save_json(tmp_file, data)
|
||||
try:
|
||||
self._read_json(tmp_file)
|
||||
except decoder.JSONDecodeError:
|
||||
return False
|
||||
replace(tmp_file, filename)
|
||||
return True
|
||||
|
||||
|
||||
dataIO = DataIO()
|
||||
17
ets2_configs/agencies.json
Normal file
17
ets2_configs/agencies.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"base": ["aberdeen", "berlin", "bialystok", "birmingham", "bremen", "brno", "brussel", "calais",
|
||||
"debrecen", "dortmund", "dover", "dresden", "edinburgh", "frankfurt", "glasgow", "graz", "grohningen",
|
||||
"hamburg", "hannover", "innsbruck", "kassel", "klagenfurt", "koln", "kosice", "leipzig", "liege",
|
||||
"linz", "liverpool", "lodz", "london", "luxembourg", "manchester", "mannheim", "munchen", "newcastle",
|
||||
"nurnberg", "ostrava", "pecs", "plymouth", "poznan", "prague", "sheffield", "southampton", "stuttgart",
|
||||
"swansea", "szczecin", "wien", "zurich"],
|
||||
"east": ["budapest", "gdansk", "krakow", "szeged", "warszava"],
|
||||
"scandinavia": ["aalborg", "bergen", "helsingborg", "kobenhavn", "malmo", "odense", "oslo", "stavanger",
|
||||
"stockholm"],
|
||||
"france": ["bordeaux", "clermont", "geneve", "larochelle", "lyon", "marseille", "metz", "paris", "reims", "rennes",
|
||||
"toulouse"],
|
||||
"italy": ["bologna", "catania", "milano", "napoli", "pescara", "roma", "taranto", "venezia"],
|
||||
"balticsea": ["daugavpils", "helsinki", "kaliningrad", "kaunas", "klaipeda", "kouvola", "lahti", "parnu", "pori",
|
||||
"pskov", "riga", "tallinn", "turku", "vilnius"],
|
||||
"blacksea": ["bucuresti", "cluj_napoca", "iasi", "istanbul", "plovdiv", "sofia"]
|
||||
}
|
||||
16
ets2_configs/dealers.json
Normal file
16
ets2_configs/dealers.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"base": ["aberdeen", "amsterdam", "berlin", "bern", "birmingham", "bratislava", "bremen", "brussel", "calais",
|
||||
"cardiff", "dortmund", "dortmund", "dresden", "dusseldorf", "edinburgh", "felixstowe", "frankfurt", "glasgow",
|
||||
"graz", "grimsby", "hamburg", "hannover", "leipzig", "lille", "london", "luxembourg", "manchester", "munchen",
|
||||
"newcastle", "nurnberg", "osnabruck", "plymouth", "prague", "rostock", "rotterdam", "salzburg", "strasbourg",
|
||||
"stuttgart", "szczecin", "wien", "wroclaw", "zurich"],
|
||||
"east": ["budapest", "gdansk", "krakow", "szeged", "warszawa"],
|
||||
"scandinavia": ["bergen", "goteborg", "kalmar", "kobenhavn", "linkoping", "oslo", "stockholm"],
|
||||
"france": ["bordeaux", "bourges", "brest", "geneve", "lemans", "limoges", "lyon", "marseille", "nantes", "paris",
|
||||
"toulouse"],
|
||||
"italy": ["bologna", "catania", "firenze", "milano", "napoli", "palermo", "roma", "taranto", "torino", "verona"],
|
||||
"balticsea": ["helsinki", "kaliningrad", "kaunas", "klaipeda", "lahti", "petersburg", "riga", "tallinn", "tartu",
|
||||
"turku", "vilnius"],
|
||||
"blacksea": ["brasov", "bucuresti", "cluj_napoca", "constanta", "edirne", "galati", "iasi", "istanbul", "pitesti",
|
||||
"plovdiv", "sofia", "veliko_tarnovo"]
|
||||
}
|
||||
8
ets2_configs/dlc.json
Normal file
8
ets2_configs/dlc.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"east": "company.volatile.quarry.katowice",
|
||||
"scandinavia": "company.volatile.sag_tre.oslo",
|
||||
"france": "company.volatile.lisette_log.roscoff",
|
||||
"italy": "company.volatile.marina_it.ancona",
|
||||
"balticsea": "company.volatile.polarislines.tallinn",
|
||||
"blacksea": "company.volatile.bhv.galati"
|
||||
}
|
||||
1
main/__init__.py
Normal file
1
main/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# initialize module 'main' for compile program
|
||||
@@ -6,25 +6,28 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>380</width>
|
||||
<height>380</height>
|
||||
<width>360</width>
|
||||
<height>370</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>380</width>
|
||||
<height>380</height>
|
||||
<width>360</width>
|
||||
<height>370</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>380</width>
|
||||
<height>380</height>
|
||||
<width>360</width>
|
||||
<height>370</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>SaveWizard</string>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QPushButton" name="apply">
|
||||
<property name="enabled">
|
||||
@@ -32,9 +35,9 @@
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<y>340</y>
|
||||
<width>151</width>
|
||||
<x>210</x>
|
||||
<y>330</y>
|
||||
<width>141</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -55,8 +58,8 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>340</y>
|
||||
<width>151</width>
|
||||
<y>330</y>
|
||||
<width>141</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -93,17 +96,30 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>80</y>
|
||||
<width>361</width>
|
||||
<y>50</y>
|
||||
<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_lineedit"/>
|
||||
<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>
|
||||
@@ -123,10 +139,23 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="xp_lineedit"/>
|
||||
<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>
|
||||
@@ -146,10 +175,23 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="loan_limit_lineedit"/>
|
||||
<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>
|
||||
@@ -174,14 +216,21 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>168</y>
|
||||
<width>361</width>
|
||||
<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_lineedit"/>
|
||||
<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">
|
||||
@@ -198,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_lineedit"/>
|
||||
<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_lineedit"/>
|
||||
<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_lineedit"/>
|
||||
<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_lineedit"/>
|
||||
<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>
|
||||
@@ -238,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_lineedit"/>
|
||||
<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">
|
||||
@@ -287,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>
|
||||
@@ -326,9 +446,9 @@
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>174</x>
|
||||
<y>348</y>
|
||||
<width>31</width>
|
||||
<x>160</x>
|
||||
<y>340</y>
|
||||
<width>41</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -336,200 +456,52 @@
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="owns_sc">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QCheckBox" name="dont_change_all_inf">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>50</y>
|
||||
<width>131</width>
|
||||
<height>16</height>
|
||||
<x>80</x>
|
||||
<y>300</y>
|
||||
<width>211</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Owns Scandinavia?</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="owns_fr">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>160</x>
|
||||
<y>50</y>
|
||||
<width>101</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Owns France?</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="owns_it">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>50</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Owns Italia?</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
<string>Don't save all changes in this form</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>path_button</tabstop>
|
||||
<tabstop>money_edit</tabstop>
|
||||
<tabstop>money_dont_change</tabstop>
|
||||
<tabstop>xp_edit</tabstop>
|
||||
<tabstop>xp_dont_change</tabstop>
|
||||
<tabstop>loan_limit_edit</tabstop>
|
||||
<tabstop>loan_limit_dont_change</tabstop>
|
||||
<tabstop>adr_edit</tabstop>
|
||||
<tabstop>adr_dont_change</tabstop>
|
||||
<tabstop>long_distance_edit</tabstop>
|
||||
<tabstop>long_distance_dont_change</tabstop>
|
||||
<tabstop>high_value_cargo_edit</tabstop>
|
||||
<tabstop>high_value_cargo_dont_change</tabstop>
|
||||
<tabstop>fragile_cargo_edit</tabstop>
|
||||
<tabstop>fragile_cargo_dont_change</tabstop>
|
||||
<tabstop>urgent_delivery_edit</tabstop>
|
||||
<tabstop>urgent_delivery_dont_change</tabstop>
|
||||
<tabstop>ecodriving_edit</tabstop>
|
||||
<tabstop>ecodriving_dont_change</tabstop>
|
||||
<tabstop>dont_change_all_inf</tabstop>
|
||||
<tabstop>backup</tabstop>
|
||||
<tabstop>second_window</tabstop>
|
||||
<tabstop>apply</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
206
main/script.py
Normal file
206
main/script.py
Normal file
@@ -0,0 +1,206 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
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):
|
||||
# Setup UI
|
||||
QMainWindow.__init__(self, parent, flags=Qt.Window)
|
||||
Ui_MainWindow.__init__(self)
|
||||
self.ui = Ui_MainWindow()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
self.file_path = ""
|
||||
self.old_file = ""
|
||||
|
||||
# Checking DLC file
|
||||
if dataIO.is_valid_json("dlc.json") is False:
|
||||
self.owns = False
|
||||
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:"],
|
||||
self.ui.loan_limit_edit: [self.ui.loan_limit_dont_change, "loan_limit:"],
|
||||
}
|
||||
self.skill_edits = {
|
||||
self.ui.long_distance_edit: [self.ui.long_distance_dont_change, "long_dist:"],
|
||||
self.ui.high_value_cargo_edit: [self.ui.high_value_cargo_dont_change, "heavy:"],
|
||||
self.ui.fragile_cargo_edit: [self.ui.fragile_cargo_dont_change, "fragile:"],
|
||||
self.ui.urgent_delivery_edit: [self.ui.urgent_delivery_dont_change, "urgent:"],
|
||||
self.ui.ecodriving_edit: [self.ui.ecodriving_dont_change, "mechanical:"],
|
||||
}
|
||||
|
||||
# Setting up validators for edits
|
||||
basic_validator = QRegExpValidator(QRegExp("[0-9]{1,9}"))
|
||||
for key in self.basic_edits.keys():
|
||||
key.setValidator(basic_validator)
|
||||
key.textEdited.connect(self.text_edited)
|
||||
|
||||
self.ui.adr_edit.textEdited.connect(self.text_edited) # TODO: Validator for ADR
|
||||
skills_validator = QRegExpValidator(QRegExp("[0-6]{1,1}"))
|
||||
for key in self.skill_edits.keys():
|
||||
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)
|
||||
self.ui.second_window.clicked.connect(self.open_second_win)
|
||||
|
||||
def text_edited(self):
|
||||
sender = self.sender()
|
||||
if sender in self.basic_edits:
|
||||
self.basic_edits[sender][0].setChecked(False)
|
||||
if sender == self.ui.adr_edit:
|
||||
self.ui.adr_dont_change.setChecked(False)
|
||||
if sender in self.skill_edits:
|
||||
self.skill_edits[sender][0].setChecked(False)
|
||||
|
||||
@staticmethod
|
||||
def get_adr(value):
|
||||
bin_code = bin(int(value))[2:]
|
||||
bin_code = "0" * (6 - len(bin_code)) + bin_code
|
||||
r = []
|
||||
for i in bin_code:
|
||||
r.append(i)
|
||||
return r
|
||||
|
||||
def get_adr_from_line(self):
|
||||
adr_list = list(self.ui.adr_edit.text())
|
||||
for i in adr_list:
|
||||
if (i == " ") or (i == ",") or (i == "."):
|
||||
adr_list.remove(i)
|
||||
return adr_list
|
||||
|
||||
def clear_fields(self):
|
||||
self.file_path = ""
|
||||
self.old_file = ""
|
||||
set_lines([])
|
||||
|
||||
if self.owns is not False:
|
||||
self.owns = {}
|
||||
|
||||
for key, value in self.basic_edits.items():
|
||||
key.setText("")
|
||||
value[0].setChecked(True)
|
||||
|
||||
self.ui.adr_edit.setText("")
|
||||
self.ui.adr_dont_change.setChecked(True)
|
||||
for key, value in self.skill_edits.items():
|
||||
key.setText("")
|
||||
value[0].setChecked(True)
|
||||
|
||||
self.ui.apply.setEnabled(False)
|
||||
self.ui.backup.setEnabled(False)
|
||||
self.ui.second_window.setEnabled(False)
|
||||
|
||||
def get_file_data(self, file):
|
||||
try:
|
||||
with open(file, "r") as f:
|
||||
self.old_file = f.read()
|
||||
except UnicodeDecodeError:
|
||||
try:
|
||||
system("SII_Decrypt.exe --on_file -i \"{}\"".format(file))
|
||||
with open(file, "r") as f:
|
||||
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.")
|
||||
return
|
||||
set_lines(self.old_file.split("\n"))
|
||||
|
||||
if self.owns is not False:
|
||||
self.owns["base"] = True
|
||||
for i in get_array_items(search_line("companies:")):
|
||||
for key, value in self.dlc.items():
|
||||
if value in i:
|
||||
self.owns[key] = True
|
||||
|
||||
for key, value in self.basic_edits.items():
|
||||
key.setText(str(get_value(search_line(value[1]))))
|
||||
|
||||
adr = self.get_adr(get_value(search_line("adr:")))
|
||||
adr_list = ""
|
||||
for i in range(6):
|
||||
adr_list += adr[i] + "," if i != 5 else adr[i]
|
||||
self.ui.adr_edit.setText(adr_list)
|
||||
|
||||
for key, value in self.skill_edits.items():
|
||||
key.setText(str(get_value(search_line(value[1]))))
|
||||
|
||||
self.ui.apply.setEnabled(True)
|
||||
self.ui.backup.setEnabled(True)
|
||||
self.ui.second_window.setEnabled(True)
|
||||
|
||||
def open_file_dialog(self):
|
||||
file, _ = QFileDialog.getOpenFileName(parent=self,
|
||||
caption=self.tr("Choose your save file..."),
|
||||
filter=self.tr("game.sii"))
|
||||
self.clear_fields()
|
||||
if file != "":
|
||||
self.file_path = file
|
||||
self.get_file_data(self.file_path)
|
||||
else:
|
||||
return
|
||||
|
||||
def apply_changes(self):
|
||||
if not self.ui.dont_change_all_inf.isChecked():
|
||||
for key, value in self.basic_edits.items():
|
||||
if value[0].isChecked() is False:
|
||||
set_value(search_line(value[1]), key.text())
|
||||
value[0].setChecked(True)
|
||||
if self.ui.adr_dont_change.isChecked() is False:
|
||||
adr_set = self.get_adr_from_line()
|
||||
if len(adr_set) < 6:
|
||||
show_message(QMessageBox.Critical, "Error", "ADR can't have less than 6 elements.")
|
||||
elif len(adr_set) > 6:
|
||||
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))
|
||||
for key, value in self.skill_edits.items():
|
||||
if value[0].isChecked() is False:
|
||||
set_value(search_line(value[1]), key.text())
|
||||
value[0].setChecked(True)
|
||||
backup = self.file_path + ".swbak"
|
||||
with open(backup, "w") as f:
|
||||
f.write(self.old_file)
|
||||
with open(self.file_path, "w") as f:
|
||||
f.write("\n".join(get_lines()))
|
||||
show_message(QMessageBox.Information, "Success", "Changes successfully applied!")
|
||||
self.get_file_data(self.file_path)
|
||||
return
|
||||
|
||||
def recover_backup(self):
|
||||
try:
|
||||
backup = self.file_path + ".swbak"
|
||||
f = open(backup, "r")
|
||||
with open(self.file_path, "w") as g:
|
||||
g.write(f.read())
|
||||
f.close()
|
||||
remove(backup)
|
||||
show_message(QMessageBox.Information, "Success", "Backup successfully recovered.")
|
||||
self.get_file_data(self.file_path)
|
||||
except IOError:
|
||||
show_message(QMessageBox.Critical, "Error", "Backup not found.")
|
||||
return
|
||||
|
||||
def open_second_win(self):
|
||||
second_win = SecondWindow(self.owns, self)
|
||||
second_win.show()
|
||||
1
second/__init__.py
Normal file
1
second/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# initialize module 'second' for compile program
|
||||
@@ -2,26 +2,40 @@
|
||||
<ui version="4.0">
|
||||
<class>SecondWindow</class>
|
||||
<widget class="QDialog" name="SecondWindow">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::WindowModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>660</width>
|
||||
<height>440</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>660</width>
|
||||
<height>400</height>
|
||||
<height>440</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>660</width>
|
||||
<height>400</height>
|
||||
<height>440</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Edit garages, cities and etc...</string>
|
||||
<string>Unlock garages, cities and etc...</string>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<widget class="QWidget" name="gridLayoutWidget_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<y>20</y>
|
||||
<width>131</width>
|
||||
<height>191</height>
|
||||
</rect>
|
||||
@@ -29,6 +43,18 @@
|
||||
<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>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="openLinks">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@@ -45,6 +71,12 @@
|
||||
<property name="text">
|
||||
<string>Owned garages:</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
@@ -66,32 +98,12 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>10</y>
|
||||
<y>20</y>
|
||||
<width>131</width>
|
||||
<height>191</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="cities_layout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QTextBrowser" name="cities_text">
|
||||
<property name="openLinks">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="cities_analyze">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Analyze</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="cities_visited_label">
|
||||
<property name="font">
|
||||
@@ -103,6 +115,28 @@
|
||||
<property name="text">
|
||||
<string>Visited cities:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="openLinks">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -111,9 +145,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>220</y>
|
||||
<y>250</y>
|
||||
<width>131</width>
|
||||
<height>171</height>
|
||||
<height>181</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="dealerships_layout">
|
||||
@@ -128,21 +162,27 @@
|
||||
<property name="text">
|
||||
<string>Dealerships:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTextBrowser" name="dealerships_text"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="dealerships_analyze">
|
||||
<widget class="QTextBrowser" name="dealerships_text">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Analyze</string>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="openLinks">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -152,9 +192,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>340</x>
|
||||
<y>220</y>
|
||||
<y>250</y>
|
||||
<width>131</width>
|
||||
<height>171</height>
|
||||
<height>181</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="agencies_layout">
|
||||
@@ -169,21 +209,27 @@
|
||||
<property name="text">
|
||||
<string>Agencies:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTextBrowser" name="agencies_text"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="agencies_analyze">
|
||||
<widget class="QTextBrowser" name="agencies_text">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Analyze</string>
|
||||
<property name="acceptDrops">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="openLinks">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -195,7 +241,7 @@
|
||||
<x>320</x>
|
||||
<y>10</y>
|
||||
<width>20</width>
|
||||
<height>381</height>
|
||||
<height>420</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
@@ -206,7 +252,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>200</y>
|
||||
<y>230</y>
|
||||
<width>641</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
@@ -221,11 +267,11 @@
|
||||
<x>150</x>
|
||||
<y>10</y>
|
||||
<width>171</width>
|
||||
<height>107</height>
|
||||
<height>135</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="add_garage">
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="garage_add">
|
||||
<property name="font">
|
||||
<font>
|
||||
@@ -234,15 +280,22 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
<string>Unlock</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="garage_lineedit"/>
|
||||
<widget class="QLineEdit" name="garage_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="garage_unlock_all">
|
||||
<item row="4" column="0">
|
||||
<widget class="QPushButton" name="garage_add_all">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
@@ -265,6 +318,19 @@
|
||||
<property name="text">
|
||||
<string>Enter garage name:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QComboBox" name="garage_size">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -273,9 +339,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>480</x>
|
||||
<y>50</y>
|
||||
<y>60</y>
|
||||
<width>171</width>
|
||||
<height>107</height>
|
||||
<height>110</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="add_city">
|
||||
@@ -288,12 +354,19 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
<string>Visit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="city_lineedit"/>
|
||||
<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">
|
||||
@@ -306,10 +379,13 @@
|
||||
<property name="text">
|
||||
<string>Enter city name:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="city_unlock_all">
|
||||
<widget class="QPushButton" name="city_add_all">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
@@ -327,14 +403,14 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>250</y>
|
||||
<y>290</y>
|
||||
<width>171</width>
|
||||
<height>107</height>
|
||||
<height>108</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="add_dealership">
|
||||
<layout class="QGridLayout" name="add_dealer">
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="dealership_add">
|
||||
<widget class="QPushButton" name="dealer_add">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
@@ -342,15 +418,22 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
<string>Research</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="dealership_lineedit"/>
|
||||
<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="dealership_label">
|
||||
<widget class="QLabel" name="dealer_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
@@ -360,10 +443,13 @@
|
||||
<property name="text">
|
||||
<string>Enter dealership name:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="dealership_unlock_all">
|
||||
<widget class="QPushButton" name="dealer_add_all">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
@@ -371,7 +457,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Unlock all</string>
|
||||
<string>Research all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -381,9 +467,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>480</x>
|
||||
<y>250</y>
|
||||
<y>290</y>
|
||||
<width>171</width>
|
||||
<height>107</height>
|
||||
<height>108</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="add_agency">
|
||||
@@ -396,13 +482,10 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
<string>Research</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="agency_lineedit"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="agency_label">
|
||||
<property name="font">
|
||||
@@ -414,10 +497,13 @@
|
||||
<property name="text">
|
||||
<string>Enter agency name:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QPushButton" name="agency_unlock_all">
|
||||
<widget class="QPushButton" name="agency_add_all">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
@@ -425,7 +511,17 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Unlock all</string>
|
||||
<string>Research all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="agency_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -435,7 +531,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>120</y>
|
||||
<y>150</y>
|
||||
<width>171</width>
|
||||
<height>80</height>
|
||||
</rect>
|
||||
@@ -452,10 +548,20 @@
|
||||
<property name="text">
|
||||
<string>Your headquarter:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="headquarter_lineedit"/>
|
||||
<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">
|
||||
@@ -472,19 +578,29 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<zorder>gridLayoutWidget_4</zorder>
|
||||
<zorder>gridLayoutWidget_5</zorder>
|
||||
<zorder>gridLayoutWidget_2</zorder>
|
||||
<zorder>gridLayoutWidget_6</zorder>
|
||||
<zorder>v_line</zorder>
|
||||
<zorder>h_line</zorder>
|
||||
<zorder>gridLayoutWidget</zorder>
|
||||
<zorder>gridLayoutWidget_3</zorder>
|
||||
<zorder>gridLayoutWidget_7</zorder>
|
||||
<zorder>gridLayoutWidget_8</zorder>
|
||||
<zorder>garage_label</zorder>
|
||||
<zorder>gridLayoutWidget_9</zorder>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>garages_text</tabstop>
|
||||
<tabstop>garages_analyze</tabstop>
|
||||
<tabstop>garage_edit</tabstop>
|
||||
<tabstop>garage_size</tabstop>
|
||||
<tabstop>garage_add</tabstop>
|
||||
<tabstop>garage_add_all</tabstop>
|
||||
<tabstop>headquarter_edit</tabstop>
|
||||
<tabstop>headquarter_change</tabstop>
|
||||
<tabstop>cities_text</tabstop>
|
||||
<tabstop>city_edit</tabstop>
|
||||
<tabstop>city_add</tabstop>
|
||||
<tabstop>city_add_all</tabstop>
|
||||
<tabstop>dealerships_text</tabstop>
|
||||
<tabstop>dealer_edit</tabstop>
|
||||
<tabstop>dealer_add</tabstop>
|
||||
<tabstop>dealer_add_all</tabstop>
|
||||
<tabstop>agencies_text</tabstop>
|
||||
<tabstop>agency_edit</tabstop>
|
||||
<tabstop>agency_add</tabstop>
|
||||
<tabstop>agency_add_all</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
257
second/script.py
Normal file
257
second/script.py
Normal file
@@ -0,0 +1,257 @@
|
||||
#!/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
|
||||
|
||||
garages_stat = {
|
||||
"Small": [1, 1],
|
||||
"Medium": [2, 3],
|
||||
"Big": [3, 5]
|
||||
}
|
||||
|
||||
|
||||
class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
def __init__(self, owns_list, parent=None):
|
||||
# Setup UI
|
||||
QDialog.__init__(self, parent, flags=Qt.Window)
|
||||
Ui_SecondWindow.__init__(self)
|
||||
self.ui = Ui_SecondWindow()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
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(QMessageBox.Warning, "Warning", "'dealers.json' not found, dealers editing has been disabled")
|
||||
else:
|
||||
self.dealers = []
|
||||
self.dealers_file = dataIO.load_json("dealers.json")
|
||||
|
||||
if dataIO.is_valid_json("agencies.json") is False:
|
||||
self.agencies = False
|
||||
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' not found, agencies editing has been "
|
||||
"disabled")
|
||||
else:
|
||||
self.agencies = []
|
||||
self.agencies_file = dataIO.load_json("agencies.json")
|
||||
|
||||
self.ui.garage_size.addItem("Small")
|
||||
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)
|
||||
self.ui.headquarter_change.clicked.connect(self.change_headquarter)
|
||||
self.ui.city_add.clicked.connect(self.add_city)
|
||||
self.ui.city_add_all.clicked.connect(self.add_all_cities)
|
||||
self.ui.dealer_add.clicked.connect(self.add_dealer)
|
||||
self.ui.dealer_add_all.clicked.connect(self.add_all_dealers)
|
||||
self.ui.agency_add.clicked.connect(self.add_agency)
|
||||
self.ui.agency_add_all.clicked.connect(self.add_all_agencies)
|
||||
|
||||
if self.owns:
|
||||
self.fill_list(self.dealers, self.dealers_file)
|
||||
self.fill_list(self.agencies, self.agencies_file)
|
||||
# Checking save-file
|
||||
self.check_cities()
|
||||
self.check_dealers()
|
||||
self.check_agencies()
|
||||
|
||||
@staticmethod
|
||||
def purchased_garages():
|
||||
garages = []
|
||||
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 all_cities():
|
||||
cities = []
|
||||
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)
|
||||
return cities
|
||||
|
||||
def fill_list(self, array, file):
|
||||
if array is False:
|
||||
return
|
||||
for key in self.owns.keys():
|
||||
if key not in file:
|
||||
continue
|
||||
for value in file[key]:
|
||||
array.append(value)
|
||||
|
||||
def check_garage_size(self):
|
||||
stat = garages_stat[self.ui.garage_size.currentText()]
|
||||
return str(stat[0]), stat[1]
|
||||
|
||||
def check_garages(self):
|
||||
self.ui.garages_text.clear()
|
||||
for garage in self.purchased_garages():
|
||||
self.ui.garages_text.append(garage)
|
||||
|
||||
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.")
|
||||
return
|
||||
self.ui.garage_edit.setText("")
|
||||
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:
|
||||
show_message(QMessageBox.Critical, "Error", "Garage in \"{}\" already unlocked.".format(garage))
|
||||
|
||||
def add_all_garages(self):
|
||||
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(QMessageBox.Critical, "Error", "Enter a name for the city.")
|
||||
return
|
||||
if get_value(search_line("hq_city:")) == hq:
|
||||
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.")
|
||||
else:
|
||||
set_value(search_line("hq_city:"), 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()
|
||||
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(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(QMessageBox.Information, "Success", "City \"{}\" successfully visited.".format(city))
|
||||
self.check_cities()
|
||||
else:
|
||||
show_message(QMessageBox.Critical, "Error", "You already visited \"{}\".".format(city))
|
||||
|
||||
def add_all_cities(self):
|
||||
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(QMessageBox.Information, "Success", "All cities successfully visited.")
|
||||
self.check_cities()
|
||||
|
||||
def check_dealers(self):
|
||||
self.ui.dealerships_text.clear()
|
||||
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(QMessageBox.Critical, "Error", "Enter a name for the city.")
|
||||
return
|
||||
self.ui.dealer_edit.setText("")
|
||||
if dealer not in self.dealers:
|
||||
show_message(QMessageBox.Critical, "Error", "There is no dealership in that city.")
|
||||
elif dealer in get_array_items(search_line("unlocked_dealers:")):
|
||||
show_message(QMessageBox.Information, "Info", "This dealership already unlocked.")
|
||||
else:
|
||||
add_array_value(search_line("unlocked_dealers:"), 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 all_cities and dealer not in visited_dealers:
|
||||
add_array_value(search_line("unlocked_dealers:"), dealer)
|
||||
show_message(QMessageBox.Information, "Success", "All dealerships unlocked.")
|
||||
self.check_dealers()
|
||||
|
||||
def check_agencies(self):
|
||||
self.ui.agencies_text.clear()
|
||||
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(QMessageBox.Critical, "Error", "Enter a name for the city.")
|
||||
return
|
||||
self.ui.agency_edit.setText("")
|
||||
if agency not in self.agencies:
|
||||
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(QMessageBox.Information, "Info", "Recruitment agency is already unlocked.")
|
||||
else:
|
||||
add_array_value(search_line("unlocked_recruitments:"), 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 all_cities and agency not in visited_agencies:
|
||||
add_array_value(search_line("unlocked_recruitments:"), agency)
|
||||
show_message(QMessageBox.Information, "Success", "All recruitment agencies unlocked.")
|
||||
self.check_agencies()
|
||||
30
setup.py
Normal file
30
setup.py
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from cx_Freeze import setup, Executable
|
||||
|
||||
executables = [Executable('__init__.py', targetName='SaveWizard.exe', base='Win32GUI')]
|
||||
excludes = ['email', 'html', 'http', 'logging', 'pydoc_data', 'unittest', 'urllib', 'xml', 'tempfile', 'select', 'pwd',
|
||||
'datetime', 'shlex', 'shutil', 'socket', 'platform', 'webbrowser', 'pydoc', 'selectors', 'tty', 'inspect',
|
||||
'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', 'ats_configs', 'ets2_configs']
|
||||
options = {
|
||||
'build_exe': {
|
||||
'excludes': excludes,
|
||||
'include_msvcr': True,
|
||||
'build_exe': 'stable_build',
|
||||
'include_files': include_files,
|
||||
'zip_include_packages': zip_include_packages,
|
||||
}
|
||||
}
|
||||
|
||||
setup(
|
||||
name='SaveWizard',
|
||||
version='1.1.1',
|
||||
description='For editing ETS2 sii files',
|
||||
executables=executables,
|
||||
options=options,
|
||||
requires=['PyQt5']
|
||||
)
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
python setup.py build
|
||||
@@ -1 +0,0 @@
|
||||
pyuic5 main_form.ui -o main_form.py
|
||||
@@ -1 +0,0 @@
|
||||
pyuic5 second_form.ui -o second_form.py
|
||||
108
src/funcs.py
108
src/funcs.py
@@ -1,108 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
from re import search, match, sub
|
||||
|
||||
|
||||
class Functions:
|
||||
# TODO: My Functions
|
||||
@staticmethod
|
||||
def showMsgBox(title: str, text: str):
|
||||
box = QMessageBox()
|
||||
box.setWindowTitle(title)
|
||||
box.setText(text)
|
||||
box.exec_()
|
||||
return
|
||||
|
||||
# TODO: Default functions
|
||||
@staticmethod
|
||||
def getADR(value):
|
||||
bincode = bin(int(value))[2:]
|
||||
bincode = "0" * (6 - len(bincode)) + bincode
|
||||
r = []
|
||||
for i in bincode:
|
||||
r.append(i)
|
||||
return r
|
||||
|
||||
@staticmethod
|
||||
def searchline(lines, term, start=0, cancel=r"thisstringmustnotexist"):
|
||||
if search(term, lines[start]):
|
||||
return start
|
||||
start += 1
|
||||
while start <= len(lines) - 1:
|
||||
if search(term, lines[start]):
|
||||
return start
|
||||
if search(cancel, lines[start]):
|
||||
return None
|
||||
start += 1
|
||||
return None
|
||||
|
||||
def searchlineinunit(self, lines, term, unit):
|
||||
line = self.searchline(lines, " : " + unit + " {")
|
||||
return self.searchline(lines, term, start=line, cancel="}")
|
||||
|
||||
def searchalllines(self, lines, term):
|
||||
matches = []
|
||||
start = 0
|
||||
while self.searchline(lines, term, start=start + 1):
|
||||
start = self.searchline(lines, term, start=start + 1)
|
||||
matches.append(start)
|
||||
if matches is None:
|
||||
return None
|
||||
return matches
|
||||
|
||||
@staticmethod
|
||||
def getvalue(lines, line):
|
||||
return search(r": (.+)$", lines[line]).group(1)
|
||||
|
||||
@staticmethod
|
||||
def setvalue(lines, line, value):
|
||||
name = match(r"(.+):", lines[line]).group(1)
|
||||
lines[line] = name + ": " + value
|
||||
|
||||
@staticmethod
|
||||
def getunitname(lines, line):
|
||||
return search(r" : (.+) {$", lines[line]).group(1)
|
||||
|
||||
@staticmethod
|
||||
def getarraylength(lines, line):
|
||||
return int(search(r": ([0-9]+)$", lines[line]).group(1))
|
||||
|
||||
@staticmethod
|
||||
def getarrayvaluebyindex(lines, line, index):
|
||||
return search(r": (.+)$", lines[line + index + 1]).group(1)
|
||||
|
||||
def getarrayindexbyvalue(self, lines, line, value):
|
||||
count = 0
|
||||
for i in range(self.getarraylength(lines, line)):
|
||||
if self.getvalue(lines, line + count + 1) == value:
|
||||
return count
|
||||
count += 1
|
||||
return None
|
||||
|
||||
def getarrayitems(self, lines, line):
|
||||
items = []
|
||||
count = self.getarraylength(lines, line)
|
||||
for i in range(count):
|
||||
items.append(search(r": (.+)$", lines[line + i + 1]).group(1))
|
||||
if items is None:
|
||||
return None
|
||||
return items
|
||||
|
||||
def addarrayvalue(self, lines, line, value):
|
||||
count = self.getarraylength(lines, line)
|
||||
name = match(r"(.+):", lines[line]).group(1)
|
||||
lines[line] = name + ": " + str(count + 1)
|
||||
lines.insert(line + count + 1, name + "[" + str(count) + "]: " + value)
|
||||
|
||||
def removearrayvalue(self, lines, line, value):
|
||||
name = match(r"(.+):", lines[line]).group(1)
|
||||
del lines[line + 1 + self.getarrayindexbyvalue(lines, line, value)]
|
||||
lines[line] = name + ": " + str(self.getarraylength(lines, line) - 1)
|
||||
for i in range(self.getarraylength(lines, line)):
|
||||
lines[line + i + 1] = sub(r"\[[0-9]+\]", "[" + str(i) + "]", lines[line + i + 1])
|
||||
|
||||
def changearrayvalue(self, lines, line, index, value):
|
||||
line += index + 1
|
||||
self.setvalue(lines, line, value)
|
||||
270
src/main_form.py
270
src/main_form.py
@@ -1,270 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'main_form.ui'
|
||||
#
|
||||
# Created by: PyQt5 UI code generator 5.6
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
|
||||
class Ui_MainWindow(object):
|
||||
def setupUi(self, MainWindow):
|
||||
MainWindow.setObjectName("MainWindow")
|
||||
MainWindow.resize(380, 380)
|
||||
MainWindow.setMinimumSize(QtCore.QSize(380, 380))
|
||||
MainWindow.setMaximumSize(QtCore.QSize(380, 380))
|
||||
self.centralwidget = QtWidgets.QWidget(MainWindow)
|
||||
self.centralwidget.setObjectName("centralwidget")
|
||||
self.apply = QtWidgets.QPushButton(self.centralwidget)
|
||||
self.apply.setEnabled(False)
|
||||
self.apply.setGeometry(QtCore.QRect(220, 340, 151, 31))
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(12)
|
||||
self.apply.setFont(font)
|
||||
self.apply.setObjectName("apply")
|
||||
self.backup = QtWidgets.QPushButton(self.centralwidget)
|
||||
self.backup.setEnabled(False)
|
||||
self.backup.setGeometry(QtCore.QRect(10, 340, 151, 31))
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(12)
|
||||
self.backup.setFont(font)
|
||||
self.backup.setObjectName("backup")
|
||||
self.path_button = QtWidgets.QPushButton(self.centralwidget)
|
||||
self.path_button.setGeometry(QtCore.QRect(10, 10, 161, 31))
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(14)
|
||||
self.path_button.setFont(font)
|
||||
self.path_button.setObjectName("path_button")
|
||||
self.gridLayoutWidget = QtWidgets.QWidget(self.centralwidget)
|
||||
self.gridLayoutWidget.setGeometry(QtCore.QRect(10, 80, 361, 81))
|
||||
self.gridLayoutWidget.setObjectName("gridLayoutWidget")
|
||||
self.basic_inf_layout = QtWidgets.QGridLayout(self.gridLayoutWidget)
|
||||
self.basic_inf_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.basic_inf_layout.setObjectName("basic_inf_layout")
|
||||
self.money_lineedit = QtWidgets.QLineEdit(self.gridLayoutWidget)
|
||||
self.money_lineedit.setObjectName("money_lineedit")
|
||||
self.basic_inf_layout.addWidget(self.money_lineedit, 0, 1, 1, 1)
|
||||
self.money_dont_change = QtWidgets.QCheckBox(self.gridLayoutWidget)
|
||||
self.money_dont_change.setObjectName("money_dont_change")
|
||||
self.basic_inf_layout.addWidget(self.money_dont_change, 0, 2, 1, 1)
|
||||
self.xp_label = QtWidgets.QLabel(self.gridLayoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(14)
|
||||
self.xp_label.setFont(font)
|
||||
self.xp_label.setObjectName("xp_label")
|
||||
self.basic_inf_layout.addWidget(self.xp_label, 1, 0, 1, 1)
|
||||
self.xp_lineedit = QtWidgets.QLineEdit(self.gridLayoutWidget)
|
||||
self.xp_lineedit.setObjectName("xp_lineedit")
|
||||
self.basic_inf_layout.addWidget(self.xp_lineedit, 1, 1, 1, 1)
|
||||
self.xp_dont_change = QtWidgets.QCheckBox(self.gridLayoutWidget)
|
||||
self.xp_dont_change.setObjectName("xp_dont_change")
|
||||
self.basic_inf_layout.addWidget(self.xp_dont_change, 1, 2, 1, 1)
|
||||
self.loan_limit_label = QtWidgets.QLabel(self.gridLayoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(14)
|
||||
self.loan_limit_label.setFont(font)
|
||||
self.loan_limit_label.setObjectName("loan_limit_label")
|
||||
self.basic_inf_layout.addWidget(self.loan_limit_label, 2, 0, 1, 1)
|
||||
self.loan_limit_lineedit = QtWidgets.QLineEdit(self.gridLayoutWidget)
|
||||
self.loan_limit_lineedit.setObjectName("loan_limit_lineedit")
|
||||
self.basic_inf_layout.addWidget(self.loan_limit_lineedit, 2, 1, 1, 1)
|
||||
self.loan_limit_dont_change = QtWidgets.QCheckBox(self.gridLayoutWidget)
|
||||
self.loan_limit_dont_change.setObjectName("loan_limit_dont_change")
|
||||
self.basic_inf_layout.addWidget(self.loan_limit_dont_change, 2, 2, 1, 1)
|
||||
self.money_label = QtWidgets.QLabel(self.gridLayoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(14)
|
||||
self.money_label.setFont(font)
|
||||
self.money_label.setObjectName("money_label")
|
||||
self.basic_inf_layout.addWidget(self.money_label, 0, 0, 1, 1)
|
||||
self.gridLayoutWidget_3 = QtWidgets.QWidget(self.centralwidget)
|
||||
self.gridLayoutWidget_3.setGeometry(QtCore.QRect(10, 168, 361, 161))
|
||||
self.gridLayoutWidget_3.setObjectName("gridLayoutWidget_3")
|
||||
self.skills_layout = QtWidgets.QGridLayout(self.gridLayoutWidget_3)
|
||||
self.skills_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.skills_layout.setObjectName("skills_layout")
|
||||
self.long_distance_lineedit = QtWidgets.QLineEdit(self.gridLayoutWidget_3)
|
||||
self.long_distance_lineedit.setObjectName("long_distance_lineedit")
|
||||
self.skills_layout.addWidget(self.long_distance_lineedit, 1, 1, 1, 1)
|
||||
self.urgent_delivery_label = QtWidgets.QLabel(self.gridLayoutWidget_3)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(13)
|
||||
self.urgent_delivery_label.setFont(font)
|
||||
self.urgent_delivery_label.setObjectName("urgent_delivery_label")
|
||||
self.skills_layout.addWidget(self.urgent_delivery_label, 4, 0, 1, 1)
|
||||
self.ecodriving_dont_change = QtWidgets.QCheckBox(self.gridLayoutWidget_3)
|
||||
self.ecodriving_dont_change.setObjectName("ecodriving_dont_change")
|
||||
self.skills_layout.addWidget(self.ecodriving_dont_change, 5, 2, 1, 1)
|
||||
self.adr_lineedit = QtWidgets.QLineEdit(self.gridLayoutWidget_3)
|
||||
self.adr_lineedit.setObjectName("adr_lineedit")
|
||||
self.skills_layout.addWidget(self.adr_lineedit, 0, 1, 1, 1)
|
||||
self.urgent_delivery_lineedit = QtWidgets.QLineEdit(self.gridLayoutWidget_3)
|
||||
self.urgent_delivery_lineedit.setObjectName("urgent_delivery_lineedit")
|
||||
self.skills_layout.addWidget(self.urgent_delivery_lineedit, 4, 1, 1, 1)
|
||||
self.fragile_cargo_dont_change = QtWidgets.QCheckBox(self.gridLayoutWidget_3)
|
||||
self.fragile_cargo_dont_change.setObjectName("fragile_cargo_dont_change")
|
||||
self.skills_layout.addWidget(self.fragile_cargo_dont_change, 3, 2, 1, 1)
|
||||
self.ecodriving_lineedit = QtWidgets.QLineEdit(self.gridLayoutWidget_3)
|
||||
self.ecodriving_lineedit.setObjectName("ecodriving_lineedit")
|
||||
self.skills_layout.addWidget(self.ecodriving_lineedit, 5, 1, 1, 1)
|
||||
self.high_value_cargo_dont_change = QtWidgets.QCheckBox(self.gridLayoutWidget_3)
|
||||
self.high_value_cargo_dont_change.setObjectName("high_value_cargo_dont_change")
|
||||
self.skills_layout.addWidget(self.high_value_cargo_dont_change, 2, 2, 1, 1)
|
||||
self.fragile_cargo_lineedit = QtWidgets.QLineEdit(self.gridLayoutWidget_3)
|
||||
self.fragile_cargo_lineedit.setObjectName("fragile_cargo_lineedit")
|
||||
self.skills_layout.addWidget(self.fragile_cargo_lineedit, 3, 1, 1, 1)
|
||||
self.adr_dont_change = QtWidgets.QCheckBox(self.gridLayoutWidget_3)
|
||||
self.adr_dont_change.setObjectName("adr_dont_change")
|
||||
self.skills_layout.addWidget(self.adr_dont_change, 0, 2, 1, 1)
|
||||
self.long_distance_dont_change = QtWidgets.QCheckBox(self.gridLayoutWidget_3)
|
||||
self.long_distance_dont_change.setObjectName("long_distance_dont_change")
|
||||
self.skills_layout.addWidget(self.long_distance_dont_change, 1, 2, 1, 1)
|
||||
self.high_value_cargo_lineedit = QtWidgets.QLineEdit(self.gridLayoutWidget_3)
|
||||
self.high_value_cargo_lineedit.setObjectName("high_value_cargo_lineedit")
|
||||
self.skills_layout.addWidget(self.high_value_cargo_lineedit, 2, 1, 1, 1)
|
||||
self.high_value_cargo_label = QtWidgets.QLabel(self.gridLayoutWidget_3)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(13)
|
||||
self.high_value_cargo_label.setFont(font)
|
||||
self.high_value_cargo_label.setObjectName("high_value_cargo_label")
|
||||
self.skills_layout.addWidget(self.high_value_cargo_label, 2, 0, 1, 1)
|
||||
self.fragile_cargo_label = QtWidgets.QLabel(self.gridLayoutWidget_3)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(13)
|
||||
self.fragile_cargo_label.setFont(font)
|
||||
self.fragile_cargo_label.setObjectName("fragile_cargo_label")
|
||||
self.skills_layout.addWidget(self.fragile_cargo_label, 3, 0, 1, 1)
|
||||
self.ecodriving_label = QtWidgets.QLabel(self.gridLayoutWidget_3)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(13)
|
||||
self.ecodriving_label.setFont(font)
|
||||
self.ecodriving_label.setObjectName("ecodriving_label")
|
||||
self.skills_layout.addWidget(self.ecodriving_label, 5, 0, 1, 1)
|
||||
self.urgent_delivery_dont_change = QtWidgets.QCheckBox(self.gridLayoutWidget_3)
|
||||
self.urgent_delivery_dont_change.setObjectName("urgent_delivery_dont_change")
|
||||
self.skills_layout.addWidget(self.urgent_delivery_dont_change, 4, 2, 1, 1)
|
||||
self.long_distance_label = QtWidgets.QLabel(self.gridLayoutWidget_3)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(13)
|
||||
self.long_distance_label.setFont(font)
|
||||
self.long_distance_label.setObjectName("long_distance_label")
|
||||
self.skills_layout.addWidget(self.long_distance_label, 1, 0, 1, 1)
|
||||
self.adr_label = QtWidgets.QLabel(self.gridLayoutWidget_3)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(13)
|
||||
self.adr_label.setFont(font)
|
||||
self.adr_label.setObjectName("adr_label")
|
||||
self.skills_layout.addWidget(self.adr_label, 0, 0, 1, 1)
|
||||
self.second_window = QtWidgets.QToolButton(self.centralwidget)
|
||||
self.second_window.setEnabled(False)
|
||||
self.second_window.setGeometry(QtCore.QRect(174, 348, 31, 21))
|
||||
self.second_window.setObjectName("second_window")
|
||||
self.owns_sc = QtWidgets.QCheckBox(self.centralwidget)
|
||||
self.owns_sc.setEnabled(False)
|
||||
self.owns_sc.setGeometry(QtCore.QRect(0, 50, 131, 16))
|
||||
palette = QtGui.QPalette()
|
||||
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
|
||||
brush.setStyle(QtCore.Qt.SolidPattern)
|
||||
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
|
||||
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
|
||||
brush.setStyle(QtCore.Qt.SolidPattern)
|
||||
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
|
||||
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
|
||||
brush.setStyle(QtCore.Qt.SolidPattern)
|
||||
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
|
||||
self.owns_sc.setPalette(palette)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
self.owns_sc.setFont(font)
|
||||
self.owns_sc.setLayoutDirection(QtCore.Qt.RightToLeft)
|
||||
self.owns_sc.setObjectName("owns_sc")
|
||||
self.owns_fr = QtWidgets.QCheckBox(self.centralwidget)
|
||||
self.owns_fr.setEnabled(False)
|
||||
self.owns_fr.setGeometry(QtCore.QRect(160, 50, 101, 16))
|
||||
palette = QtGui.QPalette()
|
||||
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
|
||||
brush.setStyle(QtCore.Qt.SolidPattern)
|
||||
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
|
||||
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
|
||||
brush.setStyle(QtCore.Qt.SolidPattern)
|
||||
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
|
||||
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
|
||||
brush.setStyle(QtCore.Qt.SolidPattern)
|
||||
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
|
||||
self.owns_fr.setPalette(palette)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
self.owns_fr.setFont(font)
|
||||
self.owns_fr.setLayoutDirection(QtCore.Qt.RightToLeft)
|
||||
self.owns_fr.setCheckable(True)
|
||||
self.owns_fr.setObjectName("owns_fr")
|
||||
self.owns_it = QtWidgets.QCheckBox(self.centralwidget)
|
||||
self.owns_it.setEnabled(False)
|
||||
self.owns_it.setGeometry(QtCore.QRect(280, 50, 91, 16))
|
||||
palette = QtGui.QPalette()
|
||||
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
|
||||
brush.setStyle(QtCore.Qt.SolidPattern)
|
||||
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush)
|
||||
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
|
||||
brush.setStyle(QtCore.Qt.SolidPattern)
|
||||
palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush)
|
||||
brush = QtGui.QBrush(QtGui.QColor(0, 0, 0))
|
||||
brush.setStyle(QtCore.Qt.SolidPattern)
|
||||
palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush)
|
||||
self.owns_it.setPalette(palette)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
self.owns_it.setFont(font)
|
||||
self.owns_it.setLayoutDirection(QtCore.Qt.RightToLeft)
|
||||
self.owns_it.setCheckable(True)
|
||||
self.owns_it.setObjectName("owns_it")
|
||||
MainWindow.setCentralWidget(self.centralwidget)
|
||||
|
||||
self.retranslateUi(MainWindow)
|
||||
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
||||
|
||||
def retranslateUi(self, MainWindow):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
MainWindow.setWindowTitle(_translate("MainWindow", "SaveWizard"))
|
||||
self.apply.setText(_translate("MainWindow", "Apply changes"))
|
||||
self.backup.setText(_translate("MainWindow", "Recover backup"))
|
||||
self.path_button.setText(_translate("MainWindow", "Choose save file..."))
|
||||
self.money_dont_change.setText(_translate("MainWindow", "Don\'t change"))
|
||||
self.xp_label.setText(_translate("MainWindow", "Experience:"))
|
||||
self.xp_dont_change.setText(_translate("MainWindow", "Don\'t change"))
|
||||
self.loan_limit_label.setText(_translate("MainWindow", "Loan limit:"))
|
||||
self.loan_limit_dont_change.setText(_translate("MainWindow", "Don\'t change"))
|
||||
self.money_label.setText(_translate("MainWindow", "Money:"))
|
||||
self.urgent_delivery_label.setText(_translate("MainWindow", "Urgent delivery:"))
|
||||
self.ecodriving_dont_change.setText(_translate("MainWindow", "Don\'t change"))
|
||||
self.fragile_cargo_dont_change.setText(_translate("MainWindow", "Don\'t change"))
|
||||
self.high_value_cargo_dont_change.setText(_translate("MainWindow", "Don\'t change"))
|
||||
self.adr_dont_change.setText(_translate("MainWindow", "Don\'t change"))
|
||||
self.long_distance_dont_change.setText(_translate("MainWindow", "Don\'t change"))
|
||||
self.high_value_cargo_label.setText(_translate("MainWindow", "High value cargo:"))
|
||||
self.fragile_cargo_label.setText(_translate("MainWindow", "Fragile cargo:"))
|
||||
self.ecodriving_label.setText(_translate("MainWindow", "Ecodriving:"))
|
||||
self.urgent_delivery_dont_change.setText(_translate("MainWindow", "Don\'t change"))
|
||||
self.long_distance_label.setText(_translate("MainWindow", "Long distance:"))
|
||||
self.adr_label.setText(_translate("MainWindow", "ADR:"))
|
||||
self.second_window.setText(_translate("MainWindow", "..."))
|
||||
self.owns_sc.setText(_translate("MainWindow", "Owns Scandinavia?"))
|
||||
self.owns_fr.setText(_translate("MainWindow", "Owns France?"))
|
||||
self.owns_it.setText(_translate("MainWindow", "Owns Italia?"))
|
||||
|
||||
@@ -1,279 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt5.QtWidgets import QMainWindow
|
||||
from funcs import *
|
||||
from main_form import *
|
||||
from wsgiref.validate import validator
|
||||
|
||||
|
||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
# TODO: Constructor
|
||||
def __init__(self, parent=None):
|
||||
QMainWindow.__init__(self, parent)
|
||||
Ui_MainWindow.__init__(self)
|
||||
self.ui = Ui_MainWindow()
|
||||
self.ui.setupUi(self)
|
||||
self.funcs = Functions()
|
||||
#
|
||||
self.file_path = ""
|
||||
self.oldfile = ""
|
||||
self.lines = ""
|
||||
self.ownsSC = False
|
||||
self.ownsFR = False
|
||||
self.ownsIT = False
|
||||
self.ownsATS = False
|
||||
#
|
||||
self.ui.path_button.clicked.connect(self.openSave)
|
||||
self.ui.apply.clicked.connect(self.applyChanges)
|
||||
self.ui.backup.clicked.connect(self.recoverBackup)
|
||||
self.ui.second_window.clicked.connect(self.openSecondWin)
|
||||
#
|
||||
from PyQt5.QtCore import QRegExp
|
||||
from PyQt5.QtGui import QRegExpValidator
|
||||
rx_inf = QRegExp("[0-9]{1,9}")
|
||||
validator_inf = QRegExpValidator(rx_inf)
|
||||
self.ui.money_lineedit.setValidator(validator_inf)
|
||||
self.ui.xp_lineedit.setValidator(validator_inf)
|
||||
self.ui.loan_limit_lineedit.setValidator(validator_inf)
|
||||
#
|
||||
rx_skill = QRegExp("[0-6]{1,1}")
|
||||
validator_skill = QRegExpValidator(rx_skill)
|
||||
self.ui.long_distance_lineedit.setValidator(validator_skill)
|
||||
self.ui.high_value_cargo_lineedit.setValidator(validator_skill)
|
||||
self.ui.fragile_cargo_lineedit.setValidator(validator_skill)
|
||||
self.ui.urgent_delivery_lineedit.setValidator(validator_skill)
|
||||
self.ui.ecodriving_lineedit.setValidator(validator_skill)
|
||||
|
||||
# TODO: Custom functions
|
||||
def openSecondWin(self):
|
||||
from second_script import SecondWindow
|
||||
sec_win = SecondWindow(self.ownsSC, self.ownsFR, self.ownsIT, self.ownsATS, self.lines, self)
|
||||
sec_win.show()
|
||||
|
||||
def getADRfromLineedit(self):
|
||||
adr_list = list(self.ui.adr_lineedit.text())
|
||||
i = 0
|
||||
for x in adr_list:
|
||||
if (adr_list[i] == ",") or (adr_list[i] == ".") or (adr_list[i] == " "):
|
||||
del adr_list[i]
|
||||
i += 1
|
||||
else:
|
||||
i += 1
|
||||
return adr_list
|
||||
|
||||
def returnLines(self, lines):
|
||||
self.lines = lines
|
||||
return
|
||||
|
||||
# TODO: Program functions
|
||||
def openSave(self):
|
||||
from PyQt5.QtWidgets import QFileDialog
|
||||
file, _ = QFileDialog.getOpenFileName(parent=self,
|
||||
caption=self.tr("Choose your file..."),
|
||||
filter=self.tr("game.sii"), # ;;Save file (*.sii)
|
||||
initialFilter=self.tr("game.sii"))
|
||||
self.reopen_file()
|
||||
if file == "":
|
||||
return
|
||||
self.file_path = file
|
||||
self.checkSaveFile(self.file_path)
|
||||
|
||||
def checkSaveFile(self, file):
|
||||
try:
|
||||
with open(file, "r") as f:
|
||||
self.oldfile = 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.oldfile = f.read()
|
||||
self.funcs.showMsgBox("Success", "File successfully decrypted.")
|
||||
except UnicodeDecodeError:
|
||||
self.funcs.showMsgBox("Error", "Error to decrypt and open file. Try again.")
|
||||
return
|
||||
self.lines = self.oldfile.split("\n")
|
||||
for i in self.lines:
|
||||
if "company.volatile.sag_tre.oslo" in i:
|
||||
self.ownsSC = True
|
||||
self.ui.owns_sc.setChecked(True)
|
||||
if "company.volatile.lisette_log.roscoff" in i:
|
||||
self.ownsFR = True
|
||||
self.ui.owns_fr.setChecked(True)
|
||||
if "company.volatile.marina_it.ancona" in i:
|
||||
self.ownsIT = True
|
||||
self.ui.owns_it.setChecked(True)
|
||||
if "company.volatile.gal_oil_gst.oakland" in i:
|
||||
self.ownsATS = True
|
||||
self.checkAcc()
|
||||
self.ui.apply.setEnabled(True)
|
||||
self.ui.backup.setEnabled(True)
|
||||
self.ui.second_window.setEnabled(True)
|
||||
|
||||
def checkAcc(self):
|
||||
self.ui.money_lineedit.setText(str(self.funcs.getvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "money_account:"))))
|
||||
self.ui.xp_lineedit.setText(str(self.funcs.getvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "experience_points:"))))
|
||||
self.ui.loan_limit_lineedit.setText(str(self.funcs.getvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "loan_limit:"))))
|
||||
#
|
||||
adr = self.funcs.getADR(self.funcs.getvalue(self.lines, self.funcs.searchline(self.lines, "adr:")))
|
||||
adr_list = ""
|
||||
for i in range(6):
|
||||
if i != 5:
|
||||
elem = adr[i] + ","
|
||||
else:
|
||||
elem = adr[i]
|
||||
adr_list += elem
|
||||
self.ui.adr_lineedit.setText(adr_list)
|
||||
#
|
||||
self.ui.long_distance_lineedit.setText(str(self.funcs.getvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "long_dist:"))))
|
||||
self.ui.high_value_cargo_lineedit.setText(str(self.funcs.getvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "heavy:"))))
|
||||
self.ui.fragile_cargo_lineedit.setText(str(self.funcs.getvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "fragile:"))))
|
||||
self.ui.urgent_delivery_lineedit.setText(str(self.funcs.getvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "urgent:"))))
|
||||
self.ui.ecodriving_lineedit.setText(str(self.funcs.getvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "mechanical:"))))
|
||||
|
||||
def applyChanges(self):
|
||||
self.applyChanges_1()
|
||||
self.applyChanges_2()
|
||||
backup = self.file_path + ".swbak"
|
||||
with open(backup, "w") as f:
|
||||
f.write(self.oldfile)
|
||||
with open(self.file_path, "w") as f:
|
||||
f.write("\n".join(self.lines))
|
||||
self.funcs.showMsgBox("Success", "Changes successfully applied!")
|
||||
self.checkSaveFile(self.file_path)
|
||||
return
|
||||
|
||||
def applyChanges_1(self):
|
||||
if not self.ui.money_dont_change.isChecked():
|
||||
self.funcs.setvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "money_account:"),
|
||||
str(self.ui.money_lineedit.text()))
|
||||
#
|
||||
if not self.ui.xp_dont_change.isChecked():
|
||||
self.funcs.setvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "experience_points:"),
|
||||
str(self.ui.xp_lineedit.text()))
|
||||
#
|
||||
if not self.ui.loan_limit_dont_change.isChecked():
|
||||
self.funcs.setvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "loan_limit:"),
|
||||
str(self.ui.loan_limit_lineedit.text()))
|
||||
#
|
||||
self.ui.money_dont_change.setChecked(False)
|
||||
self.ui.xp_dont_change.setChecked(False)
|
||||
self.ui.loan_limit_dont_change.setChecked(False)
|
||||
|
||||
def applyChanges_2(self):
|
||||
if not self.ui.adr_dont_change.isChecked():
|
||||
adrset = self.getADRfromLineedit()
|
||||
if len(adrset) > 6:
|
||||
self.funcs.showMsgBox("Error", "ADR can't have more than 6 elements.")
|
||||
else:
|
||||
adrnew = int("".join(adrset), 2)
|
||||
self.funcs.setvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "adr:"),
|
||||
str(adrnew))
|
||||
#
|
||||
if not self.ui.long_distance_dont_change.isChecked():
|
||||
self.funcs.setvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "long_dist:"),
|
||||
str(self.ui.long_distance_lineedit.text()))
|
||||
#
|
||||
if not self.ui.high_value_cargo_dont_change.isChecked():
|
||||
self.funcs.setvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "heavy:"),
|
||||
str(self.ui.high_value_cargo_lineedit.text()))
|
||||
#
|
||||
if not self.ui.fragile_cargo_dont_change.isChecked():
|
||||
self.funcs.setvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "fragile:"),
|
||||
str(self.ui.fragile_cargo_lineedit.text()))
|
||||
#
|
||||
if not self.ui.urgent_delivery_dont_change.isChecked():
|
||||
self.funcs.setvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "urgent:"),
|
||||
str(self.ui.urgent_delivery_lineedit.text()))
|
||||
#
|
||||
if not self.ui.ecodriving_dont_change.isChecked():
|
||||
self.funcs.setvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "mechanical:"),
|
||||
str(self.ui.ecodriving_lineedit.text()))
|
||||
#
|
||||
self.ui.adr_dont_change.setChecked(False)
|
||||
self.ui.long_distance_dont_change.setChecked(False)
|
||||
self.ui.high_value_cargo_dont_change.setChecked(False)
|
||||
self.ui.fragile_cargo_dont_change.setChecked(False)
|
||||
self.ui.urgent_delivery_dont_change.setChecked(False)
|
||||
self.ui.ecodriving_dont_change.setChecked(False)
|
||||
|
||||
def recoverBackup(self):
|
||||
backup = self.file_path + ".swbak"
|
||||
try:
|
||||
f = open(backup, "r")
|
||||
with open(self.file_path, "w") as g:
|
||||
g.write(f.read())
|
||||
f.close()
|
||||
from os import remove
|
||||
remove(backup)
|
||||
self.funcs.showMsgBox("Success", "Backup successfully recovered.")
|
||||
self.checkSaveFile(self.file_path)
|
||||
return
|
||||
except:
|
||||
self.funcs.showMsgBox("Error", "Backup not found.")
|
||||
return
|
||||
|
||||
def reopen_file(self):
|
||||
self.file_path = ""
|
||||
self.oldfile = ""
|
||||
self.lines = ""
|
||||
#
|
||||
self.ownsSC = False
|
||||
self.ownsFR = False
|
||||
self.ownsIT = False
|
||||
self.ui.owns_sc.setChecked(False)
|
||||
self.ui.owns_fr.setChecked(False)
|
||||
self.ui.owns_it.setChecked(False)
|
||||
self.ownsATS = False
|
||||
#
|
||||
self.ui.money_lineedit.setText("")
|
||||
self.ui.money_dont_change.setChecked(False)
|
||||
self.ui.xp_lineedit.setText("")
|
||||
self.ui.xp_dont_change.setChecked(False)
|
||||
self.ui.loan_limit_lineedit.setText("")
|
||||
self.ui.loan_limit_dont_change.setChecked(False)
|
||||
#
|
||||
self.ui.adr_lineedit.setText("")
|
||||
self.ui.adr_dont_change.setChecked(False)
|
||||
self.ui.long_distance_lineedit.setText("")
|
||||
self.ui.long_distance_dont_change.setChecked(False)
|
||||
self.ui.high_value_cargo_lineedit.setText("")
|
||||
self.ui.high_value_cargo_dont_change.setChecked(False)
|
||||
self.ui.fragile_cargo_lineedit.setText("")
|
||||
self.ui.fragile_cargo_dont_change.setChecked(False)
|
||||
self.ui.urgent_delivery_lineedit.setText("")
|
||||
self.ui.urgent_delivery_dont_change.setChecked(False)
|
||||
self.ui.ecodriving_lineedit.setText("")
|
||||
self.ui.ecodriving_dont_change.setChecked(False)
|
||||
#
|
||||
self.ui.apply.setEnabled(False)
|
||||
self.ui.backup.setEnabled(False)
|
||||
self.ui.second_window.setEnabled(False)
|
||||
return
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from sys import argv, exit
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
app = QApplication(argv)
|
||||
win = MainWindow()
|
||||
win.show()
|
||||
exit(app.exec_())
|
||||
@@ -1,304 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'second_form.ui'
|
||||
#
|
||||
# Created by: PyQt5 UI code generator 5.6
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
|
||||
class Ui_SecondWindow(object):
|
||||
def setupUi(self, SecondWindow):
|
||||
SecondWindow.setObjectName("SecondWindow")
|
||||
SecondWindow.setMinimumSize(QtCore.QSize(660, 400))
|
||||
SecondWindow.setMaximumSize(QtCore.QSize(660, 400))
|
||||
self.gridLayoutWidget_4 = QtWidgets.QWidget(SecondWindow)
|
||||
self.gridLayoutWidget_4.setGeometry(QtCore.QRect(10, 10, 131, 191))
|
||||
self.gridLayoutWidget_4.setObjectName("gridLayoutWidget_4")
|
||||
self.garages_layout = QtWidgets.QGridLayout(self.gridLayoutWidget_4)
|
||||
self.garages_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.garages_layout.setObjectName("garages_layout")
|
||||
self.garages_text = QtWidgets.QTextBrowser(self.gridLayoutWidget_4)
|
||||
self.garages_text.setOpenLinks(False)
|
||||
self.garages_text.setObjectName("garages_text")
|
||||
self.garages_layout.addWidget(self.garages_text, 1, 0, 1, 1)
|
||||
self.garages_label = QtWidgets.QLabel(self.gridLayoutWidget_4)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(14)
|
||||
self.garages_label.setFont(font)
|
||||
self.garages_label.setObjectName("garages_label")
|
||||
self.garages_layout.addWidget(self.garages_label, 0, 0, 1, 1)
|
||||
self.garages_analyze = QtWidgets.QPushButton(self.gridLayoutWidget_4)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
self.garages_analyze.setFont(font)
|
||||
self.garages_analyze.setObjectName("garages_analyze")
|
||||
self.garages_layout.addWidget(self.garages_analyze, 2, 0, 1, 1)
|
||||
self.gridLayoutWidget_5 = QtWidgets.QWidget(SecondWindow)
|
||||
self.gridLayoutWidget_5.setGeometry(QtCore.QRect(340, 10, 131, 191))
|
||||
self.gridLayoutWidget_5.setObjectName("gridLayoutWidget_5")
|
||||
self.cities_layout = QtWidgets.QGridLayout(self.gridLayoutWidget_5)
|
||||
self.cities_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.cities_layout.setObjectName("cities_layout")
|
||||
self.cities_text = QtWidgets.QTextBrowser(self.gridLayoutWidget_5)
|
||||
self.cities_text.setOpenLinks(False)
|
||||
self.cities_text.setObjectName("cities_text")
|
||||
self.cities_layout.addWidget(self.cities_text, 1, 0, 1, 1)
|
||||
self.cities_analyze = QtWidgets.QPushButton(self.gridLayoutWidget_5)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
self.cities_analyze.setFont(font)
|
||||
self.cities_analyze.setObjectName("cities_analyze")
|
||||
self.cities_layout.addWidget(self.cities_analyze, 2, 0, 1, 1)
|
||||
self.cities_visited_label = QtWidgets.QLabel(self.gridLayoutWidget_5)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(14)
|
||||
self.cities_visited_label.setFont(font)
|
||||
self.cities_visited_label.setObjectName("cities_visited_label")
|
||||
self.cities_layout.addWidget(self.cities_visited_label, 0, 0, 1, 1)
|
||||
self.gridLayoutWidget_2 = QtWidgets.QWidget(SecondWindow)
|
||||
self.gridLayoutWidget_2.setGeometry(QtCore.QRect(10, 220, 131, 171))
|
||||
self.gridLayoutWidget_2.setObjectName("gridLayoutWidget_2")
|
||||
self.dealerships_layout = QtWidgets.QGridLayout(self.gridLayoutWidget_2)
|
||||
self.dealerships_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.dealerships_layout.setObjectName("dealerships_layout")
|
||||
self.dealerships_label = QtWidgets.QLabel(self.gridLayoutWidget_2)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(14)
|
||||
self.dealerships_label.setFont(font)
|
||||
self.dealerships_label.setObjectName("dealerships_label")
|
||||
self.dealerships_layout.addWidget(self.dealerships_label, 0, 0, 1, 1)
|
||||
self.dealerships_text = QtWidgets.QTextBrowser(self.gridLayoutWidget_2)
|
||||
self.dealerships_text.setObjectName("dealerships_text")
|
||||
self.dealerships_layout.addWidget(self.dealerships_text, 1, 0, 1, 1)
|
||||
self.dealerships_analyze = QtWidgets.QPushButton(self.gridLayoutWidget_2)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
self.dealerships_analyze.setFont(font)
|
||||
self.dealerships_analyze.setObjectName("dealerships_analyze")
|
||||
self.dealerships_layout.addWidget(self.dealerships_analyze, 2, 0, 1, 1)
|
||||
self.gridLayoutWidget_6 = QtWidgets.QWidget(SecondWindow)
|
||||
self.gridLayoutWidget_6.setGeometry(QtCore.QRect(340, 220, 131, 171))
|
||||
self.gridLayoutWidget_6.setObjectName("gridLayoutWidget_6")
|
||||
self.agencies_layout = QtWidgets.QGridLayout(self.gridLayoutWidget_6)
|
||||
self.agencies_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.agencies_layout.setObjectName("agencies_layout")
|
||||
self.agencies_label = QtWidgets.QLabel(self.gridLayoutWidget_6)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(14)
|
||||
self.agencies_label.setFont(font)
|
||||
self.agencies_label.setObjectName("agencies_label")
|
||||
self.agencies_layout.addWidget(self.agencies_label, 0, 0, 1, 1)
|
||||
self.agencies_text = QtWidgets.QTextBrowser(self.gridLayoutWidget_6)
|
||||
self.agencies_text.setObjectName("agencies_text")
|
||||
self.agencies_layout.addWidget(self.agencies_text, 1, 0, 1, 1)
|
||||
self.agencies_analyze = QtWidgets.QPushButton(self.gridLayoutWidget_6)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
self.agencies_analyze.setFont(font)
|
||||
self.agencies_analyze.setObjectName("agencies_analyze")
|
||||
self.agencies_layout.addWidget(self.agencies_analyze, 2, 0, 1, 1)
|
||||
self.v_line = QtWidgets.QFrame(SecondWindow)
|
||||
self.v_line.setGeometry(QtCore.QRect(320, 10, 20, 381))
|
||||
self.v_line.setFrameShape(QtWidgets.QFrame.VLine)
|
||||
self.v_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
self.v_line.setObjectName("v_line")
|
||||
self.h_line = QtWidgets.QFrame(SecondWindow)
|
||||
self.h_line.setGeometry(QtCore.QRect(10, 200, 641, 16))
|
||||
self.h_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
self.h_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
self.h_line.setObjectName("h_line")
|
||||
self.gridLayoutWidget = QtWidgets.QWidget(SecondWindow)
|
||||
self.gridLayoutWidget.setGeometry(QtCore.QRect(150, 10, 171, 107))
|
||||
self.gridLayoutWidget.setObjectName("gridLayoutWidget")
|
||||
self.add_garage = QtWidgets.QGridLayout(self.gridLayoutWidget)
|
||||
self.add_garage.setContentsMargins(0, 0, 0, 0)
|
||||
self.add_garage.setObjectName("add_garage")
|
||||
self.garage_add = QtWidgets.QPushButton(self.gridLayoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
self.garage_add.setFont(font)
|
||||
self.garage_add.setObjectName("garage_add")
|
||||
self.add_garage.addWidget(self.garage_add, 2, 0, 1, 1)
|
||||
self.garage_lineedit = QtWidgets.QLineEdit(self.gridLayoutWidget)
|
||||
self.garage_lineedit.setObjectName("garage_lineedit")
|
||||
self.add_garage.addWidget(self.garage_lineedit, 1, 0, 1, 1)
|
||||
self.garage_unlock_all = QtWidgets.QPushButton(self.gridLayoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
self.garage_unlock_all.setFont(font)
|
||||
self.garage_unlock_all.setObjectName("garage_unlock_all")
|
||||
self.add_garage.addWidget(self.garage_unlock_all, 3, 0, 1, 1)
|
||||
self.garage_label = QtWidgets.QLabel(self.gridLayoutWidget)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(14)
|
||||
self.garage_label.setFont(font)
|
||||
self.garage_label.setObjectName("garage_label")
|
||||
self.add_garage.addWidget(self.garage_label, 0, 0, 1, 1)
|
||||
self.gridLayoutWidget_3 = QtWidgets.QWidget(SecondWindow)
|
||||
self.gridLayoutWidget_3.setGeometry(QtCore.QRect(480, 50, 171, 107))
|
||||
self.gridLayoutWidget_3.setObjectName("gridLayoutWidget_3")
|
||||
self.add_city = QtWidgets.QGridLayout(self.gridLayoutWidget_3)
|
||||
self.add_city.setContentsMargins(0, 0, 0, 0)
|
||||
self.add_city.setObjectName("add_city")
|
||||
self.city_add = QtWidgets.QPushButton(self.gridLayoutWidget_3)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
self.city_add.setFont(font)
|
||||
self.city_add.setObjectName("city_add")
|
||||
self.add_city.addWidget(self.city_add, 2, 0, 1, 1)
|
||||
self.city_lineedit = QtWidgets.QLineEdit(self.gridLayoutWidget_3)
|
||||
self.city_lineedit.setObjectName("city_lineedit")
|
||||
self.add_city.addWidget(self.city_lineedit, 1, 0, 1, 1)
|
||||
self.city_label = QtWidgets.QLabel(self.gridLayoutWidget_3)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(14)
|
||||
self.city_label.setFont(font)
|
||||
self.city_label.setObjectName("city_label")
|
||||
self.add_city.addWidget(self.city_label, 0, 0, 1, 1)
|
||||
self.city_unlock_all = QtWidgets.QPushButton(self.gridLayoutWidget_3)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
self.city_unlock_all.setFont(font)
|
||||
self.city_unlock_all.setObjectName("city_unlock_all")
|
||||
self.add_city.addWidget(self.city_unlock_all, 3, 0, 1, 1)
|
||||
self.gridLayoutWidget_7 = QtWidgets.QWidget(SecondWindow)
|
||||
self.gridLayoutWidget_7.setGeometry(QtCore.QRect(150, 250, 171, 107))
|
||||
self.gridLayoutWidget_7.setObjectName("gridLayoutWidget_7")
|
||||
self.add_dealership = QtWidgets.QGridLayout(self.gridLayoutWidget_7)
|
||||
self.add_dealership.setContentsMargins(0, 0, 0, 0)
|
||||
self.add_dealership.setObjectName("add_dealership")
|
||||
self.dealership_add = QtWidgets.QPushButton(self.gridLayoutWidget_7)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
self.dealership_add.setFont(font)
|
||||
self.dealership_add.setObjectName("dealership_add")
|
||||
self.add_dealership.addWidget(self.dealership_add, 2, 0, 1, 1)
|
||||
self.dealership_lineedit = QtWidgets.QLineEdit(self.gridLayoutWidget_7)
|
||||
self.dealership_lineedit.setObjectName("dealership_lineedit")
|
||||
self.add_dealership.addWidget(self.dealership_lineedit, 1, 0, 1, 1)
|
||||
self.dealership_label = QtWidgets.QLabel(self.gridLayoutWidget_7)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(14)
|
||||
self.dealership_label.setFont(font)
|
||||
self.dealership_label.setObjectName("dealership_label")
|
||||
self.add_dealership.addWidget(self.dealership_label, 0, 0, 1, 1)
|
||||
self.dealership_unlock_all = QtWidgets.QPushButton(self.gridLayoutWidget_7)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
self.dealership_unlock_all.setFont(font)
|
||||
self.dealership_unlock_all.setObjectName("dealership_unlock_all")
|
||||
self.add_dealership.addWidget(self.dealership_unlock_all, 3, 0, 1, 1)
|
||||
self.gridLayoutWidget_8 = QtWidgets.QWidget(SecondWindow)
|
||||
self.gridLayoutWidget_8.setGeometry(QtCore.QRect(480, 250, 171, 107))
|
||||
self.gridLayoutWidget_8.setObjectName("gridLayoutWidget_8")
|
||||
self.add_agency = QtWidgets.QGridLayout(self.gridLayoutWidget_8)
|
||||
self.add_agency.setContentsMargins(0, 0, 0, 0)
|
||||
self.add_agency.setObjectName("add_agency")
|
||||
self.agency_add = QtWidgets.QPushButton(self.gridLayoutWidget_8)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
self.agency_add.setFont(font)
|
||||
self.agency_add.setObjectName("agency_add")
|
||||
self.add_agency.addWidget(self.agency_add, 2, 0, 1, 1)
|
||||
self.agency_lineedit = QtWidgets.QLineEdit(self.gridLayoutWidget_8)
|
||||
self.agency_lineedit.setObjectName("agency_lineedit")
|
||||
self.add_agency.addWidget(self.agency_lineedit, 1, 0, 1, 1)
|
||||
self.agency_label = QtWidgets.QLabel(self.gridLayoutWidget_8)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(14)
|
||||
self.agency_label.setFont(font)
|
||||
self.agency_label.setObjectName("agency_label")
|
||||
self.add_agency.addWidget(self.agency_label, 0, 0, 1, 1)
|
||||
self.agency_unlock_all = QtWidgets.QPushButton(self.gridLayoutWidget_8)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
self.agency_unlock_all.setFont(font)
|
||||
self.agency_unlock_all.setObjectName("agency_unlock_all")
|
||||
self.add_agency.addWidget(self.agency_unlock_all, 3, 0, 1, 1)
|
||||
self.gridLayoutWidget_9 = QtWidgets.QWidget(SecondWindow)
|
||||
self.gridLayoutWidget_9.setGeometry(QtCore.QRect(150, 120, 171, 80))
|
||||
self.gridLayoutWidget_9.setObjectName("gridLayoutWidget_9")
|
||||
self.headquarter_layout = QtWidgets.QGridLayout(self.gridLayoutWidget_9)
|
||||
self.headquarter_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.headquarter_layout.setObjectName("headquarter_layout")
|
||||
self.headquarter_label = QtWidgets.QLabel(self.gridLayoutWidget_9)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(14)
|
||||
self.headquarter_label.setFont(font)
|
||||
self.headquarter_label.setObjectName("headquarter_label")
|
||||
self.headquarter_layout.addWidget(self.headquarter_label, 0, 0, 1, 1)
|
||||
self.headquarter_lineedit = QtWidgets.QLineEdit(self.gridLayoutWidget_9)
|
||||
self.headquarter_lineedit.setObjectName("headquarter_lineedit")
|
||||
self.headquarter_layout.addWidget(self.headquarter_lineedit, 1, 0, 1, 1)
|
||||
self.headquarter_change = QtWidgets.QPushButton(self.gridLayoutWidget_9)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily("Times New Roman")
|
||||
font.setPointSize(10)
|
||||
self.headquarter_change.setFont(font)
|
||||
self.headquarter_change.setObjectName("headquarter_change")
|
||||
self.headquarter_layout.addWidget(self.headquarter_change, 2, 0, 1, 1)
|
||||
self.gridLayoutWidget_4.raise_()
|
||||
self.gridLayoutWidget_5.raise_()
|
||||
self.gridLayoutWidget_2.raise_()
|
||||
self.gridLayoutWidget_6.raise_()
|
||||
self.v_line.raise_()
|
||||
self.h_line.raise_()
|
||||
self.gridLayoutWidget.raise_()
|
||||
self.gridLayoutWidget_3.raise_()
|
||||
self.gridLayoutWidget_7.raise_()
|
||||
self.gridLayoutWidget_8.raise_()
|
||||
self.garage_label.raise_()
|
||||
self.gridLayoutWidget_9.raise_()
|
||||
|
||||
self.retranslateUi(SecondWindow)
|
||||
QtCore.QMetaObject.connectSlotsByName(SecondWindow)
|
||||
|
||||
def retranslateUi(self, SecondWindow):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
SecondWindow.setWindowTitle(_translate("SecondWindow", "Edit garages, cities and etc..."))
|
||||
self.garages_label.setText(_translate("SecondWindow", "Owned garages:"))
|
||||
self.garages_analyze.setText(_translate("SecondWindow", "Analyze"))
|
||||
self.cities_analyze.setText(_translate("SecondWindow", "Analyze"))
|
||||
self.cities_visited_label.setText(_translate("SecondWindow", "Visited cities:"))
|
||||
self.dealerships_label.setText(_translate("SecondWindow", "Dealerships:"))
|
||||
self.dealerships_analyze.setText(_translate("SecondWindow", "Analyze"))
|
||||
self.agencies_label.setText(_translate("SecondWindow", "Agencies:"))
|
||||
self.agencies_analyze.setText(_translate("SecondWindow", "Analyze"))
|
||||
self.garage_add.setText(_translate("SecondWindow", "Add"))
|
||||
self.garage_unlock_all.setText(_translate("SecondWindow", "Unlock all"))
|
||||
self.garage_label.setText(_translate("SecondWindow", "Enter garage name:"))
|
||||
self.city_add.setText(_translate("SecondWindow", "Add"))
|
||||
self.city_label.setText(_translate("SecondWindow", "Enter city name:"))
|
||||
self.city_unlock_all.setText(_translate("SecondWindow", "Visit all"))
|
||||
self.dealership_add.setText(_translate("SecondWindow", "Add"))
|
||||
self.dealership_label.setText(_translate("SecondWindow", "Enter dealership name:"))
|
||||
self.dealership_unlock_all.setText(_translate("SecondWindow", "Unlock all"))
|
||||
self.agency_add.setText(_translate("SecondWindow", "Add"))
|
||||
self.agency_label.setText(_translate("SecondWindow", "Enter agency name:"))
|
||||
self.agency_unlock_all.setText(_translate("SecondWindow", "Unlock all"))
|
||||
self.headquarter_label.setText(_translate("SecondWindow", "Your headquarter:"))
|
||||
self.headquarter_change.setText(_translate("SecondWindow", "Change"))
|
||||
|
||||
@@ -1,294 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from funcs import *
|
||||
from second_form import *
|
||||
from PyQt5.QtWidgets import QDialog
|
||||
|
||||
|
||||
class SecondWindow(QDialog, Ui_SecondWindow):
|
||||
# TODO: Constructor
|
||||
def __init__(self, ownsSC, ownsFR, ownsIT, ownsATS, lines, parent=None):
|
||||
QDialog.__init__(self, parent)
|
||||
Ui_SecondWindow.__init__(self)
|
||||
self.ui = Ui_SecondWindow()
|
||||
self.ui.setupUi(self)
|
||||
#
|
||||
self.funcs = Functions()
|
||||
self.lines = lines
|
||||
self.ownsSC = ownsSC
|
||||
self.ownsFR = ownsFR
|
||||
self.ownsIT = ownsIT
|
||||
self.ownsATS = ownsATS
|
||||
#
|
||||
self.dealersets2 = ["aberdeen", "amsterdam", "berlin", "bern", "birmingham", "bratislava", "bremen", "brussel",
|
||||
"budapest", "calais", "cardiff", "dortmund", "dortmund", "dresden", "dusseldorf", "edinburgh",
|
||||
"felixstowe", "frankfurt", "gdansk", "glasgow", "graz", "grimsby", "hamburg", "hannover", "krakow",
|
||||
"leipzig", "lille", "london", "luxembourg", "manchester", "munchen", "newcastle", "nurnberg",
|
||||
"osnabruck", "plymouth", "prague", "rostock", "rotterdam", "salzburg", "strasbourg", "stuttgart",
|
||||
"szczecin", "szeged", "warszawa", "wien", "wroclaw", "zurich"] # Default dealers
|
||||
self.dealersets2_sc = ["bergen", "goteborg", "kalmar", "kobenhavn", "linkoping", "oslo", "stockholm"] # SC dealers
|
||||
self.dealersets2_fr = ["bordeaux", "bourges", "brest", "geneve", "lemans", "limoges", "lyon", "marseille", "nantes",
|
||||
"paris", "toulouse"] # FR dealers
|
||||
self.dealersets2_it = ["bologna", "catania", "firenze", "milano", "napoli", "palermo", "roma", "taranto", "torino",
|
||||
"verona"] # IT dealers
|
||||
#
|
||||
self.agenciesets2 = ["aberdeen", "berlin", "bialystok", "birmingham", "bremen", "brno",
|
||||
"brussel", "budapest", "calais", "debrecen", "dortmund", "dover", "dresden", "edinburgh",
|
||||
"frankfurt", "gdansk", "glasgow", "graz", "grohningen", "hamburg", "hannover", "innsbruck", "kassel",
|
||||
"klagenfurt", "koln", "kosice", "krakow", "leipzig", "liege", "linz", "liverpool", "lodz", "london",
|
||||
"luxembourg", "manchester", "mannheim", "munchen", "newcastle", "nurnberg", "ostrava", "pecs",
|
||||
"plymouth", "poznan", "prague", "sheffield", "southampton", "stuttgart", "swansea", "szczecin",
|
||||
"szeged", "warszava", "wien", "zurich"] # Default agnecies
|
||||
self.agenciesets2_sc = ["aalborg", "bergen", "helsingborg", "kobenhavn", "malmo", "odense", "oslo", "stavanger",
|
||||
"stockholm"] # SC agencies
|
||||
self.agenciesets2_fr = ["bordeaux", "clermont", "geneve", "larochelle", "lyon", "marseille", "metz", "paris", "reims",
|
||||
"rennes", "toulouse"] # FR agencies
|
||||
self.agenciesets2_it = ["bologna", "catania", "milano", "napoli", "pescara", "roma", "taranto", "venezia"] # IT agencies
|
||||
#
|
||||
self.dealersats = ["elko", "reno", "bakersfield", "phoenix", "flagstaff", "los_angeles", "albuquerque", "hobbs"]
|
||||
self.agenciesats = ["redding", "san_rafael", "stockton", "fresno", "santa_cruz", "bakersfield", "oxnard",
|
||||
"los_angeles", "san_diego", "carson_city", "las_vegas", "phoenix", "tucson", "sierra_vista",
|
||||
"farmington", "santa_fe", "roswell", "carlsbad_nm"]
|
||||
#
|
||||
self.ui.garages_analyze.clicked.connect(self.checkGarages)
|
||||
self.ui.garage_add.clicked.connect(self.addGarage)
|
||||
self.ui.garage_unlock_all.clicked.connect(self.addAllGarages)
|
||||
self.ui.headquarter_change.clicked.connect(self.changeHQ)
|
||||
self.ui.cities_analyze.clicked.connect(self.checkCities)
|
||||
self.ui.city_add.clicked.connect(self.addCity)
|
||||
self.ui.city_unlock_all.clicked.connect(self.addAllCities)
|
||||
self.ui.dealerships_analyze.clicked.connect(self.checkDealers)
|
||||
self.ui.dealership_add.clicked.connect(self.addDealership)
|
||||
self.ui.dealership_unlock_all.clicked.connect(self.addAllDealership)
|
||||
self.ui.agencies_analyze.clicked.connect(self.checkAgencies)
|
||||
self.ui.agency_add.clicked.connect(self.addAgency)
|
||||
self.ui.agency_unlock_all.clicked.connect(self.addAllAgency)
|
||||
|
||||
# TODO: Default functions
|
||||
def purchasedgarages(self):
|
||||
purchased_garages = []
|
||||
i = 0
|
||||
try:
|
||||
while True:
|
||||
while "garage : " not in self.lines[i]:
|
||||
i += 1
|
||||
city = match(r"garage : garage.(.+) {$", self.lines[i]).group(1)
|
||||
while "status:" not in self.lines[i]:
|
||||
i += 1
|
||||
if "0" not in self.lines[i]:
|
||||
purchased_garages.append(city)
|
||||
except:
|
||||
pass
|
||||
return purchased_garages
|
||||
|
||||
def cities(self):
|
||||
cities = []
|
||||
line = self.funcs.searchline(self.lines, "companies\[")
|
||||
while "companies[" in self.lines[line]:
|
||||
city = match(r" companies\[[0-9]+\]: company.volatile.[a-z0-9_]+[.]([a-z_]+)", self.lines[line]).group(1)
|
||||
if city not in cities:
|
||||
cities.append(city)
|
||||
line += 1
|
||||
return cities
|
||||
|
||||
# TODO: Program functions
|
||||
def checkGarages(self):
|
||||
self.ui.garages_text.clear()
|
||||
for e in self.purchasedgarages():
|
||||
self.ui.garages_text.append(e)
|
||||
hq = self.funcs.getvalue(self.lines, self.funcs.searchline(self.lines, "hq_city:"))
|
||||
self.ui.headquarter_lineedit.setText(hq)
|
||||
|
||||
def checkCities(self):
|
||||
self.ui.cities_text.clear()
|
||||
for i in self.funcs.getarrayitems(self.lines,
|
||||
self.funcs.searchline(self.lines, "visited_cities:")):
|
||||
self.ui.cities_text.append(i)
|
||||
if not self.funcs.getarrayitems(self.lines,
|
||||
self.funcs.searchline(self.lines, "visited_cities:")):
|
||||
self.ui.cities_text.append("No cities visited yet.")
|
||||
|
||||
def checkDealers(self):
|
||||
if self.ownsSC:
|
||||
self.dealersets2 += self.dealersets2_sc
|
||||
if self.ownsFR:
|
||||
self.dealersets2 += self.dealersets2_fr
|
||||
if self.ownsIT:
|
||||
self.dealersets2 += self.dealersets2_it
|
||||
self.ui.dealerships_text.clear()
|
||||
for i in self.funcs.getarrayitems(self.lines,
|
||||
self.funcs.searchline(self.lines, "unlocked_dealers:")):
|
||||
self.ui.dealerships_text.append(i)
|
||||
if not self.funcs.getarrayitems(self.lines,
|
||||
self.funcs.searchline(self.lines, "unlocked_dealers:")):
|
||||
self.ui.dealerships_text.append("No dealerships unlocked yet.")
|
||||
|
||||
def checkAgencies(self):
|
||||
if self.ownsSC:
|
||||
self.agenciesets2 += self.agenciesets2_sc
|
||||
if self.ownsFR:
|
||||
self.agenciesets2 += self.agenciesets2_fr
|
||||
if self.ownsIT:
|
||||
self.agenciesets2 += self.agenciesets2_it
|
||||
self.ui.agencies_text.clear()
|
||||
for i in self.funcs.getarrayitems(self.lines,
|
||||
self.funcs.searchline(self.lines, "unlocked_recruitments:")):
|
||||
self.ui.agencies_text.append(i)
|
||||
if not self.funcs.getarrayitems(self.lines,
|
||||
self.funcs.searchline(self.lines, "unlocked_recruitments:")):
|
||||
self.ui.agencies_text.append("No recruitment agencies unlocked yet.")
|
||||
|
||||
def addGarage(self):
|
||||
garage = str(self.ui.garage_lineedit.text()).lower()
|
||||
self.ui.garage_lineedit.setText("")
|
||||
if int(self.funcs.getvalue(self.lines,
|
||||
self.funcs.searchlineinunit(self.lines, "status:", "garage." + garage))) != 0:
|
||||
self.funcs.showMsgBox("Error", "Garage in \"{}\" already unlocked".format(garage))
|
||||
else:
|
||||
self.funcs.setvalue(self.lines,
|
||||
self.funcs.searchlineinunit(self.lines, "status:", "garage." + garage),
|
||||
"6")
|
||||
self.funcs.addarrayvalue(self.lines,
|
||||
self.funcs.searchlineinunit(self.lines, "vehicles:", "garage." + garage),
|
||||
"null")
|
||||
self.funcs.addarrayvalue(self.lines,
|
||||
self.funcs.searchlineinunit(self.lines, "drivers:", "garage." + garage),
|
||||
"null")
|
||||
self.funcs.showMsgBox("Success", "Garage in \"{}\" successfully unlocked.".format(garage))
|
||||
self.checkGarages()
|
||||
|
||||
def addAllGarages(self):
|
||||
line = 0
|
||||
try:
|
||||
while True:
|
||||
line = self.funcs.searchline(self.lines, "garage : garage.", start=line)
|
||||
if int(self.funcs.getvalue(self.lines, self.searchlineinunit("status:",
|
||||
self.funcs.getunitname(self.lines, line)))) == 0:
|
||||
self.funcs.setvalue(self.lines,
|
||||
self.funcs.searchlineinunit(self.lines, "status:",
|
||||
self.funcs.getunitname(self.lines, line)),
|
||||
"6")
|
||||
self.funcs.addarrayvalue(self.lines,
|
||||
self.funcs.searchlineinunit(self.lines, "vehicles:",
|
||||
self.funcs.getunitname(self.lines, line)),
|
||||
"null")
|
||||
self.funcs.addarrayvalue(self.lines,
|
||||
self.funcs.searchlineinunit(self.lines, "drivers:",
|
||||
self.funcs.getunitname(self.lines, line)),
|
||||
"null")
|
||||
line += 1
|
||||
except:
|
||||
pass
|
||||
self.funcs.showMsgBox("Success", "All garages successfully unlocked.")
|
||||
self.checkGarages()
|
||||
|
||||
def addCity(self):
|
||||
city = str(self.ui.city_lineedit.text()).lower()
|
||||
self.ui.city_lineedit.setText("")
|
||||
if city in self.funcs.getarrayitems(self.lines,
|
||||
self.funcs.searchline(self.lines, "visited_cities:")):
|
||||
self.funcs.showMsgBox("Error", "You already visited \"{}\"".format(city))
|
||||
else:
|
||||
self.funcs.addarrayvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "visited_cities:"),
|
||||
city)
|
||||
self.funcs.addarrayvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "visited_cities_count:"),
|
||||
"1")
|
||||
self.funcs.showMsgBox("Success", "City \"{}\" successfully visited.".format(city))
|
||||
self.checkCities()
|
||||
|
||||
def addAllCities(self):
|
||||
for city in self.cities():
|
||||
if city not in self.funcs.getarrayitems(self.lines,
|
||||
self.funcs.searchline(self.lines, "visited_cities:")):
|
||||
self.funcs.addarrayvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "visited_cities:"),
|
||||
city)
|
||||
self.funcs.addarrayvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "visited_cities_count:"),
|
||||
"1")
|
||||
self.funcs.showMsgBox("Success", "All cities successfully visited.")
|
||||
self.checkCities()
|
||||
|
||||
def addDealership(self):
|
||||
dealer = str(self.ui.dealership_lineedit.text()).lower()
|
||||
self.ui.dealership_lineedit.setText("")
|
||||
if (not self.ownsATS and dealer not in self.dealersets2) or (self.ownsATS and dealer not in self.dealersats):
|
||||
self.funcs.showMsgBox("Error", "There is no dealership in that city.")
|
||||
elif dealer in self.funcs.getarrayitems(self.lines, self.funcs.searchline(self.lines, "unlocked_dealers:")):
|
||||
self.funcs.showMsgBox("Error", "Dealership is already unlocked.")
|
||||
else:
|
||||
self.funcs.addarrayvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "unlocked_dealers:"),
|
||||
dealer)
|
||||
self.funcs.showMsgBox("Success", "Dealership in \"{}\" successfully unlocked.".format(dealer))
|
||||
self.checkDealers()
|
||||
|
||||
def addAllDealership(self):
|
||||
if not self.ownsATS:
|
||||
for dealer in self.dealersets2:
|
||||
if dealer in self.cities() and dealer not in self.funcs.getarrayitems(
|
||||
self.lines, self.funcs.searchline(self.lines, "unlocked_dealers:")):
|
||||
self.funcs.addarrayvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "unlocked_dealers:"),
|
||||
dealer)
|
||||
else:
|
||||
for dealer in self.dealersats:
|
||||
if dealer in self.cities() and dealer not in self.funcs.getarrayitems(
|
||||
self.lines, self.funcs.searchline(self.lines, "unlocked_dealers:")):
|
||||
self.funcs.addarrayvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "unlocked_dealers:"),
|
||||
dealer)
|
||||
self.funcs.showMsgBox("Success", "All dealerships unlocked.")
|
||||
self.checkDealers()
|
||||
|
||||
def addAgency(self):
|
||||
agency = str(self.ui.agency_lineedit.text()).lower()
|
||||
self.ui.agency_lineedit.setText("")
|
||||
if (not self.ownsATS and agency not in self.agenciesets2) or (self.ownsATS and agency not in self.agenciesats):
|
||||
self.funcs.showMsgBox("Error", "There is no recruitment agency in that city.")
|
||||
elif agency in self.funcs.getarrayitems(self.lines,
|
||||
self.funcs.searchline(self.lines, "unlocked_recruitments:")):
|
||||
self.funcs.showMsgBox("Error", "Recruitment agency is already unlocked.")
|
||||
else:
|
||||
self.funcs.addarrayvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "unlocked_recruitments:"),
|
||||
agency)
|
||||
self.funcs.showMsgBox("Success", "Recruitment agency in \"{}\" successfully unlocked.".format(agency))
|
||||
self.checkAgencies()
|
||||
|
||||
def addAllAgency(self):
|
||||
if not self.ownsATS:
|
||||
for agency in self.agenciesets2:
|
||||
if agency in self.cities() and agency not in self.funcs.getarrayitems(
|
||||
self.lines, self.funcs.searchline(self.lines, "unlocked_recruitments:")):
|
||||
self.funcs.addarrayvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "unlocked_recruitments:"),
|
||||
agency)
|
||||
else:
|
||||
for agency in self.agenciesats:
|
||||
if agency in self.cities() and agency not in self.funcs.getarrayitems(
|
||||
self.lines, self.funcs.searchline(self.lines, "unlocked_recruitments:")):
|
||||
self.funcs.addarrayvalue(self.lines,
|
||||
self.funcs.searchline(self.lines, "unlocked_recruitments:"),
|
||||
agency)
|
||||
self.funcs.showMsgBox("Success", "All recruitment agencies unlocked.")
|
||||
self.checkAgencies()
|
||||
|
||||
def changeHQ(self):
|
||||
hq = str(self.ui.headquarter_lineedit.text()).lower()
|
||||
if self.funcs.getvalue(self.lines, self.funcs.searchline(self.lines, "hq_city:")) == hq:
|
||||
self.funcs.showMsgBox("Error", "Your headquarter is already in this city")
|
||||
elif hq not in self.purchasedgarages():
|
||||
self.funcs.showMsgBox("Error", "You need to own the garage in this city.")
|
||||
else:
|
||||
self.funcs.setvalue(self.lines, self.funcs.searchline(self.lines, "hq_city:"), hq)
|
||||
self.funcs.showMsgBox("Success", "Headquarter successfully set to \"{}\".".format(hq))
|
||||
|
||||
# TODO: send self.lines to MainWindow()
|
||||
def closeEvent(self, event):
|
||||
from main_script import MainWindow
|
||||
mainw = MainWindow()
|
||||
mainw.returnLines(self.lines)
|
||||
35
src/setup.py
35
src/setup.py
@@ -1,35 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from cx_Freeze import setup, Executable
|
||||
|
||||
executables = [Executable('main_script.py',
|
||||
targetName="SaveWizard.exe",
|
||||
base="Win32GUI")]
|
||||
|
||||
excludes = ['email', 'html', 'http', 'logging', 'pydoc_data', 'unittest', 'urllib', 'xml', 'tempfile', 'select', 'datetime',
|
||||
'hashlib', 'shlex', 'shutil', 'socket', 'platform', 'webbrowser', 'pydoc', 'selectors', 'tty', 'inspect', 'doctest',
|
||||
'plistlib', 'calendar', 'subprocess', 'copy', 'bz2', 'stringprep', 'unicodedata', 'posixpath', 'dummy_threading',
|
||||
'_strptime', 'pwd']
|
||||
|
||||
zip_include_packages = ['collections', 'encodings', 'importlib', 'PyQt5', 'sip', 'wsgiref']
|
||||
|
||||
include_files = ['SII_Decrypt.exe']
|
||||
|
||||
options = {
|
||||
'build_exe': {
|
||||
'include_msvcr': True,
|
||||
'excludes': excludes,
|
||||
'zip_include_packages': zip_include_packages,
|
||||
'include_files': include_files,
|
||||
'build_exe': 'stable_build'
|
||||
}
|
||||
}
|
||||
|
||||
setup(
|
||||
name="SaveWizard",
|
||||
version="1.0",
|
||||
description="For editing ETS2 sii files",
|
||||
executables=executables,
|
||||
options=options
|
||||
)
|
||||
128
util.py
Normal file
128
util.py
Normal file
@@ -0,0 +1,128 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from re import search, match, sub
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
|
||||
lines = []
|
||||
|
||||
|
||||
# Custom functions
|
||||
def set_lines(new_lines):
|
||||
global lines
|
||||
lines = new_lines
|
||||
|
||||
|
||||
def get_lines(index=None):
|
||||
global lines
|
||||
if index is not None:
|
||||
return lines[index]
|
||||
return lines
|
||||
|
||||
|
||||
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]):
|
||||
return start
|
||||
start += 1
|
||||
while start <= len(lines) - 1:
|
||||
if search(term, lines[start]):
|
||||
return start
|
||||
if search(cancel, lines[start]):
|
||||
return None
|
||||
start += 1
|
||||
return None
|
||||
|
||||
|
||||
def search_line_in_unit(term, unit):
|
||||
global lines
|
||||
line = search_line(" : " + unit + " {")
|
||||
return search_line(term, start=line, cancel="}")
|
||||
|
||||
|
||||
def search_all_lines(term):
|
||||
global lines
|
||||
matches = []
|
||||
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
|
||||
|
||||
|
||||
def get_value(line):
|
||||
global lines
|
||||
return search(r": (.+)$", lines[line]).group(1)
|
||||
|
||||
|
||||
def set_value(line, value):
|
||||
global lines
|
||||
name = match(r"(.+):", lines[line]).group(1)
|
||||
lines[line] = name + ": " + value
|
||||
|
||||
|
||||
def get_unit_name(line):
|
||||
global lines
|
||||
return search(r" : (.+) {$", lines[line]).group(1)
|
||||
|
||||
|
||||
def get_array_length(line):
|
||||
global lines
|
||||
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_items(line):
|
||||
global lines
|
||||
items = []
|
||||
for i in range(get_array_length(line)):
|
||||
items.append(search(r": (.+)$", lines[line + i + 1]).group(1))
|
||||
if items is None:
|
||||
return None
|
||||
return items
|
||||
|
||||
|
||||
def add_array_value(line, value):
|
||||
global lines
|
||||
name = match(r"(.+):", lines[line]).group(1)
|
||||
count = get_array_length(line)
|
||||
lines[line] = name + ": " + str(count + 1)
|
||||
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)
|
||||
Reference in New Issue
Block a user