* Added validator for ADR (module 'main')
* Added window for choice configs (module 'choice')
* Added sync configs from github (this repo, module 'parsing')
* Updated setup.py for correct project build
* Small code fixes

Signed-off-by: JDM170 <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
2020-07-31 16:48:10 +07:00
parent b313dcaa52
commit 8a304075a1
43 changed files with 1230 additions and 640 deletions

5
.gitignore vendored
View File

@@ -3,13 +3,16 @@
## Ignoring Python complied files
/__pycache__
/parsing/__pycache__
/choice/__pycache__
/main/__pycache__
/second/__pycache__
/choice/form.py
/main/form.py
/second/form.py
## Ignoring build from cx_Freeze
/stable_build
/prog_build
## Ignoring build files from PyInstaller
/build

View File

@@ -6,10 +6,6 @@
***
The program allows you to edit ETS2 and ATS saves, just place 'dlc.json', 'dealers.json' and 'agencies.json' files next to the executable SaveWizard.exe.
***
Features:
1. Decrypt file, if save file crypted
2. Check for DLC to the save file
@@ -22,8 +18,10 @@ Features:
***
Requirments:
* Python 3.5.4 or higher
* PyQt 5.6.0 or higher
* Python 3.7.7
* PyQt5 5.15.0
* requests 2.24.0
* cx_Freeze 6.2
***

View File

@@ -3,10 +3,10 @@
from sys import argv, exit
from PyQt5.QtWidgets import QApplication
from main.script import MainWindow
from choice.script import ChoiceWindow
if __name__ == '__main__':
app = QApplication(argv)
win = MainWindow()
win = ChoiceWindow()
win.show()
exit(app.exec())

View File

@@ -1,10 +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"],
"idaho": ["boise", "coeur_dalene", "idaho_falls", "twin_falls"]
}

View File

@@ -1,9 +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"],
"idaho": ["boise", "idaho_falls", "twin_falls"]
}

View File

@@ -1,8 +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",
"idaho": "company.volatile.du_farm.nampa"
}

1
choice/__init__.py Normal file
View File

@@ -0,0 +1 @@
# initialize module 'choice'

106
choice/form.ui Normal file
View File

@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Choice</class>
<widget class="QDialog" name="Choice">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>490</width>
<height>130</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>490</width>
<height>130</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>490</width>
<height>130</height>
</size>
</property>
<property name="windowTitle">
<string>Select game</string>
</property>
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>471</width>
<height>111</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QPushButton" name="ets2_button">
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>ETS2</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="ats_button">
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string>ATS</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>18</pointsize>
</font>
</property>
<property name="text">
<string>Select the configs you want to use:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>DON'T USE CONFIGS FROM ANOTHER GAME INTENTIONALLY,
YOU CAN DAMAGE THE GAME'S SAVE.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<tabstops>
<tabstop>ats_button</tabstop>
<tabstop>ets2_button</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

58
choice/script.py Normal file
View File

@@ -0,0 +1,58 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QDialog, QMessageBox
from ast import literal_eval
from .form import Ui_Choice
from main.script import MainWindow
from parsing.script import check_remote_hashes, update_configs
from util import update_config_name
class ChoiceWindow(QDialog, Ui_Choice):
def __init__(self, parent=None):
# Setup UI
QDialog.__init__(self, parent, flags=Qt.Window)
Ui_Choice.__init__(self)
self.ui = Ui_Choice()
self.ui.setupUi(self)
self.ui.ats_button.clicked.connect(self.button_clicked)
self.ui.ets2_button.clicked.connect(self.button_clicked)
remember_data = {"answer_updates": True, "update_on_start": False}
try:
with open(update_config_name) as f:
remember_data = literal_eval(f.read())
except FileNotFoundError:
with open(update_config_name, "w") as f:
f.write(str(remember_data))
upd_list = check_remote_hashes()
if upd_list and len(upd_list) > 0:
answer = remember_data.get("answer_updates")
if answer:
box = QMessageBox(QMessageBox.Information, "Info",
"Some configs get updated, do you want update your local configs?")
box.addButton("Yes", QMessageBox.YesRole) # 0
box.addButton("Yes, remember that", QMessageBox.YesRole) # 1
box.addButton("No", QMessageBox.NoRole) # 2
box.addButton("No, remember that", QMessageBox.NoRole) # 3
update_configs(box.exec(), upd_list)
return
upd_on_start = remember_data.get("update_on_start")
if upd_on_start:
update_configs(1, upd_list)
def button_clicked(self):
sender = self.sender()
if sender == self.ui.ats_button:
selected = "ats"
elif sender == self.ui.ets2_button:
selected = "ets2"
else:
return
self.close()
win = MainWindow(selected)
win.exec()

