The settings menu refreshes texture pack when exited
This commit is contained in:
parent
21e85078a4
commit
b0292c05b2
|
@ -3,6 +3,9 @@ from typing import Optional
|
|||
|
||||
from dungeonbattle.settings import Settings
|
||||
|
||||
class DisplayActions(Enum):
|
||||
REFRESH = auto()
|
||||
UPDATE = auto()
|
||||
|
||||
class GameMode(Enum):
|
||||
MAINMENU = auto()
|
||||
|
|
|
@ -2,7 +2,7 @@ from random import randint
|
|||
from typing import Any, Optional
|
||||
|
||||
from .entities.player import Player
|
||||
from .enums import GameMode, KeyValues
|
||||
from .enums import GameMode, KeyValues, DisplayActions
|
||||
from .interfaces import Map
|
||||
from .settings import Settings
|
||||
from . import menus
|
||||
|
@ -12,7 +12,7 @@ from typing import Callable
|
|||
class Game:
|
||||
map: Map
|
||||
player: Player
|
||||
display_refresh: Callable[[], None]
|
||||
display_actions: Callable[[DisplayActions], None]
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""
|
||||
|
@ -51,7 +51,7 @@ class Game:
|
|||
while True: # pragma no cover
|
||||
screen.clear()
|
||||
screen.refresh()
|
||||
self.display_refresh()
|
||||
self.display_actions(DisplayActions.REFRESH)
|
||||
key = screen.getkey()
|
||||
self.handle_key_pressed(
|
||||
KeyValues.translate_key(key, self.settings), key)
|
||||
|
@ -68,7 +68,7 @@ class Game:
|
|||
self.main_menu.handle_key_pressed(key, self)
|
||||
elif self.state == GameMode.SETTINGS:
|
||||
self.settings_menu.handle_key_pressed(key, raw_key, self)
|
||||
self.display_refresh()
|
||||
self.display_actions(DisplayActions.REFRESH)
|
||||
|
||||
def handle_key_pressed_play(self, key: KeyValues) -> None:
|
||||
"""
|
||||
|
|
|
@ -3,7 +3,7 @@ from enum import Enum
|
|||
from typing import Any, Optional
|
||||
|
||||
from .display.texturepack import TexturePack
|
||||
from .enums import GameMode, KeyValues
|
||||
from .enums import GameMode, KeyValues, DisplayActions
|
||||
from .settings import Settings
|
||||
|
||||
|
||||
|
@ -82,6 +82,7 @@ class SettingsMenu(Menu):
|
|||
if key == KeyValues.SPACE or \
|
||||
key == KeyValues.ENTER and \
|
||||
self.position == len(self.values) - 1:
|
||||
game.display_actions(DisplayActions.UPDATE)
|
||||
game.state = GameMode.MAINMENU
|
||||
if key == KeyValues.DOWN:
|
||||
self.go_down()
|
||||
|
|
Loading…
Reference in New Issue