Skip to content

Commit

Permalink
Merge pull request #130 from fa0311/develop-v5
Browse files Browse the repository at this point in the history
v5.6.1
  • Loading branch information
fa0311 authored Mar 14, 2024
2 parents 751b986 + 91b4ec6 commit c131a73
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 18 deletions.
19 changes: 18 additions & 1 deletion DMMGamePlayerFastLauncher/component/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class EntryComponent(CTkFrame):
required: bool
command: list[tuple[str, Callable[[Variable], None]]]
state: str
alnum_only: bool

def __init__(
self,
Expand All @@ -96,6 +97,7 @@ def __init__(
required: bool = False,
command: Optional[list[tuple[str, Callable[[Variable], None]]]] = None,
state: Optional[str] = None,
alnum_only: bool = False,
) -> None:
super().__init__(master, fg_color="transparent")
self.pack(fill=ctk.X, expand=True)
Expand All @@ -105,10 +107,15 @@ def __init__(
self.required = required
self.command = command or []
self.state = state or tk.NORMAL
self.alnum_only = alnum_only

def create(self):
LabelComponent(self, text=self.text, required=self.required, tooltip=self.tooltip).create()
CTkEntry(self, textvariable=self.variable, state=self.state).pack(side=ctk.LEFT, fill=ctk.BOTH, expand=True)
entry = CTkEntry(self, textvariable=self.variable, state=self.state)
entry.pack(side=ctk.LEFT, fill=ctk.BOTH, expand=True)

if self.alnum_only:
entry.bind("<Key>", self.alnum_only_callback)

for cmd in self.command:
CTkButton(self, text=cmd[0], command=self.call(cmd[1]), width=0).pack(side=ctk.LEFT, padx=2)
Expand All @@ -117,6 +124,16 @@ def create(self):
def call(self, cmd):
return lambda: cmd(self.variable)

def alnum_only_callback(self, event):
char = event.char.encode("utf-8")
if event.keysym in ["BackSpace", "Delete", "Left", "Right"]:
return
if char.isalnum():
return
if event.char in ["_", "-"]:
return
return "break"


class ButtonComponent(CTkFrame):
frame: CTkFrame
Expand Down
5 changes: 3 additions & 2 deletions DMMGamePlayerFastLauncher/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ def thread(self, id: str, kill: bool = False, force_non_uac: bool = False):
self.launch(id, kill, force_non_uac)
self.quit()
except Exception as e:
if not Env.DEVELOP:
if Env.DEVELOP:
raise
else:
self.iconify()
ErrorWindow(self, str(e), traceback.format_exc(), quit=True).create()
raise

def launch(self, id: str, kill: bool = False, force_non_uac: bool = False):
path = DataPathConfig.SHORTCUT.joinpath(id).with_suffix(".json")
Expand Down
20 changes: 12 additions & 8 deletions DMMGamePlayerFastLauncher/lib/discord.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import time

import i18n
Expand All @@ -6,11 +7,14 @@


def start_rich_presence(pid: int, id: str, title: str):
RPC = Presence(DiscordConfig.CLIENT_ID)
RPC.connect()
RPC.update(
state=i18n.t("app.discord.state", name=title),
pid=pid,
start=int(time.time()),
large_image=f"https://media.games.dmm.com/freegame/client/{id}/200.gif",
)
try:
RPC = Presence(DiscordConfig.CLIENT_ID)
RPC.connect()
RPC.update(
state=i18n.t("app.discord.state", name=title),
pid=pid,
start=int(time.time()),
large_image=f"https://media.games.dmm.com/freegame/client/{id}/200.gif",
)
except Exception as e:
logging.error(f"Failed to start rich presence: {e}")
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.6.0"
VERSION = "v5.6.1"
RELEASE_VERSION = requests.get(UrlConfig.RELEASE_API).json().get("tag_name", VERSION)

DEVELOP: bool = os.environ.get("ENV") == "DEVELOP"
Expand Down
9 changes: 6 additions & 3 deletions DMMGamePlayerFastLauncher/tab/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ def __init__(self, master: CTkBaseClass):

def create(self):
CTkLabel(self, text=i18n.t("app.account.import_detail"), justify=ctk.LEFT).pack(anchor=ctk.W)
filename_tooltip = i18n.t("app.account.filename_tooltip")
EntryComponent(self, text=i18n.t("app.account.filename"), tooltip=filename_tooltip, required=True, variable=self.name).create()
text = i18n.t("app.account.filename")
tooltip = i18n.t("app.account.filename_tooltip")
EntryComponent(self, text=text, tooltip=tooltip, required=True, variable=self.name, alnum_only=True).create()
CTkButton(self, text=i18n.t("app.account.import"), command=self.callback).pack(fill=ctk.X, pady=10)
return self

Expand Down Expand Up @@ -111,7 +112,9 @@ def select_callback(self, value: str):
children_destroy(self.body)
path = DataPathConfig.ACCOUNT.joinpath(self.filename.get()).with_suffix(".bytes")
self.body_filename.set(self.filename.get())
EntryComponent(self.body, text=i18n.t("app.account.filename"), variable=self.body_filename).create()
text = i18n.t("app.account.filename")
tooltip = i18n.t("app.account.filename_tooltip")
EntryComponent(self.body, text=text, tooltip=tooltip, required=True, variable=self.body_filename, alnum_only=True).create()

session = DgpSessionWrap()
session.read_bytes(str(Path(path)))
Expand Down
7 changes: 5 additions & 2 deletions DMMGamePlayerFastLauncher/tab/shortcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def __init__(self, master: Frame):
self.account_name_list = [x.stem for x in DataPathConfig.ACCOUNT.iterdir() if x.suffix == ".bytes"]

def create(self):
EntryComponent(self, text=i18n.t("app.shortcut.filename"), tooltip=i18n.t("app.shortcut.filename_tooltip"), required=True, variable=self.filename).create()
text = i18n.t("app.shortcut.filename")
tooltip = i18n.t("app.shortcut.filename_tooltip")
EntryComponent(self, text=text, tooltip=tooltip, required=True, variable=self.filename, alnum_only=True).create()
text = i18n.t("app.shortcut.product_id")
OptionMenuComponent(self, text=text, tooltip=i18n.t("app.shortcut.product_id_tooltip"), values=self.product_ids, variable=self.data.product_id).create()
text = i18n.t("app.shortcut.account_path")
Expand Down Expand Up @@ -286,7 +288,8 @@ def __init__(self, master: Frame):

def create(self):
text = i18n.t("app.shortcut.filename")
EntryComponent(self, text=i18n.t("app.shortcut.filename"), tooltip=i18n.t("app.shortcut.filename_tooltip"), required=True, variable=self.filename).create()
tooltip = i18n.t("app.shortcut.filename_tooltip")
EntryComponent(self, text=text, tooltip=tooltip, required=True, variable=self.filename, alnum_only=True).create()
text = i18n.t("app.shortcut.account_path")
OptionMenuComponent(self, text=text, values=self.account_name_list, variable=self.data.account_path).create()
text = i18n.t("app.shortcut.dgp_args")
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.6.0"
#define MyAppVersion "5.6.1"
#define MyAppPublisher "yuki"
#define MyAppURL "https://github.com/fa0311/DMMGamePlayerFastLauncher"
#define MyAppExeName "DMMGamePlayerFastLauncher.exe"
Expand Down

0 comments on commit c131a73

Please sign in to comment.