diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-05-20 14:11:40 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-05-20 14:11:40 +0200 |
commit | 3bb33734a92e86024488adf88dc2a368c8c952b2 (patch) | |
tree | aee8ab7832b7fef021668d94cbaf7d21d6c9c839 /gui.cpp | |
parent | 7b22d822f9871222fbbe401c9c79d6a624d21331 (diff) |
Basic lua implementation.
Diffstat (limited to 'gui.cpp')
-rw-r--r-- | gui.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -68,7 +68,9 @@ bool GUI::showing() { /* ConsoleWindow */ -ConsoleWindow::ConsoleWindow() { +ConsoleWindow::ConsoleWindow(Lua *lua) { + this->lua = lua; + WindowManager& wmgr(WindowManager::getSingleton()); wnd = wmgr.loadWindowLayout("console.layout"); @@ -128,7 +130,21 @@ void ConsoleWindow::handle_input() { if(!s.size()) return; - FormattedListboxTextItem *item = new FormattedListboxTextItem(String((utf8*)s.c_str()), HTF_WORDWRAP_LEFT_ALIGNED); + add_line(s); + + try { + lua->dostring(s); + } catch(LuaError& e) { + add_line(e.what()); + } +} + +void ConsoleWindow::add_line(const std::string& line) { + add_line(line.c_str()); +} + +void ConsoleWindow::add_line(const char *line) { + FormattedListboxTextItem *item = new FormattedListboxTextItem(String((utf8*)line), HTF_WORDWRAP_LEFT_ALIGNED); listbox->addItem(item); listbox->ensureItemIsVisible(item); } |