From a58b93644b2af59dbca7bec359db75dd38d45740 Mon Sep 17 00:00:00 2001 From: ssssssssboom <2810462715@qq.com> Date: Thu, 30 May 2024 20:19:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=BB=91=E5=8A=A8=E7=9A=84?= =?UTF-8?q?=E9=A3=9E=E8=88=B9=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mods/dr_game/sr1_ship.py | 49 +++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/mods/dr_game/sr1_ship.py b/mods/dr_game/sr1_ship.py index af782c2..7a80d37 100644 --- a/mods/dr_game/sr1_ship.py +++ b/mods/dr_game/sr1_ship.py @@ -154,6 +154,9 @@ class SR1ShipRender(BaseScreen): ) # Buttons + self.buttons_group = Group(100, parent=main_window.main_group) + self.ships_buttons_group = Group(100, parent=main_window.main_group) + self.enter_game_button = PressEnterGameButton( window=main_window, x=500, @@ -162,7 +165,7 @@ class SR1ShipRender(BaseScreen): height=30, text="进入游戏", batch=self.main_batch, - group=main_window.main_group, + group=self.buttons_group, draw_theme=MinecraftWikiButtonTheme ) @@ -175,7 +178,7 @@ class SR1ShipRender(BaseScreen): height=30, text="加载飞船", batch=self.main_batch, - group=main_window.main_group, + group=self.buttons_group, draw_theme=MinecraftWikiButtonTheme, ) @@ -205,12 +208,36 @@ class SR1ShipRender(BaseScreen): height=self.ships_buttons_h, text=ships_files[i][8:], batch=self.main_batch, - group=main_window.main_group, + group=self.ships_buttons_group, draw_theme=MinecraftWikiButtonTheme, )) main_window.push_handlers(self.ships_buttons[-1]) + self.ship_list_line_back = Line( + self.ships_buttons_begin_x - 4, + self.ships_buttons_begin_y, + self.ships_buttons_begin_x - 4, + self.ships_buttons_end_y, + width=5, + color=(100, 100, 100, 255), + batch=self.main_batch, + group=self.ships_buttons_group, + ) + + self.ship_list_line = Line( + x = self.ships_buttons_begin_x, + y = self.ships_buttons_end_y - (self.ships_buttons_end_y - self.ships_buttons_begin_y) ** 2 / ((len(ships_files) + 1) * self.ships_buttons_h), + x2 = self.ships_buttons_begin_x, + y2 = self.ships_buttons_end_y, + width=20, + color=(200, 200, 200, 255), + batch=self.main_batch, + group=self.ships_buttons_group, + ) + + self.ships_buttons_group.visible = False + @property @@ -466,7 +493,7 @@ class SR1ShipRender(BaseScreen): def on_mouse_scroll( self, x: int, y: int, scroll_x: int, scroll_y: int, window: ClientWindow ): - logger.info(x,y,self.ships_buttons_begin_x,self.ships_buttons_end_x,self.ships_buttons_begin_y,self.ships_buttons_end_y) + # logger.info(x,y,self.ships_buttons_begin_x,self.ships_buttons_end_x,self.ships_buttons_begin_y,self.ships_buttons_end_y) if self.status.focus and \ (self.show_ships_buttons == False or \ (not (self.show_ships_buttons == True \ @@ -515,17 +542,17 @@ class SR1ShipRender(BaseScreen): for ship_button in self.ships_buttons: min_y = min(min_y, ship_button.y) max_y = max(max_y, ship_button.y) - - if max_y + scroll_y * 50 <= self.height: - scroll_y = (self.height - max_y) / 50 + + if max_y + scroll_y * 50 <= self.height - self.ships_buttons_h: + scroll_y = (self.height - self.ships_buttons_h - max_y) / 50 - if min_y + scroll_y * 50 >= 10: - scroll_y = (10 - min_y) / 50 + if min_y + scroll_y * 50 >= 0: + scroll_y = (0 - min_y) / 50 - - for ship_button in self.ships_buttons: ship_button.y = ship_button.y + scroll_y * 50 + + self.ship_list_line.y = self.ship_list_line.y - scroll_y * 50 * (self.ships_buttons_end_y - self.ships_buttons_begin_y) / ((len(self.ships_buttons) + 1) * self.ships_buttons_h)