From d40f4fea343ff45870d1a6a240679164c8d94fd6 Mon Sep 17 00:00:00 2001 From: ssssssssboom <2810462715@qq.com> Date: Mon, 27 May 2024 18:48:34 +0800 Subject: [PATCH] 1 1 --- mods/dr_game/sr1_ship.py | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/mods/dr_game/sr1_ship.py b/mods/dr_game/sr1_ship.py index 72e65c0..91114fe 100644 --- a/mods/dr_game/sr1_ship.py +++ b/mods/dr_game/sr1_ship.py @@ -126,6 +126,19 @@ class SR1ShipRender(BaseScreen): ) self.render_d_label.visible = self.status.draw_d_pos + self.enter_game_button = PressEnterGameButton( + window=main_window, + x=100, + y=100, + width=150, + height=30, + text="进入游戏", + batch=self.main_batch, + group=main_window.main_group, + draw_theme=MinecraftWikiButtonTheme + ) + main_window.push_handlers(self.enter_game_button) + # Optional data self.textures: SR1Textures = SR1Textures() self.gen_draw: Optional[Generator] = None @@ -153,6 +166,9 @@ class SR1ShipRender(BaseScreen): tag="setup", ) + + + @property def size(self) -> Tuple[int, int]: """渲染器的渲染大小""" @@ -597,6 +613,44 @@ class SR1ShipRender(BaseScreen): def view(self, value: Mat4): self.window_pointer.view = value +from Difficult_Rocket.gui.widget.button import ( + PressTextButton, + MinecraftWikiButtonTheme, + ButtonThemeOptions, + BaseButtonTheme, +) +class PressEnterGameButton(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 + + logger.info("进入游戏") + + if __name__ == "__main__": from objprint import op