From 76a49efdf62a53a54e2deeb559422f11c1e955dd Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 26 Jan 2009 22:12:04 +0000 Subject: read main menus from menu.ini --- src/ui/menu.cc | 92 ++-------------------------------------------------------- 1 file changed, 3 insertions(+), 89 deletions(-) (limited to 'src/ui/menu.cc') diff --git a/src/ui/menu.cc b/src/ui/menu.cc index 36599be..a7e2d68 100644 --- a/src/ui/menu.cc +++ b/src/ui/menu.cc @@ -30,98 +30,12 @@ Menu::~Menu() // menu_container and menu_background are deleted by Widget::~Widget() } -void Menu::load() +void Menu::set_background_texture(const char *texture) { - std::string filename("menus/"); - filename.append(label()); - - filesystem::IniFile ini; - - ini.open(filename); - - if (!ini.is_open()) { - con_error << "Could not open " << ini.name() << std::endl; - return; - } - - std::string strval; - Button *button = 0; - Label *label = 0; - - while (ini.getline()) { - if (ini.got_section()) { - if (ini.got_section("menu")) { - continue; - - } else if (ini.got_section("button")) { - button = add_button(); - - } else if (ini.got_section("label")) { - label = add_label(); - - } else if (ini.got_section()) { - ini.unknown_section(); - } - } else if (ini.got_key()) { - if (ini.in_section("menu")) { - if (ini.got_key_string("background", strval)) { - menu_background->set_texture(strval); - } else { - ini.unkown_key(); - } - } else if (ini.in_section("button")) { - if (ini.got_key_string("text", strval)) { - aux::strip_quotes(strval); - button->set_text(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); - button->set_command(strval); - - } else if (ini.got_key_string("align", strval)) { - aux::to_label(strval); - if (strval.compare("left") == 0) { - button->set_alignment(AlignLeft | AlignVCenter); - } else if (strval.compare("center") == 0) { - button->set_alignment(AlignCenter); - } else if (strval.compare("right") == 0) { - button->set_alignment(AlignRight | AlignVCenter); - } else { - ini.unknown_value(); - } - } else { - ini.unkown_key(); - } - } else if (ini.in_section("label")) { - if (ini.got_key_string("text", strval)) { - label->set_text(strval); - } else if (ini.got_key_string("align", strval)) { - aux::to_label(strval); - if (strval.compare("left") == 0) { - label->set_alignment(AlignLeft | AlignHCenter); - } else if (strval.compare("center") == 0) { - label->set_alignment(AlignCenter); - } else if (strval.compare("right") == 0) { - label->set_alignment(AlignRight | AlignHCenter); - } else { - ini.unknown_value(); - } - } else { - ini.unkown_key(); - } - } - - } - } - - con_debug << " " << ini.name() << " " << children().size() << " widgets" << std::endl; - ini.close(); + menu_background->set_texture(texture); } -void Menu::set_background_texture(const char *texture) +void Menu::set_background_texture(const std::string &texture) { menu_background->set_texture(texture); } -- cgit v1.2.3