experimental changes to topmenu api -- drawing/displaying is now properly abstracted
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401532
This commit is contained in:
@@ -462,6 +462,12 @@ void TopMenu::OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, uns
|
||||
|
||||
obj = *pObject;
|
||||
|
||||
style = obj->callbacks->OnTopMenuDrawOption(this, client, obj->object_id);
|
||||
if (style != ITEMDRAW_DEFAULT)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj->cmdname[0] == '\0')
|
||||
{
|
||||
return;
|
||||
@@ -496,7 +502,7 @@ unsigned int TopMenu::OnMenuDisplayItem(IBaseMenu *menu,
|
||||
|
||||
/* Ask the object to render the text for this client */
|
||||
char renderbuf[64];
|
||||
obj->callbacks->OnTopMenuDrawOption(this, client, obj->object_id, renderbuf, sizeof(renderbuf));
|
||||
obj->callbacks->OnTopMenuDisplayOption(this, client, obj->object_id, renderbuf, sizeof(renderbuf));
|
||||
|
||||
/* Build the new draw info */
|
||||
ItemDrawInfo new_dr = dr;
|
||||
@@ -584,7 +590,7 @@ void TopMenu::UpdateClientRoot(int client, IGamePlayer *pGamePlayer)
|
||||
{
|
||||
obj_by_name_t *temp_obj = &item_list[i];
|
||||
topmenu_object_t *obj = m_Categories[m_UnsortedCats[i]]->obj;
|
||||
obj->callbacks->OnTopMenuDrawOption(this,
|
||||
obj->callbacks->OnTopMenuDisplayOption(this,
|
||||
client,
|
||||
obj->object_id,
|
||||
temp_obj->name,
|
||||
@@ -610,7 +616,7 @@ void TopMenu::UpdateClientRoot(int client, IGamePlayer *pGamePlayer)
|
||||
|
||||
/* Set the menu's title */
|
||||
char renderbuf[128];
|
||||
m_pTitle->OnTopMenuDrawTitle(this, client, 0, renderbuf, sizeof(renderbuf));
|
||||
m_pTitle->OnTopMenuDisplayTitle(this, client, 0, renderbuf, sizeof(renderbuf));
|
||||
root_menu->SetDefaultTitle(renderbuf);
|
||||
|
||||
/* The client is now fully updated */
|
||||
@@ -676,7 +682,7 @@ void TopMenu::UpdateClientCategory(int client, unsigned int category)
|
||||
{
|
||||
obj_by_name_t *item = &item_list[i];
|
||||
topmenu_object_t *obj = cat->unsorted[i];
|
||||
obj->callbacks->OnTopMenuDrawOption(this,
|
||||
obj->callbacks->OnTopMenuDisplayOption(this,
|
||||
client,
|
||||
obj->object_id,
|
||||
item->name,
|
||||
@@ -698,7 +704,7 @@ void TopMenu::UpdateClientCategory(int client, unsigned int category)
|
||||
|
||||
/* Set the menu's title */
|
||||
char renderbuf[128];
|
||||
cat->obj->callbacks->OnTopMenuDrawTitle(this,
|
||||
cat->obj->callbacks->OnTopMenuDisplayTitle(this,
|
||||
client,
|
||||
cat->obj->object_id,
|
||||
renderbuf,
|
||||
|
||||
@@ -63,9 +63,10 @@ void Shutdown_Natives()
|
||||
|
||||
enum TopMenuAction
|
||||
{
|
||||
TopMenuAction_DrawOption = 0,
|
||||
TopMenuAction_DrawTitle = 1,
|
||||
TopMenuAction_DisplayOption = 0,
|
||||
TopMenuAction_DisplayTitle = 1,
|
||||
TopMenuAction_SelectOption = 2,
|
||||
TopMenuAction_DrawOption = 3,
|
||||
};
|
||||
|
||||
class TopMenuCallbacks : public ITopMenuObjectCallbacks
|
||||
@@ -76,32 +77,43 @@ public:
|
||||
}
|
||||
|
||||
unsigned int OnTopMenuDrawOption(ITopMenu *menu,
|
||||
int client,
|
||||
unsigned int object_id)
|
||||
{
|
||||
char buffer[2] = {ITEMDRAW_DEFAULT, 0x0};
|
||||
m_pFunction->PushCell(m_hMenuHandle);
|
||||
m_pFunction->PushCell(TopMenuAction_DrawOption);
|
||||
m_pFunction->PushCell(object_id);
|
||||
m_pFunction->PushCell(client);
|
||||
m_pFunction->PushStringEx(buffer, sizeof(buffer), 0, SM_PARAM_COPYBACK);
|
||||
m_pFunction->PushCell(sizeof(buffer));
|
||||
m_pFunction->Execute(NULL);
|
||||
return (unsigned int)buffer[0];
|
||||
}
|
||||
|
||||
void OnTopMenuDisplayOption(ITopMenu *menu,
|
||||
int client,
|
||||
unsigned int object_id,
|
||||
char buffer[],
|
||||
size_t maxlength)
|
||||
{
|
||||
cell_t result = ITEMDRAW_DEFAULT;
|
||||
|
||||
m_pFunction->PushCell(m_hMenuHandle);
|
||||
m_pFunction->PushCell(TopMenuAction_DrawOption);
|
||||
m_pFunction->PushCell(TopMenuAction_DisplayOption);
|
||||
m_pFunction->PushCell(object_id);
|
||||
m_pFunction->PushCell(client);
|
||||
m_pFunction->PushStringEx(buffer, maxlength, 0, SM_PARAM_COPYBACK);
|
||||
m_pFunction->PushCell(maxlength);
|
||||
m_pFunction->Execute(&result);
|
||||
|
||||
return result;
|
||||
m_pFunction->Execute(NULL);
|
||||
}
|
||||
|
||||
void OnTopMenuDrawTitle(ITopMenu *menu,
|
||||
void OnTopMenuDisplayTitle(ITopMenu *menu,
|
||||
int client,
|
||||
unsigned int object_id,
|
||||
char buffer[],
|
||||
size_t maxlength)
|
||||
{
|
||||
m_pFunction->PushCell(m_hMenuHandle);
|
||||
m_pFunction->PushCell(TopMenuAction_DrawTitle);
|
||||
m_pFunction->PushCell(TopMenuAction_DisplayTitle);
|
||||
m_pFunction->PushCell(object_id);
|
||||
m_pFunction->PushCell(client);
|
||||
m_pFunction->PushStringEx(buffer, maxlength, 0, SM_PARAM_COPYBACK);
|
||||
|
||||
Reference in New Issue
Block a user