* 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 ## Ignoring Python complied files
/__pycache__ /__pycache__
/parsing/__pycache__
/choice/__pycache__
/main/__pycache__ /main/__pycache__
/second/__pycache__ /second/__pycache__
/choice/form.py
/main/form.py /main/form.py
/second/form.py /second/form.py
## Ignoring build from cx_Freeze ## Ignoring build from cx_Freeze
/stable_build /prog_build
## Ignoring build files from PyInstaller ## Ignoring build files from PyInstaller
/build /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: Features:
1. Decrypt file, if save file crypted 1. Decrypt file, if save file crypted
2. Check for DLC to the save file 2. Check for DLC to the save file
@@ -22,8 +18,10 @@ Features:
*** ***
Requirments: Requirments:
* Python 3.5.4 or higher * Python 3.7.7
* PyQt 5.6.0 or higher * PyQt5 5.15.0
* requests 2.24.0
* cx_Freeze 6.2
*** ***

View File

@@ -3,10 +3,10 @@
from sys import argv, exit from sys import argv, exit
from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QApplication
from main.script import MainWindow from choice.script import ChoiceWindow
if __name__ == '__main__': if __name__ == '__main__':
app = QApplication(argv) app = QApplication(argv)
win = MainWindow() win = ChoiceWindow()
win.show() win.show()
exit(app.exec()) 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 json import decoder, load, dump
from os import replace from os import replace
from os.path import splitext from os.path import splitext
@@ -11,7 +14,7 @@ class InvalidFileIO(Exception):
class DataIO: class DataIO:
@staticmethod @staticmethod
def _read_json(filename): 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) data = load(f)
return data 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,484 +1,515 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>MainWindow</class> <class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow"> <widget class="QDialog" name="MainWindow">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>360</width> <width>360</width>
<height>370</height> <height>350</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>360</width> <width>360</width>
<height>370</height> <height>350</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>360</width> <width>360</width>
<height>370</height> <height>350</height>
</size> </size>
</property> </property>
<property name="font">
<font>
<family>Times New Roman</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>SaveWizard</string> <string>SaveWizard</string>
</property> </property>
<property name="locale"> <widget class="QWidget" name="gridLayoutWidget">
<locale language="English" country="UnitedStates"/> <property name="geometry">
</property> <rect>
<widget class="QWidget" name="centralwidget"> <x>10</x>
<widget class="QPushButton" name="apply"> <y>50</y>
<property name="enabled"> <width>341</width>
<bool>false</bool> <height>81</height>
</property> </rect>
<property name="geometry"> </property>
<rect> <layout class="QGridLayout" name="basic_inf_layout">
<x>210</x> <item row="0" column="1">
<y>330</y> <widget class="QLineEdit" name="money_edit">
<width>141</width> <property name="font">
<height>31</height> <font>
</rect> <family>Times New Roman</family>
</property> <pointsize>10</pointsize>
<property name="font"> </font>
<font> </property>
<family>Times New Roman</family> </widget>
<pointsize>12</pointsize> </item>
</font> <item row="0" column="2">
</property> <widget class="QCheckBox" name="money_dont_change">
<property name="text"> <property name="font">
<string>Apply changes</string> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>10</pointsize>
<widget class="QPushButton" name="backup"> </font>
<property name="enabled"> </property>
<bool>false</bool> <property name="text">
</property> <string>Don't change</string>
<property name="geometry"> </property>
<rect> </widget>
<x>10</x> </item>
<y>330</y> <item row="1" column="0">
<width>141</width> <widget class="QLabel" name="xp_label">
<height>31</height> <property name="font">
</rect> <font>
</property> <family>Times New Roman</family>
<property name="font"> <pointsize>14</pointsize>
<font> </font>
<family>Times New Roman</family> </property>
<pointsize>12</pointsize> <property name="text">
</font> <string>Experience:</string>
</property> </property>
<property name="text"> </widget>
<string>Recover backup</string> </item>
</property> <item row="1" column="1">
</widget> <widget class="QLineEdit" name="xp_edit">
<widget class="QPushButton" name="path_button"> <property name="font">
<property name="geometry"> <font>
<rect> <family>Times New Roman</family>
<x>10</x> <pointsize>10</pointsize>
<y>10</y> </font>
<width>161</width> </property>
<height>31</height> </widget>
</rect> </item>
</property> <item row="1" column="2">
<property name="font"> <widget class="QCheckBox" name="xp_dont_change">
<font> <property name="font">
<family>Times New Roman</family> <font>
<pointsize>14</pointsize> <family>Times New Roman</family>
</font> <pointsize>10</pointsize>
</property> </font>
<property name="text"> </property>
<string>Choose save file...</string> <property name="text">
</property> <string>Don't change</string>
</widget> </property>
<widget class="QWidget" name="gridLayoutWidget"> </widget>
<property name="geometry"> </item>
<rect> <item row="2" column="0">
<x>10</x> <widget class="QLabel" name="loan_limit_label">
<y>50</y> <property name="font">
<width>341</width> <font>
<height>81</height> <family>Times New Roman</family>
</rect> <pointsize>14</pointsize>
</property> </font>
<layout class="QGridLayout" name="basic_inf_layout"> </property>
<item row="0" column="1"> <property name="text">
<widget class="QLineEdit" name="money_edit"> <string>Loan limit:</string>
<property name="font"> </property>
<font> </widget>
<family>Times New Roman</family> </item>
<pointsize>10</pointsize> <item row="2" column="1">
</font> <widget class="QLineEdit" name="loan_limit_edit">
</property> <property name="font">
</widget> <font>
</item> <family>Times New Roman</family>
<item row="0" column="2"> <pointsize>10</pointsize>
<widget class="QCheckBox" name="money_dont_change"> </font>
<property name="font"> </property>
<font> </widget>
<family>Times New Roman</family> </item>
<pointsize>10</pointsize> <item row="2" column="2">
</font> <widget class="QCheckBox" name="loan_limit_dont_change">
</property> <property name="font">
<property name="text"> <font>
<string>Don't change</string> <family>Times New Roman</family>
</property> <pointsize>10</pointsize>
</widget> </font>
</item> </property>
<item row="1" column="0"> <property name="text">
<widget class="QLabel" name="xp_label"> <string>Don't change</string>
<property name="font"> </property>
<font> </widget>
<family>Times New Roman</family> </item>
<pointsize>14</pointsize> <item row="0" column="0">
</font> <widget class="QLabel" name="money_label">
</property> <property name="font">
<property name="text"> <font>
<string>Experience:</string> <family>Times New Roman</family>
</property> <pointsize>14</pointsize>
</widget> </font>
</item> </property>
<item row="1" column="1"> <property name="text">
<widget class="QLineEdit" name="xp_edit"> <string>Money:</string>
<property name="font"> </property>
<font> </widget>
<family>Times New Roman</family> </item>
<pointsize>10</pointsize> </layout>
</font> </widget>
</property> <widget class="QPushButton" name="path_button">
</widget> <property name="geometry">
</item> <rect>
<item row="1" column="2"> <x>10</x>
<widget class="QCheckBox" name="xp_dont_change"> <y>10</y>
<property name="font"> <width>161</width>
<font> <height>31</height>
<family>Times New Roman</family> </rect>
<pointsize>10</pointsize> </property>
</font> <property name="font">
</property> <font>
<property name="text"> <family>Times New Roman</family>
<string>Don't change</string> <pointsize>14</pointsize>
</property> </font>
</widget> </property>
</item> <property name="text">
<item row="2" column="0"> <string>Choose save file...</string>
<widget class="QLabel" name="loan_limit_label"> </property>
<property name="font"> </widget>
<font> <widget class="QPushButton" name="backup">
<family>Times New Roman</family> <property name="enabled">
<pointsize>14</pointsize> <bool>false</bool>
</font> </property>
</property> <property name="geometry">
<property name="text"> <rect>
<string>Loan limit:</string> <x>10</x>
</property> <y>310</y>
</widget> <width>141</width>
</item> <height>31</height>
<item row="2" column="1"> </rect>
<widget class="QLineEdit" name="loan_limit_edit"> </property>
<property name="font"> <property name="font">
<font> <font>
<family>Times New Roman</family> <family>Times New Roman</family>
<pointsize>10</pointsize> <pointsize>12</pointsize>
</font> </font>
</property> </property>
</widget> <property name="text">
</item> <string>Recover backup</string>
<item row="2" column="2"> </property>
<widget class="QCheckBox" name="loan_limit_dont_change"> </widget>
<property name="font"> <widget class="QCheckBox" name="dont_change_all_inf">
<font> <property name="geometry">
<family>Times New Roman</family> <rect>
<pointsize>10</pointsize> <x>80</x>
</font> <y>350</y>
</property> <width>211</width>
<property name="text"> <height>31</height>
<string>Don't change</string> </rect>
</property> </property>
</widget> <property name="font">
</item> <font>
<item row="0" column="0"> <family>Times New Roman</family>
<widget class="QLabel" name="money_label"> <pointsize>10</pointsize>
<property name="font"> </font>
<font> </property>
<family>Times New Roman</family> <property name="text">
<pointsize>14</pointsize> <string>Don't save all changes in this form</string>
</font> </property>
</property> </widget>
<property name="text"> <widget class="QWidget" name="gridLayoutWidget_3">
<string>Money:</string> <property name="geometry">
</property> <rect>
</widget> <x>10</x>
</item> <y>140</y>
</layout> <width>341</width>
</widget> <height>161</height>
<widget class="QWidget" name="gridLayoutWidget_3"> </rect>
<property name="geometry"> </property>
<rect> <layout class="QGridLayout" name="skills_layout">
<x>10</x> <item row="1" column="1">
<y>140</y> <widget class="QLineEdit" name="long_distance_edit">
<width>341</width> <property name="font">
<height>161</height> <font>
</rect> <family>Times New Roman</family>
</property> <pointsize>10</pointsize>
<layout class="QGridLayout" name="skills_layout"> </font>
<item row="1" column="1"> </property>
<widget class="QLineEdit" name="long_distance_edit"> </widget>
<property name="font"> </item>
<font> <item row="4" column="0">
<family>Times New Roman</family> <widget class="QLabel" name="urgent_delivery_label">
<pointsize>10</pointsize> <property name="font">
</font> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>13</pointsize>
</item> </font>
<item row="4" column="0"> </property>
<widget class="QLabel" name="urgent_delivery_label"> <property name="text">
<property name="font"> <string>Urgent delivery:</string>
<font> </property>
<family>Times New Roman</family> </widget>
<pointsize>13</pointsize> </item>
</font> <item row="5" column="2">
</property> <widget class="QCheckBox" name="ecodriving_dont_change">
<property name="text"> <property name="font">
<string>Urgent delivery:</string> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>10</pointsize>
</item> </font>
<item row="5" column="2"> </property>
<widget class="QCheckBox" name="ecodriving_dont_change"> <property name="text">
<property name="font"> <string>Don't change</string>
<font> </property>
<family>Times New Roman</family> </widget>
<pointsize>10</pointsize> </item>
</font> <item row="0" column="1">
</property> <widget class="QLineEdit" name="adr_edit">
<property name="text"> <property name="font">
<string>Don't change</string> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>10</pointsize>
</item> </font>
<item row="0" column="1"> </property>
<widget class="QLineEdit" name="adr_edit"> </widget>
<property name="font"> </item>
<font> <item row="4" column="1">
<family>Times New Roman</family> <widget class="QLineEdit" name="urgent_delivery_edit">
<pointsize>10</pointsize> <property name="font">
</font> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>10</pointsize>
</item> </font>
<item row="4" column="1"> </property>
<widget class="QLineEdit" name="urgent_delivery_edit"> </widget>
<property name="font"> </item>
<font> <item row="3" column="2">
<family>Times New Roman</family> <widget class="QCheckBox" name="fragile_cargo_dont_change">
<pointsize>10</pointsize> <property name="font">
</font> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>10</pointsize>
</item> </font>
<item row="3" column="2"> </property>
<widget class="QCheckBox" name="fragile_cargo_dont_change"> <property name="text">
<property name="font"> <string>Don't change</string>
<font> </property>
<family>Times New Roman</family> </widget>
<pointsize>10</pointsize> </item>
</font> <item row="5" column="1">
</property> <widget class="QLineEdit" name="ecodriving_edit">
<property name="text"> <property name="font">
<string>Don't change</string> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>10</pointsize>
</item> </font>
<item row="5" column="1"> </property>
<widget class="QLineEdit" name="ecodriving_edit"> </widget>
<property name="font"> </item>
<font> <item row="2" column="2">
<family>Times New Roman</family> <widget class="QCheckBox" name="high_value_cargo_dont_change">
<pointsize>10</pointsize> <property name="font">
</font> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>10</pointsize>
</item> </font>
<item row="2" column="2"> </property>
<widget class="QCheckBox" name="high_value_cargo_dont_change"> <property name="text">
<property name="font"> <string>Don't change</string>
<font> </property>
<family>Times New Roman</family> </widget>
<pointsize>10</pointsize> </item>
</font> <item row="3" column="1">
</property> <widget class="QLineEdit" name="fragile_cargo_edit">
<property name="text"> <property name="font">
<string>Don't change</string> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>10</pointsize>
</item> </font>
<item row="3" column="1"> </property>
<widget class="QLineEdit" name="fragile_cargo_edit"> </widget>
<property name="font"> </item>
<font> <item row="0" column="2">
<family>Times New Roman</family> <widget class="QCheckBox" name="adr_dont_change">
<pointsize>10</pointsize> <property name="font">
</font> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>10</pointsize>
</item> </font>
<item row="0" column="2"> </property>
<widget class="QCheckBox" name="adr_dont_change"> <property name="text">
<property name="font"> <string>Don't change</string>
<font> </property>
<family>Times New Roman</family> </widget>
<pointsize>10</pointsize> </item>
</font> <item row="1" column="2">
</property> <widget class="QCheckBox" name="long_distance_dont_change">
<property name="text"> <property name="font">
<string>Don't change</string> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>10</pointsize>
</item> </font>
<item row="1" column="2"> </property>
<widget class="QCheckBox" name="long_distance_dont_change"> <property name="text">
<property name="font"> <string>Don't change</string>
<font> </property>
<family>Times New Roman</family> </widget>
<pointsize>10</pointsize> </item>
</font> <item row="2" column="1">
</property> <widget class="QLineEdit" name="high_value_cargo_edit">
<property name="text"> <property name="font">
<string>Don't change</string> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>10</pointsize>
</item> </font>
<item row="2" column="1"> </property>
<widget class="QLineEdit" name="high_value_cargo_edit"> </widget>
<property name="font"> </item>
<font> <item row="2" column="0">
<family>Times New Roman</family> <widget class="QLabel" name="high_value_cargo_label">
<pointsize>10</pointsize> <property name="font">
</font> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>13</pointsize>
</item> </font>
<item row="2" column="0"> </property>
<widget class="QLabel" name="high_value_cargo_label"> <property name="text">
<property name="font"> <string>High value cargo:</string>
<font> </property>
<family>Times New Roman</family> </widget>
<pointsize>13</pointsize> </item>
</font> <item row="3" column="0">
</property> <widget class="QLabel" name="fragile_cargo_label">
<property name="text"> <property name="font">
<string>High value cargo:</string> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>13</pointsize>
</item> </font>
<item row="3" column="0"> </property>
<widget class="QLabel" name="fragile_cargo_label"> <property name="text">
<property name="font"> <string>Fragile cargo:</string>
<font> </property>
<family>Times New Roman</family> </widget>
<pointsize>13</pointsize> </item>
</font> <item row="5" column="0">
</property> <widget class="QLabel" name="ecodriving_label">
<property name="text"> <property name="font">
<string>Fragile cargo:</string> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>13</pointsize>
</item> </font>
<item row="5" column="0"> </property>
<widget class="QLabel" name="ecodriving_label"> <property name="text">
<property name="font"> <string>Ecodriving:</string>
<font> </property>
<family>Times New Roman</family> </widget>
<pointsize>13</pointsize> </item>
</font> <item row="4" column="2">
</property> <widget class="QCheckBox" name="urgent_delivery_dont_change">
<property name="text"> <property name="font">
<string>Ecodriving:</string> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>10</pointsize>
</item> </font>
<item row="4" column="2"> </property>
<widget class="QCheckBox" name="urgent_delivery_dont_change"> <property name="text">
<property name="font"> <string>Don't change</string>
<font> </property>
<family>Times New Roman</family> </widget>
<pointsize>10</pointsize> </item>
</font> <item row="1" column="0">
</property> <widget class="QLabel" name="long_distance_label">
<property name="text"> <property name="font">
<string>Don't change</string> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>13</pointsize>
</item> </font>
<item row="1" column="0"> </property>
<widget class="QLabel" name="long_distance_label"> <property name="text">
<property name="font"> <string>Long distance:</string>
<font> </property>
<family>Times New Roman</family> </widget>
<pointsize>13</pointsize> </item>
</font> <item row="0" column="0">
</property> <widget class="QLabel" name="adr_label">
<property name="text"> <property name="font">
<string>Long distance:</string> <font>
</property> <family>Times New Roman</family>
</widget> <pointsize>13</pointsize>
</item> </font>
<item row="0" column="0"> </property>
<widget class="QLabel" name="adr_label"> <property name="text">
<property name="font"> <string>ADR:</string>
<font> </property>
<family>Times New Roman</family> </widget>
<pointsize>13</pointsize> </item>
</font> </layout>
</property> </widget>
<property name="text"> <widget class="QPushButton" name="apply">
<string>ADR:</string> <property name="enabled">
</property> <bool>false</bool>
</widget> </property>
</item> <property name="geometry">
</layout> <rect>
</widget> <x>210</x>
<widget class="QToolButton" name="second_window"> <y>310</y>
<property name="enabled"> <width>141</width>
<bool>false</bool> <height>31</height>
</property> </rect>
<property name="geometry"> </property>
<rect> <property name="font">
<x>160</x> <font>
<y>340</y> <family>Times New Roman</family>
<width>41</width> <pointsize>12</pointsize>
<height>21</height> </font>
</rect> </property>
</property> <property name="text">
<property name="text"> <string>Apply changes</string>
<string>...</string> </property>
</property> </widget>
</widget> <widget class="QToolButton" name="second_window">
<widget class="QCheckBox" name="dont_change_all_inf"> <property name="enabled">
<property name="geometry"> <bool>false</bool>
<rect> </property>
<x>80</x> <property name="geometry">
<y>300</y> <rect>
<width>211</width> <x>160</x>
<height>31</height> <y>320</y>
</rect> <width>41</width>
</property> <height>21</height>
<property name="font"> </rect>
<font> </property>
<family>Times New Roman</family> <property name="text">
<pointsize>10</pointsize> <string>...</string>
</font> </property>
</property> </widget>
<property name="text"> <widget class="QLabel" name="chosen_cfgs">
<string>Don't save all changes in this form</string> <property name="geometry">
</property> <rect>
</widget> <x>210</x>
<y>10</y>
<width>141</width>
<height>31</height>
</rect>
</property>
<property name="text">
<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>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>path_button</tabstop> <tabstop>path_button</tabstop>
<tabstop>cfg_button</tabstop>
<tabstop>money_edit</tabstop> <tabstop>money_edit</tabstop>
<tabstop>money_dont_change</tabstop> <tabstop>money_dont_change</tabstop>
<tabstop>xp_edit</tabstop> <tabstop>xp_edit</tabstop>
@@ -497,10 +528,10 @@
<tabstop>urgent_delivery_dont_change</tabstop> <tabstop>urgent_delivery_dont_change</tabstop>
<tabstop>ecodriving_edit</tabstop> <tabstop>ecodriving_edit</tabstop>
<tabstop>ecodriving_dont_change</tabstop> <tabstop>ecodriving_dont_change</tabstop>
<tabstop>dont_change_all_inf</tabstop>
<tabstop>backup</tabstop> <tabstop>backup</tabstop>
<tabstop>second_window</tabstop> <tabstop>second_window</tabstop>
<tabstop>apply</tabstop> <tabstop>apply</tabstop>
<tabstop>dont_change_all_inf</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections/> <connections/>

