Skip to content

Commit

Permalink
Merge pull request #123 from fa0311/develop-v5
Browse files Browse the repository at this point in the history
5.5.2
  • Loading branch information
fa0311 authored Feb 23, 2024
2 parents 67d7526 + 97cd066 commit 33f261c
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 44 deletions.
4 changes: 2 additions & 2 deletions DMMGamePlayerFastLauncher/lib/process_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
class ProcessManager:
@staticmethod
def admin_run(args: list[str], cwd: Optional[str] = None) -> int:
file, *args = args
file = args.pop(0)
logging.info({"cwd": cwd, "args": args, "file": file})
return ctypes.windll.shell32.ShellExecuteW(None, "runas", file, " ".join([f"{arg}" for arg in args]), cwd, 1)
return ctypes.windll.shell32.ShellExecuteW(None, "runas", str(file), " ".join([f"{arg}" for arg in args]), cwd, 1)

@staticmethod
def admin_check() -> bool:
Expand Down
2 changes: 1 addition & 1 deletion DMMGamePlayerFastLauncher/static/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class Env(Dump):
VERSION = "v5.5.1"
VERSION = "v5.5.2"
RELEASE_VERSION = requests.get(UrlConfig.RELEASE_API).json().get("tag_name", VERSION)

DEVELOP: bool = os.environ.get("ENV") == "DEVELOP"
Expand Down
7 changes: 6 additions & 1 deletion DMMGamePlayerFastLauncher/static/loder.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@


def config_loder():
if not DataPathConfig.DATA.exists():
raise FileNotFoundError(f"{DataPathConfig.DATA} not found")
if not AssetsPathConfig.PATH.exists():
raise FileNotFoundError(f"{AssetsPathConfig.PATH} not found")

if DataPathConfig.APP_CONFIG.exists():
with open(DataPathConfig.APP_CONFIG, "r", encoding="utf-8") as f:
AppConfig.DATA = SettingData.from_dict(json.load(f))
Expand All @@ -35,7 +40,7 @@ def config_migrate():
version = Version(AppConfig.DATA.last_version.get() or "v0.0.0")
logging.info(f"Migration from {version} to {Env.VERSION}")

if version < Version("v5.5.0"):
if version < Version("v5.5.2"):
logging.info("Migration from v5.5.0 to v5.5.1")
Path(AssetsPathConfig.I18N).joinpath("app.ja.yml").unlink(missing_ok=True)
Path(AssetsPathConfig.I18N).joinpath("app.en.yml").unlink(missing_ok=True)
Expand Down
88 changes: 49 additions & 39 deletions DMMGamePlayerFastLauncher/tab/shortcut.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
from pathlib import Path
from tkinter import Frame, StringVar
from typing import Callable

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

def save_handler(self, fn: Callable[[], None]):
pass

@error_toast
def bypass_callback(self):
self.save()
try:
def fn():
task = Schtasks(self.filename.get())
if task.check():
task.set()
Expand All @@ -117,53 +120,52 @@ def bypass_callback(self):
except Exception:
name, icon = self.filename.get(), None
self.toast.error(i18n.t("app.shortcut.game_info_error"))

sorce = Env.DESKTOP.joinpath(name).with_suffix(".lnk")
args = ["/run", "/tn", task.name]
Shortcut().create(sorce=sorce, target=Env.SCHTASKS, args=args, icon=icon)
self.toast.info(i18n.t("app.shortcut.save_success"))
except Exception:
DataPathConfig.SHORTCUT.joinpath(self.filename.get()).with_suffix(".json").unlink()
raise

self.save_handler(fn)

