From d6179422d5f73d7d0fbf779a032a8edb0fae7772 Mon Sep 17 00:00:00 2001 From: shenjack-5600u <3695888@qq.com> Date: Wed, 5 Jun 2024 07:42:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=B9=E5=8A=B2.png?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Difficult_Rocket/gui/widget/button.py | 6 +- mods/dr_game/Difficult_Rocket_rs/src/setup.py | 2 +- .../Difficult_Rocket_rs/src/src/sr1_parse.rs | 2 +- mods/dr_game/menu.py | 75 +++++++++++-------- 4 files changed, 47 insertions(+), 38 deletions(-) diff --git a/Difficult_Rocket/gui/widget/button.py b/Difficult_Rocket/gui/widget/button.py index 7b9ce8a..388df07 100644 --- a/Difficult_Rocket/gui/widget/button.py +++ b/Difficult_Rocket/gui/widget/button.py @@ -254,7 +254,7 @@ class MinecraftWikiButtonTheme(BaseButtonTheme): + (button.font_height * 0.2) + self.list_pad // 2 ) - + self.back_ground.x = self.x + (self.pad * 2) self.back_ground.y = self.y + (self.pad * 2) self.back_ground.position = self.x + (self.pad * 2), self.y + (self.pad * 2) @@ -389,7 +389,7 @@ class PressTextButton(widgets.WidgetBase): self.draw_theme.on_update(self) self.value = text # 重新分配一下高度和宽度的位置 - + @property def x(self) -> int: return self._x @@ -477,7 +477,6 @@ class PressTextButton(widgets.WidgetBase): self.draw_theme.on_disable(self) else: self.back_rec.color = self.untouched_color - self.dispatch_event("on_release", x, y) return False def on_mouse_release(self, x, y, buttons, modifiers): @@ -487,6 +486,7 @@ class PressTextButton(widgets.WidgetBase): else: self.back_rec.color = self.touched_color self.pressed = False + self.dispatch_event("on_release", self, x, y) def _update_position(self): self.text_label.position = self._x, self._y, 0 diff --git a/mods/dr_game/Difficult_Rocket_rs/src/setup.py b/mods/dr_game/Difficult_Rocket_rs/src/setup.py index d697a13..7479924 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/setup.py +++ b/mods/dr_game/Difficult_Rocket_rs/src/setup.py @@ -12,7 +12,7 @@ package_path = "Difficult_Rocket_rs" setup( name="Difficult_Rocket_rs", - version="0.3.1", + version="0.3.5", author="shenjackyuanjie", author_email="3695888@qq.com", rust_extensions=[ diff --git a/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_parse.rs b/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_parse.rs index e16673a..bfe6afb 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_parse.rs +++ b/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_parse.rs @@ -728,7 +728,7 @@ impl SR1Ship { }; } - fn write_parts(parts: &Vec, writer: &mut Writer>>, save_status: &SaveStatus) { + fn write_parts(parts: &[SR1PartData], writer: &mut Writer>>, save_status: &SaveStatus) { writer.write_event(Event::Start(BytesStart::new("Parts"))).unwrap(); for part in parts.iter() { let mut part_attr = BytesStart::new("Part"); diff --git a/mods/dr_game/menu.py b/mods/dr_game/menu.py index e855fe3..a9fac98 100644 --- a/mods/dr_game/menu.py +++ b/mods/dr_game/menu.py @@ -93,8 +93,7 @@ class Menu(BaseScreen): # batch=self.main_batch, # group=self.main_group, # ) - self.enter_ship_editor_button = PressEnterShipEditorButton( - window=main_window, + self.enter_ship_editor_button = PressTextButton( x=100, y=100, width=150, @@ -102,8 +101,18 @@ class Menu(BaseScreen): text="进入编辑器", batch=self.main_batch, group=self.main_group, - draw_theme=MinecraftWikiButtonTheme + draw_theme=MinecraftWikiButtonTheme, + dict_theme={"pop_out": True} ) + + def on_release(button: PressTextButton, x, y): + logger.info("on_mouse_release", x, y, button, tag="dr_game") + from .sr1_ship import SR1ShipRender + main_window.remove_sub_screen("DR_game_menu") + main_window.add_sub_screen("SR1_ship", SR1ShipRender) + logger.info("added SR1_ship screen", tag="dr_game") + + self.enter_ship_editor_button.set_handler("on_release", on_release) # main_window.push_handlers(self.wiki_button1) # main_window.push_handlers(self.wiki_button2) # main_window.push_handlers(self.wiki_button3) @@ -115,37 +124,37 @@ class Menu(BaseScreen): self.main_batch.draw() -class PressEnterShipEditorButton(PressTextButton): - def __init__( - self, - window: ClientWindow, - x: int, - y: int, - width: int, - height: int, - text: str, - batch: Optional[Batch] = None, - group: Optional[Group] = None, - theme: Optional[ButtonThemeOptions] = None, - draw_theme: Optional[BaseButtonTheme] = None, - dict_theme: Optional[dict] = None, - ): - super().__init__( - x, y, width, height, text, batch, group, theme, draw_theme, dict_theme - ) - self.window = window +# class PressEnterShipEditorButton(PressTextButton): +# def __init__( +# self, +# window: ClientWindow, +# x: int, +# y: int, +# width: int, +# height: int, +# text: str, +# batch: Optional[Batch] = None, +# group: Optional[Group] = None, +# theme: Optional[ButtonThemeOptions] = None, +# draw_theme: Optional[BaseButtonTheme] = None, +# dict_theme: Optional[dict] = None, +# ): +# super().__init__( +# x, y, width, height, text, batch, group, theme, draw_theme, dict_theme +# ) +# self.window = window - def on_mouse_release(self, x, y, buttons, modifiers): - if self.pressed and (x, y) in self: - if self.draw_theme: - self.draw_theme.on_disable(self) - else: - self.back_rec.color = self.touched_color - self.pressed = False +# def on_mouse_release(self, x, y, buttons, modifiers): +# if self.pressed and (x, y) in self: +# if self.draw_theme: +# self.draw_theme.on_disable(self) +# else: +# self.back_rec.color = self.touched_color +# self.pressed = False - from .sr1_ship import SR1ShipRender +# from .sr1_ship import SR1ShipRender - self.window.remove_sub_screen("DR_game_menu") - self.window.add_sub_screen("SR1_ship", SR1ShipRender) - logger.info("added SR1_ship screen", tag="dr_game") +# self.window.remove_sub_screen("DR_game_menu") +# self.window.add_sub_screen("SR1_ship", SR1ShipRender) +# logger.info("added SR1_ship screen", tag="dr_game")