From 46cdad780b379e98267ae58487fff06b4c2463a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=B5=E3=81=81?= Date: Thu, 24 Aug 2023 20:47:24 +0900 Subject: [PATCH] update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ふぁ --- .../DMMGamePlayerFastLauncher.py | 8 +++---- DMMGamePlayerFastLauncher/launch.py | 23 +++++++++++++------ DMMGamePlayerFastLauncher/lib/toast.py | 7 +++++- DMMGamePlayerFastLauncher/tab/home.py | 6 +++-- DMMGamePlayerFastLauncher/tab/shortcut.py | 6 ++++- 5 files changed, 34 insertions(+), 16 deletions(-) diff --git a/DMMGamePlayerFastLauncher/DMMGamePlayerFastLauncher.py b/DMMGamePlayerFastLauncher/DMMGamePlayerFastLauncher.py index 3f49b36..eb56321 100644 --- a/DMMGamePlayerFastLauncher/DMMGamePlayerFastLauncher.py +++ b/DMMGamePlayerFastLauncher/DMMGamePlayerFastLauncher.py @@ -16,9 +16,7 @@ def loder(master: LanchLauncher): i18n.load_path.append(str(AssetsPathConfig.I18N)) i18n.set("locale", AppConfig.DATA.lang.get()) - logging.getLogger("urllib3").setLevel(logging.WARNING) - - if AppConfig.DATA.debug_window.get() and logging.getLogger().hasHandlers(): + if AppConfig.DATA.debug_window.get() and not logging.getLogger().hasHandlers(): handler = TkinkerHandler(TkinkerLogger(master)).create() handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)8s %(message)s")) logging.basicConfig(level=logging.DEBUG, handlers=[handler]) @@ -61,12 +59,12 @@ def loder(master: LanchLauncher): App(loder).create().mainloop() elif type == "launcher": - lanch = LanchLauncher(loder) + lanch = LanchLauncher(loder).create() lanch.thread(id) lanch.mainloop() elif type == "game": - lanch = GameLauncher(loder) + lanch = GameLauncher(loder).create() lanch.thread(id) lanch.mainloop() else: diff --git a/DMMGamePlayerFastLauncher/launch.py b/DMMGamePlayerFastLauncher/launch.py index 7825e5c..689030f 100644 --- a/DMMGamePlayerFastLauncher/launch.py +++ b/DMMGamePlayerFastLauncher/launch.py @@ -4,9 +4,9 @@ from pathlib import Path from typing import Callable +import customtkinter as ctk import i18n from component.component import CTkProgressWindow -from component.tab_menu import TabMenuComponent from customtkinter import CTk from lib.DGPSessionV2 import DgpSessionV2 from lib.process_manager import ProcessManager @@ -15,20 +15,24 @@ from models.shortcut_data import ShortcutData from static.config import AppConfig, DataPathConfig from static.env import Env +from tab.home import HomeTab class GameLauncher(CTk): loder: Callable - tab: TabMenuComponent def __init__(self, loder): super().__init__() self.title("DMMGamePlayer Fast Launcher") - self.geometry("600x300") + self.geometry("900x600") self.withdraw() loder(self) + def create(self): + HomeTab(self).create().pack(expand=True, fill=ctk.BOTH) + return self + @threading_wrapper def thread(self, id: str): try: @@ -36,7 +40,8 @@ def thread(self, id: str): self.quit() except Exception as e: if not Env.DEVELOP: - ErrorWindow(self, str(e), traceback.format_exc()).create() + self.iconify() + ErrorWindow(self, str(e), traceback.format_exc(), quit=True).create() raise def launch(self, id: str): @@ -82,16 +87,19 @@ def launch(self, id: str): class LanchLauncher(CTk): loder: Callable - tab: TabMenuComponent def __init__(self, loder): super().__init__() self.title("DMMGamePlayer Fast Launcher") - self.geometry("600x300") + self.geometry("900x600") self.withdraw() loder(self) + def create(self): + HomeTab(self).create().pack(expand=True, fill=ctk.BOTH) + return self + @threading_wrapper def thread(self, id: str): try: @@ -99,7 +107,8 @@ def thread(self, id: str): self.quit() except Exception as e: if not Env.DEVELOP: - ErrorWindow(self, str(e), traceback.format_exc()).create() + self.iconify() + ErrorWindow(self, str(e), traceback.format_exc(), quit=True).create() raise def launch(self, id: str): diff --git a/DMMGamePlayerFastLauncher/lib/toast.py b/DMMGamePlayerFastLauncher/lib/toast.py index 73e7219..a2d57e7 100644 --- a/DMMGamePlayerFastLauncher/lib/toast.py +++ b/DMMGamePlayerFastLauncher/lib/toast.py @@ -97,11 +97,16 @@ class ErrorWindow(CTkToplevel): text: str trace: str - def __init__(self, master, text: str, trace: str): + def __init__(self, master, text: str, trace: str, quit: bool = False): super().__init__(master) self.text = text self.trace = trace self.geometry("600x300") + self.lift() + self.focus_force() + + if quit: + self.protocol("WM_DELETE_WINDOW", self.quit) def create(self): ErrorFrame(self, self.text, self.trace).create().pack(fill=ctk.BOTH, padx=10, pady=10, expand=True) diff --git a/DMMGamePlayerFastLauncher/tab/home.py b/DMMGamePlayerFastLauncher/tab/home.py index 58b2880..86ab3aa 100644 --- a/DMMGamePlayerFastLauncher/tab/home.py +++ b/DMMGamePlayerFastLauncher/tab/home.py @@ -1,5 +1,7 @@ +from tkinter import Misc + import i18n -from customtkinter import CTkBaseClass, CTkFont, CTkFrame, CTkImage, CTkLabel +from customtkinter import CTkFont, CTkFrame, CTkImage, CTkLabel from lib.toast import ToastController from PIL import Image from static.config import AssetsPathConfig @@ -8,7 +10,7 @@ class HomeTab(CTkFrame): toast: ToastController - def __init__(self, master: CTkBaseClass): + def __init__(self, master: Misc): super().__init__(master, fg_color="transparent") self.toast = ToastController(self) diff --git a/DMMGamePlayerFastLauncher/tab/shortcut.py b/DMMGamePlayerFastLauncher/tab/shortcut.py index 8b28116..0109f61 100644 --- a/DMMGamePlayerFastLauncher/tab/shortcut.py +++ b/DMMGamePlayerFastLauncher/tab/shortcut.py @@ -127,8 +127,12 @@ def get_game_info(self) -> tuple[str, Path]: game_path = Path([x["detail"]["path"] for x in self.dgp_config["contents"] if x["productId"] == self.data.product_id.get()][0]) path = DataPathConfig.ACCOUNT.joinpath(self.data.account_path.get()).with_suffix(".bytes") session = DgpSessionV2().read_cookies(path) - data = session.lunch(self.data.product_id.get()).json()["data"] + response = session.lunch(self.data.product_id.get()).json() + if response["result_code"] != 100: + raise Exception(response["error"]) + + data = response["data"] title = data["title"].replace("/", "").replace("\\", "") title = title.replace(":", "").replace("*", "").replace("?", "") title = title.replace('"', "").replace("<", "").replace(">", "").replace("|", "")