From 9c2d1a1c867bbd7eea083dbc03c0acf1edace8c2 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 27 Jan 2009 18:53:24 +0000 Subject: moves docking menus from ui to client, allow map and chat window while docked --- src/client/client.cc | 177 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 158 insertions(+), 19 deletions(-) (limited to 'src/client/client.cc') diff --git a/src/client/client.cc b/src/client/client.cc index 4533f84..df56700 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -113,11 +113,26 @@ void Client::init(int count, char **arguments) func = core::Func::add("snd_restart", Client::func_snd_restart); func->set_info("restart audio subsystem"); + func = core::Func::add("list_ui", func_list_ui); + func->set_info("list user interface widgets"); + + func = core::Func::add("list_menu", func_list_menu); + func->set_info("list available menus"); + + func = core::Func::add("ui", func_ui); + func->set_info("[command] user interface functions"); + + func = core::Func::add("ui_restart", func_ui_restart); + func->set_info("reload user interface files"); + + func = core::Func::add("ui_console", func_ui_console); + func->set_info("toggle console"); + func = core::Func::add("ui_chat", Client::func_ui_chat); func->set_info("toggle chat window"); - func = core::Func::add("ui_chatsmall", Client::func_ui_chatsmall); - func->set_info("toggle small chat window"); + func = core::Func::add("ui_chatbar", Client::func_ui_chatbar); + func->set_info("toggle chat bar"); func = core::Func::add("ui_map", Client::func_ui_map); func->set_info("toggle map"); @@ -125,6 +140,9 @@ void Client::init(int count, char **arguments) func = core::Func::add("ui_menu", Client::func_ui_menu); func->set_info("toggle main menu"); + func = core::Func::add("menu", func_menu); + func->set_info("[command] menu functions"); + previous_timestamp = 0; } @@ -199,21 +217,13 @@ void Client::frame(unsigned long timestamp) // show the join menu when player does not control an entity } else if (core::game()->time() && !core::localcontrol()) { ui::root()->show_menu("join"); - - // show the view menu when docked - } else if (core::localcontrol() && core::localplayer()->view()) { - ui::root()->show_menuview("main"); } - } else { if (core::localcontrol()) { + // hide join menu if (ui::root()->active()->label().compare("join") == 0) { - ui::root()->hide_menu(); - - // hide view menu - } else if (!core::localplayer()->view() && (ui::root()->active()->label().compare("view") == 0)) { - ui::root()->hide_menu(); + ui::root()->hide_menu(); } } } @@ -231,10 +241,16 @@ void Client::shutdown() core::Func::remove("r_restart"); core::Func::remove("snd_restart"); + core::Func::remove("list_menu"); + core::Func::remove("list_ui"); + core::Func::remove("ui"); + core::Func::remove("ui_restart"); + core::Func::remove("ui_console"); core::Func::remove("ui_chat"); - core::Func::remove("ui_chatsmall"); + core::Func::remove("ui_chatbar"); core::Func::remove("ui_map"); core::Func::remove("ui_menu"); + core::Func::remove("menu"); audio::shutdown(); @@ -362,26 +378,95 @@ void Client::func_r_restart(std::string const &args) video::restart(); } +/* ---- func_ui ---------------------------------------------------- */ + +void Client::func_list_ui(std::string const &args) +{ + if (ui::root()) { + ui::root()->list(); + } +} + +void Client::func_ui_restart(std::string const &args) +{ + if (ui::root()) { + ui::root()->load_menus(); + ui::root()->load_settings(); + ui::root()->apply_render_options(); + } +} + + +void Client::func_ui_console(std::string const &args) +{ + ui::console()->toggle(); +} + +void Client::func_list_menu(std::string const &args) +{ + if (ui::root()) { + ui::root()->list_menus(); + } +} + +void Client::func_ui_help() +{ + con_print << "^BUser interface functions" << std::endl; + con_print << " ui help show this help" << std::endl; + con_print << " ui debug toggle debug mode" << std::endl; + con_print << " ui list list widgets" << std::endl; + con_print << " ui restart reload user interface files" << std::endl; +} + +void Client::func_ui(std::string const &args) +{ + if (!ui::root()) { + con_warn << "User Interface not available!" << std::endl; + return; + } + + if (!args.size()) { + func_ui_help(); + return; + } + std::stringstream argstr(args); + std::string command; + argstr >> command; + aux::to_label(command); + + if (command.compare("help") == 0) { + func_ui_help(); + } else if (command.compare("debug") == 0) { + ui::UI::ui_debug = !ui::UI::ui_debug; + } else if (command.compare("list") == 0) { + ui::root()->list(); + } else if (command.compare("restart") == 0) { + ui::root()->load_menus(); + ui::root()->load_settings(); + ui::root()->apply_render_options(); + } else { + func_ui_help(); + } +} + void Client::func_ui_chat(std::string const &args) { if (client()->connected() && client()->worldview()->playerview()->visible()) { - client()->worldview()->playerview()->chat()->set_small_view(false); - client()->worldview()->playerview()->chat()->toggle(); + client()->worldview()->playerview()->toggle_chat(); } } -void Client::func_ui_chatsmall(std::string const &args) +void Client::func_ui_chatbar(std::string const &args) { if (client()->connected() && client()->worldview()->playerview()->visible()) { - client()->worldview()->playerview()->chat()->set_small_view(true); - client()->worldview()->playerview()->chat()->toggle(); + client()->worldview()->playerview()->toggle_chatbar(); } } void Client::func_ui_map(std::string const &args) { if (client()->connected() && client()->worldview()->playerview()->visible()) { - client()->worldview()->playerview()->map()->toggle(); + client()->worldview()->playerview()->toggle_map(); } } @@ -403,5 +488,59 @@ void Client::func_ui_menu(std::string const &args) } } +void Client::func_menu(std::string const &args) +{ + if (!ui::root()) { + con_warn << "User Interface not available!" << std::endl; + return; + } + + if (!args.size()) { + con_print << "^Bmenu functions" << std::endl; + con_print << " menu help show this help" << std::endl; + con_print << " menu list list available menus" << std::endl; + con_print << " menu [name] show a menu" << std::endl; + con_print << " menu back return to the previous menu" << std::endl; + con_print << " menu previous return to the previous menu" << std::endl; + con_print << " menu close close the current menu" << std::endl; + con_print << " menu hide hide the current menu" << std::endl; + ui::root()->list_menus(); + } + + std::stringstream argstr(args); + std::string command; + argstr >> command; + + aux::to_label(command); + + if (command.compare("hide") == 0) { + ui::root()->hide_menu(); + + } else if (command.compare("close") == 0) { + ui::root()->hide_menu(); + + } else if (command.compare("back") == 0) { + ui::root()->previous_menu(); + + } else if (command.compare("previous") == 0) { + ui::root()->previous_menu(); + + } else if (command.compare("list") == 0) { + ui::root()->list_menus(); + + } else if (command.compare("view") == 0) { + if (client()->worldview()) { + std::string label; + if (!(argstr >> label)) { + label.assign("main"); + } + client()->worldview()->playerview()->show_menu(label); + } + } else { + ui::root()->show_menu(command.c_str()); + } +} + + } // namespace client -- cgit v1.2.3