REFACTOR styling

This commit is contained in:
2025-04-23 18:36:33 +02:00
parent 022e789d9c
commit 78c9dc1341
7 changed files with 40 additions and 13 deletions

View File

@@ -45,8 +45,8 @@ class Game(GameState):
def draw(self):
"""Draws everything on screen."""
self.screen.fill((0, 0, 0))
self.game_box.fill((0, 0, 0, 0))
self.screen.fill(self.styling["background_colour"])
self.game_box.fill(self.styling["background_colour"])
self.map_renderer.render()
self.player_renderer.render()

View File

@@ -6,11 +6,11 @@ class GameState:
self.context = context
self.screen = self.context.get("screen")
self.match = self.context.get("match", None)
self.font = self.context.get("font", pygame.font.Font(None, 36))
self.small_font = self.context.get("small_font", pygame.font.Font(None, 15))
self.options = self.context.get("options", {
"show_yaw": True
})
self.styling = self.context.get("styling", None)
def handle_events(self, events):
pass

View File

@@ -9,7 +9,7 @@ class SettingsMenu(GameState):
def __init__(self, switch_state_callback, context):
super().__init__(switch_state_callback, context)
self.settings_renderer = SettingsMenuRenderer(self.screen, self.context["options"], self.font)
self.settings_renderer = SettingsMenuRenderer(self.screen, self.context["options"], self.styling)
self.settings_controller = SettingsController(self.settings_renderer, self.switch_state, context)
def handle_events(self, events):

View File

@@ -24,6 +24,8 @@ class StartMenu(GameState):
self._get_demo)
self.upload_demo_button.set_text("Upload Demo")
self.upload_demo_button.set_font_size(40)
self.upload_demo_button.set_colour(self.styling["button_colour"])
self.upload_demo_button.set_pressed_colour(self.styling["pressed_button_colour"])
self.settings_button = Button(self.default_button_start_x,
350,
@@ -32,6 +34,8 @@ class StartMenu(GameState):
lambda: self.switch_state("settings_menu"))
self.settings_button.set_text("Settings")
self.settings_button.set_font_size(40)
self.settings_button.set_colour(self.styling["button_colour"])
self.settings_button.set_pressed_colour(self.styling["pressed_button_colour"])
self.quit_button = Button(self.default_button_start_x,
450,
@@ -40,6 +44,8 @@ class StartMenu(GameState):
pygame.quit)
self.quit_button.set_text("Quit")
self.quit_button.set_font_size(40)
self.quit_button.set_colour(self.styling["button_colour"])
self.quit_button.set_pressed_colour(self.styling["pressed_button_colour"])
# file dialog
self.file_dialog = None
@@ -107,7 +113,7 @@ class StartMenu(GameState):
def draw(self):
"""Draws everything on screen."""
self.screen.fill((30, 30, 30)) # Clear screen
self.screen.fill(self.styling["background_colour"]) # Clear screen
self.upload_demo_button.draw(self.screen)
self.settings_button.draw(self.screen)
self.quit_button.draw(self.screen)