50
configs/ats/agencies.json Normal file
View File

@@ -0,0 +1,50 @@
{
"arizona" : [
"phoenix",
"sierra_vista",
"tucson"
],
"base" : [
"bakersfield",
"fresno",
"los_angeles",
"oxnard",
"redding",
"san_diego",
"san_rafael",
"santa_cruz",
"stockton",
"carson_city",
"las_vegas"
],
"idaho" : [
"boise",
"coeur_dalene",
"idaho_falls",
"twin_falls"
],
"new_mexico" : [
"carlsbad_nm",
"farmington",
"roswell",
"santa_fe"
],
"oregon" : [
"bend",
"eugene",
"ontario",
"salem"
],
"utah" : [
"moab",
"salt_lake_city",
"st_george"
],
"washington" : [
"bellingham",
"olympia",
"seattle",
"wenatchee",
"yakima"
]
}

49
configs/ats/dealers.json Normal file
View File

@@ -0,0 +1,49 @@
{
"arizona" : [
"flagstaff",
"phoenix",
"tucson",
"yuma"
],
"base" : [
"bakersfield",
"los_angeles",
"sacramento",
"santa_cruz",
"san_diego",
"san_francisco"
],
"idaho" : [
"boise",
"idaho_falls",
"twin_falls"
],
"new_mexico" : [
"alamogordo",
"albuquerque",
"farmington",
"hobbs"
],
"oregon" : [
"eugene",
"medford",
"pendleton",
"portland",
"salem"
],
"utah" : [
"ogden",
"price",
"provo",
"salina",
"salt_lake_city",
"vernal"
],
"washington" : [
"bellingham",
"seattle",
"spokane",
"tacoma",
"yakima"
]
}

8
configs/ats/dlc.json Normal file
View File

@@ -0,0 +1,8 @@
{
"arizona" : "company.volatile.aport_phx.phoenix",
"idaho" : "company.volatile.du_farm.nampa",
"new_mexico" : "company.volatile.aport_abq.albuquerque",
"oregon" : "company.volatile.aport_pcc.portland",
"utah" : "company.volatile.gal_oil_sit.price",
"washington" : "company.volatile.port_sea.seattle"
}

117
configs/ets2/agencies.json Normal file
View File

@@ -0,0 +1,117 @@
{
"balticsea" : [
"daugavpils",
"helsinki",
"kaliningrad",
"kaunas",
"klaipeda",
"kouvola",
"lahti",
"parnu",
"pori",
"pskov",
"riga",
"tallinn",
"turku",
"vilnius"
],
"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"
],
"blacksea" : [
"bucuresti",
"cluj_napoca",
"iasi",
"istanbul",
"plovdiv",
"sofia"
],
"east" : [
"budapest",
"gdansk",
"krakow",
"szeged",
"warszava"
],
"france" : [
"bordeaux",
"clermont",
"geneve",
"larochelle",
"lyon",
"marseille",
"metz",
"paris",
"reims",
"rennes",
"toulouse"
],
"italy" : [
"bologna",
"catania",
"milano",
"napoli",
"pescara",
"roma",
"taranto",
"venezia"
],
"scandinavia" : [
"aalborg",
"bergen",
"helsingborg",
"kobenhavn",
"malmo",
"odense",
"oslo",
"stavanger",
"stockholm"
]
}

114
configs/ets2/dealers.json Normal file
View File