View File

@@ -4,18 +4,17 @@
from os import system, remove from os import system, remove
from PyQt5.QtCore import Qt, QRegExp from PyQt5.QtCore import Qt, QRegExp
from PyQt5.QtGui import QRegExpValidator from PyQt5.QtGui import QRegExpValidator
from PyQt5.QtWidgets import QMainWindow, QFileDialog from PyQt5.QtWidgets import QDialog, QFileDialog
from .form import Ui_MainWindow from .form import Ui_MainWindow
from util import * from util import *
from dataIO import dataIO from dataIO import dataIO
from second.script import SecondWindow from second.script import SecondWindow
class MainWindow(QMainWindow, Ui_MainWindow): class MainWindow(QDialog, Ui_MainWindow):
def __init__(self, parent=None): def __init__(self, selected_game, parent=None):
# Setup UI # Setup UI
QMainWindow.__init__(self, parent, flags=Qt.Window) QDialog.__init__(self, parent, flags=Qt.Window)
Ui_MainWindow.__init__(self) Ui_MainWindow.__init__(self)
self.ui = Ui_MainWindow() self.ui = Ui_MainWindow()
self.ui.setupUi(self) self.ui.setupUi(self)
@@ -23,13 +22,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.file_path = "" self.file_path = ""
self.old_file = "" self.old_file = ""
# Checking DLC file self.selected_game = selected_game
if dataIO.is_valid_json("dlc.json") is False: self.owns = {}
self.owns = False self.dlc = {}
show_message(QMessageBox.Warning, "Warning", "'dlc.json' not found, functionality has been limited")
else: # Editing label to show what configs chosen
self.owns = {} self.chosen_cfg_text = self.ui.chosen_cfgs.text()
self.dlc = dataIO.load_json("dlc.json") self.ui.chosen_cfgs.setText("{} {}".format(self.chosen_cfg_text, selected_game.upper()))
# Storing edits with his checkboxes and file-lines # Storing edits with his checkboxes and file-lines
self.basic_edits = { self.basic_edits = {
@@ -46,22 +45,30 @@ class MainWindow(QMainWindow, Ui_MainWindow):
} }
# Setting up validators for edits # 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(): for key in self.basic_edits.keys():
key.setValidator(basic_validator) key.setValidator(basic_validator)
key.textEdited.connect(self.text_edited) key.textEdited.connect(self.text_edited)
self.ui.adr_edit.textEdited.connect(self.text_edited) # TODO: Validator for ADR adr_validator_text = ""
skills_validator = QRegExpValidator(QRegExp("[0-6]{1,1}")) 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(): for key in self.skill_edits.keys():
key.setValidator(skills_validator) key.setValidator(skills_validator)
key.textEdited.connect(self.text_edited) key.textEdited.connect(self.text_edited)
# Connecting buttons # Connecting buttons
self.ui.path_button.clicked.connect(self.open_file_dialog) 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.backup.clicked.connect(self.recover_backup)
self.ui.second_window.clicked.connect(self.open_second_win) 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): def text_edited(self):
sender = self.sender() sender = self.sender()
@@ -88,6 +95,16 @@ class MainWindow(QMainWindow, Ui_MainWindow):
adr_list.remove(i) adr_list.remove(i)
return adr_list 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): def clear_fields(self):
self.file_path = "" self.file_path = ""
self.old_file = "" self.old_file = ""
@@ -112,12 +129,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def get_file_data(self, file): def get_file_data(self, file):
try: try:
with open(file, "r") as f: with open(file) as f:
self.old_file = f.read() self.old_file = f.read()
except UnicodeDecodeError: except UnicodeDecodeError:
try: try:
system("SII_Decrypt.exe --on_file -i \"{}\"".format(file)) 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() self.old_file = f.read()
show_message(QMessageBox.Information, "Success", "File successfully decrypted.") show_message(QMessageBox.Information, "Success", "File successfully decrypted.")
except UnicodeDecodeError: except UnicodeDecodeError:
@@ -127,13 +144,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
if self.owns is not False: if self.owns is not False:
self.owns["base"] = True 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(): for key, value in self.dlc.items():
if value in i: if value in companies:
self.owns[key] = True self.owns[key] = True
for key, value in self.basic_edits.items(): 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 = self.get_adr(get_value(search_line("adr:")))
adr_list = "" adr_list = ""
@@ -142,23 +159,51 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.ui.adr_edit.setText(adr_list) self.ui.adr_edit.setText(adr_list)
for key, value in self.skill_edits.items(): 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.apply.setEnabled(True)
self.ui.backup.setEnabled(True) self.ui.backup.setEnabled(True)
self.ui.second_window.setEnabled(True) self.ui.second_window.setEnabled(True)
def open_file_dialog(self): 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..."), caption=self.tr("Choose your save file..."),
filter=self.tr("game.sii")) filter=self.tr("game.sii"))
self.clear_fields() self.clear_fields()
if file != "": if file_path != "":
self.file_path = file self.file_path = file_path
self.get_file_data(self.file_path) self.get_file_data(file_path)
else: else:
return 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): def apply_changes(self):
if not self.ui.dont_change_all_inf.isChecked(): if not self.ui.dont_change_all_inf.isChecked():
for key, value in self.basic_edits.items(): for key, value in self.basic_edits.items():
@@ -185,22 +230,3 @@ class MainWindow(QMainWindow, Ui_MainWindow):
f.write("\n".join(get_lines())) f.write("\n".join(get_lines()))
show_message(QMessageBox.Information, "Success", "Changes successfully applied!") show_message(QMessageBox.Information, "Success", "Changes successfully applied!")
self.get_file_data(self.file_path) 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"> <ui version="4.0">
<class>SecondWindow</class> <class>SecondWindow</class>
<widget class="QDialog" name="SecondWindow"> <widget class="QDialog" name="SecondWindow">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>

View File

@@ -3,7 +3,6 @@
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QDialog from PyQt5.QtWidgets import QDialog
from .form import Ui_SecondWindow from .form import Ui_SecondWindow
from util import * from util import *
from dataIO import dataIO from dataIO import dataIO
@@ -16,7 +15,7 @@ garages_stat = {
class SecondWindow(QDialog, Ui_SecondWindow): class SecondWindow(QDialog, Ui_SecondWindow):
def __init__(self, owns_list, parent=None): def __init__(self, selected_game, owns_list, parent=None):
# Setup UI # Setup UI
QDialog.__init__(self, parent, flags=Qt.Window) QDialog.__init__(self, parent, flags=Qt.Window)
Ui_SecondWindow.__init__(self) Ui_SecondWindow.__init__(self)
@@ -26,31 +25,43 @@ class SecondWindow(QDialog, Ui_SecondWindow):
self.owns = owns_list # From main window self.owns = owns_list # From main window
# Checking files # 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.dealers = False
self.ui.dealer_edit.setEnabled(False) self.ui.dealer_edit.setEnabled(False)
self.ui.dealer_add.setEnabled(False) self.ui.dealer_add.setEnabled(False)
self.ui.dealer_add_all.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: else:
self.dealers = [] 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.agencies = False
self.ui.agency_edit.setEnabled(False) self.ui.agency_edit.setEnabled(False)
self.ui.agency_add.setEnabled(False) self.ui.agency_add.setEnabled(False)
self.ui.agency_add_all.setEnabled(False) self.ui.agency_add_all.setEnabled(False)
show_message(QMessageBox.Warning, "Warning", "'agencies.json' not found, agencies editing has been " show_message(QMessageBox.Warning, "Warning", "'agencies.json' from '{}' not found, agencies "
"disabled") "editing has been disabled".format(selected_game))
else: else:
self.agencies = [] 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("Small")
self.ui.garage_size.addItem("Medium") self.ui.garage_size.addItem("Medium")
self.ui.garage_size.addItem("Big") 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 # Connecting buttons
self.ui.garages_analyze.clicked.connect(self.check_garages) self.ui.garages_analyze.clicked.connect(self.check_garages)
self.ui.garage_add.clicked.connect(self.add_garage) 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.headquarter_change.clicked.connect(self.change_headquarter)
self.ui.city_add.clicked.connect(self.add_city) self.ui.city_add.clicked.connect(self.add_city)
self.ui.city_add_all.clicked.connect(self.add_all_cities) 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.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) self.ui.agency_add_all.clicked.connect(self.add_all_agencies)
if self.owns: if self.owns:
@@ -197,22 +208,6 @@ class SecondWindow(QDialog, Ui_SecondWindow):
for dealer in visited_dealers: for dealer in visited_dealers:
self.ui.dealerships_text.append(dealer) 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): def add_all_dealers(self):
all_cities = self.all_cities() all_cities = self.all_cities()
visited_dealers = get_array_items(search_line("unlocked_dealers:")) visited_dealers = get_array_items(search_line("unlocked_dealers:"))
@@ -231,22 +226,6 @@ class SecondWindow(QDialog, Ui_SecondWindow):
for agency in visited_agencies: for agency in visited_agencies:
self.ui.agencies_text.append(agency) 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): def add_all_agencies(self):
all_cities = self.all_cities() all_cities = self.all_cities()
visited_agencies = get_array_items(search_line("unlocked_recruitments:")) 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) add_array_value(search_line("unlocked_recruitments:"), agency)
show_message(QMessageBox.Information, "Success", "All recruitment agencies unlocked.") show_message(QMessageBox.Information, "Success", "All recruitment agencies unlocked.")
self.check_agencies() 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 #!/usr/bin/python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from sys import platform
from cx_Freeze import setup, Executable from cx_Freeze import setup, Executable
executables = [Executable('__init__.py', targetName='SaveWizard.exe', base='Win32GUI')] base = None
excludes = ['email', 'html', 'http', 'logging', 'pydoc_data', 'unittest', 'urllib', 'xml', 'tempfile', 'select', 'pwd', if platform == 'win32':
'datetime', 'shlex', 'shutil', 'socket', 'platform', 'webbrowser', 'pydoc', 'selectors', 'tty', 'inspect', base = 'Win32GUI'
'doctest', 'plistlib', 'calendar', 'subprocess', 'copy', 'bz2', 'stringprep', 'posixpath', '_strptime',
'dummy_threading'] executables = [Executable('__init__.py', targetName='SaveWizard.exe', base=base)]
zip_include_packages = ['collections', 'encodings', 'importlib', 'json', 'hashlib', 'PyQt5', 'sip', 'main', 'second']
include_files = ['SII_Decrypt.exe', 'ats_configs', 'ets2_configs'] 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 = { options = {
'build_exe': { 'build_exe': {
'excludes': excludes, 'excludes': excludes,
'includes': includes,
'include_msvcr': True, 'include_msvcr': True,
'build_exe': 'stable_build', 'build_exe': 'prog_build',
'include_files': include_files, 'include_files': include_files,
'zip_include_packages': zip_include_packages, 'zip_include_packages': zip_include_packages,
} }
@@ -22,9 +42,9 @@ options = {
setup( setup(
name='SaveWizard', name='SaveWizard',
version='1.1.1', version='1.2',
description='For editing ETS2 sii files', description='For editing ETS2 sii files',
executables=executables, executables=executables,
options=options, options=options,
requires=['PyQt5'] requires=['PyQt5', 'requests'],
) )

View File

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