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/core/descriptions.cc | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src/core/descriptions.cc') 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)) { -- cgit v1.2.3