extensions/topmenus/TopMenu.cpp
changeset 1634 241bf59d8f4d
parent 1595 dbffbe95cb75
child 1656 b0b86d57530c
     1.1 --- a/extensions/topmenus/TopMenu.cpp	Mon Oct 22 06:23:58 2007 +0000
     1.2 +++ b/extensions/topmenus/TopMenu.cpp	Mon Oct 22 06:56:17 2007 +0000
     1.3 @@ -125,6 +125,18 @@
     1.4  								FlagBits flags,
     1.5  								unsigned int parent)
     1.6  {
     1.7 +	return AddToMenu2(name, type, callbacks, owner, cmdname, flags, parent, NULL);
     1.8 +}
     1.9 +
    1.10 +unsigned int TopMenu::AddToMenu2(const char *name,
    1.11 +								 TopMenuObjectType type,
    1.12 +								 ITopMenuObjectCallbacks *callbacks,
    1.13 +								 IdentityToken_t *owner,
    1.14 +								 const char *cmdname,
    1.15 +								 FlagBits flags,
    1.16 +								 unsigned int parent,
    1.17 +								 const char *info_string)
    1.18 +{
    1.19  	/* Sanity checks */
    1.20  	if (type == TopMenuObject_Category && parent != 0)
    1.21  	{
    1.22 @@ -202,6 +214,7 @@
    1.23  	obj->parent = parent_obj;
    1.24  	strncopy(obj->name, name, sizeof(obj->name));
    1.25  	strncopy(obj->cmdname, cmdname ? cmdname : "", sizeof(obj->cmdname));
    1.26 +	strncopy(obj->info, info_string ? info_string : "", sizeof(obj->info));
    1.27  
    1.28  	if (obj->type == TopMenuObject_Category)
    1.29  	{
    1.30 @@ -239,6 +252,20 @@
    1.31  	return obj->object_id;
    1.32  }
    1.33  
    1.34 +const char *TopMenu::GetObjectInfoString(unsigned int object_id)
    1.35 +{
    1.36 +	if (object_id == 0 
    1.37 +		|| object_id > m_Objects.size() 
    1.38 +		|| m_Objects[object_id - 1]->is_free)
    1.39 +	{
    1.40 +		return NULL;
    1.41 +	}
    1.42 +
    1.43 +	topmenu_object_t *obj = m_Objects[object_id - 1];
    1.44 +
    1.45 +	return obj->info;
    1.46 +}
    1.47 +
    1.48  void TopMenu::RemoveFromMenu(unsigned int object_id)
    1.49  {
    1.50  	if (object_id == 0 
    1.51 @@ -320,11 +347,11 @@
    1.52  		}
    1.53  	}
    1.54  
    1.55 +	/* The callbacks pointer is still valid, so fire away! */
    1.56 +	obj->callbacks->OnTopMenuObjectRemoved(this, object_id);
    1.57 +
    1.58  	/* Finally, mark the object as free. */
    1.59  	obj->is_free = true;
    1.60 -
    1.61 -	/* The callbacks pointer is still valid, so fire away! */
    1.62 -	obj->callbacks->OnTopMenuObjectRemoved(this, object_id);
    1.63  }
    1.64  
    1.65  bool TopMenu::DisplayMenu(int client, unsigned int hold_time, TopMenuPosition position)