From c62fe609a69058e2e30f757e9a06f72a98464232 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 17 Sep 2010 15:19:34 +0000 Subject: Bump network protocol version to 19, menudescriptions use the info infrastructure, client-side lazy info update requests. Updated ROADMAP --- src/core/descriptions.cc | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'src/core/descriptions.cc') diff --git a/src/core/descriptions.cc b/src/core/descriptions.cc index 307cc87..26a5858 100644 --- a/src/core/descriptions.cc +++ b/src/core/descriptions.cc @@ -15,7 +15,7 @@ namespace core ButtonDescription::ButtonDescription() { - button_model = 0; + button_info = 0; button_align = Center; button_commandtype = CommandNone; } @@ -35,16 +35,14 @@ void ButtonDescription::set_command(const std::string &command, const CommandTyp button_command.assign(command); } -void ButtonDescription::set_modelname(const std::string &modelname) +void ButtonDescription::set_alignment(Align align) { - button_modelname.assign(modelname); - - button_model = model::Model::load(modelname); + button_align = align; } -void ButtonDescription::set_alignment(Align align) +void ButtonDescription::set_info(Info *info) { - button_align = align; + button_info = info; } /* ---- class MenuDescription -------------------------------------- */ @@ -92,7 +90,7 @@ void Descriptions::serialize(MenuDescription *menu, std::ostream & os) << button->alignment() << " " << button->command_type() << " " << "\"" << button->command() << "\" " - << "\"" << button->modelname() << "\" "; + << (button->info() ? button->info()->id() : 0) << " "; } } @@ -105,6 +103,7 @@ MenuDescription * Descriptions::receive(std::istream &is) std::string n; size_t nb; char c; + long id; // menu label is >> n; @@ -157,12 +156,17 @@ MenuDescription * Descriptions::receive(std::istream &is) } } - // button modelname - n.clear(); - while ((is.get(c)) && (c != '"')); - while ((is.get(c)) && (c != '"')) - n += c; - if (n.size()) button->set_modelname(n); + // button info record id + Info *info = 0; + if (is >> id) { + info = Info::find(id); + if (id && !info) { + info = new Info(id); + } + } else { + id = 0; + } + button->set_info(info); menu->add_button(button); } @@ -231,9 +235,7 @@ bool Descriptions::load_entity_menus(core::Entity *entity, const std::string &me // 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)) { aux::to_label(strval); if (strval.compare("left") == 0) { -- cgit v1.2.3