@@ -0,0 +1,114 @@
{
"balticsea" : [
"helsinki",
"kaliningrad",
"kaunas",
"klaipeda",
"lahti",
"petersburg",
"riga",
"tallinn",
"tartu",
"turku",
"vilnius"
],
"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"
],
"blacksea" : [
"brasov",
"bucuresti",
"cluj_napoca",
"constanta",
"edirne",
"galati",
"iasi",
"istanbul",
"pitesti",
"plovdiv",
"sofia",
"veliko_tarnovo"
],
"east" : [
"budapest",
"gdansk",
"krakow",
"szeged",
"warszawa"
],
"france" : [
"bordeaux",
"bourges",
"brest",
"geneve",
"lemans",
"limoges",
"lyon",
"marseille",
"nantes",
"paris",
"toulouse"
],
"italy" : [
"bologna",
"catania",
"firenze",
"milano",
"napoli",
"palermo",
"roma",
"taranto",
"torino",
"verona"
],
"scandinavia" : [
"bergen",
"goteborg",
"kalmar",
"kobenhavn",
"linkoping",
"oslo",
"stockholm"
]
}

8
configs/ets2/dlc.json Normal file
View File

@@ -0,0 +1,8 @@
{
"balticsea" : "company.volatile.polarislines.tallinn",
"blacksea" : "company.volatile.bhv.galati",
"east" : "company.volatile.quarry.katowice",
"france" : "company.volatile.lisette_log.roscoff",
"italy" : "company.volatile.marina_it.ancona",
"scandinavia" : "company.volatile.sag_tre.oslo"
}

View File

@@ -1,3 +1,6 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from json import decoder, load, dump
from os import replace
from os.path import splitext
@@ -11,7 +14,7 @@ class InvalidFileIO(Exception):
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

BIN
dlls/imageformats/qgif.dll Normal file

Binary file not shown.

BIN
dlls/imageformats/qicns.dll Normal file

Binary file not shown.

BIN
dlls/imageformats/qico.dll Normal file

Binary file not shown.

BIN
dlls/imageformats/qjpeg.dll Normal file

Binary file not shown.

BIN
dlls/imageformats/qsvg.dll Normal file

Binary file not shown.

BIN
dlls/imageformats/qtga.dll Normal file

Binary file not shown.

BIN
dlls/imageformats/qtiff.dll Normal file

Binary file not shown.

BIN
dlls/imageformats/qwbmp.dll Normal file

Binary file not shown.

BIN
dlls/imageformats/qwebp.dll Normal file

Binary file not shown.

BIN
dlls/platforms/qminimal.dll Normal file

Binary file not shown.

Binary file not shown.

BIN
dlls/platforms/qwebgl.dll Normal file

Binary file not shown.

BIN
dlls/platforms/qwindows.dll Normal file

Binary file not shown.

Binary file not shown.

View File

@@ -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"]
}

View File

@@ -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"]
}

View File

@@ -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"
}

View File

@@ -1 +1 @@
# initialize module 'main' for compile program
# initialize module 'main'

View File

@@ -1,97 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<widget class="QDialog" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>360</width>
<height>370</height>
<height>350</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>360</width>
<height>370</height>
<height>350</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>360</width>
<height>370</height>
<height>350</height>
</size>
</property>
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</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>
@@ -212,6 +151,66 @@
</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>10</x>
<y>310</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="QCheckBox" name="dont_change_all_inf">
<property name="geometry">
<rect>
<x>80</x>
<y>350</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 class="QWidget" name="gridLayoutWidget_3">
<property name="geometry">
<rect>
@@ -440,6 +439,28 @@
</item>
</layout>
</widget>
<widget class="QPushButton" name="apply">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>210</x>
<y>310</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="QToolButton" name="second_window">
<property name="enabled">
<bool>false</bool>
@@ -447,7 +468,7 @@
<property name="geometry">
<rect>
<x>160</x>
<y>340</y>
<y>320</y>
<width>41</width>
<height>21</height>
</rect>
@@ -456,29 +477,39 @@
<string>...</string>
</property>
</widget>
<widget class="QCheckBox" name="dont_change_all_inf">
<widget class="QLabel" name="chosen_cfgs">
<property name="geometry">
<rect>
<x>80</x>
<y>300</y>
<width>211</width>
<x>210</x>
<y>10</y>
<width>141</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>
<string>Chosen configs:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
<widget class="QPushButton" name="cfg_button">
<property name="geometry">
<rect>
<x>180</x>
<y>20</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>...</string>
</property>
</widget>
</widget>
<tabstops>
<tabstop>path_button</tabstop>
<tabstop>cfg_button</tabstop>
<tabstop>money_edit</tabstop>
<tabstop>money_dont_change</tabstop>
<tabstop>xp_edit</tabstop>
@@ -497,10 +528,10 @@
<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>
<tabstop>dont_change_all_inf</tabstop>
</tabstops>
<resources/>
<connections/>

