diff options
author | Stijn Buys <ingar@osirion.org> | 2008-06-02 16:20:47 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-06-02 16:20:47 +0000 |
commit | 8c17868585e2a12f947ec387947c4521ef21d775 (patch) | |
tree | 83d36d3dc36698aa0d36a3b9b9a8bb0826520586 /src/client/chat.cc | |
parent | 0f87d2fd05786f7ab128d4a041673f6fb085139f (diff) |
keyboard binds
Diffstat (limited to 'src/client/chat.cc')
-rw-r--r-- | src/client/chat.cc | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/src/client/chat.cc b/src/client/chat.cc index 6fd5008..6c3140d 100644 --- a/src/client/chat.cc +++ b/src/client/chat.cc @@ -24,46 +24,23 @@ size_t input_pos = 0; // chatbox visibility bool chat_visible = false; -//--- engine functions -------------------------------------------- - -void func_con_chat(std::string const &args) -{ - std::istringstream argstream(args); - int i; - - if (argstream >> i) { - if (i) chat_visible = true; else chat_visible = false; - } else - chat_visible = !chat_visible; - - -} - //--- public ------------------------------------------------------ void init() { // add engine functions - core::Func *func = core::Func::add("ui_chat", (core::FuncPtr) func_con_chat); - func->set_info("toggle chatbox"); - history.clear(); history.push_back(""); history_pos = history.rbegin(); input_pos = 0; - } void shutdown() { - // remove engine functions - core::Func::remove("ui_chat"); - history.clear(); input_pos = 0; } - bool visible() { return chat_visible; @@ -133,14 +110,18 @@ void toggle() (*history_pos).clear(); } - setkeyboardmode(chat_visible); + setkeyboardmode(console()->visible() || (core::application()->connected() && chat::visible())); } -void keypressed(int key) +void keypressed(unsigned int key) { std::deque<std::string>::reverse_iterator upit; switch( key ) { + case SDLK_ESCAPE: + toggle(); + break; + case SDLK_TAB: core::CommandBuffer::complete( (*history_pos), input_pos); break; |