@error_toast
def uac_callback(self):
self.save()
try:
def fn():
try:
name, icon, admin = self.get_game_info()
try:
name, icon, admin = self.get_game_info()
except Exception:
name, icon = self.filename.get(), None
self.toast.error(i18n.t("app.shortcut.game_info_error"))
sorce = Env.DESKTOP.joinpath(name).with_suffix(".lnk")
args = [self.filename.get()]
Shortcut().create(sorce=sorce, args=args, icon=icon)
self.toast.info(i18n.t("app.shortcut.save_success"))
except Exception:
name, icon = self.filename.get(), None
self.toast.error(i18n.t("app.shortcut.game_info_error"))
DataPathConfig.SHORTCUT.joinpath(self.filename.get()).with_suffix(".json").unlink()
raise

sorce = Env.DESKTOP.joinpath(name).with_suffix(".lnk")
args = [self.filename.get()]
Shortcut().create(sorce=sorce, args=args, icon=icon)
self.toast.info(i18n.t("app.shortcut.save_success"))
except Exception:
DataPathConfig.SHORTCUT.joinpath(self.filename.get()).with_suffix(".json").unlink()
raise
self.save_handler(fn)

@error_toast
def save_callback(self):
self.save()
try:
def fn():
try:
name, icon, admin = self.get_game_info()
try:
name, icon, admin = self.get_game_info()
except Exception:
name, icon, admin = self.filename.get(), None, False
self.toast.error(i18n.t("app.shortcut.game_info_error"))
if admin:
raise Exception(i18n.t("app.shortcut.administrator_error"))
except Exception:
name, icon, admin = self.filename.get(), None, False
self.toast.error(i18n.t("app.shortcut.game_info_error"))

if admin:
raise Exception(i18n.t("app.shortcut.administrator_error"))

DataPathConfig.SHORTCUT.joinpath(self.filename.get()).with_suffix(".json").unlink()
raise
sorce = Env.DESKTOP.joinpath(name).with_suffix(".lnk")
args = [self.filename.get()]
Shortcut().create(sorce=sorce, args=args, icon=icon)
self.toast.info(i18n.t("app.shortcut.save_success"))
except Exception:
DataPathConfig.SHORTCUT.joinpath(self.filename.get()).with_suffix(".json").unlink()
raise

self.save_handler(fn)

@error_toast
def save_only_callback(self):
Expand Down Expand Up @@ -203,6 +205,10 @@ def create(self):
super().create()
return self

def save_handler(self, fn: Callable[[], None]):
self.save()
fn()


class ShortcutEdit(ShortcutBase):
selected: StringVar
Expand All @@ -227,19 +233,23 @@ def create(self):

return self

def save(self):
selected = DataPathConfig.SHORTCUT.joinpath(self.selected.get()).with_suffix(".json")
selected.rename(selected.with_suffix(".json.bak"))
def save_handler(self, fn: Callable[[], None]):
selected = DataPathConfig.SHORTCUT.joinpath(self.selected.get())
selected.with_suffix(".json").rename(selected.with_suffix(".json.bak"))
try:
super().save()
selected.with_suffix(".json.bak").unlink()
self.values.remove(self.selected.get())
self.values.append(self.filename.get())
self.selected.set(self.filename.get())
self.option_callback("_")
self.save()
try:
fn()
except Exception:
DataPathConfig.SHORTCUT.joinpath(self.filename.get()).with_suffix(".json").unlink()
except Exception:
selected.with_suffix(".json.bak").rename(selected.with_suffix(".json"))
raise
selected.with_suffix(".json.bak").unlink()
self.values.remove(self.selected.get())
self.values.append(self.filename.get())
self.selected.set(self.filename.get())
self.option_callback("_")

@error_toast
def delete_callback(self):
Expand Down
2 changes: 1 addition & 1 deletion setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "DMMGamePlayerFastLauncher"
#define MyAppVersion "5.5.1"
#define MyAppVersion "5.5.2"
#define MyAppPublisher "yuki"
#define MyAppURL "https://github.com/fa0311/DMMGamePlayerFastLauncher"
#define MyAppExeName "DMMGamePlayerFastLauncher.exe"
Expand Down

0 comments on commit 33f261c

Please sign in to comment.