View File

@@ -4,18 +4,17 @@
from os import system, remove
from PyQt5.QtCore import Qt, QRegExp
from PyQt5.QtGui import QRegExpValidator
from PyQt5.QtWidgets import QMainWindow, QFileDialog
from PyQt5.QtWidgets import QDialog, 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):
class MainWindow(QDialog, Ui_MainWindow):
def __init__(self, selected_game, parent=None):
# Setup UI
QMainWindow.__init__(self, parent, flags=Qt.Window)
QDialog.__init__(self, parent, flags=Qt.Window)
Ui_MainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
@@ -23,13 +22,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.file_path = ""
self.old_file = ""
# Checking DLC file
if dataIO.is_valid_json("dlc.json") is False:
self.owns = False
show_message(QMessageBox.Warning, "Warning", "'dlc.json' not found, functionality has been limited")
else:
self.selected_game = selected_game
self.owns = {}
self.dlc = dataIO.load_json("dlc.json")
self.dlc = {}
# Editing label to show what configs chosen
self.chosen_cfg_text = self.ui.chosen_cfgs.text()
self.ui.chosen_cfgs.setText("{} {}".format(self.chosen_cfg_text, selected_game.upper()))
# Storing edits with his checkboxes and file-lines
self.basic_edits = {
@@ -46,22 +45,30 @@ class MainWindow(QMainWindow, Ui_MainWindow):
}
# Setting up validators for edits
basic_validator = QRegExpValidator(QRegExp("[0-9]{1,9}"))
basic_validator = QRegExpValidator(QRegExp("[0-9]{,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}"))
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.apply.clicked.connect(self.apply_changes)
self.ui.cfg_button.clicked.connect(self.change_configs)
self.ui.backup.clicked.connect(self.recover_backup)
self.ui.second_window.clicked.connect(self.open_second_win)
self.ui.apply.clicked.connect(self.apply_changes)
self.check_config()
self.clear_fields()
def text_edited(self):
sender = self.sender()
@@ -88,6 +95,16 @@ class MainWindow(QMainWindow, Ui_MainWindow):
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
show_message(QMessageBox.Warning, "Warning", "'dlc.json' from '{}' not found, functionality "
"has been limited".format(self.selected_game))
else:
self.owns = {}
self.dlc = dataIO.load_json(cfg_path)
def clear_fields(self):
self.file_path = ""
self.old_file = ""
@@ -112,12 +129,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def get_file_data(self, file):
try:
with open(file, "r") as f:
with open(file) 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:
with open(file) as f:
self.old_file = f.read()
show_message(QMessageBox.Information, "Success", "File successfully decrypted.")
except UnicodeDecodeError:
@@ -127,13 +144,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
if self.owns is not False:
self.owns["base"] = True
for i in get_array_items(search_line("companies:")):
companies = get_array_items(search_line("companies:"))
for key, value in self.dlc.items():
if value in i:
if value in companies:
self.owns[key] = True
for key, value in self.basic_edits.items():
key.setText(str(get_value(search_line(value[1]))))
key.setText(get_value(search_line(value[1])))
adr = self.get_adr(get_value(search_line("adr:")))
adr_list = ""
@@ -142,23 +159,51 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.ui.adr_edit.setText(adr_list)
for key, value in self.skill_edits.items():
key.setText(str(get_value(search_line(value[1]))))
key.setText(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,
file_path, file_name = 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)
if file_path != "":
self.file_path = file_path
self.get_file_data(file_path)
else:
return
def change_configs(self):
box = QMessageBox(QMessageBox.Warning, "Warning", "Do you really change configs? "
"Your changes has been lost!")
box.addButton("Yes", QMessageBox.YesRole)
box.addButton("No", QMessageBox.NoRole)
if box.exec() == 0:
self.clear_fields()
self.selected_game = "ets2" if self.selected_game == "ats" else "ats"
self.ui.chosen_cfgs.setText("{} {}".format(self.chosen_cfg_text, self.selected_game.upper()))
self.check_config()
def recover_backup(self):
try:
backup = self.file_path + ".swbak"
f = open(backup)
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.")
def open_second_win(self):
second_win = SecondWindow(self.selected_game, self.owns, self)
second_win.exec()
def apply_changes(self):
if not self.ui.dont_change_all_inf.isChecked():
for key, value in self.basic_edits.items():
@@ -185,22 +230,3 @@ class MainWindow(QMainWindow, Ui_MainWindow):
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
parsing/__init__.py Normal file
View File

