added request amb320

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40846
This commit is contained in:
David Anderson 2007-05-23 02:26:43 +00:00
parent 220aec7789
commit 82c578f32d
7 changed files with 106 additions and 0 deletions

View File

@ -198,6 +198,23 @@ void CRadioDisplay::Reset()
keys = 0;
}
unsigned int CRadioDisplay::GetCurrentKey()
{
return m_NextPos;
}
bool CRadioDisplay::SetCurrentKey(unsigned int key)
{
if (key < m_NextPos || m_NextPos > 10)
{
return false;
}
m_NextPos = key;
return true;
}
bool CRadioDisplay::SendDisplay(int client, IMenuHandler *handler, unsigned int time)
{
return g_RadioMenuStyle.DoClientMenu(client, this, handler, time);

View File

@ -79,6 +79,8 @@ public: //IMenuPanel
void DeleteThis();
void SendRawDisplay(int client, unsigned int time);
bool SetSelectableKeys(unsigned int keymap);
unsigned int GetCurrentKey();
bool SetCurrentKey(unsigned int key);
private:
String m_BufferText;
String m_Title;

View File

@ -194,6 +194,23 @@ void CValveMenuDisplay::Reset()
m_TitleDrawn = false;
}
unsigned int CValveMenuDisplay::GetCurrentKey()
{
return m_NextPos;
}
bool CValveMenuDisplay::SetCurrentKey(unsigned int key)
{
if (key < m_NextPos || key > 9)
{
return false;
}
m_NextPos = key;
return true;
}
bool CValveMenuDisplay::SetExtOption(MenuOption option, const void *valuePtr)
{
if (option == MenuOption_IntroMessage)

View File

@ -83,6 +83,8 @@ public:
void SendRawDisplay(int client, int priority, unsigned int time);
void DeleteThis();
bool SetSelectableKeys(unsigned int keymap);
unsigned int GetCurrentKey();
bool SetCurrentKey(unsigned int key);
private:
KeyValues *m_pKv;
unsigned int m_NextPos;

View File

@ -869,6 +869,34 @@ static cell_t SetPanelKeys(IPluginContext *pContext, const cell_t *params)
return panel->SetSelectableKeys(params[2]);
}
static cell_t GetPanelCurrentKey(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IMenuPanel *panel;
if ((err=ReadPanelHandle(hndl, &panel)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
return panel->GetCurrentKey();
}
static cell_t SetPanelCurrentKey(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = (Handle_t)params[1];
HandleError err;
IMenuPanel *panel;
if ((err=ReadPanelHandle(hndl, &panel)) != HandleError_None)
{
return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err);
}
return panel->SetCurrentKey(params[2]) ? 1 : 0;
}
REGISTER_NATIVES(menuNatives)
{
{"AddMenuItem", AddMenuItem},
@ -890,6 +918,7 @@ REGISTER_NATIVES(menuNatives)
{"GetMenuPagination", GetMenuPagination},
{"GetMenuStyle", GetMenuStyle},
{"GetMenuStyleHandle", GetMenuStyleHandle},
{"GetPanelCurrentKey", GetPanelCurrentKey},
{"GetPanelStyle", GetPanelStyle},
{"InsertMenuItem", InsertMenuItem},
{"RemoveAllMenuItems", RemoveAllMenuItems},
@ -898,6 +927,7 @@ REGISTER_NATIVES(menuNatives)
{"SetMenuExitButton", SetMenuExitButton},
{"SetMenuPagination", SetMenuPagination},
{"SetMenuTitle", SetMenuTitle},
{"SetPanelCurrentKey", SetPanelCurrentKey},
{"SetPanelTitle", SetPanelTitle},
{"SetPanelKeys", SetPanelKeys},
{NULL, NULL},

View File

@ -509,3 +509,24 @@ native bool:SetPanelKeys(Handle:panel, keys);
* @error Invalid Handle.
*/
native bool:SendPanelToClient(Handle:panel, client, MenuHandler:handler, time);
/**
* @brief Returns the current key position.
*
* @param panel A MenuPanel Handle.
* @return Current key position starting at 1.
* @error Invalid Handle.
*/
native GetPanelCurrentKey(Handle:panel);
/**
* @brief Sets the next key position. This cannot be used
* to traverse backwards.
*
* @param panel A MenuPanel Handle.
* @param key Key that is greater or equal to
* GetPanelCurrentKey().
* @return True on success, false otherwise.
* @error Invalid Handle.
*/
native bool:SetPanelCurrentKey(Handle:panel, key);

View File

@ -236,6 +236,23 @@ namespace SourceMod
* @return True on success, false if not supported.
*/
virtual bool SetSelectableKeys(unsigned int keymap) =0;
/**
* @brief Returns the current key position.
*
* @return Current key position starting at 1.
*/
virtual unsigned int GetCurrentKey() =0;
/**
* @brief Sets the next key position. This cannot be used
* to traverse backwards.
*
* @param key Key that is greater or equal to
* GetCurrentKey().
* @return True on success, false otherwise.
*/
virtual bool SetCurrentKey(unsigned int key) =0;
};
/**