diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-07-23 00:39:12 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-07-23 00:39:12 +0300 |
commit | 6336dabcb33ca6b4d417b352fa0b12651b6f4c57 (patch) | |
tree | a84879f46ee80d2f98d0418cbcbbb81e28da8e76 /src/gamemodifiers.cpp | |
parent | 1995e723df5d5aef32b289c0122493ee6fe18b0e (diff) | |
download | plus-6336dabcb33ca6b4d417b352fa0b12651b6f4c57.tar.gz plus-6336dabcb33ca6b4d417b352fa0b12651b6f4c57.tar.bz2 plus-6336dabcb33ca6b4d417b352fa0b12651b6f4c57.tar.xz plus-6336dabcb33ca6b4d417b352fa0b12651b6f4c57.zip |
move "change away type" option into gamemodifiers.
Diffstat (limited to 'src/gamemodifiers.cpp')
-rw-r--r-- | src/gamemodifiers.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/gamemodifiers.cpp b/src/gamemodifiers.cpp index 7c94b5c4c..cd3f1d352 100644 --- a/src/gamemodifiers.cpp +++ b/src/gamemodifiers.cpp @@ -22,13 +22,20 @@ #include "configuration.h" #include "settings.h" +#include "soundmanager.h" #include "being/localplayer.h" +#include "gui/dialogtype.h" #include "gui/viewport.h" +#include "gui/windows/chatwindow.h" +#include "gui/windows/okdialog.h" +#include "gui/windows/outfitwindow.h" + #include "gui/widgets/tabs/chattab.h" +#include "listeners/awaylistener.h" #include "listeners/updatestatuslistener.h" #include "utils/gettext.h" @@ -492,3 +499,62 @@ std::string GameModifiers::getMapDrawTypeString() return gettext(getVarItem(&mapDrawTypeStrings[0], settings.mapDrawType, mapDrawTypeSize)); } + +const unsigned awayModeSize = 2; + +void GameModifiers::changeAwayMode() +{ + if (!player_node) + return; + + settings.awayMode = !settings.awayMode; + player_node->setAfkTime(0); + player_node->setHalfAway(false); + player_node->updateName(); + UpdateStatusListener::distributeEvent(); + if (settings.awayMode) + { + if (chatWindow) + chatWindow->clearAwayLog(); + + player_node->cancelFollow(); + player_node->navigateClean(); + if (outfitWindow) + outfitWindow->wearAwayOutfit(); + // TRANSLATORS: away message box header + OkDialog *const dialog = new OkDialog(_("Away"), + config.getStringValue("afkMessage"), + DialogType::SILENCE, true, false); + player_node->setAwayDialog(dialog); + dialog->addActionListener(player_node->getAwayListener()); + soundManager.volumeOff(); + player_node->addAfkEffect(); + } + else + { + player_node->setAwayDialog(nullptr); + soundManager.volumeRestore(); + if (chatWindow) + { + chatWindow->displayAwayLog(); + chatWindow->clearAwayLog(); + } + player_node->removeAfkEffect(); + } +} + +static const char *const awayModeStrings[] = +{ + // TRANSLATORS: away type in status bar + N_("(O) on keyboard"), + // TRANSLATORS: away type in status bar + N_("(A) away"), + // TRANSLATORS: away type in status bar + N_("(?) away") +}; + +std::string GameModifiers::getAwayModeString() +{ + return gettext(getVarItem(&awayModeStrings[0], + settings.awayMode, awayModeSize)); +} |