From ec6bbf817b430c8c7e3ad7da42d5af7721e44c59 Mon Sep 17 00:00:00 2001 From: EKNr1 Date: Tue, 27 Feb 2024 20:12:13 +0100 Subject: [PATCH] Added the GUI system. --- assets/textures/floors/floor_01.png | Bin 656 -> 614 bytes assets/textures/floors/floor_01.xcf | Bin 2626 -> 1424 bytes gd_pygame.py | 5 +++++ ui.py | 31 ++++++++++++++++++++++------ 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/assets/textures/floors/floor_01.png b/assets/textures/floors/floor_01.png index 33bbfedfb7d93f549f550ef705ee13cd14e12560..c2994527703f37002fe288b62c81cb96a4cd3e16 100644 GIT binary patch delta 138 zcmbQh`iw=fGr-TCmrII^fq{Y7)59eQNGpIa2OE$quB!U7QSmS%yD+ziPUr%?$*&nT zg6%wA977@wzrDCo5U7mVp^(34~kBfF5i^yD^%yOUot zYSdgTe~DWM4f DH%c~l diff --git a/assets/textures/floors/floor_01.xcf b/assets/textures/floors/floor_01.xcf index 174ca546df7f6fe77bb4e86b56ccb7e4844f0f28..4540721f3ab17b77e00909c92587ad4484917674 100644 GIT binary patch literal 1424 zcmd^9xlY4C5ZyQl1V|v94M7a2k|HQBs1Z;A1rjB#Nj7GMkH~f)G|(ezDr&xgieEEt zoVBz_DG?3NdNXg1-Sx3+SNQ`Pb^CPRv26j6ChIqF5iAs7mchy?QcPe4EP?yrn%3O6 z3Z`Jq#nkO?==(BA5DP9Yokr40WRD(Ha!Y3ymseb=XRXS2T-kOb)#Ds@e>UUf(UTO1 zp6az`n|-$%dSOJ(%(Wx;#-UDj*)5cBCX{W;E-sJafzwriOE!W>Gtjy{3{*nC@;v3s zL`E?W3j6(7Ce%4NTJ=Belfe5?`4#YsbU* z!MXK(C%%*X_4O9{wWGlc<#Wz!&Bv+^7D0f2bbLBY)~SO71< zlT=f?V=xA*Him8ueAl(S2r;ALK{v2^ku~J+B6{PG&o8f3smZ3o?b%k#4#bdh)cU6p zMsvsFq3?)cv)mZj1K;rj-jJ>p*!>=F%gbz{++R~RxxA=63&*{I@N8}(nCn5RTN6)2 z+!c-^Tr0AIkUIIJQD{ZHeS1f}{zXZ!rWZZGhTK#Olw3k^kmgx=5+3en2NO@u-9U~| z1nCtozzfnH7@!1Fp8D>j8cr?+Tvd{QUz9 C%}f6P diff --git a/gd_pygame.py b/gd_pygame.py index 25f0d79..0dd88ee 100644 --- a/gd_pygame.py +++ b/gd_pygame.py @@ -4,6 +4,7 @@ import pygame from pygame._sdl2 import Window from dataclasses import dataclass from wobbl_tools.data_file import load_dataclass_json, save_dataclass_json +from ui import UI @dataclass @@ -28,9 +29,11 @@ class GDPygame: setattr(self.settings, "save", lambda: save_dataclass_json(self.settings, "settings.json")) self.fps = self.settings.fps + self.ui = UI(self) # colors self.gray = (20, 20, 20) + self.blue = (10, 10, 140) # pygame objects self.clock = pygame.time.Clock() @@ -58,6 +61,8 @@ class GDPygame: def loop(self): self.screen.fill(self.gray) + self.ui.draw() + self.get_events() if not self.running: return diff --git a/ui.py b/ui.py index a3d853c..2ef2141 100644 --- a/ui.py +++ b/ui.py @@ -1,14 +1,33 @@ #!/usr/bin/python3 class UI: - def __init__(self): + def __init__(self, app): + self.app = app + + self.main_menu = MainMenu(app) + self.current_page = "main_menu" - self.main_menu = Page() + def draw(self): + page = getattr(self, self.current_page) + page.draw() + + def update(self): + page = getattr(self, self.current_page) + page.update() class Page: - def __init__(self, elements: dict=None): - if not elements is None: - for name, element in elements.items(): - setattr(self, name, element) + def __init__(self, app): + self.app = app + + def draw(self): + pass + + def update(self): + pass + + +class MainMenu(Page): + def draw(self): + self.app.screen.fill(self.app.blue)