Allow sending panels to SourceTV client via settings

This commit is contained in:
A1mDev 2024-12-30 23:42:21 +07:00
parent 57bdd9fdb0
commit 93bb5ebda0
7 changed files with 45 additions and 2 deletions

View File

@ -419,7 +419,19 @@ bool BaseMenuStyle::DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh,
time);
#endif
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
if (!pPlayer || pPlayer->IsFakeClient() || !pPlayer->IsInGame())
if (!pPlayer || !pPlayer->IsInGame())
{
return false;
}
if (pPlayer->IsSourceTV())
{
if (!menu->IsAllowSendToSourceTV())
{
return false;
}
}
else if (pPlayer->IsFakeClient())
{
return false;
}

View File

@ -332,6 +332,7 @@ void CRadioDisplay::Reset()
m_Title.assign("");
m_NextPos = 1;
keys = 0;
m_SendToSourceTV = false;
}
bool CRadioDisplay::DirectSet(const char *str)
@ -359,6 +360,16 @@ bool CRadioDisplay::SetCurrentKey(unsigned int key)
return true;
}
bool CRadioDisplay::IsAllowSendToSourceTV()
{
return m_SendToSourceTV;
}
void CRadioDisplay::SetSendToSourceTV(bool type)
{
m_SendToSourceTV = type;
}
bool CRadioDisplay::SendDisplay(int client, IMenuHandler *handler, unsigned int time)
{
return g_RadioMenuStyle.DoClientMenu(client, this, handler, time);

View File

@ -132,11 +132,14 @@ public: //IMenuPanel
int GetAmountRemaining();
unsigned int GetApproxMemUsage();
bool DirectSet(const char *str);
bool IsAllowSendToSourceTV();
void SetSendToSourceTV(bool type);
private:
String m_BufferText;
String m_Title;
unsigned int m_NextPos;
int keys;
bool m_SendToSourceTV;
};
class CRadioMenu : public CBaseMenu

View File

@ -109,6 +109,8 @@ public:
int GetAmountRemaining();
unsigned int GetApproxMemUsage();
bool DirectSet(const char *str) { return false; }
bool IsAllowSendToSourceTV() { return false; }
void SetSendToSourceTV(bool type) {}
private:
KeyValues *m_pKv;
unsigned int m_NextPos;

View File

@ -1308,6 +1308,8 @@ static cell_t SendPanelToClient(IPluginContext *pContext, const cell_t *params)
}
CPanelHandler *handler = g_MenuHelpers.GetPanelHandler(pFunction);
panel->SetSendToSourceTV((params[0] >= 5) ? params[5] : false);
if (!panel->SendDisplay(params[2], handler, params[4]))
{
g_MenuHelpers.FreePanelHandler(handler);

View File

@ -1061,10 +1061,11 @@ native bool SetPanelKeys(Handle panel, int keys);
* @param client A client to draw to.
* @param handler The MenuHandler function to catch actions with.
* @param time Time to hold the menu for.
* @param sendToSTV Allow this menu to be sent to SourceTV
* @return True on success, false on failure.
* @error Invalid Handle.
*/
native bool SendPanelToClient(Handle panel, int client, MenuHandler handler, int time);
native bool SendPanelToClient(Handle panel, int client, MenuHandler handler, int time, bool sendToSTV = false);
/**
* @brief Returns the amount of text the menu can still hold. If this is

View File

@ -341,6 +341,18 @@ namespace SourceMod
* @return True if supported, otherwise false.
*/
virtual bool DirectSet(const char *str) =0;
/**
* @brief Enabled or disabled sending menus to SourceTV
*
* @return True if enabled, otherwise false.
*/
virtual bool IsAllowSendToSourceTV() = 0;
/**
* @brief Enable or disable sending menus to SourceTV
*/
virtual void SetSendToSourceTV(bool type) = 0;
};
/**