From a95028547981614e06ea7a6d22b853b85418cea3 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 15 Apr 2009 17:08:51 +0000 Subject: added info registry, list_info added network info transfer added info based buy menu and related game changes --- src/client/entitymenu.cc | 75 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 3 deletions(-) (limited to 'src/client/entitymenu.cc') diff --git a/src/client/entitymenu.cc b/src/client/entitymenu.cc index f727ff3..f1529e1 100644 --- a/src/client/entitymenu.cc +++ b/src/client/entitymenu.cc @@ -16,8 +16,10 @@ EntityMenu::EntityMenu(ui::Widget *parent, const char * label) : ui::Window(pare { set_border(false); set_background(false); - set_label(label); - set_label("entitymenu"); + if (label) + set_label(label); + else + set_label("entitymenu"); menu_container = new ui::Container(this); hide(); @@ -73,7 +75,74 @@ void EntityMenu::generate(core::Entity *entity, const char *menulabel) for (core::MenuDescription::Buttons::iterator it = menudescr->buttons().begin(); it != menudescr->buttons().end(); it++) { core::ButtonDescription *buttondescr = (*it); - Button *button = new Button(menu_container, buttondescr->text().c_str(), buttondescr->command().c_str()); + + // parse the command sequence + size_t i = 0; + std::string result; + std::string current; + bool quote = false; + + while (i < buttondescr->command().size()) { + const char c = buttondescr->command()[i]; + + if (c == '"') { + quote = !quote; + result += c; + + } else if (c == ';') { + + if (quote) { + current += c; + + } else if (current.size()) { + if (buttondescr->command_type() == core::ButtonDescription::CommandGame) { + if (result.size()) { + result += ';'; + } + + result.append("remote "); + result.append(current); + + } else if (buttondescr->command_type() == core::ButtonDescription::CommandMenu) { + if (result.size()) { + result += ';'; + } + + result.append("view "); + result.append(current); + } + current.clear(); + } + + } else { + current += c; + } + + i++; + } + + if (current.size()) { + if (buttondescr->command_type() == core::ButtonDescription::CommandGame) { + if (result.size()) { + result += ';'; + } + + result.append("remote "); + result.append(current); + + } else if (buttondescr->command_type() == core::ButtonDescription::CommandMenu) { + if (result.size()) { + result += ';'; + } + + result.append("view "); + result.append(current); + } + + } + + Button *button = new Button(menu_container, buttondescr->text().c_str(), result.c_str()); + switch (buttondescr->alignment()) { case core::ButtonDescription::Center: button->set_alignment(AlignCenter); -- cgit v1.2.3