按钮背景不会动以及乱七八糟的bug
This commit is contained in:
parent
637c3e5eca
commit
d216939171
@ -95,6 +95,7 @@ class SR1ShipRender(BaseScreen):
|
|||||||
self.height = main_window.height
|
self.height = main_window.height
|
||||||
|
|
||||||
self.main_batch = Batch()
|
self.main_batch = Batch()
|
||||||
|
self.ships_buttons_batch = Batch()
|
||||||
self.group_camera = CenterGroupCamera(
|
self.group_camera = CenterGroupCamera(
|
||||||
window=main_window,
|
window=main_window,
|
||||||
order=10,
|
order=10,
|
||||||
@ -196,13 +197,13 @@ class SR1ShipRender(BaseScreen):
|
|||||||
main_window.push_handlers(self.select_ship_button)
|
main_window.push_handlers(self.select_ship_button)
|
||||||
|
|
||||||
# 扫描所有飞船
|
# 扫描所有飞船
|
||||||
self.show_ships_buttons = True
|
self.show_ships_buttons = False
|
||||||
self.ships_buttons_w = 150
|
self.ships_buttons_w = 150
|
||||||
self.ships_buttons_h = 30
|
self.ships_buttons_h = 30
|
||||||
self.ships_buttons_begin_x = self.width - self.ships_buttons_w
|
self.ships_buttons_begin_x = self.width - self.ships_buttons_w
|
||||||
self.ships_buttons_begin_y = 0
|
self.ships_buttons_begin_y = 0
|
||||||
self.ships_buttons_end_x = self.width
|
self.ships_buttons_end_x = self.width
|
||||||
self.ships_buttons_end_y = self.height
|
self.ships_buttons_end_y = self.height - self.ships_buttons_h * 5
|
||||||
|
|
||||||
ships_path = "./ships/"
|
ships_path = "./ships/"
|
||||||
ships_files = self.scan_all_ships_list(ships_path)
|
ships_files = self.scan_all_ships_list(ships_path)
|
||||||
@ -218,7 +219,7 @@ class SR1ShipRender(BaseScreen):
|
|||||||
width=self.ships_buttons_w,
|
width=self.ships_buttons_w,
|
||||||
height=self.ships_buttons_h,
|
height=self.ships_buttons_h,
|
||||||
text=ships_files[i][8:],
|
text=ships_files[i][8:],
|
||||||
batch=self.main_batch,
|
batch=self.ships_buttons_batch,
|
||||||
group=self.ships_buttons_group,
|
group=self.ships_buttons_group,
|
||||||
draw_theme=MinecraftWikiButtonTheme,
|
draw_theme=MinecraftWikiButtonTheme,
|
||||||
)
|
)
|
||||||
@ -233,7 +234,7 @@ class SR1ShipRender(BaseScreen):
|
|||||||
self.ships_buttons_end_y,
|
self.ships_buttons_end_y,
|
||||||
width=5,
|
width=5,
|
||||||
color=(100, 100, 100, 255),
|
color=(100, 100, 100, 255),
|
||||||
batch=self.main_batch,
|
batch=self.ships_buttons_batch,
|
||||||
group=self.ships_buttons_group,
|
group=self.ships_buttons_group,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -246,11 +247,12 @@ class SR1ShipRender(BaseScreen):
|
|||||||
y2=self.ships_buttons_end_y,
|
y2=self.ships_buttons_end_y,
|
||||||
width=20,
|
width=20,
|
||||||
color=(200, 200, 200, 255),
|
color=(200, 200, 200, 255),
|
||||||
batch=self.main_batch,
|
batch=self.ships_buttons_batch,
|
||||||
group=self.ships_buttons_group,
|
group=self.ships_buttons_group,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.ships_buttons_group.visible = False
|
# self.ships_buttons_group.visible = False
|
||||||
|
self.show_ships_buttons = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def size(self) -> Tuple[int, int]:
|
def size(self) -> Tuple[int, int]:
|
||||||
@ -475,6 +477,8 @@ class SR1ShipRender(BaseScreen):
|
|||||||
self.window_pointer.height,
|
self.window_pointer.height,
|
||||||
)
|
)
|
||||||
self.main_batch.draw() # use group camera, no need to with
|
self.main_batch.draw() # use group camera, no need to with
|
||||||
|
if self.show_ships_buttons:
|
||||||
|
self.ships_buttons_batch.draw()
|
||||||
gl.glViewport(0, 0, self.window_pointer.width, self.window_pointer.height)
|
gl.glViewport(0, 0, self.window_pointer.width, self.window_pointer.height)
|
||||||
gl.glScissor(0, 0, self.window_pointer.width, self.window_pointer.height)
|
gl.glScissor(0, 0, self.window_pointer.width, self.window_pointer.height)
|
||||||
gl.glDisable(gl.GL_SCISSOR_TEST)
|
gl.glDisable(gl.GL_SCISSOR_TEST)
|
||||||
@ -563,8 +567,8 @@ class SR1ShipRender(BaseScreen):
|
|||||||
min_y = min(min_y, ship_button.y)
|
min_y = min(min_y, ship_button.y)
|
||||||
max_y = max(max_y, ship_button.y)
|
max_y = max(max_y, ship_button.y)
|
||||||
|
|
||||||
if max_y + scroll_y * 50 <= self.height - self.ships_buttons_h:
|
if max_y + scroll_y * 50 <= self.ships_buttons_end_y - self.ships_buttons_h:
|
||||||
scroll_y = (self.height - self.ships_buttons_h - max_y) / 50
|
scroll_y = (self.ships_buttons_end_y - self.ships_buttons_h - max_y) / 50
|
||||||
|
|
||||||
if min_y + scroll_y * 50 >= 0:
|
if min_y + scroll_y * 50 >= 0:
|
||||||
scroll_y = (0 - min_y) / 50
|
scroll_y = (0 - min_y) / 50
|
||||||
@ -804,6 +808,15 @@ class PressSelectShipButton(PressTextButton):
|
|||||||
self.parent_window = parent_window
|
self.parent_window = parent_window
|
||||||
|
|
||||||
def on_mouse_release(self, x, y, buttons, modifiers):
|
def on_mouse_release(self, x, y, buttons, modifiers):
|
||||||
|
logger.info(self.parent_window.ships_buttons_begin_y,self.parent_window.ships_buttons_end_y,x,y)
|
||||||
|
logger.info(y >= self.parent_window.ships_buttons_begin_y and y <= self.parent_window.ships_buttons_end_y)
|
||||||
|
if (
|
||||||
|
self.parent_window.show_ships_buttons
|
||||||
|
and x >= self.parent_window.ships_buttons_begin_x
|
||||||
|
and x <= self.parent_window.ships_buttons_end_x
|
||||||
|
and y >= self.parent_window.ships_buttons_begin_y
|
||||||
|
and y <= self.parent_window.ships_buttons_end_y
|
||||||
|
):
|
||||||
if self.pressed and (x, y) in self:
|
if self.pressed and (x, y) in self:
|
||||||
if self.draw_theme:
|
if self.draw_theme:
|
||||||
self.draw_theme.on_disable(self)
|
self.draw_theme.on_disable(self)
|
||||||
|
Loading…
Reference in New Issue
Block a user