From 744b9d6689b67779a1d17c6d3de7cd016ca1033b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 20 Jul 2014 20:58:31 +0300 Subject: move "change move" option into gamemodifiers. --- src/gamemodifiers.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 6 deletions(-) (limited to 'src/gamemodifiers.cpp') diff --git a/src/gamemodifiers.cpp b/src/gamemodifiers.cpp index 3aa5b3b0f..aea2fa6d6 100644 --- a/src/gamemodifiers.cpp +++ b/src/gamemodifiers.cpp @@ -21,11 +21,16 @@ #include "gamemodifiers.h" #include "configuration.h" +#include "settings.h" + +#include "being/localplayer.h" #include "gui/widgets/tabs/chattab.h" #include "listeners/updatestatuslistener.h" +#include "utils/gettext.h" + #include "debug.h" GameModifiers *modifiers = nullptr; @@ -39,12 +44,12 @@ GameModifiers::~GameModifiers() } void GameModifiers::changeMode(unsigned *restrict const var, - const unsigned limit, - const char *restrict const conf, - std::string (GameModifiers::*const func)(), - const unsigned def, - const bool save, - const bool forward) + const unsigned limit, + const char *restrict const conf, + std::string (GameModifiers::*const func)(), + const unsigned def, + const bool save, + const bool forward) { if (!var) return; @@ -70,3 +75,43 @@ void GameModifiers::changeMode(unsigned *restrict const var, if (str.size() > 4) debugMsg(str.substr(4)); } + +const char *GameModifiers::getVarItem(const char *const *const arr, + const unsigned index, + const unsigned sz) +{ + if (index < sz) + return arr[index]; + return arr[sz]; +} + +static const unsigned moveTypeSize = 5; + +void GameModifiers::changeMoveType(const bool forward) +{ + player_node->setMoveState(0); + changeMode(&settings.moveType, moveTypeSize, "invertMoveDirection", + &GameModifiers::getMoveTypeString, 0, false, forward); +} + +static const char *const moveTypeStrings[] = +{ + // TRANSLATORS: move type in status bar + N_("(D) default moves"), + // TRANSLATORS: move type in status bar + N_("(I) invert moves"), + // TRANSLATORS: move type in status bar + N_("(c) moves with some crazy moves"), + // TRANSLATORS: move type in status bar + N_("(C) moves with crazy moves"), + // TRANSLATORS: move type in status bar + N_("(d) double normal + crazy"), + // TRANSLATORS: move type in status bar + N_("(?) unknown move") +}; + +std::string GameModifiers::getMoveTypeString() +{ + return gettext(getVarItem(&moveTypeStrings[0], + settings.moveType, moveTypeSize)); +} -- cgit v1.2.3-60-g2f50