Skip to content

Commit 33f261c

Browse files
authored
Merge pull request #123 from fa0311/develop-v5
5.5.2
2 parents 67d7526 + 97cd066 commit 33f261c

File tree

5 files changed

+59
-44
lines changed

5 files changed

+59
-44
lines changed

DMMGamePlayerFastLauncher/lib/process_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
class ProcessManager:
1616
@staticmethod
1717
def admin_run(args: list[str], cwd: Optional[str] = None) -> int:
18-
file, *args = args
18+
file = args.pop(0)
1919
logging.info({"cwd": cwd, "args": args, "file": file})
20-
return ctypes.windll.shell32.ShellExecuteW(None, "runas", file, " ".join([f"{arg}" for arg in args]), cwd, 1)
20+
return ctypes.windll.shell32.ShellExecuteW(None, "runas", str(file), " ".join([f"{arg}" for arg in args]), cwd, 1)
2121

2222
@staticmethod
2323
def admin_check() -> bool:

DMMGamePlayerFastLauncher/static/env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
class Env(Dump):
11-
VERSION = "v5.5.1"
11+
VERSION = "v5.5.2"
1212
RELEASE_VERSION = requests.get(UrlConfig.RELEASE_API).json().get("tag_name", VERSION)
1313

1414
DEVELOP: bool = os.environ.get("ENV") == "DEVELOP"

DMMGamePlayerFastLauncher/static/loder.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010

1111

1212
def config_loder():
13+
if not DataPathConfig.DATA.exists():
14+
raise FileNotFoundError(f"{DataPathConfig.DATA} not found")
15+
if not AssetsPathConfig.PATH.exists():
16+
raise FileNotFoundError(f"{AssetsPathConfig.PATH} not found")
17+
1318
if DataPathConfig.APP_CONFIG.exists():
1419
with open(DataPathConfig.APP_CONFIG, "r", encoding="utf-8") as f:
1520
AppConfig.DATA = SettingData.from_dict(json.load(f))
@@ -35,7 +40,7 @@ def config_migrate():
3540
version = Version(AppConfig.DATA.last_version.get() or "v0.0.0")
3641
logging.info(f"Migration from {version} to {Env.VERSION}")
3742

38-
if version < Version("v5.5.0"):
43+
if version < Version("v5.5.2"):
3944
logging.info("Migration from v5.5.0 to v5.5.1")
4045
Path(AssetsPathConfig.I18N).joinpath("app.ja.yml").unlink(missing_ok=True)
4146
Path(AssetsPathConfig.I18N).joinpath("app.en.yml").unlink(missing_ok=True)

DMMGamePlayerFastLauncher/tab/shortcut.py

Lines changed: 49 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
from pathlib import Path
33
from tkinter import Frame, StringVar
4+
from typing import Callable
45

56
import customtkinter as ctk
67
import i18n
@@ -105,10 +106,12 @@ def save(self):
105106
with open(path, "w", encoding="utf-8") as f:
106107
f.write(json.dumps(self.data.to_dict()))
107108

109+
def save_handler(self, fn: Callable[[], None]):
110+
pass
111+
108112
@error_toast
109113
def bypass_callback(self):
110-
self.save()
111-
try:
114+
def fn():
112115
task = Schtasks(self.filename.get())
113116
if task.check():
114117
task.set()
@@ -117,53 +120,52 @@ def bypass_callback(self):
117120
except Exception:
118121
name, icon = self.filename.get(), None
119122
self.toast.error(i18n.t("app.shortcut.game_info_error"))
120-
121123
sorce = Env.DESKTOP.joinpath(name).with_suffix(".lnk")
122124
args = ["/run", "/tn", task.name]
123125
Shortcut().create(sorce=sorce, target=Env.SCHTASKS, args=args, icon=icon)
124126
self.toast.info(i18n.t("app.shortcut.save_success"))
125-
except Exception:
126-
DataPathConfig.SHORTCUT.joinpath(self.filename.get()).with_suffix(".json").unlink()
127-
raise
127+
128+
self.save_handler(fn)
128129

