added helper function for panel text
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401367
This commit is contained in:
@@ -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()
|
||||
{
|
||||
delete this;
|
||||
|
||||
@@ -99,6 +99,7 @@ public: //IMenuPanel
|
||||
bool SetSelectableKeys(unsigned int keymap);
|
||||
unsigned int GetCurrentKey();
|
||||
bool SetCurrentKey(unsigned int key);
|
||||
int GetAmountRemaining();
|
||||
private:
|
||||
String m_BufferText;
|
||||
String m_Title;
|
||||
|
||||
@@ -342,6 +342,12 @@ bool CValveMenuDisplay::SetSelectableKeys(unsigned int keymap)
|
||||
return false;
|
||||
}
|
||||
|
||||
int CValveMenuDisplay::GetAmountRemaining()
|
||||
{
|
||||
/* :TODO: this is a lie, but nothing really seems meaningful... */
|
||||
return -1;
|
||||
}
|
||||
|
||||
CValveMenu::CValveMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner) :
|
||||
CBaseMenu(pHandler, &g_ValveMenuStyle, pOwner),
|
||||
m_IntroColor(255, 0, 0, 255)
|
||||
|
||||
@@ -102,6 +102,7 @@ public:
|
||||
bool SetSelectableKeys(unsigned int keymap);
|
||||
unsigned int GetCurrentKey();
|
||||
bool SetCurrentKey(unsigned int key);
|
||||
int GetAmountRemaining();
|
||||
private:
|
||||
KeyValues *m_pKv;
|
||||
unsigned int m_NextPos;
|
||||
|
||||
@@ -1217,6 +1217,20 @@ static cell_t GetPanelCurrentKey(IPluginContext *pContext, const cell_t *params)
|
||||
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)
|
||||
{
|
||||
Handle_t hndl = (Handle_t)params[1];
|
||||
@@ -1355,6 +1369,7 @@ REGISTER_NATIVES(menuNatives)
|
||||
{"GetMenuStyle", GetMenuStyle},
|
||||
{"GetMenuStyleHandle", GetMenuStyleHandle},
|
||||
{"GetMenuTitle", GetMenuTitle},
|
||||
{"GetPanelTextRemaining", GetPanelTextRemaining},
|
||||
{"GetPanelCurrentKey", GetPanelCurrentKey},
|
||||
{"GetPanelStyle", GetPanelStyle},
|
||||
{"InsertMenuItem", InsertMenuItem},
|
||||
|
||||
Reference in New Issue
Block a user