Fixed bug that only the buttons in the button list got updated.
This commit is contained in:
parent
6b69d32ad1
commit
9b2fe07fca
1 changed files with 11 additions and 11 deletions
22
cowyeet.py
22
cowyeet.py
|
@ -3,7 +3,7 @@
|
|||
import os
|
||||
import pygame
|
||||
from tools import pg # if you import pg from tools, you dont need to init pygame.
|
||||
from tools.settings import Settings
|
||||
from tools.file_dict import FileDict
|
||||
|
||||
|
||||
# integrated settings (I dont trust my own settings class.)
|
||||
|
@ -18,10 +18,10 @@ screen = pygame.display.set_mode(DEFAULT_WINDOW_SIZE)
|
|||
pygame.display.set_caption("Cowyeet 2.0")
|
||||
|
||||
if os.path.isfile("settings.txt"):
|
||||
settings = Settings("settings.txt")
|
||||
settings = FileDict("settings.txt")
|
||||
|
||||
else:
|
||||
settings = Settings()
|
||||
settings = FileDict()
|
||||
settings.path = "settings.txt"
|
||||
settings["win_size"] = DEFAULT_WINDOW_SIZE
|
||||
settings.save()
|
||||
|
@ -70,8 +70,8 @@ def center(size):
|
|||
|
||||
|
||||
# buttons
|
||||
start_button = pg.TextButton("Start", center, screen, lambda: page_switch("game"), text_color=white_smoke, bg_color=dim_gray, font=bigger_default_font)
|
||||
buttons.append(start_button)
|
||||
buttons.append(pg.TextButton("Start", center, screen, lambda: page_switch("game"), text_color=white_smoke, bg_color=dim_gray, font=bigger_default_font))
|
||||
start_button = len(buttons) - 1
|
||||
text_buttons.append(start_button)
|
||||
|
||||
|
||||
|
@ -82,11 +82,13 @@ def close():
|
|||
|
||||
def window_size_reload(new_size):
|
||||
for button in text_buttons:
|
||||
button.update()
|
||||
buttons[button].update()
|
||||
|
||||
settings["win_size"] = new_size
|
||||
|
||||
|
||||
def main_menu_page():
|
||||
start_button.blit(screen)
|
||||
buttons[start_button].blit(screen)
|
||||
|
||||
|
||||
def page_selector():
|
||||
|
@ -101,9 +103,6 @@ def page_switch(new_page: str=None):
|
|||
if not new_page is None:
|
||||
page = new_page
|
||||
|
||||
if page == "main_menu":
|
||||
active_buttons = [start_button]
|
||||
|
||||
else:
|
||||
print("Error: Page not found.")
|
||||
|
||||
|
@ -161,10 +160,11 @@ def loop():
|
|||
# loading completed
|
||||
|
||||
screen = pygame.display.set_mode(settings["win_size"], flags=pygame.RESIZABLE)
|
||||
window_size_reload(settings["win_size"])
|
||||
screen.fill(nero)
|
||||
pygame.display.update()
|
||||
|
||||
page_switch()
|
||||
page_switch("main_menu")
|
||||
|
||||
running = True
|
||||
|
||||
|
|
Loading…
Reference in a new issue