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

Method RenderMenu

core/MenuManager.cpp:236–714  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234}
235
236IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder order)
237{
238 IBaseMenu *menu = md.menu;
239
240 if (!menu)
241 {
242 return NULL;
243 }
244
245 struct
246 {
247 unsigned int position;
248 ItemDrawInfo draw;
249 } drawItems[10];
250
251 /* Figure out how many items to draw */
252 IMenuStyle *style = menu->GetDrawStyle();
253 unsigned int pgn = menu->GetPagination();
254 unsigned int maxItems = style->GetMaxPageItems();
255 bool exitButton = (menu->GetMenuOptionFlags() & MENUFLAG_BUTTON_EXIT) == MENUFLAG_BUTTON_EXIT;
256 bool novoteButton = (menu->GetMenuOptionFlags() & MENUFLAG_BUTTON_NOVOTE) == MENUFLAG_BUTTON_NOVOTE;
257
258 if (pgn != MENU_NO_PAGINATION)
259 {
260 maxItems = pgn;
261 }
262 else if (exitButton)
263 {
264 maxItems--;
265 }
266
267 if (novoteButton)
268 {
269 maxItems--;
270 }
271
272 /* This is very not allowed! */
273 if (maxItems < 2)
274 {
275 return NULL;
276 }
277
278 unsigned int totalItems = menu->GetItemCount();
279 unsigned int startItem = 0;
280
281 /* For pagination, find the starting point. */
282 if (pgn != MENU_NO_PAGINATION)
283 {
284 if (order == ItemOrder_Ascending)
285 {
286 startItem = md.lastItem;
287 /* This shouldn't happen with well-coded menus.
288 * If the item is out of bounds, switch the order to
289 * Items_Descending and make us start from the top.
290 */
291 if (startItem >= totalItems)
292 {
293 startItem = totalItems - 1;

Callers 2

DoClientMenuMethod · 0.80
RedoClientMenuMethod · 0.80

Calls 15

IsSlotItemFunction · 0.85
GetDrawStyleMethod · 0.80
GetPaginationMethod · 0.80
GetMenuOptionFlagsMethod · 0.80
GetItemCountMethod · 0.80
GetItemInfoMethod · 0.80
GetDefaultTitleMethod · 0.80
GetMaxPageItemsMethod · 0.45
CreatePanelMethod · 0.45
OnMenuDrawItemMethod · 0.45
DeleteThisMethod · 0.45
DrawItemMethod · 0.45

Tested by

no test coverage detected