diff --git a/core/MenuManager.cpp b/core/MenuManager.cpp index 7efcf6cd..7d9b102e 100644 --- a/core/MenuManager.cpp +++ b/core/MenuManager.cpp @@ -368,7 +368,7 @@ IMenuDisplay *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder o /* There were no items to draw! */ if (!foundItems) { - delete display; + display->DeleteThis(); return NULL; } @@ -520,9 +520,15 @@ skip_search: slots[position].type = ItemSel_None; } } - ItemDrawInfo dr(text, 0); + + /* Put a fake spacer before control stuff, if possible */ + { + ItemDrawInfo draw("", ITEMDRAW_RAWLINE|ITEMDRAW_SPACER); + display->DrawItem(draw); + } /* PREVIOUS */ + ItemDrawInfo dr(text, 0); if (displayPrev || canDrawDisabled) { CorePlayerTranslate(client, text, sizeof(text), "Back", NULL); diff --git a/core/MenuStyle_Base.cpp b/core/MenuStyle_Base.cpp index eb139b50..976d5dd4 100644 --- a/core/MenuStyle_Base.cpp +++ b/core/MenuStyle_Base.cpp @@ -376,7 +376,7 @@ bool BaseMenuStyle::DoClientMenu(int client, CBaseMenu *menu, IMenuHandler *mh, SendDisplay(client, display); /* Free the display pointer */ - delete display; + display->DeleteThis(); /* We can be interrupted again! */ player->bAutoIgnore = false; @@ -403,7 +403,7 @@ bool BaseMenuStyle::RedoClientMenu(int client, ItemOrder order) SendDisplay(client, display); - delete display; + display->DeleteThis(); player->bAutoIgnore = false; diff --git a/core/MenuStyle_Valve.cpp b/core/MenuStyle_Valve.cpp index 7d8282df..fb1e6e04 100644 --- a/core/MenuStyle_Valve.cpp +++ b/core/MenuStyle_Valve.cpp @@ -177,6 +177,11 @@ CValveMenuDisplay::CValveMenuDisplay(CValveMenu *pMenu) m_pKv->SetString("title", pMenu->m_IntroMsg); } +void CValveMenuDisplay::DeleteThis() +{ + delete this; +} + CValveMenuDisplay::~CValveMenuDisplay() { m_pKv->deleteThis(); diff --git a/core/MenuStyle_Valve.h b/core/MenuStyle_Valve.h index 78d1a887..039bebe3 100644 --- a/core/MenuStyle_Valve.h +++ b/core/MenuStyle_Valve.h @@ -81,6 +81,7 @@ public: bool SetExtOption(MenuOption option, const void *valuePtr); bool CanDrawItem(unsigned int drawFlags); void SendRawDisplay(int client, int priority, unsigned int time); + void DeleteThis(); private: KeyValues *m_pKv; unsigned int m_NextPos; @@ -92,13 +93,14 @@ class CValveMenu : public CBaseMenu friend class CValveMenuDisplay; public: CValveMenu(); -public: +public: //IBaseMenu bool SetExtOption(MenuOption option, const void *valuePtr); IMenuDisplay *CreateDisplay(); bool GetExitButton(); bool SetExitButton(bool set); bool SetPagination(unsigned int itemsPerPage); bool Display(int client, IMenuHandler *handler, unsigned int time); +public: //CBaseMenu void Cancel_Finally(); private: Color m_IntroColor; diff --git a/public/IMenuManager.h b/public/IMenuManager.h index 3f182011..db2a0dd3 100644 --- a/public/IMenuManager.h +++ b/public/IMenuManager.h @@ -117,20 +117,18 @@ namespace SourceMod #define MENU_NO_PAGINATION -1 /**< Menu should not be paginated (10 items max) */ #define MENU_TIME_FOREVER 0 /**< Menu should be displayed as long as possible */ - #define MENU_DETAIL_NOITEMCOLORS (1<<0) /**< Disables extended colors; menus will be white only */ - /** * @brief Extended menu options. */ enum MenuOption { - MenuOption_DetailFlags, /**< INT *: A combination of MENU_DETAIL properties (default=0) */ MenuOption_IntroMessage, /**< CONST CHAR *: Valve menus only; defaults to: "You have a menu, hit ESC" */ MenuOption_IntroColor, /**< INT[4]: Valve menus only; specifies the intro message colour using R,G,B,A (defaults to 255,0,0,255) */ + MenuOption_Priority, /**< INT *: Valve menus only; priority (less is higher) */ }; /** @@ -151,10 +149,6 @@ namespace SourceMod */ class IMenuDisplay { - public: - virtual ~IMenuDisplay() - { - } public: /** * @brief Returns the parent IMenuStyle pointer. @@ -223,6 +217,11 @@ namespace SourceMod * @return True on success, false otherwise. */ virtual bool SendDisplay(int client, IMenuHandler *handler, unsigned int time) =0; + + /** + * @brief Destroys the display object. + */ + virtual void DeleteThis() =0; }; /** @@ -252,7 +251,7 @@ namespace SourceMod /** * @brief Creates an IMenuDisplay object. * - * Note: the object should be freed using delete. + * Note: the object should be freed using ::DeleteThis. * * @return IMenuDisplay object. */ @@ -400,7 +399,7 @@ namespace SourceMod * @brief Creates a new IMenuDisplay object using extended options specific * to the IMenuStyle parent. Titles, items, etc, are not copied. * - * Note: The object should be freed with delete. + * Note: The object should be freed with IMenuDisplay::DeleteThis. * * @return IMenuDisplay pointer. */ @@ -638,7 +637,7 @@ namespace SourceMod * @return IDisplay pointer, or NULL if no items could be * found in the IBaseMenu pointer, or NULL if any * other error occurred. Any valid pointer must - * be freed using delete. + * be freed using IMenuDisplay::DeleteThis. */ virtual IMenuDisplay *RenderMenu(int client, menu_states_t &states, ItemOrder order) =0; };