129130
@error_toast
130131
def uac_callback(self):
131-
self.save()
132-
try:
132+
def fn():
133133
try:
134-
name, icon, admin = self.get_game_info()
134+
try:
135+
name, icon, admin = self.get_game_info()
136+
except Exception:
137+
name, icon = self.filename.get(), None
138+
self.toast.error(i18n.t("app.shortcut.game_info_error"))
139+
sorce = Env.DESKTOP.joinpath(name).with_suffix(".lnk")
140+
args = [self.filename.get()]
141+
Shortcut().create(sorce=sorce, args=args, icon=icon)
142+
self.toast.info(i18n.t("app.shortcut.save_success"))
135143
except Exception:
136-
name, icon = self.filename.get(), None
137-
self.toast.error(i18n.t("app.shortcut.game_info_error"))
144+
DataPathConfig.SHORTCUT.joinpath(self.filename.get()).with_suffix(".json").unlink()
145+
raise
138146

139-
sorce = Env.DESKTOP.joinpath(name).with_suffix(".lnk")
140-
args = [self.filename.get()]
141-
Shortcut().create(sorce=sorce, args=args, icon=icon)
142-
self.toast.info(i18n.t("app.shortcut.save_success"))
143-
except Exception:
144-
DataPathConfig.SHORTCUT.joinpath(self.filename.get()).with_suffix(".json").unlink()
145-
raise
147+
self.save_handler(fn)
146148

147149
@error_toast
148150
def save_callback(self):
149-
self.save()
150-
try:
151+
def fn():
151152
try:
152-
name, icon, admin = self.get_game_info()
153+
try:
154+
name, icon, admin = self.get_game_info()
155+
except Exception:
156+
name, icon, admin = self.filename.get(), None, False
157+
self.toast.error(i18n.t("app.shortcut.game_info_error"))
158+
if admin:
159+
raise Exception(i18n.t("app.shortcut.administrator_error"))
153160
except Exception:
154-
name, icon, admin = self.filename.get(), None, False
155-
self.toast.error(i18n.t("app.shortcut.game_info_error"))
156-
157-
if admin:
158-
raise Exception(i18n.t("app.shortcut.administrator_error"))
159-
161+
DataPathConfig.SHORTCUT.joinpath(self.filename.get()).with_suffix(".json").unlink()
162+
raise
160163
sorce = Env.DESKTOP.joinpath(name).with_suffix(".lnk")
161164
args = [self.filename.get()]
162165
Shortcut().create(sorce=sorce, args=args, icon=icon)
163166
self.toast.info(i18n.t("app.shortcut.save_success"))
164-
except Exception:
165-
DataPathConfig.SHORTCUT.joinpath(self.filename.get()).with_suffix(".json").unlink()
166-
raise
167+
168+
self.save_handler(fn)
167169

168170
@error_toast
169171
def save_only_callback(self):
@@ -203,6 +205,10 @@ def create(self):
203205
super().create()
204206
return self
205207

208+
def save_handler(self, fn: Callable[[], None]):
209+
self.save()
210+
fn()
211+
206212

207213
class ShortcutEdit(ShortcutBase):
208214
selected: StringVar
@@ -227,19 +233,23 @@ def create(self):
227233

228234
return self
229235

230-
def save(self):
231-
selected = DataPathConfig.SHORTCUT.joinpath(self.selected.get()).with_suffix(".json")
232-
selected.rename(selected.with_suffix(".json.bak"))
236+
def save_handler(self, fn: Callable[[], None]):
237+
selected = DataPathConfig.SHORTCUT.joinpath(self.selected.get())
238+
selected.with_suffix(".json").rename(selected.with_suffix(".json.bak"))
233239
try:
234-
super().save()
235-
selected.with_suffix(".json.bak").unlink()
236-
self.values.remove(self.selected.get())
237-
self.values.append(self.filename.get())
238-
self.selected.set(self.filename.get())
239-
self.option_callback("_")
240+
self.save()
241+
try:
242+
fn()
243+
except Exception:
244+
DataPathConfig.SHORTCUT.joinpath(self.filename.get()).with_suffix(".json").unlink()
240245
except Exception:
241246
selected.with_suffix(".json.bak").rename(selected.with_suffix(".json"))
242247
raise
248+
selected.with_suffix(".json.bak").unlink()
249+
self.values.remove(self.selected.get())
250+
self.values.append(self.filename.get())
251+
self.selected.set(self.filename.get())
252+
self.option_callback("_")
243253

244254
@error_toast
245255
def delete_callback(self):

setup.iss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33

44
#define MyAppName "DMMGamePlayerFastLauncher"
5-
#define MyAppVersion "5.5.1"
5+
#define MyAppVersion "5.5.2"
66
#define MyAppPublisher "yuki"
77
#define MyAppURL "https://github.com/fa0311/DMMGamePlayerFastLauncher"
88
#define MyAppExeName "DMMGamePlayerFastLauncher.exe"

0 commit comments

Comments
 (0)