Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/descriptions.cc')
-rw-r--r--src/core/descriptions.cc27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/core/descriptions.cc b/src/core/descriptions.cc
index fe37d2c..8c0f4ee 100644
--- a/src/core/descriptions.cc
+++ b/src/core/descriptions.cc
@@ -16,6 +16,7 @@ ButtonDescription::ButtonDescription()
{
button_model = 0;
button_align = Center;
+ button_commandtype = CommandNone;
}
ButtonDescription::~ButtonDescription()
@@ -27,8 +28,9 @@ void ButtonDescription::set_text(const std::string &text)
button_text.assign(text);
}
-void ButtonDescription::set_command(const std::string &command)
+void ButtonDescription::set_command(const std::string &command, const CommandType command_type)
{
+ button_commandtype = command_type;
button_command.assign(command);
}
@@ -85,9 +87,10 @@ void Descriptions::serialize(MenuDescription *menu, std::ostream & os)
for (MenuDescription::Buttons::iterator it = menu-> buttons().begin(); it != menu->buttons().end(); it++) {
ButtonDescription *button = (*it);
- os << "\"" << button->text() << "\" "
+ os << "\"" << button->text() << "\" "
<< button->alignment() << " "
- << "\"" << button->command() << "\" "
+ << button->command_type() << " "
+ << "\"" << button->command() << "\" "
<< "\"" << button->modelname() << "\" ";
}
}
@@ -97,6 +100,7 @@ MenuDescription * Descriptions::receive(std::istream &is)
MenuDescription *menu = new MenuDescription();
int a;
+ int t;
std::string n;
size_t nb;
char c;
@@ -135,12 +139,22 @@ MenuDescription * Descriptions::receive(std::istream &is)
else
button->set_alignment(ButtonDescription::Center);
+ // button command type
+ is >> t;
+
// button command
n.clear();
while ( (is.get(c)) && (c != '"'));
while ( (is.get(c)) && (c != '"'))
n += c;
- if (n.size()) button->set_command(n);
+
+ if (n.size()) {
+ if (t == ButtonDescription::CommandGame) {
+ button->set_command(n, ButtonDescription::CommandGame);
+ } else if (t == ButtonDescription::CommandMenu) {
+ button->set_command(n, ButtonDescription::CommandMenu);
+ }
+ }
// button modelname
n.clear();
@@ -213,7 +227,10 @@ bool Descriptions::load_entity_menus(core::Entity *entity, const std::string &me
if (strval[i] == ',') strval[i] = ';';
}
aux::strip_quotes(strval);
- button->set_command(strval);
+
+ // default command is a game command
+ button->set_command(strval, ButtonDescription::CommandGame);
+
} else if (inifile.got_key_string("model", strval)) {
button->set_modelname(strval);
} else if (inifile.got_key_string("align", strval)) {