From 8c17868585e2a12f947ec387947c4521ef21d775 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 2 Jun 2008 16:20:47 +0000 Subject: keyboard binds --- src/client/chat.cc | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) (limited to 'src/client/chat.cc') 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::reverse_iterator upit; switch( key ) { + case SDLK_ESCAPE: + toggle(); + break; + case SDLK_TAB: core::CommandBuffer::complete( (*history_pos), input_pos); break; -- cgit v1.2.3