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":
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(
name="ascii",

View File

@ -2,6 +2,7 @@ import sys
from enum import Enum
from typing import Any, Optional
from .display.texturepack import TexturePack
from .enums import GameMode, KeyValues
from .settings import Settings
@ -64,7 +65,11 @@ class SettingsMenu(Menu):
s += "?"
else:
s += getattr(settings, key).replace("\n", "\\n")
s += 8 * " " # Write over old text
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,
game: Any) -> None:
@ -78,9 +83,15 @@ class SettingsMenu(Menu):
self.go_down()
if key == KeyValues.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]
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.update_values(game.settings)
else: