From e38b75a15ea466ec11bce6fa6dc5742f710b76f9 Mon Sep 17 00:00:00 2001 From: shenjack-mac <3695888@qq.com> Date: Thu, 8 Jun 2023 00:57:03 +0800 Subject: [PATCH] make obj printable --- Difficult_Rocket/client/__init__.py | 3 +++ Difficult_Rocket/server/__init__.py | 3 +++ Difficult_Rocket/utils/options.py | 6 ++++++ configs/main.toml | 4 ++-- libs/MCDR/version.py | 3 +++ mods/dr_game/__init__.py | 4 ++-- 6 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Difficult_Rocket/client/__init__.py b/Difficult_Rocket/client/__init__.py index e917e2f..fe0313b 100644 --- a/Difficult_Rocket/client/__init__.py +++ b/Difficult_Rocket/client/__init__.py @@ -92,6 +92,9 @@ class Client: self.window.start_game() # 游戏启动 # TODO 写一下服务端启动相关,还是需要服务端啊 + def __repr__(self): + return f'' + def pyglet_load_fonts_folder(folder) -> None: file_folder_list = os.listdir(folder) diff --git a/Difficult_Rocket/server/__init__.py b/Difficult_Rocket/server/__init__.py index a8eea07..935520d 100644 --- a/Difficult_Rocket/server/__init__.py +++ b/Difficult_Rocket/server/__init__.py @@ -43,3 +43,6 @@ class Server: def run(self): self.logger.info(tr().server.os.pid_is().format(os.getpid(), os.getppid())) + + def __repr__(self): + return f'' diff --git a/Difficult_Rocket/utils/options.py b/Difficult_Rocket/utils/options.py index 1be17c2..6e07d1d 100644 --- a/Difficult_Rocket/utils/options.py +++ b/Difficult_Rocket/utils/options.py @@ -77,6 +77,12 @@ class Options: traceback.print_exc() self.flush_option() + def __str__(self): + return f"<{self.__class__.__name__} {self.name}>" if self.name else f"<{self.__class__.__name__}>" + + def __repr__(self): + return self.__str__() + if TYPE_CHECKING: _options: Dict[str, Union[Callable, object]] = {} diff --git a/configs/main.toml b/configs/main.toml index 147b732..4f5eb27 100644 --- a/configs/main.toml +++ b/configs/main.toml @@ -7,8 +7,8 @@ fonts_folder = "libs/fonts" [window] style = "None" -width = 2542 -height = 1489 +width = 1021 +height = 1078 visible = true gui_scale = 1 caption = "Difficult Rocket v{DR_version}" diff --git a/libs/MCDR/version.py b/libs/MCDR/version.py index 54ce239..2fef632 100644 --- a/libs/MCDR/version.py +++ b/libs/MCDR/version.py @@ -111,6 +111,9 @@ class Version: version_str += '+' + str(self.build) return version_str + def __repr__(self): + return self.__str__() + def __getitem__(self, index: int) -> int: if index < len(self.component): return self.component[index] diff --git a/mods/dr_game/__init__.py b/mods/dr_game/__init__.py index ab7a810..3b247a6 100644 --- a/mods/dr_game/__init__.py +++ b/mods/dr_game/__init__.py @@ -9,10 +9,9 @@ import traceback from typing import Optional -from libs.MCDR.version import Version from Difficult_Rocket.main import Game from Difficult_Rocket.api.mod import ModInfo -from Difficult_Rocket.api.types import Options +from Difficult_Rocket.api.types import Options, Version from Difficult_Rocket.client import ClientWindow DR_rust_version = Version("0.2.10.1") # DR_mod 的 Rust 编写部分的兼容版本 @@ -76,6 +75,7 @@ class DR_mod(ModInfo): else: self.config.flush_option() print("DR_mod: on_load") + print(self.as_markdown()) return True def on_client_start(self, game: Game, client: ClientWindow):