summaryrefslogtreecommitdiff
path: root/src/console/ConsoleModel.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-08-21 16:58:45 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-08-21 16:58:45 (GMT)
commitb7328e03acc683839ee84f3ea3eb12c9dfa8d8f1 (patch)
treeaa8b0954e0659c8ddfffed3ef3916191b8766624 /src/console/ConsoleModel.cpp
parentfb6f36907f3fc2169916b72c572637ee07ec44d8 (diff)
downloadpowder-b7328e03acc683839ee84f3ea3eb12c9dfa8d8f1.zip
powder-b7328e03acc683839ee84f3ea3eb12c9dfa8d8f1.tar.gz
Remember Console history
Diffstat (limited to 'src/console/ConsoleModel.cpp')
-rw-r--r--src/console/ConsoleModel.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/console/ConsoleModel.cpp b/src/console/ConsoleModel.cpp
index fcbee80..df900a3 100644
--- a/src/console/ConsoleModel.cpp
+++ b/src/console/ConsoleModel.cpp
@@ -5,15 +5,25 @@
* Author: Simon
*/
+#include "client/Client.h"
#include "ConsoleModel.h"
ConsoleModel::ConsoleModel() {
-
+ std::vector<std::string> previousHistory = Client::Ref().GetPrefStringArray("Console.History");
+ for(std::vector<std::string>::reverse_iterator iter = previousHistory.rbegin(), end = previousHistory.rend(); iter != end; ++iter)
+ {
+ if(previousCommands.size()<25)
+ {
+ previousCommands.push_front(ConsoleCommand(*iter, 0, ""));
+ currentCommandIndex = previousCommands.size();
+ }
+ }
}
void ConsoleModel::AddObserver(ConsoleView * observer)
{
observers.push_back(observer);
+ observer->NotifyPreviousCommandsChanged(this);
}
int ConsoleModel::GetCurrentCommandIndex()
@@ -67,6 +77,6 @@ void ConsoleModel::notifyCurrentCommandChanged()
}
ConsoleModel::~ConsoleModel() {
-
+ Client::Ref().SetPref("Console.History", std::vector<std::string>(previousCommands.begin(), previousCommands.end()));
}