summaryrefslogtreecommitdiff
path: root/src/beingmanager.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-08-29 09:01:27 -0600
committerJared Adams <jaxad0127@gmail.com>2010-08-29 22:19:24 -0600
commitd55c1345449a34adb3192c23fe3760bd0aae645b (patch)
tree0dfe78eba2571b2f156c14deafe375d3f3241164 /src/beingmanager.cpp
parentb61faa43db7a48c6a6871fb94dce2de2abd79dfe (diff)
downloadmana-d55c1345449a34adb3192c23fe3760bd0aae645b.tar.gz
mana-d55c1345449a34adb3192c23fe3760bd0aae645b.tar.bz2
mana-d55c1345449a34adb3192c23fe3760bd0aae645b.tar.xz
mana-d55c1345449a34adb3192c23fe3760bd0aae645b.zip
Move handling of autocomplete and input history into TextField
Reviewed-by: Freeyorp
Diffstat (limited to 'src/beingmanager.cpp')
-rw-r--r--src/beingmanager.cpp61
1 files changed, 46 insertions, 15 deletions
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp
index 931e4579..d7045684 100644
--- a/src/beingmanager.cpp
+++ b/src/beingmanager.cpp
@@ -53,8 +53,48 @@ class FindBeingFunctor
Being::Type type;
} beingFinder;
+class PlayerNamesLister : public AutoCompleteLister
+{
+ void getAutoCompleteList(std::vector<std::string>& names) const
+ {
+ Beings::iterator i = beingManager->mBeings.begin();
+ names.clear();
+
+ while (i != beingManager->mBeings.end())
+ {
+ Being *being = (*i);
+ if (being->getType() == Being::PLAYER && being->getName() != "")
+ names.push_back(being->getName());
+
+ ++i;
+ }
+ }
+};
+
+class PlayerNPCNamesLister : public AutoCompleteLister
+{
+ void getAutoCompleteList(std::vector<std::string>& names) const
+ {
+ Beings::iterator i = beingManager->mBeings.begin();
+ names.clear();
+
+ while (i != beingManager->mBeings.end())
+ {
+ Being *being = (*i);
+ if ((being->getType() == Being::PLAYER
+ || being->getType() == Being::NPC)
+ && being->getName() != "")
+ names.push_back(being->getName());
+
+ ++i;
+ }
+ }
+};
+
BeingManager::BeingManager()
{
+ mPlayerNames = new PlayerNamesLister;
+ mPlayerNPCNames = new PlayerNPCNamesLister;
}
BeingManager::~BeingManager()
@@ -263,23 +303,14 @@ bool BeingManager::hasBeing(Being *being) const
return false;
}
-void BeingManager::getPlayerNames(std::vector<std::string> &names,
- bool npcNames)
+AutoCompleteLister *BeingManager::getPlayerNameLister()
{
- Beings::iterator i = mBeings.begin();
- names.clear();
+ return mPlayerNames;
+}
- while (i != mBeings.end())
- {
- Being *being = (*i);
- if ((being->getType() == Being::PLAYER
- || (being->getType() == Being::NPC && npcNames))
- && being->getName() != "")
- {
- names.push_back(being->getName());
- }
- ++i;
- }
+AutoCompleteLister *BeingManager::getPlayerNPCNameLister()
+{
+ return mPlayerNPCNames;
}
void BeingManager::updatePlayerNames()