diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-12-06 01:30:04 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-12-06 01:30:04 +0300 |
commit | 7a2d595785a61ec874ddc566e0d999495684c2aa (patch) | |
tree | c0b6d8b0137e002eb4847d8ead44562264ad1e18 /src/gui/chatwindow.cpp | |
parent | 2d452dd8faf2529fda01913b0ab26f4a1f22ef3d (diff) | |
download | ManaVerse-7a2d595785a61ec874ddc566e0d999495684c2aa.tar.gz ManaVerse-7a2d595785a61ec874ddc566e0d999495684c2aa.tar.bz2 ManaVerse-7a2d595785a61ec874ddc566e0d999495684c2aa.tar.xz ManaVerse-7a2d595785a61ec874ddc566e0d999495684c2aa.zip |
Add gm commands to chat autocomplete list (only for gms)
Diffstat (limited to 'src/gui/chatwindow.cpp')
-rw-r--r-- | src/gui/chatwindow.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 9ba54016e..33c24e9c7 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -60,6 +60,8 @@ #include "utils/gettext.h" #include "utils/stringutils.h" +#include "resources/resourcemanager.h" + #include <guichan/focushandler.hpp> #include <guichan/focuslistener.hpp> @@ -152,7 +154,8 @@ public: ChatWindow::ChatWindow(): Window(_("Chat"), false, nullptr, "chat.xml"), mTmpVisible(false), - mChatHistoryIndex(0) + mChatHistoryIndex(0), + mGMLoaded(false) { listen(CHANNEL_NOTICES); listen(Mana::CHANNEL_ATTRIBUTES); @@ -212,6 +215,8 @@ ChatWindow::ChatWindow(): mColorPicker->setVisible(config.getBoolValue("showChatColorsList")); fillCommands(); + if (player_node && player_node->isGM()) + loadGMCommands(); initTradeFilter(); loadCustomList(); parseHighlights(); @@ -302,6 +307,29 @@ void ChatWindow::fillCommands() mCommands.push_back("/pseudoaway "); } +void ChatWindow::loadGMCommands() +{ + if (mGMLoaded) + return; + + const char *fileName = "gmcommands.txt"; + ResourceManager *resman = ResourceManager::getInstance(); + std::vector<std::string> list; + resman->loadTextFile(fileName, list); + std::vector<std::string>::const_iterator it = list.begin(); + std::vector<std::string>::const_iterator it_end = list.end(); + + while (it != it_end) + { + const std::string str = *it; + if (!str.empty()) + mCommands.push_back(str); + + ++ it; + } + mGMLoaded = true; +} + void ChatWindow::resetToDefaultSize() { Window::resetToDefaultSize(); |