From da0715c2648b662892a72e32e8528a08608d0d0b Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 31 May 2008 09:02:50 +0000 Subject: chatbox accepts console commands --- src/client/chat.cc | 11 ++++++++--- src/client/console.cc | 6 +++--- src/client/input.cc | 2 ++ 3 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/client/chat.cc b/src/client/chat.cc index 9171387..6fd5008 100644 --- a/src/client/chat.cc +++ b/src/client/chat.cc @@ -44,7 +44,8 @@ void func_con_chat(std::string const &args) void init() { // add engine functions - core::Func::add("con_chat", (core::FuncPtr) func_con_chat); + core::Func *func = core::Func::add("ui_chat", (core::FuncPtr) func_con_chat); + func->set_info("toggle chatbox"); history.clear(); history.push_back(""); @@ -56,7 +57,7 @@ void init() void shutdown() { // remove engine functions - //core::Func::remove("con_chat"); + core::Func::remove("ui_chat"); history.clear(); input_pos = 0; @@ -150,7 +151,11 @@ void keypressed(int key) history.pop_front(); } - core::cmd() << "say " << (*history_pos) << std::endl; + if ((*history_pos).c_str()[0] == '/' || (*history_pos).c_str()[0] == '\\') { + core::cmd() << &(*history_pos).c_str()[1] << std::endl; + } else { + core::cmd() << "say " << (*history_pos) << std::endl; + } (*history.rbegin()) = (*history_pos); history.push_back(""); diff --git a/src/client/console.cc b/src/client/console.cc index 8eab607..a09272a 100644 --- a/src/client/console.cc +++ b/src/client/console.cc @@ -27,7 +27,7 @@ Console *console() { //--- engine functions -------------------------------------------- -void func_con_toggle(std::string const &args) +void func_ui_console(std::string const &args) { console()->toggle(); @@ -39,7 +39,7 @@ void Console::init() { con_print << "^BInitializing console..." << std::endl; - core::Func *func = core::Func::add("con_toggle", (core::FuncPtr) func_con_toggle); + core::Func *func = core::Func::add("ui_console", (core::FuncPtr) func_ui_console); func->set_info("toggle console on or off"); console()->load_history(); } @@ -51,7 +51,7 @@ void Console::shutdown() console()->save_history(); // remove engine functions - core::Func::remove("con_toggle"); + core::Func::remove("ui_console"); } //--- Console ----------------------------------------------------- diff --git a/src/client/input.cc b/src/client/input.cc index 22db6bc..d594dbf 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -241,8 +241,10 @@ void frame(float seconds) //last_control = 0; console()->toggle(); + /* if (console()->visible() && chat::visible()) chat::toggle(); + */ } else if (console()->visible()) { // send key events to the console console()->keypressed(translate_keysym(event.key.keysym)); -- cgit v1.2.3