Skip to content

Commit

Permalink
added automatic version check
Browse files Browse the repository at this point in the history
  • Loading branch information
dyang886 committed Oct 18, 2024
1 parent ecb84b3 commit a0d34de
Show file tree
Hide file tree
Showing 14 changed files with 11,319 additions and 8,237 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ __pycache__
*.mo
build
dist
*.bat
compile.ps1
Game Cheats Manager.spec
utility.py
ResourceHacker.ini
elevator.manifest
elevate.manifest
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ Below are funding options:

| WeChat | Alipay | QQ |
| :----------------------------------------------------------: | :------------------------------------------------------: | :--------------------------------------------------: |
| <img src="assets\wechat.png" alt="WeChat Pay" width="200" /> | <img src="assets\alipay.png" alt="Alipay" width="200" /> | <img src="assets\qq.png" alt="QQ Pay" width="200" /> |
| <img src="assets/wechat.png" alt="WeChat Pay" width="200" /> | <img src="assets/alipay.png" alt="Alipay" width="200" /> | <img src="assets/qq.png" alt="QQ Pay" width="200" /> |

2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ Game Cheats Manager 是一个独立工具,与任何外部修改器提供商均

| 微信 | 支付宝 | QQ |
| :----------------------------------------------------------: | :------------------------------------------------------: | :--------------------------------------------------: |
| <img src="assets\wechat.png" alt="WeChat Pay" width="200" /> | <img src="assets\alipay.png" alt="Alipay" width="200" /> | <img src="assets\qq.png" alt="QQ Pay" width="200" /> |
| <img src="assets/wechat.png" alt="WeChat Pay" width="200" /> | <img src="assets/alipay.png" alt="Alipay" width="200" /> | <img src="assets/qq.png" alt="QQ Pay" width="200" /> |

2 changes: 1 addition & 1 deletion README_TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ Game Cheats Manager 是一個獨立工具,與任何外部修改器提供商均

| 微信 | 支付寶 | QQ |
| :----------------------------------------------------------: | :------------------------------------------------------: | :--------------------------------------------------: |
| <img src="assets\wechat.png" alt="WeChat Pay" width="200" /> | <img src="assets\alipay.png" alt="Alipay" width="200" /> | <img src="assets\qq.png" alt="QQ Pay" width="200" /> |
| <img src="assets/wechat.png" alt="WeChat Pay" width="200" /> | <img src="assets/alipay.png" alt="Alipay" width="200" /> | <img src="assets/qq.png" alt="QQ Pay" width="200" /> |

3 changes: 2 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def load_settings():
"enSearchResults": False,
"autoUpdateDatabase": True,
"autoUpdate": True,
"appUpdate": True,
"WeModPath": os.path.join(os.environ["LOCALAPPDATA"], "WeMod"),
"autoStart": False,
"showWarning": True,
Expand Down Expand Up @@ -147,7 +148,7 @@ def ensure_trainer_download_path_is_valid():
unzip_path = resource_path("dependency/7z/7z.exe")
binmay_path = resource_path("dependency/binmay.exe")
emptyMidi_path = resource_path("dependency/TrainerBGM.mid")
elevator_path = resource_path("dependency/elevator.exe")
elevator_path = resource_path("dependency/Elevate.exe")
search_path = resource_path("assets/search.png")

