added key selection setting

fixed amb309

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40825
This commit is contained in:
David Anderson 2007-05-21 01:11:37 +00:00
parent 98374f2ce6
commit daceab19cd
7 changed files with 53 additions and 1 deletions

View File

@ -286,6 +286,8 @@ void CRadioDisplay::SendRawDisplay(int client, unsigned int time)
cell_t players[1] = {client};
int _sel_keys = (keys == 0) ? (1<<9) : keys;
char *ptr = buffer;
char save = 0;
while (true)
@ -296,7 +298,7 @@ void CRadioDisplay::SendRawDisplay(int client, unsigned int time)
ptr[240] = '\0';
}
bf_write *buffer = g_UserMsgs.StartMessage(g_ShowMenuId, players, 1, 0);
buffer->WriteWord(keys);
buffer->WriteWord(_sel_keys);
buffer->WriteChar(time ? time : -1);
buffer->WriteByte( (len > 240) ? 1 : 0 );
buffer->WriteString(ptr);
@ -317,6 +319,11 @@ void CRadioDisplay::DeleteThis()
delete this;
}
bool CRadioDisplay::SetSelectableKeys(unsigned int keymap)
{
keys = (signed)keymap;
}
CRadioMenu::CRadioMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner) :
CBaseMenu(pHandler, &g_RadioMenuStyle, pOwner)
{

View File

@ -78,6 +78,7 @@ public: //IMenuPanel
bool SendDisplay(int client, IMenuHandler *handler, unsigned int time);
void DeleteThis();
void SendRawDisplay(int client, unsigned int time);
bool SetSelectableKeys(unsigned int keymap);
private:
String m_BufferText;
String m_Title;

View File

@ -305,6 +305,11 @@ bool CValveMenuDisplay::SendDisplay(int client, IMenuHandler *handler, unsigned
return g_ValveMenuStyle.DoClientMenu(client, this, handler, time);
}
bool CValveMenuDisplay::SetSelectableKeys(unsigned int keymap)
{
return false;
}
CValveMenu::CValveMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner) :
CBaseMenu(pHandler, &g_ValveMenuStyle, pOwner),
m_IntroColor(255, 0, 0, 255)

View File

@ -82,6 +82,7 @@ public:
bool CanDrawItem(unsigned int drawFlags);
void SendRawDisplay(int client, int priority, unsigned int time);
void DeleteThis();
bool SetSelectableKeys(unsigned int keymap);
private:
KeyValues *m_pKv;
unsigned int m_NextPos;

View File

@ -855,6 +855,20 @@ static cell_t SendPanelToClient(IPluginContext *pContext, const cell_t *params)
return 1;
}
static cell_t SetPanelKeys(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->SetSelectableKeys(params[2]);
}
REGISTER_NATIVES(menuNatives)
{
{"AddMenuItem", AddMenuItem},
@ -885,5 +899,6 @@ REGISTER_NATIVES(menuNatives)
{"SetMenuPagination", SetMenuPagination},
{"SetMenuTitle", SetMenuTitle},
{"SetPanelTitle", SetPanelTitle},
{"SetPanelKeys", SetPanelKeys},
{NULL, NULL},
};

View File

@ -479,6 +479,17 @@ native DrawPanelText(Handle:panel, const String:text[]);
*/
native CanPanelDrawFlags(Handle:panel, style);
/**
* Sets the selectable key map of a panel. This is not supported by
* all styles (only by Radio, as of this writing).
*
* @param keys An integer where each bit N allows key
* N+1 to be selected. If no keys are selectable,
* then key 0 (bit 9) is automatically set.
* @return True if supported, false otherwise.
*/
native bool:SetPanelKeys(Handle:panel, keys);
/**
* Sends a panel to a client. Unlike full menus, the handler
* function will only receive the following actions, both of

View File

@ -224,6 +224,18 @@ namespace SourceMod
* @brief Destroys the display object.
*/
virtual void DeleteThis() =0;
/**
* @brief Sets the selectable key map. Returns false if the function
* is not supported.
*
* @param keys A bit string where each bit N-1 specifies
* that key N is selectable (key 0 is bit 9).
* If the selectable key map is 0, it will be
* automatically set to allow 0.
* @return True on success, false if not supported.
*/
virtual bool SetSelectableKeys(unsigned int keymap) =0;
};
/**