From 9d39702824e8fae5127e09fb5a05b521b48cd028 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 9 Nov 2008 11:43:28 +0000 Subject: docking menus --- src/core/entity.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/core/entity.cc') diff --git a/src/core/entity.cc b/src/core/entity.cc index 9bc3f3c..e2aac1c 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -133,6 +133,12 @@ Entity::Entity(std::istream & is) Entity::~Entity() { + // delete entity menus + for (Menus::iterator it = menus().begin(); it != menus().end(); it++) { + delete (*it); + } + menus().clear(); + if (entity_clientstate) { delete entity_clientstate; entity_clientstate = 0; @@ -346,6 +352,29 @@ void Entity::frame(float seconds) { } +void Entity::add_menu(MenuDescription *menu) +{ + entity_menus.push_back(menu); +} + +MenuDescription *Entity::find_menu(std::string const &label) +{ + for (Menus::iterator it = menus().begin(); it != menus().end(); it++) { + if (label.compare((*it)->label()) == 0) + return (*it); + } + return 0; +} + +void Entity::remove_menu(std::string const &label) +{ + for (Menus::iterator it = menus().begin(); it != menus().end(); it++) { + if (label.compare((*it)->label()) == 0) + menus().erase(it); + return; + } +} + /* ---- class EntityDynamic ---------------------------------------- */ EntityDynamic::EntityDynamic(unsigned int flags) : -- cgit v1.2.3