2
This commit is contained in:
parent
31b0deaa1e
commit
1561999e70
@ -70,7 +70,7 @@ class SR1ShipRender(BaseScreen):
|
|||||||
"""用于渲染 sr1 船的类"""
|
"""用于渲染 sr1 船的类"""
|
||||||
|
|
||||||
name = "DR_game_sr1_ship_render"
|
name = "DR_game_sr1_ship_render"
|
||||||
|
ships_buttons = []
|
||||||
def __init__(self, main_window: ClientWindow):
|
def __init__(self, main_window: ClientWindow):
|
||||||
super().__init__(main_window)
|
super().__init__(main_window)
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
@ -182,20 +182,29 @@ class SR1ShipRender(BaseScreen):
|
|||||||
main_window.push_handlers(self.enter_game_button)
|
main_window.push_handlers(self.enter_game_button)
|
||||||
main_window.push_handlers(self.select_ship_button)
|
main_window.push_handlers(self.select_ship_button)
|
||||||
|
|
||||||
self.new_button = PressSelectShipButton(
|
# 扫描所有飞船
|
||||||
window=main_window,
|
ships_path = "./ships"
|
||||||
parent_window = self,
|
ships_files=self.scan_all_ships_list(ships_path)
|
||||||
x=button_x,
|
button_x = 600
|
||||||
y=button_y,
|
button_y = 0
|
||||||
width=button_w,
|
button_w = 150
|
||||||
height=button_h,
|
button_h = 30
|
||||||
text=button_text,
|
for i in range(len(ships_files)):
|
||||||
batch=self.main_batch,
|
self.ships_buttons.append(PressOpenShipButton(
|
||||||
group=main_window.main_group,
|
window=main_window,
|
||||||
draw_theme=MinecraftWikiButtonTheme,
|
ship_path = ships_files[i],
|
||||||
)
|
parent_window = self,
|
||||||
|
x=button_x,
|
||||||
|
y=button_y + i * button_h,
|
||||||
|
width=button_w,
|
||||||
|
height=button_h,
|
||||||
|
text=ships_files[i],
|
||||||
|
batch=self.main_batch,
|
||||||
|
group=main_window.main_group,
|
||||||
|
draw_theme=MinecraftWikiButtonTheme,
|
||||||
|
))
|
||||||
|
|
||||||
main_window.push_handlers(self.new_button)
|
main_window.push_handlers(self.ships_buttons[-1])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -741,6 +750,43 @@ class PressSelectShipButton(PressTextButton):
|
|||||||
logger.info("加载飞船from "+self.path_var)
|
logger.info("加载飞船from "+self.path_var)
|
||||||
return self.path_var
|
return self.path_var
|
||||||
|
|
||||||
|
class PressOpenShipButton(PressTextButton):
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
window: ClientWindow,
|
||||||
|
ship_path,
|
||||||
|
parent_window,
|
||||||
|
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
|
||||||
|
self.parent_window = parent_window
|
||||||
|
self.ship_path = ship_path
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
self.parent_window.begin_ship_render_from_path(self.ship_path)
|
||||||
|
logger.info("加载飞船from "+self.ship_path)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user