language_options = {
Expand Down
Binary file renamed dependency/Elevator.exe → dependency/Elevate.exe
Binary file not shown.
19,432 changes: 11,212 additions & 8,220 deletions dependency/xgqdetail.json

Large diffs are not rendered by default.

File renamed without changes.
8 changes: 7 additions & 1 deletion helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,13 @@ def __init__(self, parent=None):
self.autoUpdateCheckbox.setChecked(settings["autoUpdate"])
settingsWidgetsLayout.addWidget(self.autoUpdateCheckbox)

# Check software update at startup
self.appUpdateCheckbox = QCheckBox(tr("Check for software update at startup"))
self.appUpdateCheckbox.setChecked(settings["appUpdate"])
settingsWidgetsLayout.addWidget(self.appUpdateCheckbox)

# Launch app on startup
self.autoStartCheckbox = QCheckBox(tr("Launch app on startup"))
self.autoStartCheckbox = QCheckBox(tr("Launch app on system startup"))
self.autoStartCheckbox.setChecked(settings["autoStart"])
settingsWidgetsLayout.addWidget(self.autoStartCheckbox)

Expand Down Expand Up @@ -199,6 +204,7 @@ def apply_settings_page(self):
settings["removeBgMusic"] = self.removeBgMusicCheckbox.isChecked()
settings["autoUpdateDatabase"] = self.autoUpdateDatabaseCheckbox.isChecked()
settings["autoUpdate"] = self.autoUpdateCheckbox.isChecked()
settings["appUpdate"] = self.appUpdateCheckbox.isChecked()
settings["autoStart"] = self.autoStartCheckbox.isChecked()
settings["downloadServer"] = server_options[self.serverCombo.currentText()]
apply_settings(settings)
Expand Down
22 changes: 20 additions & 2 deletions locale/en_US/LC_MESSAGES/Game Cheats Manager.po
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ msgstr "Update trainer databases automatically"
msgid "Update trainers automatically"
msgstr "Update trainers automatically"

msgid "Launch app on startup"
msgstr "Launch app on startup"
msgid "Check for software update at startup"
msgstr "Check for software update at startup"

msgid "Launch app on system startup"
msgstr "Launch app on system startup"

msgid "Apply"
msgstr "Apply"
Expand Down Expand Up @@ -249,6 +252,21 @@ msgstr "Launch"
msgid "Delete"
msgstr "Delete"

msgid "Update Available"
msgstr "Update Available"

msgid "New version found: {old_version} ➜ {new_version}"
msgstr "New version found: {old_version} ➜ {new_version}"

msgid "Please navigate to `Options` ➜ `About` to download the latest version."
msgstr "Please navigate to `Options` ➜ `About` to download the latest version."

msgid "Update Check Failed"
msgstr "Update Check Failed"

msgid "Failed to check for software update. You can navigate to `Options` ➜ `About` to check for updates manually."
msgstr "Failed to check for software update. You can navigate to `Options` ➜ `About` to check for updates manually."

msgid "Delete trainer"
msgstr "Delete trainer"

Expand Down
20 changes: 19 additions & 1 deletion locale/zh_CN/LC_MESSAGES/Game Cheats Manager.po
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ msgstr "自动更新修改器数据库"
msgid "Update trainers automatically"
msgstr "自动更新修改器"

msgid "Launch app on startup"
msgid "Check for software update at startup"
msgstr "软件启动时检查更新"

msgid "Launch app on system startup"
msgstr "开机自启"

msgid "Apply"
Expand Down Expand Up @@ -249,6 +252,21 @@ msgstr "启动"
msgid "Delete"
msgstr "删除"

msgid "Update Available"
msgstr "可用更新"

msgid "New version found: {old_version} ➜ {new_version}"
msgstr "发现新版本:{old_version} ➜ {new_version}"

msgid "Please navigate to `Options` ➜ `About` to download the latest version."
msgstr "请移至 `选项` ➜ `关于` 下载最新版本。"

msgid "Update Check Failed"
msgstr "检查更新失败"

msgid "Failed to check for software update. You can navigate to `Options` ➜ `About` to check for updates manually."
msgstr "无法检查软件更新,请移至 `选项` ➜ `关于` 以手动检查更新。"

msgid "Delete trainer"
msgstr "删除修改器"

Expand Down
20 changes: 19 additions & 1 deletion locale/zh_TW/LC_MESSAGES/Game Cheats Manager.po
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ msgstr "自動更新修改器資料庫"
msgid "Update trainers automatically"
msgstr "自動更新修改器"

msgid "Launch app on startup"
msgid "Check for software update at startup"
msgstr "軟體啟動時檢查更新"

msgid "Launch app on system startup"
msgstr "開機自啟"

msgid "Apply"
Expand Down Expand Up @@ -249,6 +252,21 @@ msgstr "啟動"
msgid "Delete"
msgstr "刪除"

msgid "Update Available"
msgstr "可用更新"

msgid "New version found: {old_version} ➜ {new_version}"
msgstr "發現新版本:{old_version} ➜ {new_version}"

msgid "Please navigate to `Options` ➜ `About` to download the latest version."
msgstr "請移至 `選項` ➜ `關於` 下載最新版本。"

msgid "Update Check Failed"
msgstr "檢查更新失敗"

msgid "Failed to check for software update. You can navigate to `Options` ➜ `About` to check for updates manually."
msgstr "無法檢查軟體更新,請移至 `選項` ➜ `關於` 以手動檢查更新。"

msgid "Delete trainer"
msgstr "刪除修改器"

Expand Down
33 changes: 31 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from PyQt6.QtCore import Qt, QTimer
from PyQt6.QtGui import QAction, QColor, QFont, QFontDatabase, QIcon, QPixmap
from PyQt6.QtWidgets import QApplication, QFileDialog, QGridLayout, QHBoxLayout, QLabel, QLineEdit, QListWidget, QListWidgetItem, QMainWindow, QMessageBox, QStatusBar, QVBoxLayout, QWidget
from PyQt6.QtWidgets import QApplication, QFileDialog, QGridLayout, QHBoxLayout, QLabel, QLineEdit, QListWidget, QListWidgetItem, QMainWindow, QMessageBox, QStatusBar, QVBoxLayout, QWidget, QSystemTrayIcon
from tendo import singleton

from helper import *
Expand All @@ -32,7 +32,7 @@ def __init__(self):
self.setMinimumSize(680, 520)

# Version and links
self.appVersion = "2.1.2"
self.appVersion = "2.1.3"
self.githubLink = "https://github.com/dyang886/Game-Cheats-Manager"
self.updateLink = "https://api.github.com/repos/dyang886/Game-Cheats-Manager/releases/latest"
self.bilibiliLink = "https://space.bilibili.com/256673766"
Expand Down Expand Up @@ -194,6 +194,13 @@ def __init__(self):
if settings["showWarning"]:
dialog = CopyRightWarning(self)
dialog.show()

# Check for software update
if settings['appUpdate']:
self.versionFetcher = VersionFetchWorker(self.updateLink)
self.versionFetcher.versionFetched.connect(lambda latest_version: self.send_notification(True, latest_version))
self.versionFetcher.fetchFailed.connect(lambda: self.send_notification(False))
self.versionFetcher.start()

# Update database, trainer update
self.timer = QTimer(self)
Expand All @@ -207,6 +214,28 @@ def __init__(self):
def closeEvent(self, event):
super().closeEvent(event)
os._exit(0)

def send_notification(self, success, latest_version=0):
tray_icon = QSystemTrayIcon(QIcon(resource_path("assets/logo.ico")), self)
tray_icon.show()

if success and latest_version > self.appVersion:
tray_icon.showMessage(
tr('Update Available'),
tr('New version found: {old_version} ➜ {new_version}').format(
old_version=self.appVersion,
new_version=latest_version
) + '\n' + tr('Please navigate to `Options` ➜ `About` to download the latest version.'),
QSystemTrayIcon.MessageIcon.Information
)
elif not success:
tray_icon.showMessage(
tr('Update Check Failed'),
tr('Failed to check for software update. You can navigate to `Options` ➜ `About` to check for updates manually.'),
QSystemTrayIcon.MessageIcon.Warning
)

self.versionFetcher.quit()

def init_settings(self):
if settings["theme"] == "black":
Expand Down
8 changes: 4 additions & 4 deletions wemod.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ def run(self):
patch_success = False

patterns = {
r'(getUserAccount\()(.*)(}async getUserAccountFlags)': r'\1\2.then(function(response){response.subscription = {period:"yearly",state:"active"};response.flags = 78;return response;})\3',
r'(getUserAccountFlags\()(.*)(\)\).flags)': r'\1\2\3.then(function(response){if (response.mask==4){response.flags = 4};return response;})',
r'(changeAccountEmail\()(.*)(email:.?,currentPassword:.?}\))': r'\1\2\3.then(function(response){response.subscription = {period:"yearly",state:"active"};response.flags = 78;return response;})',
r'(getPromotion\()(.*)(}}},)': r'\1\2.then(function(response){response.components.appBanner = null;response.flags = 0;return response;})\3'
r'(getUserAccount\()(.*)(}async getUserAccountFlags)': r'\1\2.then(function(response) {response.subscription={period:"yearly",state:"active"}; response.flags=78; return response;})\3',
r'(getUserAccountFlags\()(.*)(\)\).flags)': r'\1\2\3.then(function(response) {if (response.mask==4) {response.flags=4}; return response;})',
r'(changeAccountEmail\()(.*)(email:.?,currentPassword:.?}\))': r'\1\2\3.then(function(response) {response.subscription={period:"yearly", state:"active"}; response.flags=78; return response;})',
r'(getPromotion\()(.*)(collectMetrics:!0}\))': r'\1\2\3.then(function(response) {response.components.appBanner=null; response.flags=0; return response;})'
}

# Mapping of patterns to files where they were found: {pattern key: file path}
Expand Down

0 comments on commit a0d34de

Please sign in to comment.