added helper function for panel text

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401367
This commit is contained in:
David Anderson
2007-08-19 18:34:36 +00:00
parent 2a3de44ddb
commit 25f045bdea
7 changed files with 58 additions and 1 deletions
+10
View File
@@ -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;
+1
View File
@@ -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;
+6
View File
@@ -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)
+1
View File
@@ -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;
+15
View File
@@ -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},