We can open an empty inventory!

This commit is contained in:
Yohann D'ANELLO 2020-12-04 14:41:59 +01:00
parent 268e2d0dd2
commit 39af791012
12 changed files with 99 additions and 67 deletions

View File

@ -6,8 +6,8 @@ from squirrelbattle.display.display import VerticalSplit, HorizontalSplit
from squirrelbattle.display.mapdisplay import MapDisplay from squirrelbattle.display.mapdisplay import MapDisplay
from squirrelbattle.display.messagedisplay import MessageDisplay from squirrelbattle.display.messagedisplay import MessageDisplay
from squirrelbattle.display.statsdisplay import StatsDisplay from squirrelbattle.display.statsdisplay import StatsDisplay
from squirrelbattle.display.menudisplay import SettingsMenuDisplay, \ from squirrelbattle.display.menudisplay import MainMenuDisplay, \
MainMenuDisplay InventoryDisplay, SettingsMenuDisplay
from squirrelbattle.display.logsdisplay import LogsDisplay from squirrelbattle.display.logsdisplay import LogsDisplay
from squirrelbattle.display.texturepack import TexturePack from squirrelbattle.display.texturepack import TexturePack
from typing import Any from typing import Any
@ -23,10 +23,11 @@ class DisplayManager:
pack = TexturePack.get_pack(self.game.settings.TEXTURE_PACK) pack = TexturePack.get_pack(self.game.settings.TEXTURE_PACK)
self.mapdisplay = MapDisplay(screen, pack) self.mapdisplay = MapDisplay(screen, pack)
self.statsdisplay = StatsDisplay(screen, pack) self.statsdisplay = StatsDisplay(screen, pack)
self.logsdisplay = LogsDisplay(screen, pack)
self.inventorydisplay = InventoryDisplay(screen, pack)
self.mainmenudisplay = MainMenuDisplay(self.game.main_menu, self.mainmenudisplay = MainMenuDisplay(self.game.main_menu,
screen, pack) screen, pack)
self.settingsmenudisplay = SettingsMenuDisplay(screen, pack) self.settingsmenudisplay = SettingsMenuDisplay(screen, pack)
self.logsdisplay = LogsDisplay(screen, pack)
self.messagedisplay = MessageDisplay(screen=screen, pack=None) self.messagedisplay = MessageDisplay(screen=screen, pack=None)
self.hbar = HorizontalSplit(screen, pack) self.hbar = HorizontalSplit(screen, pack)
self.vbar = VerticalSplit(screen, pack) self.vbar = VerticalSplit(screen, pack)
@ -46,6 +47,7 @@ class DisplayManager:
d.pack = TexturePack.get_pack(self.game.settings.TEXTURE_PACK) d.pack = TexturePack.get_pack(self.game.settings.TEXTURE_PACK)
self.mapdisplay.update_map(self.game.map) self.mapdisplay.update_map(self.game.map)
self.statsdisplay.update_player(self.game.player) self.statsdisplay.update_player(self.game.player)
self.inventorydisplay.update_menu(self.game.inventory_menu)
self.settingsmenudisplay.update_menu(self.game.settings_menu) self.settingsmenudisplay.update_menu(self.game.settings_menu)
self.logsdisplay.update_logs(self.game.logs) self.logsdisplay.update_logs(self.game.logs)
self.messagedisplay.update_message(self.game.message) self.messagedisplay.update_message(self.game.message)
@ -64,10 +66,12 @@ class DisplayManager:
self.rows // 5 - 1, self.cols * 4 // 5) self.rows // 5 - 1, self.cols * 4 // 5)
self.hbar.refresh(self.rows * 4 // 5, 0, 1, self.cols * 4 // 5) self.hbar.refresh(self.rows * 4 // 5, 0, 1, self.cols * 4 // 5)
self.vbar.refresh(0, self.cols * 4 // 5, self.rows, 1) self.vbar.refresh(0, self.cols * 4 // 5, self.rows, 1)
if self.game.state == GameMode.MAINMENU: elif self.game.state == GameMode.INVENTORY:
self.inventorydisplay.refresh(0, 0, self.rows, self.cols)
elif self.game.state == GameMode.MAINMENU:
self.mainmenudisplay.refresh(0, 0, self.rows, self.cols) self.mainmenudisplay.refresh(0, 0, self.rows, self.cols)
if self.game.state == GameMode.SETTINGS: elif self.game.state == GameMode.SETTINGS:
self.settingsmenudisplay.refresh(0, 0, self.rows, self.cols - 1) self.settingsmenudisplay.refresh(0, 0, self.rows, self.cols)
if self.game.message: if self.game.message:
height, width = 0, 0 height, width = 0, 0

View File

@ -100,3 +100,8 @@ class MainMenuDisplay(Display):
self.menudisplay.refresh( self.menudisplay.refresh(
menuy, menux, min(self.menudisplay.preferred_height, menuy, menux, min(self.menudisplay.preferred_height,
self.height - menuy), menuwidth) self.height - menuy), menuwidth)
class InventoryDisplay(MenuDisplay):
def update_pad(self) -> None:
pass

View File

@ -37,6 +37,7 @@ class KeyValues(Enum):
LEFT = auto() LEFT = auto()
RIGHT = auto() RIGHT = auto()
ENTER = auto() ENTER = auto()
INVENTORY = auto()
SPACE = auto() SPACE = auto()
@staticmethod @staticmethod
@ -58,6 +59,8 @@ class KeyValues(Enum):
return KeyValues.UP return KeyValues.UP
elif key == settings.KEY_ENTER: elif key == settings.KEY_ENTER:
return KeyValues.ENTER return KeyValues.ENTER
elif key == settings.KEY_INVENTORY:
return KeyValues.INVENTORY
elif key == ' ': elif key == ' ':
return KeyValues.SPACE return KeyValues.SPACE
return None return None

View File

@ -39,6 +39,7 @@ class Game:
self.main_menu = menus.MainMenu() self.main_menu = menus.MainMenu()
self.settings_menu = menus.SettingsMenu() self.settings_menu = menus.SettingsMenu()
self.settings_menu.update_values(self.settings) self.settings_menu.update_values(self.settings)
self.inventory_menu = menus.InventoryMenu()
self.logs = Logs() self.logs = Logs()
self.message = None self.message = None
@ -104,6 +105,8 @@ class Game:
elif key == KeyValues.RIGHT: elif key == KeyValues.RIGHT:
if self.player.move_right(): if self.player.move_right():
self.map.tick() self.map.tick()
elif key == KeyValues.INVENTORY:
self.state = GameMode.INVENTORY
elif key == KeyValues.SPACE: elif key == KeyValues.SPACE:
self.state = GameMode.MAINMENU self.state = GameMode.MAINMENU

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: squirrelbattle 3.14.1\n" "Project-Id-Version: squirrelbattle 3.14.1\n"
"Report-Msgid-Bugs-To: squirrel-battle@crans.org\n" "Report-Msgid-Bugs-To: squirrel-battle@crans.org\n"
"POT-Creation-Date: 2020-11-28 16:03+0100\n" "POT-Creation-Date: 2020-12-04 14:18+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,8 +17,8 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: squirrelbattle/tests/game_test.py:284 squirrelbattle/tests/game_test.py:287
#: squirrelbattle/tests/translations_test.py:16 #: squirrelbattle/tests/translations_test.py:16
#: squirrelbattle/tests/game_test.py:290
msgid "New game" msgid "New game"
msgstr "Neu Spiel" msgstr "Neu Spiel"
@ -79,38 +79,42 @@ msgid "Key to validate a menu"
msgstr "Menütaste" msgstr "Menütaste"
#: squirrelbattle/tests/translations_test.py:45 #: squirrelbattle/tests/translations_test.py:45
msgid "Key used to open the inventory"
msgstr "Bestandtaste"
#: squirrelbattle/tests/translations_test.py:47
msgid "Texture pack" msgid "Texture pack"
msgstr "Textur-Packung" msgstr "Textur-Packung"
#: squirrelbattle/tests/translations_test.py:46 #: squirrelbattle/tests/translations_test.py:48
msgid "Language" msgid "Language"
msgstr "Sprache" msgstr "Sprache"
#: squirrelbattle/tests/translations_test.py:49 #: squirrelbattle/tests/translations_test.py:51
msgid "player" msgid "player"
msgstr "Spieler" msgstr "Spieler"
#: squirrelbattle/tests/translations_test.py:51 #: squirrelbattle/tests/translations_test.py:53
msgid "tiger" msgid "tiger"
msgstr "Tiger" msgstr "Tiger"
#: squirrelbattle/tests/translations_test.py:52 #: squirrelbattle/tests/translations_test.py:54
msgid "hedgehog" msgid "hedgehog"
msgstr "Igel" msgstr "Igel"
#: squirrelbattle/tests/translations_test.py:53 #: squirrelbattle/tests/translations_test.py:55
msgid "rabbit" msgid "rabbit"
msgstr "Kanninchen" msgstr "Kanninchen"
#: squirrelbattle/tests/translations_test.py:54 #: squirrelbattle/tests/translations_test.py:56
msgid "teddy bear" msgid "teddy bear"
msgstr "Teddybär" msgstr "Teddybär"
#: squirrelbattle/tests/translations_test.py:56 #: squirrelbattle/tests/translations_test.py:58
msgid "bomb" msgid "bomb"
msgstr "Bombe" msgstr "Bombe"
#: squirrelbattle/tests/translations_test.py:57 #: squirrelbattle/tests/translations_test.py:59
msgid "heart" msgid "heart"
msgstr "Herz" msgstr "Herz"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: squirrelbattle 3.14.1\n" "Project-Id-Version: squirrelbattle 3.14.1\n"
"Report-Msgid-Bugs-To: squirrel-battle@crans.org\n" "Report-Msgid-Bugs-To: squirrel-battle@crans.org\n"
"POT-Creation-Date: 2020-11-28 16:03+0100\n" "POT-Creation-Date: 2020-12-04 14:18+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -38,6 +38,7 @@ msgstr ""
#: squirrelbattle/menus.py:45 squirrelbattle/tests/translations_test.py:14 #: squirrelbattle/menus.py:45 squirrelbattle/tests/translations_test.py:14
#: squirrelbattle/tests/game_test.py:284 squirrelbattle/tests/game_test.py:287 #: squirrelbattle/tests/game_test.py:284 squirrelbattle/tests/game_test.py:287
#: squirrelbattle/tests/translations_test.py:16 #: squirrelbattle/tests/translations_test.py:16
#: squirrelbattle/tests/game_test.py:290
msgid "New game" msgid "New game"
msgstr "" msgstr ""
@ -145,12 +146,14 @@ msgstr ""
#: squirrelbattle/settings.py:31 squirrelbattle/tests/translations_test.py:39 #: squirrelbattle/settings.py:31 squirrelbattle/tests/translations_test.py:39
#: squirrelbattle/tests/translations_test.py:43 #: squirrelbattle/tests/translations_test.py:43
#: squirrelbattle/tests/translations_test.py:45 #: squirrelbattle/tests/translations_test.py:45
#: squirrelbattle/tests/translations_test.py:47
msgid "Texture pack" msgid "Texture pack"
msgstr "" msgstr ""
#: squirrelbattle/settings.py:32 squirrelbattle/tests/translations_test.py:40 #: squirrelbattle/settings.py:32 squirrelbattle/tests/translations_test.py:40
#: squirrelbattle/tests/translations_test.py:44 #: squirrelbattle/tests/translations_test.py:44
#: squirrelbattle/tests/translations_test.py:46 #: squirrelbattle/tests/translations_test.py:46
#: squirrelbattle/tests/translations_test.py:48
msgid "Language" msgid "Language"
msgstr "" msgstr ""
@ -161,35 +164,46 @@ msgstr ""
#: squirrelbattle/tests/translations_test.py:47 #: squirrelbattle/tests/translations_test.py:47
#: squirrelbattle/tests/translations_test.py:49 #: squirrelbattle/tests/translations_test.py:49
#: squirrelbattle/tests/translations_test.py:51
msgid "player" msgid "player"
msgstr "" msgstr ""
#: squirrelbattle/tests/translations_test.py:49 #: squirrelbattle/tests/translations_test.py:49
#: squirrelbattle/tests/translations_test.py:51 #: squirrelbattle/tests/translations_test.py:51
#: squirrelbattle/tests/translations_test.py:53
msgid "tiger" msgid "tiger"
msgstr "" msgstr ""
#: squirrelbattle/tests/translations_test.py:50 #: squirrelbattle/tests/translations_test.py:50
#: squirrelbattle/tests/translations_test.py:52 #: squirrelbattle/tests/translations_test.py:52
#: squirrelbattle/tests/translations_test.py:54
msgid "hedgehog" msgid "hedgehog"
msgstr "" msgstr ""
#: squirrelbattle/tests/translations_test.py:51 #: squirrelbattle/tests/translations_test.py:51
#: squirrelbattle/tests/translations_test.py:53 #: squirrelbattle/tests/translations_test.py:53
#: squirrelbattle/tests/translations_test.py:55
msgid "rabbit" msgid "rabbit"
msgstr "" msgstr ""
#: squirrelbattle/tests/translations_test.py:52 #: squirrelbattle/tests/translations_test.py:52
#: squirrelbattle/tests/translations_test.py:54 #: squirrelbattle/tests/translations_test.py:54
#: squirrelbattle/tests/translations_test.py:56
msgid "teddy bear" msgid "teddy bear"
msgstr "" msgstr ""
#: squirrelbattle/tests/translations_test.py:54 #: squirrelbattle/tests/translations_test.py:54
#: squirrelbattle/tests/translations_test.py:56 #: squirrelbattle/tests/translations_test.py:56
#: squirrelbattle/tests/translations_test.py:58
msgid "bomb" msgid "bomb"
msgstr "" msgstr ""
#: squirrelbattle/tests/translations_test.py:55 #: squirrelbattle/tests/translations_test.py:55
#: squirrelbattle/tests/translations_test.py:57 #: squirrelbattle/tests/translations_test.py:57
#: squirrelbattle/tests/translations_test.py:59
msgid "heart" msgid "heart"
msgstr "" msgstr ""
#: squirrelbattle/tests/translations_test.py:45
msgid "Key used to open the inventory"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: squirrelbattle 3.14.1\n" "Project-Id-Version: squirrelbattle 3.14.1\n"
"Report-Msgid-Bugs-To: squirrel-battle@crans.org\n" "Report-Msgid-Bugs-To: squirrel-battle@crans.org\n"
"POT-Creation-Date: 2020-11-28 16:03+0100\n" "POT-Creation-Date: 2020-12-04 14:18+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -25,43 +25,43 @@ msgstr "Inventaire :"
msgid "YOU ARE DEAD" msgid "YOU ARE DEAD"
msgstr "VOUS ÊTES MORT" msgstr "VOUS ÊTES MORT"
#: squirrelbattle/interfaces.py:394 squirrelbattle/interfaces.py:398 #: squirrelbattle/interfaces.py:398
#, python-brace-format #, python-brace-format
msgid "{name} hits {opponent}." msgid "{name} hits {opponent}."
msgstr "{name} frappe {opponent}." msgstr "{name} frappe {opponent}."
#: squirrelbattle/interfaces.py:405 squirrelbattle/interfaces.py:410 #: squirrelbattle/interfaces.py:410
#, python-brace-format #, python-brace-format
msgid "{name} takes {amount} damage." msgid "{name} takes {amount} damage."
msgstr "{name} prend {amount} points de dégât." msgstr "{name} prend {amount} points de dégât."
#: squirrelbattle/menus.py:45 squirrelbattle/tests/translations_test.py:14 #: squirrelbattle/menus.py:45
#: squirrelbattle/tests/game_test.py:284 squirrelbattle/tests/game_test.py:287
#: squirrelbattle/tests/translations_test.py:16 #: squirrelbattle/tests/translations_test.py:16
#: squirrelbattle/tests/game_test.py:290
msgid "New game" msgid "New game"
msgstr "Nouvelle partie" msgstr "Nouvelle partie"
#: squirrelbattle/menus.py:46 squirrelbattle/tests/translations_test.py:15 #: squirrelbattle/menus.py:46
#: squirrelbattle/tests/translations_test.py:17 #: squirrelbattle/tests/translations_test.py:17
msgid "Resume" msgid "Resume"
msgstr "Continuer" msgstr "Continuer"
#: squirrelbattle/menus.py:47 squirrelbattle/tests/translations_test.py:17 #: squirrelbattle/menus.py:47
#: squirrelbattle/tests/translations_test.py:19 #: squirrelbattle/tests/translations_test.py:19
msgid "Save" msgid "Save"
msgstr "Sauvegarder" msgstr "Sauvegarder"
#: squirrelbattle/menus.py:48 squirrelbattle/tests/translations_test.py:16 #: squirrelbattle/menus.py:48
#: squirrelbattle/tests/translations_test.py:18 #: squirrelbattle/tests/translations_test.py:18
msgid "Load" msgid "Load"
msgstr "Charger" msgstr "Charger"
#: squirrelbattle/menus.py:49 squirrelbattle/tests/translations_test.py:18 #: squirrelbattle/menus.py:49
#: squirrelbattle/tests/translations_test.py:20 #: squirrelbattle/tests/translations_test.py:20
msgid "Settings" msgid "Settings"
msgstr "Paramètres" msgstr "Paramètres"
#: squirrelbattle/menus.py:50 squirrelbattle/tests/translations_test.py:19 #: squirrelbattle/menus.py:50
#: squirrelbattle/tests/translations_test.py:21 #: squirrelbattle/tests/translations_test.py:21
msgid "Exit" msgid "Exit"
msgstr "Quitter" msgstr "Quitter"
@ -78,7 +78,7 @@ msgstr ""
"Certaines clés de votre ficher de sauvegarde sont manquantes.\n" "Certaines clés de votre ficher de sauvegarde sont manquantes.\n"
"Votre sauvegarde semble corrompue. Elle a été supprimée." "Votre sauvegarde semble corrompue. Elle a été supprimée."
#: squirrelbattle/game.py:155 squirrelbattle/game.py:156 #: squirrelbattle/game.py:156
msgid "" msgid ""
"No player was found on this map!\n" "No player was found on this map!\n"
"Maybe you died?" "Maybe you died?"
@ -86,7 +86,7 @@ msgstr ""
"Aucun joueur n'a été trouvé sur la carte !\n" "Aucun joueur n'a été trouvé sur la carte !\n"
"Peut-être êtes-vous mort ?" "Peut-être êtes-vous mort ?"
#: squirrelbattle/game.py:175 squirrelbattle/game.py:176 #: squirrelbattle/game.py:176
msgid "" msgid ""
"The JSON file is not correct.\n" "The JSON file is not correct.\n"
"Your save seems corrupted. It got deleted." "Your save seems corrupted. It got deleted."
@ -94,108 +94,94 @@ msgstr ""
"Le fichier JSON de sauvegarde est incorrect.\n" "Le fichier JSON de sauvegarde est incorrect.\n"
"Votre sauvegarde semble corrompue. Elle a été supprimée." "Votre sauvegarde semble corrompue. Elle a été supprimée."
#: squirrelbattle/settings.py:21 squirrelbattle/tests/translations_test.py:21 #: squirrelbattle/settings.py:21
#: squirrelbattle/tests/translations_test.py:25
#: squirrelbattle/tests/translations_test.py:27 #: squirrelbattle/tests/translations_test.py:27
msgid "Main key to move up" msgid "Main key to move up"
msgstr "Touche principale pour aller vers le haut" msgstr "Touche principale pour aller vers le haut"
#: squirrelbattle/settings.py:22 squirrelbattle/tests/translations_test.py:23 #: squirrelbattle/settings.py:22
#: squirrelbattle/tests/translations_test.py:27
#: squirrelbattle/tests/translations_test.py:29 #: squirrelbattle/tests/translations_test.py:29
msgid "Secondary key to move up" msgid "Secondary key to move up"
msgstr "Touche secondaire pour aller vers le haut" msgstr "Touche secondaire pour aller vers le haut"
#: squirrelbattle/settings.py:23 squirrelbattle/tests/translations_test.py:25 #: squirrelbattle/settings.py:23
#: squirrelbattle/tests/translations_test.py:29
#: squirrelbattle/tests/translations_test.py:31 #: squirrelbattle/tests/translations_test.py:31
msgid "Main key to move down" msgid "Main key to move down"
msgstr "Touche principale pour aller vers le bas" msgstr "Touche principale pour aller vers le bas"
#: squirrelbattle/settings.py:24 squirrelbattle/tests/translations_test.py:27 #: squirrelbattle/settings.py:24
#: squirrelbattle/tests/translations_test.py:31
#: squirrelbattle/tests/translations_test.py:33 #: squirrelbattle/tests/translations_test.py:33
msgid "Secondary key to move down" msgid "Secondary key to move down"
msgstr "Touche secondaire pour aller vers le bas" msgstr "Touche secondaire pour aller vers le bas"
#: squirrelbattle/settings.py:25 squirrelbattle/tests/translations_test.py:29 #: squirrelbattle/settings.py:25
#: squirrelbattle/tests/translations_test.py:33
#: squirrelbattle/tests/translations_test.py:35 #: squirrelbattle/tests/translations_test.py:35
msgid "Main key to move left" msgid "Main key to move left"
msgstr "Touche principale pour aller vers la gauche" msgstr "Touche principale pour aller vers la gauche"
#: squirrelbattle/settings.py:26 squirrelbattle/tests/translations_test.py:31 #: squirrelbattle/settings.py:26
#: squirrelbattle/tests/translations_test.py:35
#: squirrelbattle/tests/translations_test.py:37 #: squirrelbattle/tests/translations_test.py:37
msgid "Secondary key to move left" msgid "Secondary key to move left"
msgstr "Touche secondaire pour aller vers la gauche" msgstr "Touche secondaire pour aller vers la gauche"
#: squirrelbattle/settings.py:27 squirrelbattle/tests/translations_test.py:33 #: squirrelbattle/settings.py:27
#: squirrelbattle/tests/translations_test.py:37
#: squirrelbattle/tests/translations_test.py:39 #: squirrelbattle/tests/translations_test.py:39
msgid "Main key to move right" msgid "Main key to move right"
msgstr "Touche principale pour aller vers la droite" msgstr "Touche principale pour aller vers la droite"
#: squirrelbattle/settings.py:29 squirrelbattle/tests/translations_test.py:35 #: squirrelbattle/settings.py:29
#: squirrelbattle/tests/translations_test.py:39
#: squirrelbattle/tests/translations_test.py:41 #: squirrelbattle/tests/translations_test.py:41
msgid "Secondary key to move right" msgid "Secondary key to move right"
msgstr "Touche secondaire pour aller vers la droite" msgstr "Touche secondaire pour aller vers la droite"
#: squirrelbattle/settings.py:30 squirrelbattle/tests/translations_test.py:37 #: squirrelbattle/settings.py:30
#: squirrelbattle/tests/translations_test.py:41
#: squirrelbattle/tests/translations_test.py:43 #: squirrelbattle/tests/translations_test.py:43
msgid "Key to validate a menu" msgid "Key to validate a menu"
msgstr "Touche pour valider un menu" msgstr "Touche pour valider un menu"
#: squirrelbattle/settings.py:31 squirrelbattle/tests/translations_test.py:39
#: squirrelbattle/tests/translations_test.py:43
#: squirrelbattle/tests/translations_test.py:45 #: squirrelbattle/tests/translations_test.py:45
msgid "Key used to open the inventory"
msgstr "Touche utilisée pour ouvrir l'inventaire"
#: squirrelbattle/settings.py:31
#: squirrelbattle/tests/translations_test.py:47
msgid "Texture pack" msgid "Texture pack"
msgstr "Pack de textures" msgstr "Pack de textures"
#: squirrelbattle/settings.py:32 squirrelbattle/tests/translations_test.py:40 #: squirrelbattle/settings.py:32
#: squirrelbattle/tests/translations_test.py:44 #: squirrelbattle/tests/translations_test.py:48
#: squirrelbattle/tests/translations_test.py:46
msgid "Language" msgid "Language"
msgstr "Langue" msgstr "Langue"
#: squirrelbattle/interfaces.py:407 squirrelbattle/interfaces.py:412 #: squirrelbattle/interfaces.py:412
#, python-brace-format #, python-brace-format
msgid "{name} dies." msgid "{name} dies."
msgstr "{name} meurt." msgstr "{name} meurt."
#: squirrelbattle/tests/translations_test.py:47 #: squirrelbattle/tests/translations_test.py:51
#: squirrelbattle/tests/translations_test.py:49
msgid "player" msgid "player"
msgstr "joueur" msgstr "joueur"
#: squirrelbattle/tests/translations_test.py:49 #: squirrelbattle/tests/translations_test.py:53
#: squirrelbattle/tests/translations_test.py:51
msgid "tiger" msgid "tiger"
msgstr "tigre" msgstr "tigre"
#: squirrelbattle/tests/translations_test.py:50 #: squirrelbattle/tests/translations_test.py:54
#: squirrelbattle/tests/translations_test.py:52
msgid "hedgehog" msgid "hedgehog"
msgstr "hérisson" msgstr "hérisson"
#: squirrelbattle/tests/translations_test.py:51 #: squirrelbattle/tests/translations_test.py:55
#: squirrelbattle/tests/translations_test.py:53
msgid "rabbit" msgid "rabbit"
msgstr "lapin" msgstr "lapin"
#: squirrelbattle/tests/translations_test.py:52 #: squirrelbattle/tests/translations_test.py:56
#: squirrelbattle/tests/translations_test.py:54
msgid "teddy bear" msgid "teddy bear"
msgstr "nounours" msgstr "nounours"
#: squirrelbattle/tests/translations_test.py:54 #: squirrelbattle/tests/translations_test.py:58
#: squirrelbattle/tests/translations_test.py:56
msgid "bomb" msgid "bomb"
msgstr "bombe" msgstr "bombe"
#: squirrelbattle/tests/translations_test.py:55 #: squirrelbattle/tests/translations_test.py:59
#: squirrelbattle/tests/translations_test.py:57
msgid "heart" msgid "heart"
msgstr "cœur" msgstr "cœur"

View File

@ -115,3 +115,8 @@ class SettingsMenu(Menu):
game.settings.write_settings() game.settings.write_settings()
self.waiting_for_key = False self.waiting_for_key = False
self.update_values(game.settings) self.update_values(game.settings)
class InventoryMenu(Menu):
# FIXME Use real menu
values = ["bomb"]

View File

@ -27,6 +27,7 @@ class Settings:
self.KEY_RIGHT_PRIMARY = ['d', 'Main key to move right'] self.KEY_RIGHT_PRIMARY = ['d', 'Main key to move right']
self.KEY_RIGHT_SECONDARY = ['KEY_RIGHT', 'Secondary key to move right'] self.KEY_RIGHT_SECONDARY = ['KEY_RIGHT', 'Secondary key to move right']
self.KEY_ENTER = ['\n', 'Key to validate a menu'] self.KEY_ENTER = ['\n', 'Key to validate a menu']
self.KEY_INVENTORY = ['i', 'Key used to open the inventory']
self.TEXTURE_PACK = ['ascii', 'Texture pack'] self.TEXTURE_PACK = ['ascii', 'Texture pack']
self.LOCALE = [locale.getlocale()[0][:2], 'Language'] self.LOCALE = [locale.getlocale()[0][:2], 'Language']

View File

@ -266,6 +266,7 @@ class TestGame(unittest.TestCase):
self.game.handle_key_pressed(KeyValues.DOWN) self.game.handle_key_pressed(KeyValues.DOWN)
self.game.handle_key_pressed(KeyValues.DOWN) self.game.handle_key_pressed(KeyValues.DOWN)
self.game.handle_key_pressed(KeyValues.DOWN) self.game.handle_key_pressed(KeyValues.DOWN)
self.game.handle_key_pressed(KeyValues.DOWN)
# Change texture pack # Change texture pack
self.assertEqual(self.game.settings.TEXTURE_PACK, "ascii") self.assertEqual(self.game.settings.TEXTURE_PACK, "ascii")

View File

@ -4,9 +4,13 @@
import unittest import unittest
from squirrelbattle.settings import Settings from squirrelbattle.settings import Settings
from squirrelbattle.translations import Translator
class TestSettings(unittest.TestCase): class TestSettings(unittest.TestCase):
def setUp(self) -> None:
Translator.setlocale("en")
def test_settings(self) -> None: def test_settings(self) -> None:
""" """
Ensure that settings are well loaded. Ensure that settings are well loaded.

View File

@ -42,6 +42,8 @@ class TestTranslations(unittest.TestCase):
"Touche secondaire pour aller vers la droite") "Touche secondaire pour aller vers la droite")
self.assertEqual(_("Key to validate a menu"), self.assertEqual(_("Key to validate a menu"),
"Touche pour valider un menu") "Touche pour valider un menu")
self.assertEqual(_("Key used to open the inventory"),
"Touche utilisée pour ouvrir l'inventaire")
self.assertEqual(_("Texture pack"), "Pack de textures") self.assertEqual(_("Texture pack"), "Pack de textures")
self.assertEqual(_("Language"), "Langue") self.assertEqual(_("Language"), "Langue")