mirror of
https://github.com/seuyh/stellaris-dlc-unlocker.git
synced 2026-06-12 19:11:27 -07:00
Fixes
This commit is contained in:
@@ -58,7 +58,7 @@ class CreamAPI(QtCore.QThread):
|
||||
"Upgrade-Insecure-Requests": "1"
|
||||
}
|
||||
try:
|
||||
response = get(url, headers=headers, timeout=3)
|
||||
response = get(url, headers=headers, timeout=8)
|
||||
data = response.json()
|
||||
dlc_list_json = data['data'][str(app_id)]['extended']['listofdlc']
|
||||
dlc_list = dlc_list_json.split(',')
|
||||
|
||||
+13
-2
@@ -46,20 +46,31 @@ def stellaris_path():
|
||||
return 0
|
||||
|
||||
|
||||
def is_drive_root(path: str) -> bool:
|
||||
if not path:
|
||||
return False
|
||||
norm = os.path.normpath(path)
|
||||
drive, tail = os.path.splitdrive(norm)
|
||||
return bool(drive) and (tail in ("", os.sep))
|
||||
|
||||
|
||||
def launcher_path():
|
||||
try:
|
||||
user_logon_name = get_user_logon_name()
|
||||
except:
|
||||
user_logon_name = os.getlogin()
|
||||
|
||||
user_home = os.path.join("C:\\Users", user_logon_name)
|
||||
|
||||
launcher_path_1 = reg_search(r"Software\Paradox Interactive\Paradox Launcher v2", "LauncherInstallation")
|
||||
launcher_path_2 = reg_search(r"Software\Paradox Interactive\Paradox Launcher v2", "LauncherPathFolder")
|
||||
|
||||
if not launcher_path_1:
|
||||
if (launcher_path_1 and is_drive_root(launcher_path_1)) or not launcher_path_1:
|
||||
launcher_path_1 = os.path.join(user_home, "AppData", "Local", "Programs", "Paradox Interactive", "launcher")
|
||||
if not launcher_path_2:
|
||||
if (launcher_path_2 and is_drive_root(launcher_path_2)) or not launcher_path_2:
|
||||
launcher_path_2 = os.path.join(user_home, "AppData", "Local", "Paradox Interactive")
|
||||
|
||||
|
||||
launcher_path_3 = os.path.join(user_home, "AppData", "Roaming", "Paradox Interactive")
|
||||
launcher_path_4 = os.path.join(user_home, "AppData", "Roaming", "paradox-launcher-v2")
|
||||
|
||||
|
||||
@@ -27,14 +27,17 @@ class ReinstallThread(QtCore.QThread):
|
||||
def run(self):
|
||||
user_home = os.path.join("C:\\Users", self.user_logon_name)
|
||||
if self.paradox_folder1 == self.msi_path:
|
||||
self.paradox_folder1 = os.path.join(user_home, "AppData", "Local", "Programs", "Paradox Interactive", "launcher")
|
||||
self.paradox_folder1 = os.path.join(user_home, "AppData", "Local", "Programs", "Paradox Interactive",
|
||||
"launcher")
|
||||
latest_file = None
|
||||
latest_version = (0, 0)
|
||||
|
||||
def extract_version(filename):
|
||||
match = search(r'launcher-installer-windows_(\d+\.\d+)', filename)
|
||||
if match:
|
||||
return tuple(map(int, match.group(1).split('.')))
|
||||
return None
|
||||
|
||||
msi_files = glob(os.path.join(self.msi_path, "launcher-installer-windows_*.msi"))
|
||||
if self.launcher_downloaded:
|
||||
print('Alt unlock. Deleting all other launches')
|
||||
@@ -103,18 +106,30 @@ class ReinstallThread(QtCore.QThread):
|
||||
if os.path.exists(paradox_folder1):
|
||||
print(f'Removing {paradox_folder1}')
|
||||
rmtree(paradox_folder1)
|
||||
except Exception as e:
|
||||
print(f'Cant delete {e}')
|
||||
pass
|
||||
|
||||
try:
|
||||
if os.path.exists(paradox_folder2):
|
||||
print(f'Removing {paradox_folder2}')
|
||||
rmtree(paradox_folder2)
|
||||
except Exception as e:
|
||||
print(f'Cant delete {e}')
|
||||
pass
|
||||
|
||||
try:
|
||||
if os.path.exists(paradox_folder3):
|
||||
print(f'Removing {paradox_folder3}')
|
||||
rmtree(paradox_folder3)
|
||||
except Exception as e:
|
||||
print(f'Cant delete {e}')
|
||||
pass
|
||||
|
||||
try:
|
||||
if os.path.exists(paradox_folder4):
|
||||
print(f'Removing {paradox_folder4}')
|
||||
rmtree(paradox_folder4)
|
||||
except Exception as e:
|
||||
print(f'Cant delete {e}')
|
||||
pass
|
||||
pass
|
||||
|
||||
+24
-14
@@ -7,10 +7,9 @@ import requests
|
||||
import winreg
|
||||
from PyQt5.QtGui import QDesktopServices, QColor, QBrush, QIcon
|
||||
from PyQt5.QtWidgets import QMainWindow, QFileDialog, QListWidgetItem, QProgressDialog, QApplication
|
||||
from PyQt5.QtCore import Qt, QUrl, QTimer, QTranslator
|
||||
from PyQt5.QtCore import Qt, QUrl, QTimer, QTranslator, QLocale
|
||||
from subprocess import run, CREATE_NO_WINDOW
|
||||
from pathlib import Path
|
||||
from locale import getlocale
|
||||
|
||||
import UI.ui_main as ui_main
|
||||
from Libs.ConnectionCheck import ConnectionCheckThread
|
||||
@@ -66,7 +65,7 @@ class MainWindow(QMainWindow, ui_main.Ui_MainWindow):
|
||||
self.creamapidone = False
|
||||
|
||||
self.GITHUB_REPO = "https://api.github.com/repos/seuyh/stellaris-dlc-unlocker/releases/latest"
|
||||
self.current_version = '2.25'
|
||||
self.current_version = '2.263'
|
||||
self.version_label.setText(f'Ver. {str(self.current_version)}')
|
||||
|
||||
self.copy_files_radio.setVisible(False)
|
||||
@@ -118,17 +117,20 @@ class MainWindow(QMainWindow, ui_main.Ui_MainWindow):
|
||||
self.log_widget.clear()
|
||||
|
||||
def get_app_language(self):
|
||||
lang, _ = getlocale()
|
||||
lang = QLocale.system().name().lower()
|
||||
print(f"Detected language: {lang}")
|
||||
if not lang:
|
||||
return "en"
|
||||
lang = lang.lower()
|
||||
if "russian" in lang:
|
||||
if lang.startswith("ru"):
|
||||
return "ru"
|
||||
elif "chinese" in lang:
|
||||
elif lang.startswith("zh"):
|
||||
return "zh"
|
||||
else:
|
||||
return "en"
|
||||
|
||||
def apply_initial_language(self):
|
||||
self.set_language_radio(self.get_app_language())
|
||||
|
||||
def set_language_radio(self, lang):
|
||||
if lang == "ru":
|
||||
@@ -143,23 +145,27 @@ class MainWindow(QMainWindow, ui_main.Ui_MainWindow):
|
||||
def apply_language(self, lang):
|
||||
app = QApplication.instance()
|
||||
app.removeTranslator(self.translator)
|
||||
print(f"Trying to apply language: {lang}")
|
||||
|
||||
if lang == "ru":
|
||||
if self.translator.load(os.path.join("UI", "translations", "ru_RU.qm")):
|
||||
app.installTranslator(self.translator)
|
||||
ok = self.translator.load(os.path.join(self.parent_directory, "UI", "translations", "ru_RU.qm"))
|
||||
elif lang == "zh":
|
||||
if self.translator.load(os.path.join("UI", "translations", "zh_CN.qm")):
|
||||
app.installTranslator(self.translator)
|
||||
ok = self.translator.load(os.path.join(self.parent_directory, "UI", "translations", "zh_CN.qm"))
|
||||
else:
|
||||
ok = False
|
||||
|
||||
if ok:
|
||||
app.installTranslator(self.translator)
|
||||
|
||||
self.retranslateUi(self)
|
||||
|
||||
def showEvent(self, event):
|
||||
super(MainWindow, self).showEvent(event)
|
||||
self.set_language_radio(self.get_app_language())
|
||||
self.apply_initial_language()
|
||||
print('Start connection check')
|
||||
QTimer.singleShot(5, self.start_connection_check)
|
||||
QTimer.singleShot(2, self.start_connection_check)
|
||||
print('Start updates check')
|
||||
QTimer.singleShot(4, lambda: self.check_for_updates(self.current_version))
|
||||
QTimer.singleShot(2, lambda: self.check_for_updates(self.current_version))
|
||||
|
||||
def switch_to_russian(self):
|
||||
if self.ru_lang.isChecked():
|
||||
@@ -294,7 +300,7 @@ class MainWindow(QMainWindow, ui_main.Ui_MainWindow):
|
||||
latest_release = response.json()
|
||||
latest_version = latest_release['tag_name']
|
||||
|
||||
if latest_version != current_version:
|
||||
if latest_version > current_version:
|
||||
print(f"Found new version: {latest_version}.")
|
||||
if self.dialogexec(self.tr('New version'),
|
||||
self.tr('New version found\nPlease update the program to correctly work '),
|
||||
@@ -305,6 +311,9 @@ class MainWindow(QMainWindow, ui_main.Ui_MainWindow):
|
||||
exe_asset_url = asset['browser_download_url']
|
||||
self.open_link_in_browser(exe_asset_url)
|
||||
self.close()
|
||||
elif latest_version < current_version:
|
||||
self.errorexec(self.tr("Beta"), self.tr("Ok"),
|
||||
exitApp=False)
|
||||
else:
|
||||
print(f"Unlocker is up to date")
|
||||
except:
|
||||
@@ -593,6 +602,7 @@ class MainWindow(QMainWindow, ui_main.Ui_MainWindow):
|
||||
self.download_files_radio.setChecked(True)
|
||||
print('Reinstalling')
|
||||
paradox_folder1, paradox_folder2, paradox_folder3, paradox_folder4 = launcher_path()
|
||||
print(f"Launcher folders: [{paradox_folder1, paradox_folder2, paradox_folder3, paradox_folder4}]")
|
||||
if not self.skip_launcher_reinstall_checbox.isChecked():
|
||||
self.reinstall_thread = ReinstallThread(self.game_path, paradox_folder1, paradox_folder2, paradox_folder3,
|
||||
paradox_folder4, self.launcher_downloaded,
|
||||
|
||||
Reference in New Issue
Block a user