added amb766 - GetMenuTitle()

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401296
This commit is contained in:
David Anderson 2007-08-09 18:25:00 +00:00
parent 9588414f45
commit 3cd3a0a8d6
2 changed files with 31 additions and 0 deletions

View File

@ -811,6 +811,25 @@ static cell_t SetMenuTitle(IPluginContext *pContext, const cell_t *params)
return 1;
}
static cell_t GetMenuTitle(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IBaseMenu *menu;
if ((err=g_Menus.ReadMenuHandle(params[1], &menu)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
size_t written;
const char *title = menu->GetDefaultTitle();
pContext->StringToLocalUTF8(params[2], params[3], title, &written);
return (cell_t)written;
}
static cell_t CreatePanelFromMenu(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
@ -1329,6 +1348,7 @@ REGISTER_NATIVES(menuNatives)
{"GetMenuPagination", GetMenuPagination},
{"GetMenuStyle", GetMenuStyle},
{"GetMenuStyleHandle", GetMenuStyleHandle},
{"GetMenuTitle", GetMenuTitle},
{"GetPanelCurrentKey", GetPanelCurrentKey},
{"GetPanelStyle", GetPanelStyle},
{"InsertMenuItem", InsertMenuItem},

View File

@ -264,6 +264,17 @@ native Handle:GetMenuStyle(Handle:menu);
*/
native SetMenuTitle(Handle:menu, const String:fmt[], any:...);
/**
* Returns the text of a menu's title.
*
* @param menu Menu Handle.
* @param buffer Buffer to store title.
* @param maxlength Maximum length of the buffer.
* @return Number of bytes written.
* @error Invalid Handle/
*/
native GetMenuTitle(Handle:menu, String:buffer[], maxlength);
/**
* Creates a raw MenuPanel based off the menu's style.
* The Handle must be freed with CloseHandle().