@@ -0,0 +1 @@
# initialize module 'parsing'

67
parsing/script.py Normal file
View File

@@ -0,0 +1,67 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from requests import get
from hashlib import md5
from ast import literal_eval
import os
from dataIO import dataIO
from util import github_link, update_config_name
def send_response(txt):
response = get(txt)
return response if response.status_code == 200 else False
def generate_md5(fn):
hash_md5 = md5()
try:
with open(fn, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return hash_md5.hexdigest()
except FileNotFoundError:
return False
def check_files(path):
temp = os.getcwd()
for item in path.split("/"):
temp = os.path.join(temp, item)
if not os.path.exists(temp):
if item.find(".json") > 0:
f = open(temp, "w")
f.close()
else:
os.mkdir(temp)
def check_remote_hashes():
response = send_response(github_link + "configs/version.cfg")
if response is not False:
remote_cfg = literal_eval(response.text)
need_to_be_updated = []
for key, value in remote_cfg.items():
path = key.split("_")
path = "configs/{}/{}.json".format(path[0], path[1])
if generate_md5(path) != value:
need_to_be_updated.append(path)
return need_to_be_updated
return False
def update_configs(is_save, cfg_list):
if is_save in (0, 1):
for cfg in cfg_list:
check_files(cfg)
response = send_response(github_link + cfg)
if response is not False:
remote_cfg = literal_eval(response.text)
if dataIO.is_valid_json(cfg) or os.path.exists(cfg):
dataIO.save_json(cfg, remote_cfg)
if is_save in (1, 3):
text = str({"answer_updates": is_save == 3,
"update_on_start": is_save == 1})
with open(update_config_name, "w") as f:
f.write(text)

View File

@@ -1 +1 @@
# initialize module 'second' for compile program
# initialize module 'second'

View File

@@ -2,9 +2,6 @@
<ui version="4.0">
<class>SecondWindow</class>
<widget class="QDialog" name="SecondWindow">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>

View File

@@ -3,7 +3,6 @@
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QDialog
from .form import Ui_SecondWindow
from util import *
from dataIO import dataIO
@@ -16,7 +15,7 @@ garages_stat = {
class SecondWindow(QDialog, Ui_SecondWindow):
def __init__(self, owns_list, parent=None):
def __init__(self, selected_game, owns_list, parent=None):
# Setup UI
QDialog.__init__(self, parent, flags=Qt.Window)
Ui_SecondWindow.__init__(self)
@@ -26,31 +25,43 @@ class SecondWindow(QDialog, Ui_SecondWindow):
self.owns = owns_list # From main window
# Checking files
if dataIO.is_valid_json("dealers.json") is False:
cfg_path = "configs/{}".format(selected_game)
dealers_path = "{}/dealers.json".format(cfg_path)
agencies_path = "{}/agencies.json".format(cfg_path)
if dataIO.is_valid_json(dealers_path) is False:
self.dealers = False
self.ui.dealer_edit.setEnabled(False)
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")
show_message(QMessageBox.Warning, "Warning", "'dealers.json' from '{}' not found, dealers "
"editing has been disabled".format(selected_game))
else:
self.dealers = []
self.dealers_file = dataIO.load_json("dealers.json")
self.dealers_file = dataIO.load_json(dealers_path)
if dataIO.is_valid_json("agencies.json") is False:
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)
show_message(QMessageBox.Warning, "Warning", "'agencies.json' not found, agencies editing has been "
"disabled")
show_message(QMessageBox.Warning, "Warning", "'agencies.json' from '{}' not found, agencies "
"editing has been disabled".format(selected_game))
else:
self.agencies = []
self.agencies_file = dataIO.load_json("agencies.json")
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")
# Dealers and agencies properties
self.da_array = {
self.ui.dealer_add: [self.ui.dealer_edit, "unlocked_dealers:", "Dealership", self.dealers,
self.check_dealers],
self.ui.agency_add: [self.ui.agency_edit, "unlocked_recruitments:", "Recruitment agency",
self.agencies, self.check_agencies],
}
# Connecting buttons
self.ui.garages_analyze.clicked.connect(self.check_garages)
self.ui.garage_add.clicked.connect(self.add_garage)
@@ -58,9 +69,9 @@ class SecondWindow(QDialog, Ui_SecondWindow):
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.clicked.connect(self.da_clicked)
self.ui.dealer_add_all.clicked.connect(self.add_all_dealers)
self.ui.agency_add.clicked.connect(self.add_agency)
self.ui.agency_add.clicked.connect(self.da_clicked)
self.ui.agency_add_all.clicked.connect(self.add_all_agencies)
if self.owns:
@@ -197,22 +208,6 @@ class SecondWindow(QDialog, Ui_SecondWindow):
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:"))
@@ -231,22 +226,6 @@ class SecondWindow(QDialog, Ui_SecondWindow):
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:"))
@@ -255,3 +234,23 @@ class SecondWindow(QDialog, Ui_SecondWindow):
add_array_value(search_line("unlocked_recruitments:"), agency)
show_message(QMessageBox.Information, "Success", "All recruitment agencies unlocked.")
self.check_agencies()
def da_clicked(self):
da_arr = self.da_array.get(self.sender())
if da_arr is None:
return
edit, file_var, message_var = da_arr[0], da_arr[1], da_arr[2]
city_element = edit.text().lower()
if not city_element:
show_message(QMessageBox.Critical, "Error", "Enter a name for the city.")
return
edit.setText("")
if city_element not in da_arr[3]:
show_message(QMessageBox.Critical, "Error", "There is no {} in that city.".format(message_var.lower()))
elif city_element in get_array_items(search_line(file_var)):
show_message(QMessageBox.Information, "Info", "{} is already unlocked.".format(message_var))
else:
add_array_value(search_line(file_var), city_element)
show_message(QMessageBox.Information, "Success", "{} in \"{}\" successfully unlocked."
"".format(message_var, city_element))
da_arr[4]()

View File

@@ -1,20 +1,40 @@
#!/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__.py', targetName='SaveWizard.exe', base=base)]
excludes = ['html', 'pydoc_data', 'unittest', 'xml', 'pwd', 'shlex', 'platform', 'webbrowser', 'pydoc', 'tty',
'inspect', 'doctest', 'plistlib', 'subprocess', 'bz2', '_strptime', 'dummy_threading']
includes = ['pkgutil', 'enum', 'queue', 'PyQt5.sip']
zip_include_packages = [
# Stock modules
'collections', 'encodings', 'importlib', 'json', 'hashlib', 'selectors', 'select', 'http', 'email', 'datetime',
'calendar', 'urllib', 'posixpath', 'tempfile', 'shutil', 'copy', 'stringprep', 'socket', 'ast',
# PyQt5
'PyQt5',
# Modules for parsing cfg's
'requests', 'logging', 'certifi', 'chardet', 'idna', 'urllib3',
# Self-written modules
'parsing', 'choice', 'main', 'second'
]
include_files = ['dlls/imageformats', 'dlls/platforms', 'dlls/styles', 'SII_Decrypt.exe', 'configs']
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 +42,9 @@ options = {
setup(
name='SaveWizard',
version='1.1.1',
version='1.2',
description='For editing ETS2 sii files',
executables=executables,
options=options,
requires=['PyQt5']
requires=['PyQt5', 'requests'],
)

View File

@@ -4,6 +4,8 @@
from re import search, match, sub
from PyQt5.QtWidgets import QMessageBox
github_link = "https://raw.githubusercontent.com/JDM170/SaveWizard/master/"
update_config_name = "update.cfg"
lines = []