diff options
author | Stijn Buys <ingar@osirion.org> | 2009-04-15 17:08:51 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2009-04-15 17:08:51 +0000 |
commit | a95028547981614e06ea7a6d22b853b85418cea3 (patch) | |
tree | d4d6998a4118a4d8690ce138d586abfba4893179 /src/client/entitymenu.cc | |
parent | 4f33f59571f10019c1e7a0e3640b2f69c159a8cf (diff) |
added info registry, list_info
added network info transfer
added info based buy menu and related game changes
Diffstat (limited to 'src/client/entitymenu.cc')
-rw-r--r-- | src/client/entitymenu.cc | 75 |
1 files changed, 72 insertions, 3 deletions
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); |