added helper function for panel text
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401367
This commit is contained in:
parent
2a3de44ddb
commit
25f045bdea
@ -361,6 +361,16 @@ void CRadioDisplay::SendRawDisplay(int client, unsigned int time)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CRadioDisplay::GetAmountRemaining()
|
||||||
|
{
|
||||||
|
size_t amt = m_Title.size() + 1 + m_BufferText.size();
|
||||||
|
if (amt >= 511)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return (int)(511 - amt);
|
||||||
|
}
|
||||||
|
|
||||||
void CRadioDisplay::DeleteThis()
|
void CRadioDisplay::DeleteThis()
|
||||||
{
|
{
|
||||||
delete this;
|
delete this;
|
||||||
|
@ -99,6 +99,7 @@ public: //IMenuPanel
|
|||||||
bool SetSelectableKeys(unsigned int keymap);
|
bool SetSelectableKeys(unsigned int keymap);
|
||||||
unsigned int GetCurrentKey();
|
unsigned int GetCurrentKey();
|
||||||
bool SetCurrentKey(unsigned int key);
|
bool SetCurrentKey(unsigned int key);
|
||||||
|
int GetAmountRemaining();
|
||||||
private:
|
private:
|
||||||
String m_BufferText;
|
String m_BufferText;
|
||||||
String m_Title;
|
String m_Title;
|
||||||
|
@ -342,6 +342,12 @@ bool CValveMenuDisplay::SetSelectableKeys(unsigned int keymap)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CValveMenuDisplay::GetAmountRemaining()
|
||||||
|
{
|
||||||
|
/* :TODO: this is a lie, but nothing really seems meaningful... */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
CValveMenu::CValveMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner) :
|
CValveMenu::CValveMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner) :
|
||||||
CBaseMenu(pHandler, &g_ValveMenuStyle, pOwner),
|
CBaseMenu(pHandler, &g_ValveMenuStyle, pOwner),
|
||||||
m_IntroColor(255, 0, 0, 255)
|
m_IntroColor(255, 0, 0, 255)
|
||||||
|
@ -102,6 +102,7 @@ public:
|
|||||||
bool SetSelectableKeys(unsigned int keymap);
|
bool SetSelectableKeys(unsigned int keymap);
|
||||||
unsigned int GetCurrentKey();
|
unsigned int GetCurrentKey();
|
||||||
bool SetCurrentKey(unsigned int key);
|
bool SetCurrentKey(unsigned int key);
|
||||||
|
int GetAmountRemaining();
|
||||||
private:
|
private:
|
||||||
KeyValues *m_pKv;
|
KeyValues *m_pKv;
|
||||||
unsigned int m_NextPos;
|
unsigned int m_NextPos;
|
||||||
|
@ -1217,6 +1217,20 @@ static cell_t GetPanelCurrentKey(IPluginContext *pContext, const cell_t *params)
|
|||||||
return panel->GetCurrentKey();
|
return panel->GetCurrentKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t GetPanelTextRemaining(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->GetAmountRemaining();
|
||||||
|
}
|
||||||
|
|
||||||
static cell_t SetPanelCurrentKey(IPluginContext *pContext, const cell_t *params)
|
static cell_t SetPanelCurrentKey(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
Handle_t hndl = (Handle_t)params[1];
|
Handle_t hndl = (Handle_t)params[1];
|
||||||
@ -1355,6 +1369,7 @@ REGISTER_NATIVES(menuNatives)
|
|||||||
{"GetMenuStyle", GetMenuStyle},
|
{"GetMenuStyle", GetMenuStyle},
|
||||||
{"GetMenuStyleHandle", GetMenuStyleHandle},
|
{"GetMenuStyleHandle", GetMenuStyleHandle},
|
||||||
{"GetMenuTitle", GetMenuTitle},
|
{"GetMenuTitle", GetMenuTitle},
|
||||||
|
{"GetPanelTextRemaining", GetPanelTextRemaining},
|
||||||
{"GetPanelCurrentKey", GetPanelCurrentKey},
|
{"GetPanelCurrentKey", GetPanelCurrentKey},
|
||||||
{"GetPanelStyle", GetPanelStyle},
|
{"GetPanelStyle", GetPanelStyle},
|
||||||
{"InsertMenuItem", InsertMenuItem},
|
{"InsertMenuItem", InsertMenuItem},
|
||||||
|
@ -644,6 +644,20 @@ native bool:SetPanelKeys(Handle:panel, keys);
|
|||||||
*/
|
*/
|
||||||
native bool:SendPanelToClient(Handle:panel, client, MenuHandler:handler, time);
|
native bool:SendPanelToClient(Handle:panel, client, MenuHandler:handler, time);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the amount of text the menu can still hold. If this is
|
||||||
|
* limit is reached or overflowed, the text is silently truncated.
|
||||||
|
*
|
||||||
|
* Radio menus: Currently 511 characters (512 bytes).
|
||||||
|
* Valve menus: Currently -1 (no meaning).
|
||||||
|
*
|
||||||
|
* @param panel A MenuPanel Handle.
|
||||||
|
* @return Number of characters that the menu can still hold,
|
||||||
|
* or -1 if there is no known limit.
|
||||||
|
* @error Invalid Handle.
|
||||||
|
*/
|
||||||
|
native GetPanelTextRemaining(Handle:panel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns the current key position.
|
* @brief Returns the current key position.
|
||||||
*
|
*
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include <IHandleSys.h>
|
#include <IHandleSys.h>
|
||||||
|
|
||||||
#define SMINTERFACE_MENUMANAGER_NAME "IMenuManager"
|
#define SMINTERFACE_MENUMANAGER_NAME "IMenuManager"
|
||||||
#define SMINTERFACE_MENUMANAGER_VERSION 11
|
#define SMINTERFACE_MENUMANAGER_VERSION 12
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file IMenuManager.h
|
* @file IMenuManager.h
|
||||||
@ -312,6 +312,16 @@ namespace SourceMod
|
|||||||
* @return True on success, false otherwise.
|
* @return True on success, false otherwise.
|
||||||
*/
|
*/
|
||||||
virtual bool SetCurrentKey(unsigned int key) =0;
|
virtual bool SetCurrentKey(unsigned int key) =0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the number of characters that can be added to the
|
||||||
|
* menu. The internal buffer is truncated if overflowed; this is for
|
||||||
|
* manual truncation/wrapping purposes.
|
||||||
|
*
|
||||||
|
* @return Number of bytes available. If the result is
|
||||||
|
* -1, then the panel has no text limit.
|
||||||
|
*/
|
||||||
|
virtual int GetAmountRemaining() =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user