Add title to boxes to have pretty boxes, fixes #28

This commit is contained in:
Yohann D'ANELLO 2020-12-12 17:15:08 +01:00
parent 158338637a
commit 73e1fac89a
5 changed files with 116 additions and 84 deletions

View File

@ -222,6 +222,10 @@ class HorizontalSplit(Display):
class Box(Display): class Box(Display):
title: str = ""
def update_title(self, title: str) -> None:
self.title = title
def __init__(self, *args, fg_border_color: Optional[int] = None, **kwargs): def __init__(self, *args, fg_border_color: Optional[int] = None, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
@ -236,5 +240,11 @@ class Box(Display):
self.addstr(self.pad, i, self.width - 1, "", self.fg_border_color) self.addstr(self.pad, i, self.width - 1, "", self.fg_border_color)
self.addstr(self.pad, self.height - 1, 0, self.addstr(self.pad, self.height - 1, 0,
"" + "" * (self.width - 2) + "", self.fg_border_color) "" + "" * (self.width - 2) + "", self.fg_border_color)
if self.title:
self.addstr(self.pad, 0, (self.width - len(self.title) - 8) // 2,
f" == {self.title} == ", curses.COLOR_GREEN,
italic=True, bold=True)
self.refresh_pad(self.pad, 0, 0, self.y, self.x, self.refresh_pad(self.pad, 0, 0, self.y, self.x,
self.y + self.height - 1, self.x + self.width - 1) self.y + self.height - 1, self.x + self.width - 1)

View File

@ -6,7 +6,7 @@ from random import randint
from typing import List from typing import List
from squirrelbattle.menus import Menu, MainMenu from squirrelbattle.menus import Menu, MainMenu
from .display import Display, Box from .display import Box, Display
from ..enums import KeyValues from ..enums import KeyValues
from ..game import Game from ..game import Game
from ..resources import ResourceManager from ..resources import ResourceManager
@ -135,15 +135,12 @@ class MainMenuDisplay(Display):
class PlayerInventoryDisplay(MenuDisplay): class PlayerInventoryDisplay(MenuDisplay):
message = _("== INVENTORY ==")
def update_pad(self) -> None: def update_pad(self) -> None:
self.addstr(self.pad, 0, (self.width - len(self.message)) // 2, self.menubox.update_title(_("INVENTORY"))
self.message, bold=True, italic=True)
for i, item in enumerate(self.menu.values): for i, item in enumerate(self.menu.values):
rep = self.pack[item.name.upper()] rep = self.pack[item.name.upper()]
selection = f"[{rep}]" if i == self.menu.position else f" {rep} " selection = f"[{rep}]" if i == self.menu.position else f" {rep} "
self.addstr(self.pad, 2 + i, 0, selection self.addstr(self.pad, i + 1, 0, selection
+ " " + item.translated_name.capitalize()) + " " + item.translated_name.capitalize())
@property @property
@ -163,15 +160,12 @@ class PlayerInventoryDisplay(MenuDisplay):
class StoreInventoryDisplay(MenuDisplay): class StoreInventoryDisplay(MenuDisplay):
message = _("== STALL ==")
def update_pad(self) -> None: def update_pad(self) -> None:
self.addstr(self.pad, 0, (self.width - len(self.message)) // 2, self.menubox.update_title(_("STALL"))
self.message, bold=True, italic=True)
for i, item in enumerate(self.menu.values): for i, item in enumerate(self.menu.values):
rep = self.pack[item.name.upper()] rep = self.pack[item.name.upper()]
selection = f"[{rep}]" if i == self.menu.position else f" {rep} " selection = f"[{rep}]" if i == self.menu.position else f" {rep} "
self.addstr(self.pad, 2 + i, 0, selection self.addstr(self.pad, i + 1, 0, selection
+ " " + item.translated_name.capitalize() + " " + item.translated_name.capitalize()
+ ": " + str(item.price) + " Hazels") + ": " + str(item.price) + " Hazels")

View File

@ -1,12 +1,14 @@
# German translation of Squirrel Battle # SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ÿnérant, eichhornchen, nicomarg, charlse # Copyright (C) YEAR ÿnérant, eichhornchen, nicomarg, charlse, ifugao
# This file is distributed under the same license as the squirrelbattle package. # This file is distributed under the same license as the squirrelbattle package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# #
#, fuzzy
msgid "" 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-12-11 18:06+0100\n" "POT-Creation-Date: 2020-12-12 17:07+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"
@ -15,19 +17,19 @@ 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/display/menudisplay.py:113 #: squirrelbattle/display/menudisplay.py:139
msgid "== INVENTORY ==" msgid "INVENTORY"
msgstr "== BESTAND ==" msgstr "BESTAND"
#: squirrelbattle/display/menudisplay.py:134 #: squirrelbattle/display/menudisplay.py:164
msgid "== STALL ==" msgid "STALL"
msgstr "== STAND ==" msgstr "STAND"
#: squirrelbattle/display/statsdisplay.py:34 #: squirrelbattle/display/statsdisplay.py:33
msgid "Inventory:" msgid "Inventory:"
msgstr "Bestand:" msgstr "Bestand:"
#: squirrelbattle/display/statsdisplay.py:53 #: squirrelbattle/display/statsdisplay.py:52
msgid "YOU ARE DEAD" msgid "YOU ARE DEAD"
msgstr "SIE WURDEN GESTORBEN" msgstr "SIE WURDEN GESTORBEN"
@ -51,16 +53,16 @@ msgstr "Die Sonne ist warm heute"
msgid "Bomb is exploding." msgid "Bomb is exploding."
msgstr "Die Bombe explodiert." msgstr "Die Bombe explodiert."
#: squirrelbattle/entities/items.py:224 #: squirrelbattle/entities/items.py:248
#, python-brace-format #, python-brace-format
msgid "{player} exchanged its body with {entity}." msgid "{player} exchanged its body with {entity}."
msgstr "{player} täuscht seinem Körper mit {entity} aus." msgstr "{player} täuscht seinem Körper mit {entity} aus."
#: squirrelbattle/game.py:199 squirrelbattle/tests/game_test.py:537 #: squirrelbattle/game.py:203 squirrelbattle/tests/game_test.py:573
msgid "You do not have enough money" msgid "You do not have enough money"
msgstr "" msgstr "Sie haben nicht genug Geld"
#: squirrelbattle/game.py:243 #: squirrelbattle/game.py:247
msgid "" msgid ""
"Some keys are missing in your save file.\n" "Some keys are missing in your save file.\n"
"Your save seems to be corrupt. It got deleted." "Your save seems to be corrupt. It got deleted."
@ -68,7 +70,7 @@ msgstr ""
"In Ihrer Speicherdatei fehlen einige Schlüssel.\n" "In Ihrer Speicherdatei fehlen einige Schlüssel.\n"
"Ihre Speicherung scheint korrupt zu sein. Es wird gelöscht." "Ihre Speicherung scheint korrupt zu sein. Es wird gelöscht."
#: squirrelbattle/game.py:251 #: squirrelbattle/game.py:255
msgid "" msgid ""
"No player was found on this map!\n" "No player was found on this map!\n"
"Maybe you died?" "Maybe you died?"
@ -76,7 +78,7 @@ msgstr ""
"Auf dieser Karte wurde kein Spieler gefunden!\n" "Auf dieser Karte wurde kein Spieler gefunden!\n"
"Vielleicht sind Sie gestorben?" "Vielleicht sind Sie gestorben?"
#: squirrelbattle/game.py:271 #: squirrelbattle/game.py:275
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."
@ -103,8 +105,8 @@ msgstr "{name} stirbt."
msgid "Back" msgid "Back"
msgstr "Zurück" msgstr "Zurück"
#: squirrelbattle/tests/game_test.py:314 squirrelbattle/tests/game_test.py:317 #: squirrelbattle/tests/game_test.py:344 squirrelbattle/tests/game_test.py:347
#: squirrelbattle/tests/game_test.py:320 #: squirrelbattle/tests/game_test.py:350 squirrelbattle/tests/game_test.py:353
#: squirrelbattle/tests/translations_test.py:16 #: squirrelbattle/tests/translations_test.py:16
msgid "New game" msgid "New game"
msgstr "Neu Spiel" msgstr "Neu Spiel"

View File

@ -1,49 +1,67 @@
# Spanish translation of Squirrel Battle # SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ÿnérant, eichhornchen, nicomarg, charlse # Copyright (C) YEAR ÿnérant, eichhornchen, nicomarg, charlse, ifugao
# This file is distributed under the same license as the squirrelbattle package. # This file is distributed under the same license as the squirrelbattle package.
# Translation by ifugaao # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# #
#, fuzzy
msgid "" 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-12-05 14:46+0100\n" "POT-Creation-Date: 2020-12-12 17:07+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: ifugao\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n" "Language: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"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"
# Suggested in Weblate: == INVENTORIO == #: squirrelbattle/display/menudisplay.py:139
#: squirrelbattle/display/menudisplay.py:105 msgid "INVENTORY"
msgid "== INVENTORY ==" msgstr "INVENTORIO"
msgstr "== INVENTORIO =="
# Suggested in Weblate: Inventorio : #: squirrelbattle/display/menudisplay.py:164
#: squirrelbattle/display/statsdisplay.py:34 msgid "STALL"
msgstr "PUESTO"
#: squirrelbattle/display/statsdisplay.py:33
msgid "Inventory:" msgid "Inventory:"
msgstr "Inventorio :" msgstr "Inventorio :"
# Suggested in Weblate: ERES MUERTO #: squirrelbattle/display/statsdisplay.py:52
#: squirrelbattle/display/statsdisplay.py:50
msgid "YOU ARE DEAD" msgid "YOU ARE DEAD"
msgstr "ERES MUERTO" msgstr "ERES MUERTO"
#: squirrelbattle/entities/friendly.py:33
msgid "I don't sell any squirrel"
msgstr "No vendo ninguna ardilla"
#: squirrelbattle/entities/friendly.py:46
msgid "Flower power!!"
msgstr "Poder de las flores!!"
#: squirrelbattle/entities/friendly.py:46
msgid "The sun is warm today"
msgstr "El sol está caliente hoy"
#. The bomb is exploding. #. The bomb is exploding.
#. Each entity that is close to the bomb takes damages. #. Each entity that is close to the bomb takes damages.
#. The player earn XP if the entity was killed. #. The player earn XP if the entity was killed.
#: squirrelbattle/entities/items.py:128 #: squirrelbattle/entities/items.py:151
msgid "Bomb is exploding." msgid "Bomb is exploding."
msgstr "La bomba está explotando." msgstr "La bomba está explotando."
#: squirrelbattle/entities/items.py:172 #: squirrelbattle/entities/items.py:248
#, python-brace-format #, python-brace-format
msgid "{player} exchanged its body with {entity}." msgid "{player} exchanged its body with {entity}."
msgstr "{player} intercambió su cuerpo con {entity}." msgstr "{player} intercambió su cuerpo con {entity}."
#: squirrelbattle/game.py:177 #: squirrelbattle/game.py:203 squirrelbattle/tests/game_test.py:573
msgid "You do not have enough money"
msgstr "No tienes suficiente dinero"
#: squirrelbattle/game.py:247
msgid "" msgid ""
"Some keys are missing in your save file.\n" "Some keys are missing in your save file.\n"
"Your save seems to be corrupt. It got deleted." "Your save seems to be corrupt. It got deleted."
@ -51,7 +69,7 @@ msgstr ""
"Algunas claves faltan en su archivo de guarda.\n" "Algunas claves faltan en su archivo de guarda.\n"
"Su guarda parece a ser corruptido. Fue eliminado." "Su guarda parece a ser corruptido. Fue eliminado."
#: squirrelbattle/game.py:185 #: squirrelbattle/game.py:255
msgid "" msgid ""
"No player was found on this map!\n" "No player was found on this map!\n"
"Maybe you died?" "Maybe you died?"
@ -59,7 +77,7 @@ msgstr ""
"No jugador encontrado sobre la carta !\n" "No jugador encontrado sobre la carta !\n"
"¿ Quizas murió ?" "¿ Quizas murió ?"
#: squirrelbattle/game.py:205 #: squirrelbattle/game.py:275
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."
@ -67,28 +85,27 @@ msgstr ""
"El JSON archivo no es correcto.\n" "El JSON archivo no es correcto.\n"
"Su guarda parece corrupta. Fue eliminada." "Su guarda parece corrupta. Fue eliminada."
#: squirrelbattle/interfaces.py:400 #: squirrelbattle/interfaces.py:429
#, python-brace-format #, python-brace-format
msgid "{name} hits {opponent}." msgid "{name} hits {opponent}."
msgstr "{name} golpea a {opponent}." msgstr "{name} golpea a {opponent}."
#: squirrelbattle/interfaces.py:412 #: squirrelbattle/interfaces.py:441
#, python-brace-format #, python-brace-format
msgid "{name} takes {amount} damage." msgid "{name} takes {amount} damage."
msgstr "{name} recibe {amount} daño." msgstr "{name} recibe {amount} daño."
#: squirrelbattle/interfaces.py:414 #: squirrelbattle/interfaces.py:443
#, python-brace-format #, python-brace-format
msgid "{name} dies." msgid "{name} dies."
msgstr "{name} se muere." msgstr "{name} se muere."
#: squirrelbattle/menus.py:72 #: squirrelbattle/menus.py:73
msgid "Back" msgid "Back"
msgstr "Volver" msgstr "Volver"
#: squirrelbattle/tests/game_test.py:300, #: squirrelbattle/tests/game_test.py:344 squirrelbattle/tests/game_test.py:347
#: squirrelbattle/tests/game_test.py:303, #: squirrelbattle/tests/game_test.py:350 squirrelbattle/tests/game_test.py:353
#: squirrelbattle/tests/game_test.py:306,
#: squirrelbattle/tests/translations_test.py:16 #: squirrelbattle/tests/translations_test.py:16
msgid "New game" msgid "New game"
msgstr "Nuevo partido" msgstr "Nuevo partido"
@ -166,41 +183,49 @@ msgid "Key used to drop an item in the inventory"
msgstr "Tecla para dejar un objeto del inventorio" msgstr "Tecla para dejar un objeto del inventorio"
#: squirrelbattle/tests/translations_test.py:53 #: squirrelbattle/tests/translations_test.py:53
msgid "Key used to talk to a friendly entity"
msgstr "Tecla para hablar con una entidad amiga"
#: squirrelbattle/tests/translations_test.py:55
msgid "Texture pack" msgid "Texture pack"
msgstr "Paquete de texturas" msgstr "Paquete de texturas"
#: squirrelbattle/tests/translations_test.py:54 #: squirrelbattle/tests/translations_test.py:56
msgid "Language" msgid "Language"
msgstr "Languaje" msgstr "Languaje"
#: squirrelbattle/tests/translations_test.py:57 #: squirrelbattle/tests/translations_test.py:59
msgid "player" msgid "player"
msgstr "jugador" msgstr "jugador"
#: squirrelbattle/tests/translations_test.py:59 #: squirrelbattle/tests/translations_test.py:61
msgid "tiger" msgid "tiger"
msgstr "tigre" msgstr "tigre"
#: squirrelbattle/tests/translations_test.py:60 #: squirrelbattle/tests/translations_test.py:62
msgid "hedgehog" msgid "hedgehog"
msgstr "erizo" msgstr "erizo"
#: squirrelbattle/tests/translations_test.py:61 #: squirrelbattle/tests/translations_test.py:63
msgid "rabbit" msgid "rabbit"
msgstr "conejo" msgstr "conejo"
#: squirrelbattle/tests/translations_test.py:62 #: squirrelbattle/tests/translations_test.py:64
msgid "teddy bear" msgid "teddy bear"
msgstr "osito de peluche" msgstr "osito de peluche"
#: squirrelbattle/tests/translations_test.py:64 #: squirrelbattle/tests/translations_test.py:66
msgid "body snatch potion" msgid "body snatch potion"
msgstr "poción de intercambio" msgstr "poción de intercambio"
#: squirrelbattle/tests/translations_test.py:65 #: squirrelbattle/tests/translations_test.py:67
msgid "bomb" msgid "bomb"
msgstr "bomba" msgstr "bomba"
#: squirrelbattle/tests/translations_test.py:66 #: squirrelbattle/tests/translations_test.py:68
msgid "heart" msgid "heart"
msgstr "corazón" msgstr "corazón"
#: squirrelbattle/tests/translations_test.py:69
msgid "sword"
msgstr "espada"

View File

@ -1,34 +1,35 @@
# French translation of Squirrel Battle # SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ÿnérant, eichhornchen, nicomarg, charlse # Copyright (C) YEAR ÿnérant, eichhornchen, nicomarg, charlse, ifugao
# This file is distributed under the same license as the squirrelbattle package. # This file is distributed under the same license as the squirrelbattle package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# #
#, fuzzy #, fuzzy
msgid "" 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-12-11 18:06+0100\n" "POT-Creation-Date: 2020-12-12 17:07+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"
"Language: fr\n" "Language: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"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/display/menudisplay.py:113 #: squirrelbattle/display/menudisplay.py:139
msgid "== INVENTORY ==" msgid "INVENTORY"
msgstr "== INVENTAIRE ==" msgstr "INVENTAIRE"
#: squirrelbattle/display/menudisplay.py:134 #: squirrelbattle/display/menudisplay.py:164
msgid "== STALL ==" msgid "STALL"
msgstr "== STAND ==" msgstr "STAND"
#: squirrelbattle/display/statsdisplay.py:34 #: squirrelbattle/display/statsdisplay.py:33
msgid "Inventory:" msgid "Inventory:"
msgstr "Inventaire :" msgstr "Inventaire :"
#: squirrelbattle/display/statsdisplay.py:53 #: squirrelbattle/display/statsdisplay.py:52
msgid "YOU ARE DEAD" msgid "YOU ARE DEAD"
msgstr "VOUS ÊTES MORT" msgstr "VOUS ÊTES MORT"
@ -52,16 +53,16 @@ msgstr "Le soleil est chaud aujourd'hui"
msgid "Bomb is exploding." msgid "Bomb is exploding."
msgstr "La bombe explose." msgstr "La bombe explose."
#: squirrelbattle/entities/items.py:224 #: squirrelbattle/entities/items.py:248
#, python-brace-format #, python-brace-format
msgid "{player} exchanged its body with {entity}." msgid "{player} exchanged its body with {entity}."
msgstr "{player} a échangé son corps avec {entity}." msgstr "{player} a échangé son corps avec {entity}."
#: squirrelbattle/game.py:199 squirrelbattle/tests/game_test.py:537 #: squirrelbattle/game.py:203 squirrelbattle/tests/game_test.py:573
msgid "You do not have enough money" msgid "You do not have enough money"
msgstr "" msgstr "Vous n'avez pas assez d'argent"
#: squirrelbattle/game.py:243 #: squirrelbattle/game.py:247
msgid "" msgid ""
"Some keys are missing in your save file.\n" "Some keys are missing in your save file.\n"
"Your save seems to be corrupt. It got deleted." "Your save seems to be corrupt. It got deleted."
@ -69,7 +70,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:251 #: squirrelbattle/game.py:255
msgid "" msgid ""
"No player was found on this map!\n" "No player was found on this map!\n"
"Maybe you died?" "Maybe you died?"
@ -77,7 +78,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:271 #: squirrelbattle/game.py:275
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."
@ -104,8 +105,8 @@ msgstr "{name} meurt."
msgid "Back" msgid "Back"
msgstr "Retour" msgstr "Retour"
#: squirrelbattle/tests/game_test.py:314 squirrelbattle/tests/game_test.py:317 #: squirrelbattle/tests/game_test.py:344 squirrelbattle/tests/game_test.py:347
#: squirrelbattle/tests/game_test.py:320 #: squirrelbattle/tests/game_test.py:350 squirrelbattle/tests/game_test.py:353
#: squirrelbattle/tests/translations_test.py:16 #: squirrelbattle/tests/translations_test.py:16
msgid "New game" msgid "New game"
msgstr "Nouvelle partie" msgstr "Nouvelle partie"