Change texture pack

This commit is contained in:
Yohann D'ANELLO 2020-11-11 23:09:15 +01:00
parent 13ac2ba13a
commit ddf0b21e37
2 changed files with 18 additions and 3 deletions

View File

@ -31,6 +31,10 @@ class TexturePack:
def get_pack(cls, name: str) -> "TexturePack": def get_pack(cls, name: str) -> "TexturePack":
return cls._packs[name.lower()] return cls._packs[name.lower()]
@classmethod
def get_next_pack_name(cls, name: str) -> str:
return "squirrel" if name == "ascii" else "ascii"
TexturePack.ASCII_PACK = TexturePack( TexturePack.ASCII_PACK = TexturePack(
name="ascii", name="ascii",

View File

@ -2,6 +2,7 @@ import sys
from enum import Enum from enum import Enum
from typing import Any, Optional from typing import Any, Optional
from .display.texturepack import TexturePack
from .enums import GameMode, KeyValues from .enums import GameMode, KeyValues
from .settings import Settings from .settings import Settings
@ -61,10 +62,14 @@ class SettingsMenu(Menu):
s = settings.get_comment(key) s = settings.get_comment(key)
s += " : " s += " : "
if self.waiting_for_key and i == self.position: if self.waiting_for_key and i == self.position:
s += "? " s += "?"
else: else:
s += getattr(settings, key).replace("\n", "\\n") s += getattr(settings, key).replace("\n", "\\n")
s += 8 * " " # Write over old text
self.values.append(s) self.values.append(s)
self.values.append("")
self.values.append("Changer le pack de textures n'aura effet")
self.values.append("qu'après avoir relancé le jeu.")
def handle_key_pressed(self, key: Optional[KeyValues], raw_key: str, def handle_key_pressed(self, key: Optional[KeyValues], raw_key: str,
game: Any) -> None: game: Any) -> None:
@ -78,9 +83,15 @@ class SettingsMenu(Menu):
self.go_down() self.go_down()
if key == KeyValues.UP: if key == KeyValues.UP:
self.go_up() self.go_up()
if key == KeyValues.ENTER: if key == KeyValues.ENTER and self.position < len(self.values) - 3:
option = list(game.settings.settings_keys)[self.position] option = list(game.settings.settings_keys)[self.position]
if option != "TEXTURE_PACK": if option == "TEXTURE_PACK":
game.settings.TEXTURE_PACK = \
TexturePack.get_next_pack_name(
game.settings.TEXTURE_PACK)
game.settings.write_settings()
self.update_values(game.settings)
else:
self.waiting_for_key = True self.waiting_for_key = True
self.update_values(game.settings) self.update_values(game.settings)
else: else: