mirror of
https://github.com/JDM170/SaveWizard
synced 2025-04-20 22:30:42 +07:00
Compare commits
56 Commits
1.1.1
...
1ad1f536de
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ad1f536de | ||
|
89f56be8b2
|
|||
|
2b14be3832
|
|||
|
6330a0dfa8
|
|||
|
e9eef9f785
|
|||
|
|
f989c54664 | ||
|
2d40c51f9c
|
|||
|
|
9223095fe7 | ||
|
b9607db785
|
|||
|
bafcb26fbe
|
|||
|
b8cc20a184
|
|||
|
dd238a0ae1
|
|||
|
1afd4b6079
|
|||
|
dbcec7a6ed
|
|||
|
70fceee6a2
|
|||
|
242de815da
|
|||
|
c4cf9491d6
|
|||
|
944c79dac0
|
|||
|
33c21c4043
|
|||
|
54331abf5a
|
|||
|
aa071c7ea5
|
|||
|
375e66e989
|
|||
|
59d4f89a96
|
|||
|
d2d814c870
|
|||
|
befed61b0c
|
|||
|
ef36387e05
|
|||
|
da25c7bbc4
|
|||
|
e21266970e
|
|||
|
a2d4f84877
|
|||
|
e7e4939882
|
|||
|
66a571309d
|
|||
|
7991cde695
|
|||
|
b3d5776a3b
|
|||
|
b082e6ca3f
|
|||
|
dab9dc0467
|
|||
|
8932327b5c
|
|||
|
994d6e4b13
|
|||
|
9c90daf8d5
|
|||
|
78141ae9aa
|
|||
|
8888a80b0c
|
|||
|
bcb5cd03e6
|
|||
| a7e5e47cb0 | |||
| e6ef2bd50f | |||
| 1f5c867444 | |||
| f8ed7ec27f | |||
| fa552aa424 | |||
| f1934d8d61 | |||
| d5a9fe14a3 | |||
| 69b815e917 | |||
| 3dd855ff38 | |||
| 28a54d14f0 | |||
| 34f38b5a59 | |||
| 33ce4d1148 | |||
| 4dcfe37c5b | |||
| 8a304075a1 | |||
| b313dcaa52 |
31
.gitignore
vendored
31
.gitignore
vendored
@@ -1,16 +1,27 @@
|
||||
## Ignoring PyCharm settings
|
||||
## Ignore PyCharm settings
|
||||
/.idea
|
||||
|
||||
## Ignoring Python complied files
|
||||
/__pycache__
|
||||
/main/__pycache__
|
||||
/second/__pycache__
|
||||
/main/form.py
|
||||
/second/form.py
|
||||
## Ignore virtual enviroment
|
||||
/venv
|
||||
|
||||
## Ignoring build from cx_Freeze
|
||||
/stable_build
|
||||
## Ignore Python complied files
|
||||
*__pycache__
|
||||
|
||||
## Ignoring build files from PyInstaller
|
||||
## Ignore ui -> py transform
|
||||
*/form.py
|
||||
|
||||
## Ignore UPX
|
||||
/upx
|
||||
|
||||
## Ignore build from cx_Freeze
|
||||
/prog_build
|
||||
|
||||
## Ignore build files from PyInstaller
|
||||
/build
|
||||
/dist
|
||||
|
||||
## Ignore .bak files
|
||||
*.bak
|
||||
|
||||
## Ignore created 'update.cfg' file
|
||||
update.cfg
|
||||
|
||||
35
DLC_TABLE.md
Normal file
35
DLC_TABLE.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# American Truck Simulator DLC table
|
||||
|
||||
| DLC name | Config name | File name (.scs) |
|
||||
| --- | --- | --- |
|
||||
| Arizona | arizona | dlc_arizona |
|
||||
| New Mexico | new_mexico | dlc_nm |
|
||||
| Oregon | oregon | dlc_or |
|
||||
| Washington | washington | dlc_wa |
|
||||
| Utah | utah | dlc_ut |
|
||||
| Idaho | idaho | dlc_id |
|
||||
| Colorado | colorado | dlc_co |
|
||||
| Wyoming | wyoming | dlc_wy |
|
||||
| Montana | montana | dlc_mt |
|
||||
| Texas | texas | dlc_tx |
|
||||
| Oklahoma | oklahoma | dlc_ok |
|
||||
| Kansas | kansas | dlc_ks |
|
||||
| Nebraska (not released) | nebraska | ? |
|
||||
| Arkansas (not released) | arkansas | ? |
|
||||
| Missouri (not released) | missouri | ? |
|
||||
|
||||
# Euro Truck Simulator 2 DLC table
|
||||
|
||||
| DLC name | Config name | File name (.scs) |
|
||||
| --- | --- | --- |
|
||||
| Going East | going_east | dlc_east |
|
||||
| Scandinavia | scandinavia | dlc_north |
|
||||
| Vive la France | france | dlc_fr |
|
||||
| Italia | italy | dlc_it |
|
||||
| Beyond the Baltic Sea | baltic_sea | dlc_balt |
|
||||
| Road to the Black Sea | black_sea | dlc_balkan_e |
|
||||
| Iberia | iberia | dlc_iberia |
|
||||
| Heart of Russia (not released) | mother_russia | ? |
|
||||
| West Balkans | west_balkans | dlc_balkan_w |
|
||||
| Greece (not released) | greece | ? |
|
||||
| Nordic Horizons (not released) | nordic_horizons | ? |
|
||||
23
README.md
23
README.md
@@ -2,29 +2,26 @@
|
||||
|
||||
* Author of original "SaveWizard" script: DrEGZo
|
||||
* 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)
|
||||
|
||||
***
|
||||
|
||||
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.
|
||||
* Utility to decrypt file: <https://github.com/TheLazyTomcat/SII_Decrypt>
|
||||
|
||||
***
|
||||
|
||||
Features:
|
||||
1. Decrypt file, if save file crypted
|
||||
2. Check for DLC to the save file
|
||||
2. Check for DLC to the save file (available DLC listed at [DLC_TABLE.md](https://github.com/JDM170/SaveWizard/blob/configs/DLC_TABLE.md))
|
||||
3. Edit money, experience and loan limit
|
||||
4. Edit skills
|
||||
5. Unlock garages, visit cities, unlock dealers and agencies
|
||||
|
||||
**This functionality of the program isn't final!**
|
||||
5. Visit cities, unlock garages, dealers and agencies
|
||||
|
||||
***
|
||||
|
||||
Requirments:
|
||||
* Python 3.5.4 or higher
|
||||
* PyQt 5.6.0 or higher
|
||||
To build project You need Python 3.10.7 and installed requirements from [requirements.txt](https://github.com/JDM170/SaveWizard/blob/dev/requirements.txt)
|
||||
|
||||
Command to convert .ui to .py: ```pyuic5 -x input.ui -o output.py```
|
||||
Commands to build project:
|
||||
- cx_Freeze: ```python setup.py build```
|
||||
- PyInstaller: ```pyinstaller build.spec --clean```
|
||||
|
||||
***
|
||||
|
||||
#### Since the program is in development, I won't give up help and guidance on my errors in the code.
|
||||
#### If you've found a bug - please open an issue
|
||||
|
||||
BIN
SII_Decrypt.dll
Normal file
BIN
SII_Decrypt.dll
Normal file
Binary file not shown.
BIN
SII_Decrypt.exe
BIN
SII_Decrypt.exe
Binary file not shown.
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"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"]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"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"]
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
91
build.spec
91
build.spec
@@ -1,38 +1,59 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
|
||||
block_cipher = None
|
||||
app = Analysis(
|
||||
['init_main_program.py'],
|
||||
pathex=['.'],
|
||||
datas=[
|
||||
('SII_Decrypt.dll', '.'),
|
||||
('configs/ats', 'configs/ats'),
|
||||
('configs/ets2', 'configs/ets2')
|
||||
]
|
||||
)
|
||||
cfg = Analysis(
|
||||
['init_config_editor.py'],
|
||||
pathex=['.']
|
||||
)
|
||||
|
||||
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')
|
||||
MERGE(
|
||||
(app, 'SaveWizard', 'SaveWizard'),
|
||||
(cfg, 'SaveWizard_Config_Editor', 'SaveWizard_Config_Editor')
|
||||
)
|
||||
|
||||
app_pyz = PYZ(app.pure, app.zipped_data)
|
||||
cfg_pyz = PYZ(cfg.pure, cfg.zipped_data)
|
||||
|
||||
app_exe = EXE(
|
||||
app_pyz,
|
||||
app.scripts,
|
||||
[],
|
||||
exclude_binaries=True,
|
||||
name='SaveWizard',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
console=False
|
||||
)
|
||||
cfg_exe = EXE(
|
||||
cfg_pyz,
|
||||
cfg.scripts,
|
||||
[],
|
||||
exclude_binaries=True,
|
||||
name='SaveWizard_Config_Editor',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
console=False
|
||||
)
|
||||
|
||||
coll = COLLECT(
|
||||
app_exe,
|
||||
app.binaries,
|
||||
app.zipfiles,
|
||||
app.datas,
|
||||
cfg_exe,
|
||||
cfg.binaries,
|
||||
cfg.zipfiles,
|
||||
cfg.datas,
|
||||
strip=False,
|
||||
name='app_build'
|
||||
)
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
python setup.py build
|
||||
@@ -1 +0,0 @@
|
||||
pyinstaller build.spec
|
||||
88
configs/ats/agencies.json
Normal file
88
configs/ats/agencies.json
Normal file
@@ -0,0 +1,88 @@
|
||||
{
|
||||
"base" : [
|
||||
"bakersfield",
|
||||
"carson_city",
|
||||
"fresno",
|
||||
"las_vegas",
|
||||
"los_angeles",
|
||||
"oxnard",
|
||||
"redding",
|
||||
"san_diego",
|
||||
"san_rafael",
|
||||
"santa_cruz",
|
||||
"stockton"
|
||||
],
|
||||
"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",
|
||||
"price",
|
||||
"salt_lake",
|
||||
"st_george"
|
||||
],
|
||||
"idaho" : [
|
||||
"boise",
|
||||
"coeur_dalene",
|
||||
"idaho_falls",
|
||||
"twin_falls"
|
||||
],
|
||||
"colorado" : [
|
||||
"alamosa",
|
||||
"denver",
|
||||
"fort_collins"
|
||||
],
|
||||
"wyoming" : [
|
||||
"casper",
|
||||
"cheyenne",
|
||||
"rock_springs",
|
||||
"sheridan"
|
||||
],
|
||||
"montana" : [
|
||||
"great_falls",
|
||||
"havre",
|
||||
"helena",
|
||||
"kalispell"
|
||||
],
|
||||
"texas" : [
|
||||
"corpus_chris",
|
||||
"dallas",
|
||||
"el_paso",
|
||||
"houston",
|
||||
"huntsville",
|
||||
"laredo",
|
||||
"san_antonio"
|
||||
],
|
||||
"oklahoma" : [
|
||||
"ardmore",
|
||||
"enid"
|
||||
],
|
||||
"kansas" : [
|
||||
"hays",
|
||||
"kansas_ci_ks",
|
||||
"salina_ks",
|
||||
"topeka",
|
||||
"wichita"
|
||||
]
|
||||
}
|
||||
111
configs/ats/dealers.json
Normal file
111
configs/ats/dealers.json
Normal file
@@ -0,0 +1,111 @@
|
||||
{
|
||||
"base" : [
|
||||
"bakersfield",
|
||||
"elko",
|
||||
"las_vegas",
|
||||
"los_angeles",
|
||||
"oxnard",
|
||||
"redding",
|
||||
"reno",
|
||||
"sacramento",
|
||||
"san_diego",
|
||||
"san_francisc",
|
||||
"santa_cruz",
|
||||
"stockton"
|
||||
],
|
||||
"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",
|
||||
"st_george",
|
||||
"vernal"
|
||||
],
|
||||
"idaho" : [
|
||||
"boise",
|
||||
"idaho_falls",
|
||||
"lewiston",
|
||||
"twin_falls"
|
||||
],
|
||||
"colorado" : [
|
||||
"alamosa",
|
||||
"colorado_spr",
|
||||
"denver",
|
||||
"fort_collins",
|
||||
"grand_juncti",
|
||||
"montrose",
|
||||
"pueblo"
|
||||
],
|
||||
"wyoming" : [
|
||||
"casper",
|
||||
"cheyenne",
|
||||
"gillette",
|
||||
"rock_springs"
|
||||
],
|
||||
"montana" : [
|
||||
"billings",
|
||||
"great_falls",
|
||||
"helena",
|
||||
"kalispell",
|
||||
"missoula"
|
||||
],
|
||||
"texas" : [
|
||||
"abilene",
|
||||
"amarillo",
|
||||
"austin",
|
||||
"corpus_chris",
|
||||
"dallas",
|
||||
"el_paso",
|
||||
"fort_worth",
|
||||
"houston",
|
||||
"laredo",
|
||||
"longview_tx",
|
||||
"lubbock",
|
||||
"mcallen",
|
||||
"odessa",
|
||||
"san_angelo",
|
||||
"san_antonio",
|
||||
"waco"
|
||||
],
|
||||
"oklahoma" : [
|
||||
"ardmore",
|
||||
"enid",
|
||||
"oklahoma_cit"
|
||||
],
|
||||
"kansas" : [
|
||||
"dodge_city",
|
||||
"emporia",
|
||||
"garden_city",
|
||||
"hays",
|
||||
"kansas_ci_ks",
|
||||
"salina_ks",
|
||||
"wichita"
|
||||
]
|
||||
}
|
||||
14
configs/ats/dlc.json
Normal file
14
configs/ats/dlc.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"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.cm_min_qryp.moab",
|
||||
"idaho" : "company.volatile.du_farm.nampa",
|
||||
"colorado" : "company.volatile.aport_den.denver",
|
||||
"wyoming" : "company.volatile.aml_rail_str.cheyenne",
|
||||
"montana" : "company.volatile.aport_gtf.great_falls",
|
||||
"texas" : "company.volatile.aport_dfw.fort_worth",
|
||||
"oklahoma" : "company.volatile.aport_tul.tulsa",
|
||||
"kansas" : "company.volatile.ai_car_whs.junction_cty"
|
||||
}
|
||||
139
configs/ets2/agencies.json
Normal file
139
configs/ets2/agencies.json
Normal file
@@ -0,0 +1,139 @@
|
||||
{
|
||||
"base" : [
|
||||
"aberdeen",
|
||||
"berlin",
|
||||
"bialystok",
|
||||
"birmingham",
|
||||
"bremen",
|
||||
"brno",
|
||||
"brussel",
|
||||
"calais",
|
||||
"debrecen",
|
||||
"dortmund",
|
||||
"dover",
|
||||
"dresden",
|
||||
"edinburgh",
|
||||
"frankfurt",
|
||||
"glasgow",
|
||||
"graz",
|
||||
"groningen",
|
||||
"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",
|
||||
"travemunde",
|
||||
"wien",
|
||||
"zurich"
|
||||
],
|
||||
"east" : [
|
||||
"budapest",
|
||||
"gdansk",
|
||||
"krakow",
|
||||
"szeged",
|
||||
"warszawa"
|
||||
],
|
||||
"scandinavia" : [
|
||||
"aalborg",
|
||||
"bergen",
|
||||
"helsingborg",
|
||||
"kobenhavn",
|
||||
"malmo",
|
||||
"odense",
|
||||
"oslo",
|
||||
"stavanger",
|
||||
"stockholm"
|
||||
],
|
||||
"france" : [
|
||||
"ajaccio",
|
||||
"bordeaux",
|
||||
"clermont",
|
||||
"geneve",
|
||||
"larochelle",
|
||||
"lyon",
|
||||
"marseille",
|
||||
"metz",
|
||||
"paris",
|
||||
"rennes",
|
||||
"toulouse"
|
||||
],
|
||||
"italy" : [
|
||||
"bologna",
|
||||
"cagliari",
|
||||
"catania",
|
||||
"milano",
|
||||
"napoli",
|
||||
"pescara",
|
||||
"roma",
|
||||
"taranto",
|
||||
"venezia"
|
||||
],
|
||||
"baltic_sea" : [
|
||||
"daugavpils",
|
||||
"helsinki",
|
||||
"kaliningrad",
|
||||
"kaunas",
|
||||
"klaipeda",
|
||||
"kouvola",
|
||||
"lahti",
|
||||
"parnu",
|
||||
"pori",
|
||||
"pskov",
|
||||
"riga",
|
||||
"tallinn",
|
||||
"turku",
|
||||
"vilnius"
|
||||
],
|
||||
"black_sea" : [
|
||||
"bucuresti",
|
||||
"cluj_napoca",
|
||||
"iasi",
|
||||
"istanbul",
|
||||
"plovdiv",
|
||||
"sofia"
|
||||
],
|
||||
"iberia" : [
|
||||
"bilbao",
|
||||
"leon",
|
||||
"lisboa",
|
||||
"madrid",
|
||||
"malaga",
|
||||
"murcia",
|
||||
"porto",
|
||||
"valencia",
|
||||
"zaragoza"
|
||||
],
|
||||
"west_balkans" : [
|
||||
"beograd",
|
||||
"ljubljana",
|
||||
"maribor",
|
||||
"sarajevo",
|
||||
"skopje",
|
||||
"tirana",
|
||||
"zagreb"
|
||||
]
|
||||
}
|
||||
149
configs/ets2/dealers.json
Normal file
149
configs/ets2/dealers.json
Normal file
@@ -0,0 +1,149 @@
|
||||
{
|
||||
"base" : [
|
||||
"aberdeen",
|
||||
"amsterdam",
|
||||
"berlin",
|
||||
"bern",
|
||||
"birmingham",
|
||||
"bratislava",
|
||||
"bremen",
|
||||
"brussel",
|
||||
"calais",
|
||||
"cardiff",
|
||||
"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" : [
|
||||
"ajaccio",
|
||||
"bayonne",
|
||||
"bordeaux",
|
||||
"bourges",
|
||||
"brest",
|
||||
"geneve",
|
||||
"lemans",
|
||||
"limoges",
|
||||
"lyon",
|
||||
"marseille",
|
||||
"nantes",
|
||||
"paris",
|
||||
"toulouse"
|
||||
],
|
||||
"italy" : [
|
||||
"bologna",
|
||||
"cagliari",
|
||||
"catania",
|
||||
"firenze",
|
||||
"milano",
|
||||
"napoli",
|
||||
"palermo",
|
||||
"roma",
|
||||
"sassari",
|
||||
"taranto",
|
||||
"torino",
|
||||
"verona"
|
||||
],
|
||||
"baltic_sea" : [
|
||||
"helsinki",
|
||||
"kaliningrad",
|
||||
"kaunas",
|
||||
"klaipeda",
|
||||
"lahti",
|
||||
"petersburg",
|
||||
"riga",
|
||||
"tallinn",
|
||||
"tartu",
|
||||
"turku",
|
||||
"vilnius"
|
||||
],
|
||||
"black_sea" : [
|
||||
"brasov",
|
||||
"bucuresti",
|
||||
"cluj_napoca",
|
||||
"constanta",
|
||||
"edirne",
|
||||
"galati",
|
||||
"iasi",
|
||||
"istanbul",
|
||||
"pitesti",
|
||||
"plovdiv",
|
||||
"sofia",
|
||||
"veliko_tarnovo"
|
||||
],
|
||||
"iberia" : [
|
||||
"albacete",
|
||||
"almeria",
|
||||
"badajoz",
|
||||
"barcelona",
|
||||
"burgos",
|
||||
"cordoba",
|
||||
"gijon",
|
||||
"leon",
|
||||
"lisboa",
|
||||
"madrid",
|
||||
"malaga",
|
||||
"porto",
|
||||
"sevilla",
|
||||
"valladolid",
|
||||
"zaragoza"
|
||||
],
|
||||
"west_balkans" : [
|
||||
"banja_luka",
|
||||
"beograd",
|
||||
"kragujevac",
|
||||
"ljubljana",
|
||||
"maribor",
|
||||
"podgorica",
|
||||
"pristina",
|
||||
"rijeka",
|
||||
"skopje",
|
||||
"split",
|
||||
"tirana",
|
||||
"tuzla",
|
||||
"zagreb"
|
||||
]
|
||||
}
|
||||
10
configs/ets2/dlc.json
Normal file
10
configs/ets2/dlc.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"east" : "company.volatile.quarry.katowice",
|
||||
"scandinavia" : "company.volatile.sag_tre.oslo",
|
||||
"france" : "company.volatile.batisse_base.calvi",
|
||||
"italy" : "company.volatile.c_navale.ancona",
|
||||
"baltic_sea" : "company.volatile.aerobalt.helsinki",
|
||||
"black_sea" : "company.volatile.balkan_loco.craiova",
|
||||
"iberia" : "company.volatile.tdc_auto.vigo",
|
||||
"west_balkans" : "company.volatile.adrica.rijeka"
|
||||
}
|
||||
8
configs/version.cfg
Normal file
8
configs/version.cfg
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"ats_dlc": "96254fdb25d45d084b85b52a571f15db",
|
||||
"ats_agencies": "7a1499478092ca45ed226bd8ca7d6867",
|
||||
"ats_dealers": "78a88c9ce064276063f34eb4bc1cff88",
|
||||
"ets2_dlc": "38a4fa4c9ec51a4cb4754b4bd315cd24",
|
||||
"ets2_agencies": "155bfef072aedf17963a426e791d5b92",
|
||||
"ets2_dealers": "7412c51266e3378828e5bdeca3fe8912"
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
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
|
||||
27
dataIO.py
27
dataIO.py
@@ -1,26 +1,16 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
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:
|
||||
with open(filename, encoding="utf-8") 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:
|
||||
@@ -37,15 +27,12 @@ class DataIO:
|
||||
|
||||
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)
|
||||
with open(filename, encoding="utf-8", mode="w") as f:
|
||||
dump(data, f, indent=4, separators=(",", " : "))
|
||||
try:
|
||||
self._read_json(tmp_file)
|
||||
self._read_json(filename)
|
||||
except decoder.JSONDecodeError:
|
||||
return False
|
||||
replace(tmp_file, filename)
|
||||
return True
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"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"]
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"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"]
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
12
init_config_editor.py
Normal file
12
init_config_editor.py
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from sys import argv, exit
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from module_config_editor.script import EditorWindow
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(argv)
|
||||
win = EditorWindow()
|
||||
win.show()
|
||||
exit(app.exec_())
|
||||
@@ -3,10 +3,10 @@
|
||||
|
||||
from sys import argv, exit
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
from main.script import MainWindow
|
||||
from module_main.script import MainWindow
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QApplication(argv)
|
||||
win = MainWindow()
|
||||
win.show()
|
||||
exit(app.exec())
|
||||
exit(app.exec_())
|
||||
@@ -1 +0,0 @@
|
||||
# initialize module 'main' for compile program
|
||||
507
main/form.ui
507
main/form.ui
@@ -1,507 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>360</width>
|
||||
<height>370</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>360</width>
|
||||
<height>370</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<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">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>330</y>
|
||||
<width>141</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Apply changes</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="backup">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>330</y>
|
||||
<width>141</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Recover backup</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="path_button">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>161</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Choose save file...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="gridLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<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_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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="xp_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Experience:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="loan_limit_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Loan limit:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="money_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Money:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="gridLayoutWidget_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>140</y>
|
||||
<width>341</width>
|
||||
<height>161</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="skills_layout">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="long_distance_edit">
|
||||
<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">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Urgent delivery:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QCheckBox" name="ecodriving_dont_change">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="adr_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="urgent_delivery_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QCheckBox" name="fragile_cargo_dont_change">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="ecodriving_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QCheckBox" name="high_value_cargo_dont_change">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="fragile_cargo_edit">
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="long_distance_dont_change">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="high_value_cargo_edit">
|
||||
<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">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>High value cargo:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="fragile_cargo_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fragile cargo:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="ecodriving_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ecodriving:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="long_distance_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Long distance:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="adr_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ADR:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="second_window">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>160</x>
|
||||
<y>340</y>
|
||||
<width>41</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="dont_change_all_inf">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>300</y>
|
||||
<width>211</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't save all changes in this form</string>
|
||||
</property>
|
||||
</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
206
main/script.py
@@ -1,206 +0,0 @@
|
||||
#!/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
module_config_editor/__init__.py
Normal file
1
module_config_editor/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# initializing module 'config_editor'
|
||||
133
module_config_editor/form.ui
Normal file
133
module_config_editor/form.ui
Normal file
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<author>JDM170</author>
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>504</width>
|
||||
<height>374</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>9</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>SaveWizard config editor</string>
|
||||
</property>
|
||||
<property name="dockOptions">
|
||||
<set>QMainWindow::AllowTabbedDocks</set>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>501</width>
|
||||
<height>351</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Verdana</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>504</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="defaultUp">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="nativeMenuBar">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuOptions">
|
||||
<property name="title">
|
||||
<string>Options</string>
|
||||
</property>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="actionSave_As"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionMD5"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionCloseFile"/>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
<addaction name="menuOptions"/>
|
||||
</widget>
|
||||
<action name="actionOpen">
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+O</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_As">
|
||||
<property name="text">
|
||||
<string>Save As</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Shift+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCloseFile">
|
||||
<property name="text">
|
||||
<string>Close file</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Closing current file</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+W</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExit">
|
||||
<property name="text">
|
||||
<string>Exit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMD5">
|
||||
<property name="text">
|
||||
<string>Copy MD5</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
111
module_config_editor/script.py
Normal file
111
module_config_editor/script.py
Normal file
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt5.QtGui import QResizeEvent, QCloseEvent, QClipboard
|
||||
from PyQt5.QtWidgets import QMainWindow, QFileDialog, QMessageBox, QApplication
|
||||
from ast import literal_eval
|
||||
from .form import Ui_MainWindow
|
||||
from dataIO import dataIO
|
||||
from util import util
|
||||
|
||||
|
||||
class EditorWindow(QMainWindow, Ui_MainWindow):
|
||||
def __init__(self, parent=None):
|
||||
QMainWindow.__init__(self, parent, flags=Qt.Window)
|
||||
Ui_MainWindow.__init__(self)
|
||||
self.ui = Ui_MainWindow()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
self.file_path = ""
|
||||
self.win_title = self.tr("{}".format(self.windowTitle()))
|
||||
|
||||
self.ui.textEdit.document().contentsChanged.connect(self.content_changed)
|
||||
|
||||
for action, method in {
|
||||
self.ui.actionOpen: self.open_file,
|
||||
self.ui.actionSave: self.save_file,
|
||||
self.ui.actionSave_As: self.save_as,
|
||||
self.ui.actionMD5: self.copy_hash,
|
||||
self.ui.actionCloseFile: self.close_file,
|
||||
self.ui.actionExit: self.exit
|
||||
}.items():
|
||||
action.triggered.connect(method)
|
||||
|
||||
def resizeEvent(self, event: QResizeEvent):
|
||||
window = self.ui.centralwidget.geometry().getCoords()
|
||||
edit = self.ui.textEdit.geometry().getCoords()
|
||||
self.ui.textEdit.setGeometry(edit[0], edit[1],
|
||||
window[2], window[3]-(self.ui.menubar.size().height()-1))
|
||||
|
||||
def closeEvent(self, event: QCloseEvent):
|
||||
if self.maybe_save():
|
||||
event.accept()
|
||||
else:
|
||||
event.ignore()
|
||||
|
||||
def content_changed(self):
|
||||
self.setWindowModified(self.ui.textEdit.document().isModified())
|
||||
|
||||
def open_file(self):
|
||||
file_path, file_name = QFileDialog.getOpenFileName(parent=self,
|
||||
caption=self.tr("Choose config..."),
|
||||
filter=self.tr("*.json"))
|
||||
if file_path != "":
|
||||
self.file_path = file_path
|
||||
with open(file_path) as f:
|
||||
self.ui.textEdit.setPlainText(f.read())
|
||||
self.setWindowTitle(self.tr("[*]{} - {}".format(file_path, self.win_title)))
|
||||
self.ui.textEdit.document().setModified(False)
|
||||
self.setWindowModified(False)
|
||||
|
||||
def save_file(self):
|
||||
if self.file_path != "":
|
||||
data = literal_eval(self.ui.textEdit.toPlainText())
|
||||
ret = dataIO.save_json(self.file_path, data)
|
||||
if ret:
|
||||
self.ui.textEdit.document().setModified(False)
|
||||
self.setWindowModified(False)
|
||||
return ret
|
||||
|
||||
def save_as(self):
|
||||
file_path, file_name = QFileDialog.getSaveFileName(parent=self,
|
||||
caption=self.tr("Select place to save file"),
|
||||
filter=self.tr("*.json"))
|
||||
file_data = literal_eval(self.ui.textEdit.toPlainText())
|
||||
ret = dataIO.save_json(file_path, file_data)
|
||||
if ret:
|
||||
self.file_path = file_path
|
||||
self.setWindowTitle(self.tr("[*]{} - {}".format(file_path, self.win_title)))
|
||||
self.ui.textEdit.document().setModified(False)
|
||||
self.setWindowModified(False)
|
||||
|
||||
def copy_hash(self):
|
||||
if self.maybe_save():
|
||||
result = util.generate_md5(self.file_path)
|
||||
clip = QApplication.clipboard()
|
||||
QClipboard.setText(clip, result)
|
||||
QMessageBox.information(self, "Information", "Hash successfully copied into your clipboard.")
|
||||
|
||||
def close_file(self):
|
||||
if self.maybe_save():
|
||||
self.setWindowTitle(self.win_title)
|
||||
self.ui.textEdit.clear()
|
||||
self.file_path = ""
|
||||
|
||||
def exit(self):
|
||||
self.close()
|
||||
|
||||
def maybe_save(self):
|
||||
if not self.ui.textEdit.document().isModified():
|
||||
return True
|
||||
box = QMessageBox.warning(self,
|
||||
self.tr("SaveWizard config editor"),
|
||||
self.tr("The document has been modified.\nDo you want to save your changes?"),
|
||||
QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
|
||||
if box == QMessageBox.Save:
|
||||
return self.save_file()
|
||||
elif box == QMessageBox.Discard:
|
||||
return True
|
||||
elif box == QMessageBox.Cancel:
|
||||
return False
|
||||
return True
|
||||
1
module_main/__init__.py
Normal file
1
module_main/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# initialize module 'main'
|
||||
563
module_main/form.ui
Normal file
563
module_main/form.ui
Normal file
@@ -0,0 +1,563 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<author>JDM170</author>
|
||||
<class>MainWindow</class>
|
||||
<widget class="QDialog" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>360</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>360</width>
|
||||
<height>400</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>360</width>
|
||||
<height>400</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>SaveWizard</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="gridLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>50</y>
|
||||
<width>341</width>
|
||||
<height>104</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="basic_inf_layout">
|
||||
<item row="1" 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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="xp_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Experience:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<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="1">
|
||||
<widget class="QLineEdit" name="money_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="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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<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="3" 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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="money_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Money:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="loan_limit_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Loan limit:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QLabel" name="basic_inf_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Basic info</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="path_button">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>161</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Choose save file...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="backup">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>360</y>
|
||||
<width>111</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Recover backup</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="dont_change_all_inf">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>400</y>
|
||||
<width>211</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Don't save all changes in this form</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="gridLayoutWidget_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>160</y>
|
||||
<width>341</width>
|
||||
<height>191</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="skills_layout">
|
||||
<item row="3" 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="2" 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="6" column="1">
|
||||
<widget class="QLineEdit" name="ecodriving_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="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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<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="6" column="0">
|
||||
<widget class="QLabel" name="ecodriving_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ecodriving:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="high_value_cargo_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>High value cargo:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<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="5" 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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="fragile_cargo_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Fragile cargo:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="long_distance_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Long distance:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="adr_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ADR:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="urgent_delivery_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Urgent delivery:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<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="5" column="1">
|
||||
<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="4" 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="6" 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="1" column="1">
|
||||
<widget class="QLineEdit" name="adr_edit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QLabel" name="skills_label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Skills</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="apply">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>250</x>
|
||||
<y>360</y>
|
||||
<width>101</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Apply changes</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QToolButton" name="second_window">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>360</y>
|
||||
<width>111</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Unlock garages</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="updates_checkbox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
<y>10</y>
|
||||
<width>181</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Check updates on startup</string>
|
||||
</property>
|
||||
</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>second_window</tabstop>
|
||||
<tabstop>backup</tabstop>
|
||||
<tabstop>apply</tabstop>
|
||||
<tabstop>dont_change_all_inf</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
241
module_main/script.py
Normal file
241
module_main/script.py
Normal file
@@ -0,0 +1,241 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from ast import literal_eval
|
||||
from ctypes import CDLL
|
||||
from os import getcwd, remove
|
||||
|
||||
from PyQt5.QtCore import QRegExp
|
||||
from PyQt5.QtGui import QRegExpValidator
|
||||
from PyQt5.QtWidgets import QDialog, QFileDialog
|
||||
|
||||
from dataIO import dataIO
|
||||
from module_parsing.script import update_configs
|
||||
from module_second.script import SecondWindow
|
||||
from statics import update_config_name
|
||||
from util import *
|
||||
from .form import Ui_MainWindow
|
||||
|
||||
libDecrypt = CDLL("{}\\SII_Decrypt.dll".format(getcwd()))
|
||||
|
||||
|
||||
class MainWindow(QDialog, Ui_MainWindow):
|
||||
def __init__(self, parent=None):
|
||||
# Setup UI
|
||||
QDialog.__init__(self, parent, flags=Qt.Window)
|
||||
Ui_MainWindow.__init__(self)
|
||||
self.ui = Ui_MainWindow()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
update_cfg = {"update_on_start": False}
|
||||
if isfile(update_config_name):
|
||||
with open(update_config_name, "r") as f:
|
||||
update_cfg = literal_eval(f.read())
|
||||
|
||||
update_bool = update_cfg.get("update_on_start")
|
||||
if update_bool:
|
||||
self.ui.updates_checkbox.setChecked(update_bool)
|
||||
update_configs()
|
||||
|
||||
self.file_path = ""
|
||||
self.old_file = ""
|
||||
|
||||
self.selected_game = ""
|
||||
self.owns = {}
|
||||
self.dlc = {}
|
||||
|
||||
# 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]{,9}"))
|
||||
for key in self.basic_edits.keys():
|
||||
key.setValidator(basic_validator)
|
||||
key.textEdited.connect(self.text_edited)
|
||||
|
||||
adr_validator_text = ""
|
||||
for i in range(6):
|
||||
adr_validator_text += r"\d[., ]?" if i != 5 else r"\d"
|
||||
self.ui.adr_edit.textEdited.connect(self.text_edited)
|
||||
self.ui.adr_edit.setValidator(QRegExpValidator(QRegExp(adr_validator_text)))
|
||||
skills_validator = QRegExpValidator(QRegExp("[0-6]{,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.updates_checkbox.clicked.connect(self.update_on_startup)
|
||||
self.ui.second_window.clicked.connect(self.open_second_win)
|
||||
self.ui.backup.clicked.connect(self.recover_backup)
|
||||
self.ui.apply.clicked.connect(self.apply_changes)
|
||||
|
||||
self.clear_form_data()
|
||||
|
||||
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 check_config(self):
|
||||
cfg_path = "configs/{}/dlc.json".format(self.selected_game)
|
||||
if dataIO.is_valid_json(cfg_path) is False:
|
||||
self.owns = False
|
||||
QMessageBox.warning(self, "Warning", "'dlc.json' from '{}' have errors or not found, "
|
||||
"functionality has been limited".format(self.selected_game))
|
||||
else:
|
||||
self.owns = {}
|
||||
self.dlc = dataIO.load_json(cfg_path)
|
||||
|
||||
def clear_form_data(self):
|
||||
self.file_path = ""
|
||||
self.old_file = ""
|
||||
util.set_lines([])
|
||||
|
||||
self.selected_game = ""
|
||||
self.owns = {}
|
||||
self.dlc = {}
|
||||
|
||||
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_path):
|
||||
bytes_file_path = file_path.replace("/", "\\").encode("utf-8")
|
||||
if libDecrypt.GetFileFormat(bytes_file_path) == 2:
|
||||
if libDecrypt.DecryptAndDecodeFile(bytes_file_path, bytes_file_path) != 0:
|
||||
QMessageBox.critical(self, "Error", "Something went wrong with decrypting file. Try again.")
|
||||
return
|
||||
|
||||
with open(file_path) as f:
|
||||
self.old_file = f.read()
|
||||
util.set_lines(self.old_file.split("\n"))
|
||||
|
||||
if util.search_line("company.volatile.eurogoodies.magdeburg"):
|
||||
self.selected_game = "ets2"
|
||||
else:
|
||||
self.selected_game = "ats"
|
||||
self.check_config()
|
||||
|
||||
if self.owns is not False:
|
||||
self.owns["base"] = True
|
||||
companies = util.get_array_items(util.search_line("companies:"))
|
||||
for key, value in self.dlc.items():
|
||||
if value in companies:
|
||||
self.owns[key] = True
|
||||
|
||||
for key, value in self.basic_edits.items():
|
||||
key.setText(util.get_value(util.search_line(value[1])))
|
||||
|
||||
adr = self.get_adr(util.get_value(util.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(util.get_value(util.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_path, file_name = QFileDialog.getOpenFileName(parent=self,
|
||||
caption=self.tr("Choose your save file..."),
|
||||
filter=self.tr("game.sii"))
|
||||
self.clear_form_data()
|
||||
if file_path != "":
|
||||
self.file_path = file_path
|
||||
self.get_file_data(file_path)
|
||||
else:
|
||||
return
|
||||
|
||||
def update_on_startup(self):
|
||||
with open(update_config_name, "w") as f:
|
||||
f.write(str({"update_on_start": self.ui.updates_checkbox.isChecked()}))
|
||||
|
||||
def open_second_win(self):
|
||||
second_win = SecondWindow(self.selected_game, self.owns, self)
|
||||
second_win.exec_()
|
||||
|
||||
def recover_backup(self):
|
||||
backup_path = self.file_path + ".swbak"
|
||||
if not isfile(backup_path):
|
||||
QMessageBox.critical(self, "Error", "Backup not found.")
|
||||
return
|
||||
with open(self.file_path, "w") as current:
|
||||
with open(backup_path) as backup:
|
||||
current.write(backup.read())
|
||||
remove(backup_path)
|
||||
QMessageBox.information(self, "Success", "Backup successfully recovered.")
|
||||
self.get_file_data(self.file_path)
|
||||
|
||||
def apply_changes(self):
|
||||
if self.ui.dont_change_all_inf.isChecked():
|
||||
return
|
||||
for key, value in self.basic_edits.items():
|
||||
if value[0].isChecked() is False:
|
||||
util.set_value(util.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:
|
||||
QMessageBox.critical(self, "Error", "ADR can't have less than 6 elements.")
|
||||
elif len(adr_set) > 6:
|
||||
QMessageBox.critical(self, "Error", "ADR can't have more than 6 elements.")
|
||||
else:
|
||||
adr_new = int("".join(adr_set), 2)
|
||||
util.set_value(util.search_line("adr:"), str(adr_new))
|
||||
for key, value in self.skill_edits.items():
|
||||
if value[0].isChecked() is False:
|
||||
util.set_value(util.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(util.get_lines()))
|
||||
QMessageBox.information(self, "Success", "Changes successfully applied!")
|
||||
self.get_file_data(self.file_path)
|
||||
1
module_parsing/__init__.py
Normal file
1
module_parsing/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# initialize module 'parsing'
|
||||
66
module_parsing/script.py
Normal file
66
module_parsing/script.py
Normal file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from ast import literal_eval
|
||||
|
||||
from requests import get
|
||||
|
||||
from dataIO import dataIO
|
||||
from statics import github_link
|
||||
from util import util
|
||||
|
||||
|
||||
def get_response_result(url):
|
||||
"""
|
||||
Getting the result from a given url
|
||||
:param url: place where we get data
|
||||
:return: status code (True or False), response body
|
||||
"""
|
||||
response = get(url)
|
||||
return response.status_code == 200, response
|
||||
|
||||
|
||||
def check_path(path):
|
||||
"""
|
||||
Checks if the path exists (if not, creates it)
|
||||
:param path: path to check
|
||||
"""
|
||||
current_path = os.getcwd()
|
||||
for item in path.split("/"):
|
||||
current_path = os.path.join(str(current_path), item)
|
||||
if not os.path.exists(current_path):
|
||||
if item.find(".json") > 0:
|
||||
open(current_path, "w").close()
|
||||
else:
|
||||
os.mkdir(current_path)
|
||||
|
||||
|
||||
def check_remote_hashes():
|
||||
response_status, response = get_response_result(github_link + "configs/version.cfg")
|
||||
if response_status:
|
||||
remote_cfg = literal_eval(response.text)
|
||||
need_update = []
|
||||
for key, value in remote_cfg.items():
|
||||
path = key.split("_")
|
||||
path = "configs/{}/{}.json".format(path[0], path[1])
|
||||
if util.generate_md5(path) != value:
|
||||
need_update.append(path)
|
||||
return need_update
|
||||
return False
|
||||
|
||||
|
||||
def update_configs():
|
||||
update_list = check_remote_hashes()
|
||||
if not update_list or len(update_list) == 0:
|
||||
return
|
||||
progress_bar = util.show_progress_bar("Download progress", "Downloading configs...", len(update_list))
|
||||
for cfg in update_list:
|
||||
check_path(cfg)
|
||||
response_status, response = get_response_result(github_link + cfg)
|
||||
if response_status:
|
||||
remote_cfg = literal_eval(response.text)
|
||||
if dataIO.is_valid_json(cfg) or os.path.exists(cfg):
|
||||
dataIO.save_json(cfg, remote_cfg)
|
||||
util.update_progress_bar(progress_bar)
|
||||
util.update_progress_bar(progress_bar, len(update_list))
|
||||
1
module_second/__init__.py
Normal file
1
module_second/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# initialize module 'second'
|
||||
@@ -1,10 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<author>JDM170</author>
|
||||
<class>SecondWindow</class>
|
||||
<widget class="QDialog" name="SecondWindow">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::WindowModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@@ -41,25 +39,6 @@
|
||||
</rect>
|
||||
</property>
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="garages_label">
|
||||
<property name="font">
|
||||
@@ -92,6 +71,25 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTextEdit" 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="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="gridLayoutWidget_5">
|
||||
@@ -121,7 +119,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTextBrowser" name="cities_text">
|
||||
<widget class="QTextEdit" name="cities_text">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
@@ -134,8 +132,8 @@
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="openLinks">
|
||||
<bool>false</bool>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -168,7 +166,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTextBrowser" name="dealerships_text">
|
||||
<widget class="QTextEdit" name="dealerships_text">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
@@ -181,8 +179,8 @@
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="openLinks">
|
||||
<bool>false</bool>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -215,7 +213,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTextBrowser" name="agencies_text">
|
||||
<widget class="QTextEdit" name="agencies_text">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Times New Roman</family>
|
||||
@@ -228,8 +226,8 @@
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="openLinks">
|
||||
<bool>false</bool>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
297
module_second/script.py
Normal file
297
module_second/script.py
Normal file
@@ -0,0 +1,297 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
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, selected_game, owns_list, parent=None):
|
||||
# Setup UI
|
||||
QDialog.__init__(self, parent, flags=(Qt.Window | Qt.WindowTitleHint | Qt.WindowCloseButtonHint))
|
||||
Ui_SecondWindow.__init__(self)
|
||||
self.ui = Ui_SecondWindow()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
self.owns = owns_list # From main window
|
||||
|
||||
# Checking config files
|
||||
cfg_path = "configs/{}".format(selected_game)
|
||||
dealers_path = "{}/dealers.json".format(cfg_path)
|
||||
if dataIO.is_valid_json(dealers_path) is False:
|
||||
self.dealers = False
|
||||
self.ui.dealer_edit.setEnabled(False)
|
||||
self.ui.dealer_add.setEnabled(False)
|
||||
self.ui.dealer_add_all.setEnabled(False)
|
||||
QMessageBox.warning(self, "Warning", "'dealers.json' from '{}' have errors or not found.\n"
|
||||
"Dealers editing has been disabled".format(selected_game))
|
||||
else:
|
||||
self.dealers = []
|
||||
self.dealers_file = dataIO.load_json(dealers_path)
|
||||
|
||||
agencies_path = "{}/agencies.json".format(cfg_path)
|
||||
if dataIO.is_valid_json(agencies_path) is False:
|
||||
self.agencies = False
|
||||
self.ui.agency_edit.setEnabled(False)
|
||||
self.ui.agency_add.setEnabled(False)
|
||||
self.ui.agency_add_all.setEnabled(False)
|
||||
QMessageBox.warning(self, "Warning", "'agencies.json' from '{}' have errors or not found.\n"
|
||||
"Agencies editing has been disabled".format(selected_game))
|
||||
else:
|
||||
self.agencies = []
|
||||
self.agencies_file = dataIO.load_json(agencies_path)
|
||||
|
||||
self.ui.garage_size.addItem("Small")
|
||||
self.ui.garage_size.addItem("Medium")
|
||||
self.ui.garage_size.addItem("Big")
|
||||
|
||||
self.da_statics = {
|
||||
"dealer": [
|
||||
self.dealers, # city_list
|
||||
"unlocked_dealers:", # line_to_search
|
||||
self.check_dealers, # check_func
|
||||
],
|
||||
"agency": [
|
||||
self.agencies, # city_list
|
||||
"unlocked_recruitments:", # line_to_search
|
||||
self.check_agencies, # check_func
|
||||
],
|
||||
}
|
||||
|
||||
self.add_da_handlers = {
|
||||
self.ui.dealer_add: [
|
||||
"dealer",
|
||||
self.ui.dealer_edit, # city_to_add
|
||||
"Dealership", # message_variable
|
||||
],
|
||||
self.ui.dealer_add_all: [
|
||||
"dealer",
|
||||
"All dealerships unlocked.", # success_message
|
||||
"Visiting dealers", # progress_message
|
||||
],
|
||||
self.ui.agency_add: [
|
||||
"agency",
|
||||
self.ui.agency_edit, # city_to_add
|
||||
"Recruitment agency", # message_variable
|
||||
],
|
||||
self.ui.agency_add_all: [
|
||||
"agency",
|
||||
"All recruitment agencies unlocked.", # success_message
|
||||
"Visiting agencies", # progress_message
|
||||
],
|
||||
}
|
||||
|
||||
# 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_da_clicked)
|
||||
self.ui.agency_add.clicked.connect(self.add_da_clicked)
|
||||
self.ui.dealer_add_all.clicked.connect(self.add_all_da_clicked)
|
||||
self.ui.agency_add_all.clicked.connect(self.add_all_da_clicked)
|
||||
|
||||
if self.owns:
|
||||
self.fill_list(self.owns, self.dealers, self.dealers_file)
|
||||
self.fill_list(self.owns, self.agencies, self.agencies_file)
|
||||
|
||||
# Checking save-file
|
||||
self.check_cities()
|
||||
self.check_dealers()
|
||||
self.check_agencies()
|
||||
|
||||
@staticmethod
|
||||
def all_cities():
|
||||
cities = []
|
||||
for line in util.get_array_items(util.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
|
||||
|
||||
@staticmethod
|
||||
def add_vehicles_and_drivers(start_line, garage_size):
|
||||
vehicles_array = util.search_line("vehicles:", start=start_line)
|
||||
drivers_array = util.search_line("drivers:", start=start_line)
|
||||
for i in range(1, garage_size + 1):
|
||||
util.add_array_value(vehicles_array, "null")
|
||||
util.add_array_value(drivers_array + i, "null")
|
||||
|
||||
@staticmethod
|
||||
def purchased_garages():
|
||||
garages = []
|
||||
for index in util.search_all_lines("garage : garage."):
|
||||
city = match(r"garage : garage.(.+) {$", util.get_lines(index)).group(1)
|
||||
if util.get_value(util.search_line("status:", start=index)) != "0":
|
||||
garages.append(city)
|
||||
return garages
|
||||
|
||||
@staticmethod
|
||||
def fill_list(owns, array, file):
|
||||
if array is False:
|
||||
return
|
||||
for key in owns.keys():
|
||||
if key not in file:
|
||||
continue
|
||||
for value in file[key]:
|
||||
array.append(value)
|
||||
|
||||
def check_garage_size(self):
|
||||
status_id, size = garages_stat[self.ui.garage_size.currentText()]
|
||||
return str(status_id), size
|
||||
|
||||
def check_garages(self):
|
||||
self.ui.garages_text.clear()
|
||||
garages = self.purchased_garages()
|
||||
for garage in garages:
|
||||
self.ui.garages_text.append(garage)
|
||||
self.ui.garages_text.scrollToAnchor(garages[0])
|
||||
|
||||
def add_garage(self):
|
||||
garage = self.ui.garage_edit.text().lower()
|
||||
if garage == "":
|
||||
QMessageBox.critical(self, "Error", "Enter city name!")
|
||||
return
|
||||
self.ui.garage_edit.setText("")
|
||||
current_garage = util.search_line("garage : garage." + garage + " {")
|
||||
if current_garage is None:
|
||||
QMessageBox.critical(self, "Error", "Garage in \"{}\" not found.".format(garage))
|
||||
return
|
||||
current_status = util.search_line_in_unit("status:", "garage." + garage)
|
||||
if util.get_value(current_status) == "0":
|
||||
new_status, size = self.check_garage_size()
|
||||
util.set_value(current_status, new_status)
|
||||
self.add_vehicles_and_drivers(current_garage, size)
|
||||
QMessageBox.information(self, "Success", "Garage in \"{}\" successfully unlocked.".format(garage))
|
||||
else:
|
||||
QMessageBox.critical(self, "Error", "Garage in \"{}\" already unlocked.".format(garage))
|
||||
|
||||
def add_all_garages(self):
|
||||
new_status, size = self.check_garage_size()
|
||||
for item in util.get_array_items(util.search_line("garages:")):
|
||||
item = match(r"garage.(.+)$", item).group(1)
|
||||
current_garage = util.search_line("garage : garage." + item + " {")
|
||||
current_status = util.search_line("status:", start=current_garage)
|
||||
if util.get_value(current_status) == "0":
|
||||
util.set_value(current_status, new_status)
|
||||
self.add_vehicles_and_drivers(current_garage, size)
|
||||
QMessageBox.information(self, "Success", "All garages successfully unlocked.")
|
||||
|
||||
def change_headquarter(self):
|
||||
hq = self.ui.headquarter_edit.text().lower()
|
||||
if hq == "":
|
||||
QMessageBox.critical(self, "Error", "Enter city name!")
|
||||
return
|
||||
if util.get_value(util.search_line("hq_city:")) == hq:
|
||||
QMessageBox.information(self, "Info", "Your headquarter is already in this city.")
|
||||
elif hq not in self.purchased_garages():
|
||||
QMessageBox.critical(self, "Error", "You need a garage in \"{}\" to set headquarter.".format(hq))
|
||||
else:
|
||||
util.set_value(util.search_line("hq_city:"), hq)
|
||||
QMessageBox.information(self, "Success", "Headquarter successfully set to \"{}\".".format(hq))
|
||||
|
||||
def check_cities(self):
|
||||
self.ui.headquarter_edit.setText(util.get_value(util.search_line("hq_city:")))
|
||||
self.ui.cities_text.clear()
|
||||
visited_cities = util.get_array_items(util.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)
|
||||
self.ui.cities_text.scrollToAnchor(visited_cities[0])
|
||||
|
||||
def add_city(self):
|
||||
city = self.ui.city_edit.text().lower()
|
||||
if city == "":
|
||||
QMessageBox.critical(self, "Error", "Enter city name!")
|
||||
return
|
||||
self.ui.city_edit.setText("")
|
||||
if city not in util.get_array_items(util.search_line("visited_cities:")):
|
||||
util.add_array_value(util.search_line("visited_cities:"), city)
|
||||
util.add_array_value(util.search_line("visited_cities_count:"), "1")
|
||||
QMessageBox.information(self, "Success", "City \"{}\" successfully visited.".format(city))
|
||||
self.check_cities()
|
||||
else:
|
||||
QMessageBox.critical(self, "Error", "You've already visited \"{}\".".format(city))
|
||||
|
||||
def add_all_cities(self):
|
||||
all_cities = self.all_cities()
|
||||
visited_cities = util.get_array_items(util.search_line("visited_cities:"))
|
||||
progress = util.show_progress_bar("Visiting cities", "Visiting cities...", len(all_cities)-len(visited_cities))
|
||||
for city in all_cities:
|
||||
if city not in visited_cities:
|
||||
util.add_array_value(util.search_line("visited_cities:"), city)
|
||||
util.add_array_value(util.search_line("visited_cities_count:"), "1")
|
||||
util.update_progress_bar(progress)
|
||||
QMessageBox.information(self, "Success", "All cities successfully visited.")
|
||||
self.check_cities()
|
||||
|
||||
def check_dealers(self):
|
||||
self.ui.dealerships_text.clear()
|
||||
visited_dealers = util.get_array_items(util.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)
|
||||
self.ui.dealerships_text.scrollToAnchor(visited_dealers[0])
|
||||
|
||||
def check_agencies(self):
|
||||
self.ui.agencies_text.clear()
|
||||
visited_agencies = util.get_array_items(util.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)
|
||||
self.ui.agencies_text.scrollToAnchor(visited_agencies[0])
|
||||
|
||||
def add_da_clicked(self):
|
||||
da_arr = self.add_da_handlers.get(self.sender())
|
||||
if da_arr is None:
|
||||
return
|
||||
static_key, city_to_add, message_variable = da_arr
|
||||
city_list, line_to_search, check_func = self.da_statics.get(static_key)
|
||||
city_element = city_to_add.text().lower()
|
||||
if not city_element:
|
||||
QMessageBox.critical(self, "Error", "Enter city name!")
|
||||
return
|
||||
city_to_add.setText("")
|
||||
if city_element not in city_list:
|
||||
QMessageBox.critical(self, "Error", "There is no {} in that city.".format(message_variable.lower()))
|
||||
elif city_element in util.get_array_items(util.search_line(line_to_search)):
|
||||
QMessageBox.information(self, "Info", "{} in \"{}\" is already unlocked.".format(message_variable,
|
||||
city_element))
|
||||
else:
|
||||
util.add_array_value(util.search_line(line_to_search), city_element)
|
||||
QMessageBox.information(self, "Success", "{} in \"{}\" successfully unlocked."
|
||||
"".format(message_variable, city_element))
|
||||
check_func()
|
||||
|
||||
def add_all_da_clicked(self):
|
||||
da_arr = self.add_da_handlers.get(self.sender())
|
||||
if da_arr is None:
|
||||
return
|
||||
static_key, success_message, progress_message = da_arr
|
||||
city_list, line_to_search, check_func = self.da_statics.get(static_key)
|
||||
all_cities = self.all_cities()
|
||||
array_line = util.search_line(line_to_search)
|
||||
visited_cities = util.get_array_items(array_line)
|
||||
progress = util.show_progress_bar(progress_message, progress_message+"...", len(all_cities)-len(visited_cities))
|
||||
for element in city_list:
|
||||
if (element in all_cities) and (element not in visited_cities):
|
||||
util.add_array_value(array_line, element)
|
||||
util.update_progress_bar(progress)
|
||||
QMessageBox.information(self, "Success", success_message)
|
||||
check_func()
|
||||
17
requirements.txt
Normal file
17
requirements.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
altgraph==0.17.4
|
||||
certifi==2023.11.17
|
||||
charset-normalizer==3.3.2
|
||||
cx_Freeze==7.0.0
|
||||
cx-Logging==3.1.0
|
||||
idna==3.7
|
||||
lief==0.14.0
|
||||
packaging==23.2
|
||||
pefile==2023.2.7
|
||||
pyinstaller==6.3.0
|
||||
pyinstaller-hooks-contrib==2023.11
|
||||
PyQt5==5.15.10
|
||||
PyQt5-Qt5==5.15.2
|
||||
PyQt5-sip==12.13.0
|
||||
pywin32-ctypes==0.2.2
|
||||
requests==2.32.0
|
||||
urllib3==2.2.2
|
||||
@@ -1 +0,0 @@
|
||||
# initialize module 'second' for compile program
|
||||
257
second/script.py
257
second/script.py
@@ -1,257 +0,0 @@
|
||||
#!/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()
|
||||
47
setup.py
47
setup.py
@@ -1,20 +1,47 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from sys import platform
|
||||
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']
|
||||
base = None
|
||||
if platform == 'win32':
|
||||
base = 'Win32GUI'
|
||||
|
||||
executables = [
|
||||
Executable('init_main_program.py', target_name='SaveWizard.exe', base=base),
|
||||
Executable('init_config_editor.py', target_name='SaveWizard_Config_Editor.exe', base=base)
|
||||
]
|
||||
|
||||
excludes = ['html', 'pydoc_data', 'unittest', 'xml', 'pwd', 'shlex', 'platform', 'webbrowser', 'pydoc',
|
||||
'tty', 'doctest', 'plistlib', 'subprocess', 'bz2', '_strptime', 'dummy_threading']
|
||||
|
||||
includes = ['pkgutil', 'enum', 'queue']
|
||||
|
||||
zip_include_packages = [
|
||||
# Stock modules
|
||||
'collections', 'encodings', 'importlib', 'json', 'hashlib', 'selectors', 'select', 'http', 'email', 'datetime',
|
||||
'calendar', 'urllib', 'posixpath', 'tempfile', 'shutil', 'copy', 'stringprep', 'socket', 'ast', 'ssl', 'ctypes',
|
||||
# PyQt5
|
||||
'PyQt5',
|
||||
# Modules for parsing cfg's
|
||||
'requests', 'logging', 'certifi', 'chardet', 'idna', 'urllib3', 'inspect',
|
||||
# Self-written modules
|
||||
'module_parsing', 'module_main', 'module_second', 'module_config_editor'
|
||||
]
|
||||
|
||||
include_files = [
|
||||
'SII_Decrypt.dll',
|
||||
('configs/ats', 'configs/ats'),
|
||||
('configs/ets2', 'configs/ets2')
|
||||
]
|
||||
|
||||
options = {
|
||||
'build_exe': {
|
||||
'excludes': excludes,
|
||||
'includes': includes,
|
||||
'include_msvcr': True,
|
||||
'build_exe': 'stable_build',
|
||||
'build_exe': 'prog_build',
|
||||
'include_files': include_files,
|
||||
'zip_include_packages': zip_include_packages,
|
||||
}
|
||||
@@ -22,9 +49,9 @@ options = {
|
||||
|
||||
setup(
|
||||
name='SaveWizard',
|
||||
version='1.1.1',
|
||||
version='1.4.1',
|
||||
description='For editing ETS2 sii files',
|
||||
executables=executables,
|
||||
options=options,
|
||||
requires=['PyQt5']
|
||||
requires=['PyQt5', 'requests'],
|
||||
)
|
||||
|
||||
6
statics.py
Normal file
6
statics.py
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
update_config_name = "update.cfg"
|
||||
github_link = "https://raw.githubusercontent.com/JDM170/SaveWizard/configs/"
|
||||
hash_chunk_size = 4096
|
||||
229
util.py
229
util.py
@@ -1,128 +1,133 @@
|
||||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from re import search, match, sub
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
|
||||
lines = []
|
||||
from os.path import isfile
|
||||
from re import search, match
|
||||
# from re import search, match, sub
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import (
|
||||
QMessageBox, QProgressDialog, QApplication
|
||||
)
|
||||
from hashlib import md5
|
||||
from statics import hash_chunk_size
|
||||
|
||||
|
||||
# Custom functions
|
||||
def set_lines(new_lines):
|
||||
global lines
|
||||
lines = new_lines
|
||||
class CustomFuncs:
|
||||
# Custom functions
|
||||
def __init__(self):
|
||||
self.lines = []
|
||||
|
||||
def set_lines(self, new_lines):
|
||||
self.lines = new_lines
|
||||
|
||||
def get_lines(index=None):
|
||||
global lines
|
||||
if index is not None:
|
||||
return lines[index]
|
||||
return lines
|
||||
def get_lines(self, index=None):
|
||||
if index is not None:
|
||||
return self.lines[index]
|
||||
return self.lines
|
||||
|
||||
@staticmethod
|
||||
def generate_md5(fn):
|
||||
if not isfile(fn):
|
||||
return False
|
||||
hash_md5 = md5()
|
||||
with open(fn, "rb") as f:
|
||||
for chunk in iter(lambda: f.read(hash_chunk_size), b""):
|
||||
hash_md5.update(chunk)
|
||||
return hash_md5.hexdigest()
|
||||
|
||||
def show_message(icon, title, text):
|
||||
box = QMessageBox(icon, title, text, QMessageBox.Ok)
|
||||
box.exec()
|
||||
@staticmethod
|
||||
def show_progress_bar(title, text, length):
|
||||
if (not title) or (not text) or (not length) or (length <= 0):
|
||||
return
|
||||
progress_bar = QProgressDialog(text, None, 0, length, flags=Qt.Window | Qt.WindowTitleHint)
|
||||
progress_bar.setWindowTitle(title)
|
||||
progress_bar.setWindowModality(Qt.WindowModal)
|
||||
progress_bar.show()
|
||||
return progress_bar
|
||||
|
||||
@staticmethod
|
||||
def update_progress_bar(progress_bar, value=1):
|
||||
if not progress_bar:
|
||||
return
|
||||
progress_bar.setValue(progress_bar.value() + value)
|
||||
QApplication.processEvents()
|
||||
|
||||
# Stock functions
|
||||
def search_line(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]):
|
||||
# Stock functions
|
||||
def search_line(self, term, start=0, cancel=r"this_string_must_not_exist"):
|
||||
if search(term, self.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:
|
||||
while start <= len(self.lines) - 1:
|
||||
if search(term, self.lines[start]):
|
||||
return start
|
||||
if search(cancel, self.lines[start]):
|
||||
return None
|
||||
start += 1
|
||||
return None
|
||||
return matches
|
||||
|
||||
def search_line_in_unit(self, term, unit):
|
||||
line = self.search_line(" : " + unit + " {")
|
||||
return self.search_line(term, start=line, cancel="}")
|
||||
|
||||
def search_all_lines(self, term):
|
||||
matches = []
|
||||
line = 0
|
||||
while self.search_line(term, start=line + 1):
|
||||
line = self.search_line(term, start=line + 1)
|
||||
matches.append(line)
|
||||
if matches is None:
|
||||
return None
|
||||
return matches
|
||||
|
||||
def get_value(self, line):
|
||||
return search(r": (.+)$", self.lines[line]).group(1)
|
||||
|
||||
def set_value(self, line, value):
|
||||
name = match(r"(.+):", self.lines[line]).group(1)
|
||||
self.lines[line] = name + ": " + value
|
||||
|
||||
# def get_unit_name(self, line):
|
||||
# return search(r" : (.+) {$", self.lines[line]).group(1)
|
||||
|
||||
def get_array_length(self, line):
|
||||
return int(search(r": ([0-9]+)$", self.lines[line]).group(1))
|
||||
|
||||
# def get_array_value_by_index(self, line, index):
|
||||
# return search(r": (.+)$", self.lines[line + index + 1]).group(1)
|
||||
|
||||
# def get_array_index_by_value(self, line, value):
|
||||
# count = 0
|
||||
# for i in range(self.get_array_length(line)):
|
||||
# if self.get_value(line + count + 1) == value:
|
||||
# return count
|
||||
# count += 1
|
||||
# return None
|
||||
|
||||
def get_array_items(self, line):
|
||||
items = []
|
||||
for i in range(self.get_array_length(line)):
|
||||
items.append(search(r": (.+)$", self.lines[line + i + 1]).group(1))
|
||||
if items is None:
|
||||
return None
|
||||
return items
|
||||
|
||||
def add_array_value(self, line, value):
|
||||
name = match(r"(.+):", self.lines[line]).group(1)
|
||||
count = self.get_array_length(line)
|
||||
self.lines[line] = name + ": " + str(count + 1)
|
||||
self.lines.insert(line + count + 1, name + "[" + str(count) + "]: " + value)
|
||||
|
||||
# def remove_array_value(self, line, value):
|
||||
# name = match(r"(.+):", self.lines[line]).group(1)
|
||||
# del self.lines[line + 1 + self.get_array_index_by_value(line, value)]
|
||||
# count = self.get_array_length(line)
|
||||
# self.lines[line] = name + ": " + str(count - 1)
|
||||
# for i in range(count):
|
||||
# self.lines[line + i + 1] = sub(r"\[[0-9]+]", "[" + str(i) + "]", lines[line + i + 1])
|
||||
|
||||
# def change_array_value(self, line, index, value):
|
||||
# line += index + 1
|
||||
# self.set_value(line, value)
|
||||
|
||||
|
||||
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)
|
||||
util = CustomFuncs()
|
||||
|
||||
Reference in New Issue
Block a user