From 5dea1a263136c4cbe011de3325605dd3dc4523af Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 13 Oct 2012 15:38:03 +0000 Subject: Added dialog infrastructure. --- src/client/mainmenu.cc | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) (limited to 'src/client/mainmenu.cc') diff --git a/src/client/mainmenu.cc b/src/client/mainmenu.cc index cfed85f..7271bcf 100644 --- a/src/client/mainmenu.cc +++ b/src/client/mainmenu.cc @@ -5,6 +5,7 @@ */ #include "client/buttonmenu.h" +#include "client/dialog.h" #include "client/mainmenu.h" #include "client/savegamemenu.h" #include "core/core.h" @@ -62,6 +63,7 @@ void MainMenu::load_definitions() con_debug << " Loading menu definitions..." << std::endl; + Dialog *dialog = 0; ui::Label *label = 0; ui::Button *button = 0; ButtonMenu *menu = 0; @@ -72,6 +74,13 @@ void MainMenu::load_definitions() if (ini.got_section()) { if (ini.got_section("menu")) { + dialog = 0; + menu = 0; + continue; + + // dialog + } else if (ini.got_section("dialog")) { + dialog = 0; menu = 0; continue; @@ -83,6 +92,7 @@ void MainMenu::load_definitions() } else { button = menu->add_button(); } + continue; // menu label } else if (ini.got_section("label")) { @@ -92,6 +102,7 @@ void MainMenu::load_definitions() } else { label = menu->add_label(); } + continue; } else { ini.unknown_section(); @@ -99,18 +110,46 @@ void MainMenu::load_definitions() } } else if (ini.got_key()) { - - if (ini.in_section("menu")) { + + if (ini.in_section("dialog")) { + if (!dialog) { + if (ini.got_key_label("label", strval)) { + dialog = new Dialog(this); + dialog->set_label(strval); + } + } else { + + if (ini.got_key_label("label", strval)) { + dialog->set_label(strval); + + } else if (ini.got_key_string("text", strval)) { + dialog->set_text(strval); + + } else if (ini.got_key_string("button", strval)) { + dialog->set_button(strval); + + } else if (ini.got_key_string("command", strval)) { + for (size_t i = 0; i <= strval.size(); i++) { + if (strval[i] == ',') strval[i] = ';'; + } + aux::strip_quotes(strval); + dialog->set_command(strval); + } else { + ini.unknown_key(); + } + } + + } else if (ini.in_section("menu")) { - if (ini.got_key_string("label", strval)) { - aux::to_label(strval); + if (ini.got_key_label("label", strval)) { for (ui::Widget::Children::iterator child = children().begin(); child != children().end(); ++child) { if ((*child)->label().compare(strval) == 0) { + // assert child is a menu menu = static_cast((*child)); } } - + if (!menu) { menu = new ButtonMenu(this, strval.c_str()); } -- cgit v1.2.3