From 5c7d962e605e123e1ce4e0610e8f330b1f4f5e82 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sat, 16 Dec 2017 20:42:33 +0000 Subject: Move text.cpp into game. --- src/common.hpp | 26 ------------- src/game/game.hpp | 26 +++++++++++++ src/game/text.cpp | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/text.cpp | 112 ------------------------------------------------------ 4 files changed, 138 insertions(+), 138 deletions(-) create mode 100644 src/game/text.cpp delete mode 100644 src/text.cpp (limited to 'src') diff --git a/src/common.hpp b/src/common.hpp index fd7327d..872a40d 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -345,32 +345,6 @@ namespace render { extern render::state_t *debug_render; -namespace text { - typedef enum { - LANG_ENGLISH, - LANG_POLISH - } language_t; - - extern language_t language; - - typedef enum { - SAY_NO_PATH, - SAY_BLOCKED, - SAY_READY, - SAY_MOVING, - UNIT_NAME_SPIDER, - UNIT_NAME_SOLDIER, - UNIT_DEATH, - UNIT_ATTACK, - UNIT_MISS, - UNIT_CRITICAL_MISS, - UNIT_CRITICAL_HIT, - UNIT_DAMAGE - } index_t; - - std::string get(index_t index); -} - // Divide and round to minus infinity. template T divide_rmi(T x, T y, T *rem) diff --git a/src/game/game.hpp b/src/game/game.hpp index 3fed3ec..b2bf0dd 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -55,6 +55,32 @@ namespace game { void load(void); } + namespace text { + typedef enum { + LANG_ENGLISH, + LANG_POLISH + } language_t; + + extern language_t language; + + typedef enum { + SAY_NO_PATH, + SAY_BLOCKED, + SAY_READY, + SAY_MOVING, + UNIT_NAME_SPIDER, + UNIT_NAME_SOLDIER, + UNIT_DEATH, + UNIT_ATTACK, + UNIT_MISS, + UNIT_CRITICAL_MISS, + UNIT_CRITICAL_HIT, + UNIT_DAMAGE + } index_t; + + std::string get(index_t index); + } + class entity_t : public world::entity_t { public: game::state_t *game = 0; diff --git a/src/game/text.cpp b/src/game/text.cpp new file mode 100644 index 0000000..3b611e2 --- /dev/null +++ b/src/game/text.cpp @@ -0,0 +1,112 @@ +#include "game.hpp" + +namespace game::text { + +language_t language = LANG_ENGLISH; + +static const char *soldier_names[] = { + "Kowalski", "Jackson", "Carter", "O'Neill", "Hammond", "Mitchell" +}; + +static std::string get_english(index_t index) +{ + switch (index) { + case SAY_BLOCKED: + return "Something is in my way."; + + case SAY_NO_PATH: + return "I can't get there."; + + case SAY_READY: + return "Ready for orders."; + + case SAY_MOVING: + return "On my way."; + + case UNIT_NAME_SPIDER: + return "Spider"; + + case UNIT_NAME_SOLDIER: + return soldier_names[rand() % count(soldier_names)]; + + case UNIT_DEATH: + return "died"; + + case UNIT_ATTACK: + return "attacks"; + + case UNIT_MISS: + return "miss"; + + case UNIT_CRITICAL_MISS: + return "critical miss"; + + case UNIT_CRITICAL_HIT: + return "critical hit"; + + case UNIT_DAMAGE: + return "deals damage"; + + default: + abort(); + } +} + +static std::string get_polish(index_t index) +{ + switch (index) { + case SAY_BLOCKED: + return "Coś jest na mojej drodze."; + + case SAY_NO_PATH: + return "Nie mogę się tam dostać."; + + case SAY_READY: + return "Gotowy na rozkaz."; + + case SAY_MOVING: + return "Jestem w drodze."; + + case UNIT_NAME_SPIDER: + return "Pająk"; + + case UNIT_NAME_SOLDIER: + return soldier_names[rand() % count(soldier_names)]; + + case UNIT_DEATH: + return "nie żyje"; + + case UNIT_ATTACK: + return "atakuje"; + + case UNIT_MISS: + return "chybienie"; + + case UNIT_CRITICAL_MISS: + return "chybienie krytyczne"; + + case UNIT_CRITICAL_HIT: + return "trafienie krytyczne"; + + case UNIT_DAMAGE: + return "zadaje obrażenia"; + + default: + abort(); + } +} +std::string get(index_t index) +{ + switch (language) { + case LANG_ENGLISH: + return get_english(index); + + case LANG_POLISH: + return get_polish(index); + + default: + abort(); + } +} + +} // namespace text diff --git a/src/text.cpp b/src/text.cpp deleted file mode 100644 index 3204776..0000000 --- a/src/text.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "common.hpp" - -namespace text { - -language_t language = LANG_ENGLISH; - -static const char *soldier_names[] = { - "Kowalski", "Jackson", "Carter", "O'Neill", "Hammond", "Mitchell" -}; - -static std::string get_english(index_t index) -{ - switch (index) { - case SAY_BLOCKED: - return "Something is in my way."; - - case SAY_NO_PATH: - return "I can't get there."; - - case SAY_READY: - return "Ready for orders."; - - case SAY_MOVING: - return "On my way."; - - case UNIT_NAME_SPIDER: - return "Spider"; - - case UNIT_NAME_SOLDIER: - return soldier_names[rand() % count(soldier_names)]; - - case UNIT_DEATH: - return "died"; - - case UNIT_ATTACK: - return "attacks"; - - case UNIT_MISS: - return "miss"; - - case UNIT_CRITICAL_MISS: - return "critical miss"; - - case UNIT_CRITICAL_HIT: - return "critical hit"; - - case UNIT_DAMAGE: - return "deals damage"; - - default: - abort(); - } -} - -static std::string get_polish(index_t index) -{ - switch (index) { - case SAY_BLOCKED: - return "Coś jest na mojej drodze."; - - case SAY_NO_PATH: - return "Nie mogę się tam dostać."; - - case SAY_READY: - return "Gotowy na rozkaz."; - - case SAY_MOVING: - return "Jestem w drodze."; - - case UNIT_NAME_SPIDER: - return "Pająk"; - - case UNIT_NAME_SOLDIER: - return soldier_names[rand() % count(soldier_names)]; - - case UNIT_DEATH: - return "nie żyje"; - - case UNIT_ATTACK: - return "atakuje"; - - case UNIT_MISS: - return "chybienie"; - - case UNIT_CRITICAL_MISS: - return "chybienie krytyczne"; - - case UNIT_CRITICAL_HIT: - return "trafienie krytyczne"; - - case UNIT_DAMAGE: - return "zadaje obrażenia"; - - default: - abort(); - } -} -std::string get(index_t index) -{ - switch (language) { - case LANG_ENGLISH: - return get_english(index); - - case LANG_POLISH: - return get_polish(index); - - default: - abort(); - } -} - -} // namespace text -- cgit