REFACTOR menus
This commit is contained in:
@@ -7,15 +7,20 @@ class SettingsMenu(GameState):
|
||||
def __init__(self, switch_state_callback, context):
|
||||
super().__init__(switch_state_callback, context)
|
||||
|
||||
self.text_start_x = 100
|
||||
self.widget_start_x = 500
|
||||
|
||||
# Text
|
||||
self.show_yaw_text = self.font.render("Show Yaw: ", True, (255, 255, 255))
|
||||
self.show_health_text = self.font.render("Show Health: ", True, (255, 255, 255))
|
||||
|
||||
# Buttons
|
||||
self.back_button = Button(10, 10, 50, 50, lambda: self.switch_state(self.context["previous_states"].pop()))
|
||||
self.back_button.set_image("assets/arrow.png")
|
||||
|
||||
self.show_yaw_text = self.font.render("Show Yaw: ", True, (255, 255, 255))
|
||||
self.show_yaw_button = Switch(100, 100, 50, 50, self.options["show_yaw"])
|
||||
|
||||
self.show_health_text = self.font.render("Show Health: ", True, (255, 255, 255))
|
||||
self.show_health_button = Switch(100, 150, 50, 50, self.options["show_health"])
|
||||
# Switches
|
||||
self.show_yaw_button = Switch(self.widget_start_x, 100, 100, self.show_yaw_text.get_rect().height, self.options["show_yaw"])
|
||||
self.show_health_button = Switch(self.widget_start_x, 150, 100, self.show_health_text.get_rect().height, self.options["show_health"])
|
||||
|
||||
def handle_events(self, events):
|
||||
"""Handles user inputs."""
|
||||
@@ -44,12 +49,10 @@ class SettingsMenu(GameState):
|
||||
def draw(self):
|
||||
"""Renders the settings menu."""
|
||||
self.screen.fill((30, 30, 30)) # Clear screen
|
||||
self.screen.blit(self.show_yaw_text, (self.show_yaw_button.x + self.show_yaw_button.width + 10,
|
||||
self.show_yaw_button.y))
|
||||
self.screen.blit(self.show_yaw_text, (self.text_start_x, self.show_yaw_button.y))
|
||||
self.show_yaw_button.draw(self.screen)
|
||||
|
||||
self.screen.blit(self.show_health_text, (self.show_health_button.x + self.show_health_button.width + 10,
|
||||
self.show_health_button.y))
|
||||
self.screen.blit(self.show_health_text, (self.text_start_x, self.show_health_button.y))
|
||||
self.show_health_button.draw(self.screen)
|
||||
|
||||
self.back_button.draw(self.screen)
|
||||
|
||||
@@ -18,7 +18,7 @@ class StartMenu(GameState):
|
||||
|
||||
# buttons
|
||||
self.upload_demo_button = Button(self.default_button_start_x,
|
||||
100,
|
||||
250,
|
||||
self.default_button_width,
|
||||
50,
|
||||
self._get_demo)
|
||||
@@ -26,7 +26,7 @@ class StartMenu(GameState):
|
||||
self.upload_demo_button.set_font_size(40)
|
||||
|
||||
self.settings_button = Button(self.default_button_start_x,
|
||||
200,
|
||||
350,
|
||||
self.default_button_width,
|
||||
50,
|
||||
lambda: self.switch_state("settings_menu"))
|
||||
|
||||
Reference in New Issue
Block a user