Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/entitymenu.cc')
-rw-r--r--src/client/entitymenu.cc75
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);