Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: ふぁ <yuki@yuki0311.com>
  • Loading branch information
fa0311 committed Aug 24, 2023
1 parent 72eccf2 commit 46cdad7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 deletions.
8 changes: 3 additions & 5 deletions DMMGamePlayerFastLauncher/DMMGamePlayerFastLauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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:
Expand Down
23 changes: 16 additions & 7 deletions DMMGamePlayerFastLauncher/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,28 +15,33 @@
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:
self.launch(id)
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):
Expand Down Expand Up @@ -82,24 +87,28 @@ 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:
self.launch(id)
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):
Expand Down
7 changes: 6 additions & 1 deletion DMMGamePlayerFastLauncher/lib/toast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions DMMGamePlayerFastLauncher/tab/home.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)

Expand Down
6 changes: 5 additions & 1 deletion DMMGamePlayerFastLauncher/tab/shortcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("|", "")
Expand Down

0 comments on commit 46cdad7

Please sign in to comment.