本文整理汇总了C++中IBaseMenu::CreatePanel方法的典型用法代码示例。如果您正苦于以下问题:C++ IBaseMenu::CreatePanel方法的具体用法?C++ IBaseMenu::CreatePanel怎么用?C++ IBaseMenu::CreatePanel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBaseMenu
的用法示例。
在下文中一共展示了IBaseMenu::CreatePanel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShowChar
void CRPGPlayer::ShowChar()
{
IMenuStyle *style = menus->GetDefaultStyle();
IBaseMenu *menu = style->CreateMenu(&g_RPGPlugin, myself->GetIdentity());
IMenuPanel *panel = menu->CreatePanel();
menu->SetDefaultTitle(MENU_CHAR_TITLE);
panel->DrawTitle(MENU_CHAR_TITLE);
char text[255];
sprintf(text, "Player ID: %d", GetSQLIndex());
panel->DrawItem(ItemDrawInfo(text));
int classnum = GetCurrentClass();
if (classnum > RPG_CLASS_NONE)
{
int team = GetCachedTeam();
if ( team == TEAM_SURVIVORS)
{
sprintf(text, "Class: %s", HumanClasses[classnum]);
}
else if (team == TEAM_UNDEAD)
{
sprintf(text, "Class: %s", ZombieClasses[classnum]);
}
else
{
sprintf(text, "Class: None");
}
panel->DrawItem(ItemDrawInfo(text)); // item 1
sprintf(text, "Level: %d", GetLevel());
panel->DrawItem(ItemDrawInfo(text)); // item 2
sprintf(text, "Experience: %d", GetExperience());
panel->DrawItem(ItemDrawInfo(text)); // item 3
for (int i = 0; i < MAX_SKILLS; i++) // item 4-7
{
sprintf(text, "%s - (Level %d)", SkillNames[skills[i].iIndex], skills[i].iLevel);
panel->DrawItem(ItemDrawInfo(text));
}
}
panel->SendDisplay(GetIndex(), &g_RPGPlugin, MENU_TIME_FOREVER );
}
示例2: CreatePanelFromMenu
static cell_t CreatePanelFromMenu(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);
}
IMenuPanel *panel = menu->CreatePanel();
hndl = MakePanelHandle(panel, pContext);
if (!hndl)
{
panel->DeleteThis();
}
return hndl;
}
示例3: if
IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder order)
{
IBaseMenu *menu = md.menu;
if (!menu)
{
return NULL;
}
struct
{
unsigned int position;
ItemDrawInfo draw;
} drawItems[10];
/* Figure out how many items to draw */
IMenuStyle *style = menu->GetDrawStyle();
unsigned int pgn = menu->GetPagination();
unsigned int maxItems = style->GetMaxPageItems();
bool exitButton = (menu->GetMenuOptionFlags() & MENUFLAG_BUTTON_EXIT) == MENUFLAG_BUTTON_EXIT;
bool novoteButton = (menu->GetMenuOptionFlags() & MENUFLAG_BUTTON_NOVOTE) == MENUFLAG_BUTTON_NOVOTE;
if (pgn != MENU_NO_PAGINATION)
{
maxItems = pgn;
}
else if (exitButton)
{
maxItems--;
}
if (novoteButton)
{
maxItems--;
}
/* This is very not allowed! */
if (maxItems < 2)
{
return NULL;
}
unsigned int totalItems = menu->GetItemCount();
unsigned int startItem = 0;
/* For pagination, find the starting point. */
if (pgn != MENU_NO_PAGINATION)
{
if (order == ItemOrder_Ascending)
{
startItem = md.lastItem;
/* This shouldn't happen with well-coded menus.
* If the item is out of bounds, switch the order to
* Items_Descending and make us start from the top.
*/
if (startItem >= totalItems)
{
startItem = totalItems - 1;
order = ItemOrder_Descending;
}
}
else if (order == ItemOrder_Descending)
{
startItem = md.firstItem;
/* This shouldn't happen with well-coded menus.
* If searching backwards doesn't give us enough room,
* start from the beginning and change to ascending.
*/
if (startItem <= maxItems)
{
startItem = 0;
order = ItemOrder_Ascending;
}
}
}
/* Get our Display pointer and initialize some crap */
IMenuPanel *panel = menu->CreatePanel();
IMenuHandler *mh = md.mh;
bool foundExtra = false;
unsigned int extraItem = 0;
if (panel == NULL)
{
return NULL;
}
/**
* We keep searching until:
* 1) There are no more items
* 2) We reach one OVER the maximum number of slot items
* 3) We have reached maxItems and pagination is MENU_NO_PAGINATION
*/
unsigned int i = startItem;
unsigned int foundItems = 0;
while (totalItems)
{
ItemDrawInfo &dr = drawItems[foundItems].draw;
/* Is the item valid? */
if (menu->GetItemInfo(i, &dr) != NULL)
//.........这里部分代码省略.........