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