diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/chat.cc | 6 | ||||
-rw-r--r-- | src/client/client.cc | 14 | ||||
-rw-r--r-- | src/client/console.cc | 8 | ||||
-rw-r--r-- | src/client/input.cc | 7 |
4 files changed, 26 insertions, 9 deletions
diff --git a/src/client/chat.cc b/src/client/chat.cc index 7f5c22c..8de2665 100644 --- a/src/client/chat.cc +++ b/src/client/chat.cc @@ -33,6 +33,8 @@ void func_con_chat(std::string const &args) if (i) chat_visible = true; else chat_visible = false; } else chat_visible = !chat_visible; + + } //--- public ------------------------------------------------------ @@ -40,7 +42,7 @@ 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::add("con_chat", (core::FuncPtr) func_con_chat); history.clear(); history.push_back(""); @@ -97,6 +99,8 @@ void toggle() history_pos = history.rbegin(); (*history_pos).clear(); } + + setkeyboardmode(chat_visible); } void keypressed(int key) diff --git a/src/client/client.cc b/src/client/client.cc index b09618e..ab27d0f 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -90,9 +90,15 @@ void Client::init() core::Application::init(); // client variables - core::Cvar::get("cl_name", "Player", core::Cvar::Archive | core::Cvar::Info); - core::Cvar::get("cl_color", "1.0 1.0 1.0", core::Cvar::Archive | core::Cvar::Info); + core::Cvar *cvar = 0; + cvar = core::Cvar::get("cl_name", "Player", core::Cvar::Archive | core::Cvar::Info); + cvar->set_info("[str] client player name"); + + cvar = core::Cvar::get("cl_color", "1.0 1.0 1.0", core::Cvar::Archive | core::Cvar::Info); + cvar->set_info("[r g b] client player clor"); + cl_framerate = core::Cvar::get("cl_framerate", "120", core::Cvar::Archive); + cl_framerate->set_info("client framerate in frames/sec"); // initialize SDL, but do not initialize any subsystems SDL_Init(0); @@ -111,7 +117,9 @@ void Client::init() input::init(); // add engine functions - core::Func::add("r_restart", (core::FuncPtr) func_r_restart); + core::Func *func = 0; + func = core::Func::add("r_restart", (core::FuncPtr) func_r_restart); + func->set_info("restart render subsystem"); } void Client::run() diff --git a/src/client/console.cc b/src/client/console.cc index 2d667a8..ca84384 100644 --- a/src/client/console.cc +++ b/src/client/console.cc @@ -84,7 +84,7 @@ void init() console_visible = false; // add engine functions - //core::Func::add("con_toggle", (core::FuncPtr) func_con_toggle); + core::Func::add("con_toggle", (core::FuncPtr) func_con_toggle); text.clear(); console_scroll = 0; @@ -214,7 +214,13 @@ void toggle() history_pos = history.rbegin(); (*history_pos).clear(); + + SDL_WM_GrabInput(SDL_GRAB_OFF); + } else { + SDL_WM_GrabInput(SDL_GRAB_ON); } + + setkeyboardmode(console::visible()); } void keypressed(int key) diff --git a/src/client/input.cc b/src/client/input.cc index 88d1dd3..a7e67cc 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -35,7 +35,8 @@ int mouse_y = 0; void init() { con_print << "Initializing input..." << std::endl; - client::setkeyboardmode(console::visible()); + client::setkeyboardmode(false); + SDL_WM_GrabInput(SDL_GRAB_ON); // SDL_EnableUNICODE(1); } @@ -139,7 +140,7 @@ void frame(float seconds) if (event.key.keysym.sym == '`' || event.key.keysym.sym == '~') { last_control = 0; console::toggle(); - setkeyboardmode(console::visible()); + if (console::visible() && chat::visible()) chat::toggle(); } else if (console::visible()) { @@ -149,7 +150,6 @@ void frame(float seconds) } else if (chat::visible()) { if(event.key.keysym.sym == SDLK_ESCAPE) { chat::toggle(); - setkeyboardmode(chat::visible()); } else { // send key events to the chatbox chat::keypressed(translate_keysym(event.key.keysym)); @@ -157,7 +157,6 @@ void frame(float seconds) } else if(core::application()->connected()) { if ((event.key.keysym.sym == 't') || (event.key.keysym.sym == 'T')) { chat::toggle(); - setkeyboardmode(chat::visible()); } else if (core::localcontrol()) { // send key events to the game world keypressed(event.key.keysym); |