From f63562eaf702aa66351415f89f9ba273085bbede Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Thu, 9 Feb 2023 14:47:39 +0800 Subject: [PATCH] update client start way --- Difficult_Rocket/client/__init__.py | 34 +++++++++++------------------ configs/main.toml | 4 ++-- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/Difficult_Rocket/client/__init__.py b/Difficult_Rocket/client/__init__.py index fac1a76..98721a3 100644 --- a/Difficult_Rocket/client/__init__.py +++ b/Difficult_Rocket/client/__init__.py @@ -57,12 +57,13 @@ class ClientOption(Options): def load_file(self) -> None: file = tools.load_file('./configs/main.toml') - self.fps = file['runtime']['fps'] - self.width = file['window']['width'] - self.height = file['window']['height'] - self.fullscreen = file['window']['full_screen'] - self.resizeable = file['window']['resizable'] - self.gui_scale = file['window']['gui_scale'] + self.fps = int(file['runtime']['fps']) + self.width = int(file['window']['width']) + self.height = int(file['window']['height']) + self.fullscreen = tools.format_bool(file['window']['full_screen']) + self.resizeable = tools.format_bool(file['window']['resizable']) + self.gui_scale = float(file['window']['gui_scale']) + self.caption = DR_runtime.format(file['window']['caption']) class Client: @@ -71,23 +72,18 @@ class Client: # logging self.logger = logging.getLogger('client') # config - self.config = tools.load_file('./configs/main.toml') + self.config = ClientOption() # value self.process_id = 'Client' self.process_name = 'Client process' self.process_pid = os.getpid() self.net_mode = net_mode - self.caption = DR_runtime.format(self.config['window']['caption']) file_drop = bool( pyglet.compat_platform != 'darwin' or DR_option.pyglet_macosx_dev_test ) - self.window = ClientWindow(net_mode=self.net_mode, - width=int(self.config['window']['width']), - height=int(self.config['window']['height']), - fullscreen=tools.format_bool(self.config['window']['full_screen']), - caption=self.caption, - resizable=tools.format_bool(self.config['window']['resizable']), - visible=tools.format_bool(self.config['window']['visible']), + self.window = ClientWindow(net_mode=self.net_mode, width=self.config.width, height=self.config.height, + fullscreen=self.config.fullscreen, caption=self.config.caption, + resizable=self.config.resizeable, visible=self.config.visible, file_drops=file_drop) self.logger.info(tr().client.setup.done()) end_time = time.time_ns() @@ -210,10 +206,6 @@ class ClientWindow(Window): # 淦,还写了个递归来处理 pyglet_load_fonts_folder(fonts_folder_path) - # @new_thread('window load_editor') - def load_editor(self): - pass - def start_game(self) -> None: self.run_input = True self.read_input() @@ -336,7 +328,7 @@ class ClientWindow(Window): @_call_screen_after def on_mouse_motion(self, x, y, dx, dy) -> None: - pass + ... @_call_screen_after def on_mouse_scroll(self, x, y, scroll_x, scroll_y): @@ -352,7 +344,7 @@ class ClientWindow(Window): @_call_screen_after def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers) -> None: - pass + ... @_call_screen_after def on_mouse_press(self, x, y, button, modifiers) -> None: diff --git a/configs/main.toml b/configs/main.toml index 9fa747f..4819852 100644 --- a/configs/main.toml +++ b/configs/main.toml @@ -8,8 +8,8 @@ fonts_folder = "libs/fonts" [window] style = "None" -width = 1358 -height = 739 +width = 928 +height = 1532 visible = true gui_scale = 1 caption = "Difficult Rocket v{DR_version}|DR_rs v{DR_Rust_get_version}"