From 34337fb95922d9d0a15dc353e2f64b86254f325a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Gr=C3=BCnbacher?= Date: Wed, 21 May 2014 18:51:55 +0200 Subject: [PATCH] Newmenus: Add Menu::Close to remove a bunch of redundant code --- amxmodx/newmenus.cpp | 20 ++++++++++++++++++++ amxmodx/newmenus.h | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/amxmodx/newmenus.cpp b/amxmodx/newmenus.cpp index d94d6f45..c252bedd 100755 --- a/amxmodx/newmenus.cpp +++ b/amxmodx/newmenus.cpp @@ -321,6 +321,26 @@ bool Menu::Display(int player, page_t page) return true; } +void Menu::Close(int player) +{ + CPlayer *pPlayer = GET_PLAYER_POINTER_I(player); + + int status; + if (gpGlobals->time > pPlayer->menuexpire) + status = MENU_TIMEOUT; + else + status = MENU_EXIT; + + pPlayer->keys = 0; + pPlayer->menu = 0; + pPlayer->newmenu = -1; + + executeForwards(func, + static_cast(player), + static_cast(thisId), + static_cast(status)); +} + const char *Menu::GetTextString(int player, page_t page, int &keys) { page_t pages = GetPageCount(); diff --git a/amxmodx/newmenus.h b/amxmodx/newmenus.h index 0e7f6579..e90b807e 100755 --- a/amxmodx/newmenus.h +++ b/amxmodx/newmenus.h @@ -127,7 +127,8 @@ public: const char *GetTextString(int player, page_t page, int &keys); bool Display(int player, page_t page); - + void Close(int player); + int PagekeyToItem(page_t page, item_t key); int GetMenuMenuid(); public: