MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / OnMenuSelect2

Method OnMenuSelect2

extensions/topmenus/TopMenu.cpp:566–609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

564}
565
566void TopMenu::OnMenuSelect2(IBaseMenu *menu, int client, unsigned int item, unsigned int item_on_page)
567{
568 const char *item_name = menu->GetItemInfo(item, NULL);
569 if (!item_name)
570 {
571 return;
572 }
573
574 topmenu_object_t *obj;
575 topmenu_player_t *pClient = &m_clients[client];
576 if (!m_ObjLookup.retrieve(item_name, &obj))
577 return;
578
579 /* We now have the object... what do we do with it? */
580 if (obj->type == TopMenuObject_Category)
581 {
582 /* If it's a category, the user wants to view it.. */
583 assert(obj->cat_id < m_Categories.size());
584 assert(m_Categories[obj->cat_id]->obj == obj);
585 pClient->last_root_pos = item_on_page;
586 if (!DisplayCategory(client, obj->cat_id, MENU_TIME_FOREVER, false))
587 {
588 /* If we can't display the category, re-display the root menu.
589 * This code should be dead as of bug 3256, which disables categories
590 * that cannot be displayed.
591 */
592 DisplayMenu(client, MENU_TIME_FOREVER, TopMenuPosition_LastRoot);
593 }
594 }
595 else
596 {
597 pClient->last_position = item_on_page;
598
599 /* Re-check access in case this user had their credentials revoked */
600 if (obj->cmdname[0] != '\0' && !adminsys->CheckAccess(client, obj->cmdname, obj->flags, false))
601 {
602 DisplayMenu(client, 0, TopMenuPosition_LastCategory);
603 return;
604 }
605
606 /* Pass the information on to the callback */
607 obj->callbacks->OnTopMenuSelectOption(this, client, obj->object_id);
608 }
609}
610
611void TopMenu::OnMenuDrawItem(IBaseMenu *menu, int client, unsigned int item, unsigned int &style)
612{

Callers

nothing calls this directly

Calls 6

DisplayMenuFunction · 0.85
GetItemInfoMethod · 0.80
OnTopMenuSelectOptionMethod · 0.80
retrieveMethod · 0.45
sizeMethod · 0.45
CheckAccessMethod · 0.45

Tested by

no test coverage detected