Newmenus: Add Menu::Close to remove a bunch of redundant code

This commit is contained in:
Valentin Grünbacher 2014-05-21 18:51:55 +02:00
parent 6a4c55de7d
commit 34337fb959
2 changed files with 22 additions and 1 deletions

View File

@ -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<cell>(player),
static_cast<cell>(thisId),
static_cast<cell>(status));
}
const char *Menu::GetTextString(int player, page_t page, int &keys)
{
page_t pages = GetPageCount();

View File

@ -127,6 +127,7 @@ 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();