From 909045248287773345f6cb2381e43e7a3a483428 Mon Sep 17 00:00:00 2001 From: ssssssssboom <2810462715@qq.com> Date: Fri, 17 May 2024 19:24:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9C=89=E6=95=88=E6=9E=9C?= =?UTF-8?q?=E7=9A=84=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mods/dr_game/__init__.py | 6 ++--- mods/dr_game/menu.py | 49 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/mods/dr_game/__init__.py b/mods/dr_game/__init__.py index 398b711..d3961d9 100644 --- a/mods/dr_game/__init__.py +++ b/mods/dr_game/__init__.py @@ -93,14 +93,14 @@ class DR_mod(ModInfo): # NOQA return True def on_client_start(self, game: Game, client: ClientWindow): - from .sr1_ship import SR1ShipRender + #from .sr1_ship import SR1ShipRender from .menu import Menu client.add_sub_screen("DR_game_menu", Menu) logger.info("added dr_game_menu screen", tag="dr_game") - client.add_sub_screen("SR1_ship", SR1ShipRender) - logger.info("added SR1_ship screen", tag="dr_game") + #client.add_sub_screen("SR1_ship", SR1ShipRender) + #logger.info("added SR1_ship screen", tag="dr_game") def on_unload(self, game: Game): game.client.window.screen_list.pop("SR1_ship") diff --git a/mods/dr_game/menu.py b/mods/dr_game/menu.py index a4d7133..71869df 100644 --- a/mods/dr_game/menu.py +++ b/mods/dr_game/menu.py @@ -4,12 +4,13 @@ # All rights reserved # ------------------------------- +from typing import Optional, Tuple from pyglet.graphics import Batch, Group from Difficult_Rocket.client import ClientWindow from Difficult_Rocket.api.screen import BaseScreen - -from Difficult_Rocket.gui.widget.button import PressTextButton, MinecraftWikiButtonTheme +from Difficult_Rocket.main import Game +from Difficult_Rocket.gui.widget.button import PressTextButton, MinecraftWikiButtonTheme, ButtonThemeOptions, BaseButtonTheme # from . import DR_mod_runtime @@ -83,11 +84,55 @@ class Menu(BaseScreen): batch=self.main_batch, group=self.main_group, ) + self.enter_ship_editor_button = PressEnterShipEditorButton( + window=main_window, + x=100, + y=100, + width=150, + height=30, + text="进入编辑器", + batch=self.main_batch, + group=self.main_group, + ) main_window.push_handlers(self.wiki_button1) main_window.push_handlers(self.wiki_button2) main_window.push_handlers(self.wiki_button3) main_window.push_handlers(self.wiki_button4) main_window.push_handlers(self.button3) + main_window.push_handlers(self.enter_ship_editor_button) def on_draw(self, dt: float, window: ClientWindow): 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[type(BaseButtonTheme)] = None, + dict_theme: Optional[dict] = None,): + super().__init__(x,y,width,height,text,batch,group,theme,draw_theme,dict_theme) + self.window=window + + #from lib_not_dr import loggers + 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 + 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") + +