Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions sp/src/game/client/c_baseplayer.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -1133,6 +1133,9 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2 | IN_VALIDVGUIINPUT);
#ifdef MAPBASE
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
return;
}
#else
Expand All@@ -1142,6 +1145,10 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
#ifdef MAPBASE
pCmd->buttons &= ~(IN_USE | IN_ATTACK3);
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
return;
}
#endif
Expand DownExpand Up@@ -1206,6 +1213,10 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
#ifdef MAPBASE
pCmd->buttons &= ~(IN_USE | IN_ATTACK3);
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
}
}

Expand Down
129 changes: 100 additions & 29 deletions sp/src/game/client/c_vguiscreen.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,14 @@ extern vgui::IInputInternal *g_InputInternal;
#define VGUI_SCREEN_MODE_RADIUS 80

//Precache the materials
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectVGuiScreen)
CLIENTEFFECT_MATERIAL("engine/writez")
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectVGuiScreen)
CLIENTEFFECT_MATERIAL("engine/writez")
CLIENTEFFECT_REGISTER_END()

#ifdef MAPBASE
C_EntityClassList<C_VGuiScreen> g_VGUIScreenList;
template <> C_VGuiScreen* C_EntityClassList<C_VGuiScreen>::m_pClassList = NULL;
#endif // MAPBASE

// ----------------------------------------------------------------------------- //
// This is a cache of preloaded keyvalues.
Expand DownExpand Up@@ -102,11 +106,19 @@ C_VGuiScreen::C_VGuiScreen()

m_WriteZMaterial.Init( "engine/writez", TEXTURE_GROUP_VGUI );
m_OverlayMaterial.Init( m_WriteZMaterial );

#ifdef MAPBASE
g_VGUIScreenList.Insert(this);
#endif // MAPBASE
}

C_VGuiScreen::~C_VGuiScreen()
{
DestroyVguiScreen();

#ifdef MAPBASE
g_VGUIScreenList.Remove(this);
#endif // MAPBASE
}

//-----------------------------------------------------------------------------
Expand DownExpand Up@@ -416,35 +428,70 @@ void C_VGuiScreen::ClientThink( void )
int px = (int)(u * m_nPixelWidth + 0.5f);
int py = (int)(v * m_nPixelHeight + 0.5f);

#ifndef MAPBASE
// Generate mouse input commands
if ((px != m_nOldPx) || (py != m_nOldPy))
{
g_InputInternal->InternalCursorMoved( px, py );
g_InputInternal->InternalCursorMoved(px, py);

m_nOldPx = px;
m_nOldPy = py;
}

if (m_nButtonPressed & IN_ATTACK)
{
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_PRESSED);
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_LEFT);
}
if (m_nButtonPressed & IN_ATTACK2)
{
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_RIGHT);
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_RIGHT);
}
if ((m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus
if ((m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus
{
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_LEFT);
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_LEFT);
}
if (m_nButtonReleased & IN_ATTACK2)
{
g_InputInternal->SetMouseCodeState( MOUSE_RIGHT, vgui::BUTTON_RELEASED );
g_InputInternal->InternalMouseReleased( MOUSE_RIGHT );
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_RIGHT);
}
#else
vgui::VPANEL focus = g_InputInternal->GetMouseOver();
// Generate mouse input commands
if ((px != m_nOldPx) || (py != m_nOldPy))
{
g_InputInternal->UpdateCursorPosInternal(px, py);

m_nOldPx = px;
m_nOldPy = py;

focus = pPanel->IsWithinTraverse(px, py, true);
g_InputInternal->SetMouseFocus(focus);
vgui::ivgui()->PostMessage(focus, new KeyValues("CursorMoved", "xpos", px, "ypos", py), NULL);
}

for (int i = 0; i < 2; i++)
{
const int nBit = i ? IN_ATTACK2 : (IN_ATTACK | IN_USE);
const vgui::MouseCode nButton = i ? MOUSE_RIGHT : MOUSE_LEFT;

if ((m_nButtonReleased & nBit) || ((m_nButtonState & nBit) && m_bLoseThinkNextFrame)) // for a button release on loosing focus
{
g_InputInternal->SetMouseCodeState(nButton, vgui::BUTTON_RELEASED);
vgui::ivgui()->PostMessage(focus, new KeyValues("MouseReleased", "code", nButton), NULL);
}
else if (m_nButtonPressed & nBit)
{
g_InputInternal->SetMouseCodeState(nButton, vgui::BUTTON_PRESSED);
vgui::ivgui()->PostMessage(focus, new KeyValues("MousePressed", "code", nButton), NULL);
}
}
#endif // !MAPBASE


if ( m_bLoseThinkNextFrame == true )
{
m_bLoseThinkNextFrame = false;
Expand DownExpand Up@@ -627,36 +674,37 @@ bool C_VGuiScreen::IsInputOnlyToOwner( void )
return (m_fScreenFlags & VGUI_SCREEN_ONLY_USABLE_BY_OWNER) != 0;
}

#ifndef MAPBASE
//-----------------------------------------------------------------------------
//
// Enumator class for finding vgui screens close to the local player
//
//-----------------------------------------------------------------------------
class CVGuiScreenEnumerator : public IPartitionEnumerator
{
DECLARE_CLASS_GAMEROOT(CVGuiScreenEnumerator, IPartitionEnumerator);
DECLARE_CLASS_GAMEROOT(CVGuiScreenEnumerator, IPartitionEnumerator);
public:
virtual IterationRetval_t EnumElement(IHandleEntity *pHandleEntity );
virtual IterationRetval_t EnumElement(IHandleEntity* pHandleEntity);

int GetScreenCount();
C_VGuiScreen *GetVGuiScreen(int index);
C_VGuiScreen* GetVGuiScreen(int index);

private:
CUtlVector< CHandle< C_VGuiScreen > > m_VguiScreens;
};

IterationRetval_t CVGuiScreenEnumerator::EnumElement(IHandleEntity *pHandleEntity )
IterationRetval_t CVGuiScreenEnumerator::EnumElement(IHandleEntity* pHandleEntity)
{
C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle(pHandleEntity->GetRefEHandle());
if (pEnt == NULL)
C_BaseEntity* pEnt = ClientEntityList().GetBaseEntityFromHandle(pHandleEntity->GetRefEHandle());
if (pEnt == NULL)
return ITERATION_CONTINUE;

// FIXME.. pretty expensive...
C_VGuiScreen *pScreen = dynamic_cast<C_VGuiScreen*>(pEnt);
if (pScreen)
C_VGuiScreen* pScreen = dynamic_cast<C_VGuiScreen*>(pEnt);
if (pScreen)
{
int i = m_VguiScreens.AddToTail();
m_VguiScreens[i].Set(pScreen);
int i = m_VguiScreens.AddToTail();
m_VguiScreens[i].Set(pScreen);
}

return ITERATION_CONTINUE;
Expand All@@ -667,10 +715,12 @@ int CVGuiScreenEnumerator::GetScreenCount()
return m_VguiScreens.Count();
}

C_VGuiScreen *CVGuiScreenEnumerator::GetVGuiScreen(int index)
C_VGuiScreen* CVGuiScreenEnumerator::GetVGuiScreen(int index)
{
return m_VguiScreens[index].Get();
}
}
#endif // !MAPBASE



//-----------------------------------------------------------------------------
Expand DownExpand Up@@ -704,18 +754,29 @@ C_BaseEntity *FindNearbyVguiScreen( const Vector &viewPosition, const QAngle &vi
Ray_t lookRay;
lookRay.Init( viewPosition, lookEnd );

#ifndef MAPBASE
// Look for vgui screens that are close to the player
CVGuiScreenEnumerator localScreens;
partition->EnumerateElementsInSphere( PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens );
partition->EnumerateElementsInSphere(PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens);
#endif // !MAPBASE

Vector vecOut, vecViewDelta;

float flBestDist = 2.0f;
C_VGuiScreen *pBestScreen = NULL;
#ifndef MAPBASE
for (int i = localScreens.GetScreenCount(); --i >= 0; )
#else
for (C_VGuiScreen* pScreen = g_VGUIScreenList.m_pClassList; pScreen != NULL; pScreen = pScreen->m_pNext)
#endif // !MAPBASE
{
C_VGuiScreen *pScreen = localScreens.GetVGuiScreen(i);

#ifndef MAPBASE
C_VGuiScreen* pScreen = localScreens.GetVGuiScreen(i);
#else
// Skip if out of PVS
if (pScreen->IsDormant())
continue;
#endif
if ( pScreen->IsAttachedToViewModel() )
continue;

Expand DownExpand Up@@ -865,11 +926,21 @@ vgui::Panel *CVGuiScreenPanel::CreateControlByName(const char *controlName)
//-----------------------------------------------------------------------------
// Purpose: Called when the user presses a button
//-----------------------------------------------------------------------------
void CVGuiScreenPanel::OnCommand(const char *command)
void CVGuiScreenPanel::OnCommand(const char* command)
{
if (Q_stricmp(command, "vguicancel" ) )
if (Q_stricmp(command, "vguicancel"))
{
engine->ClientCmd( const_cast<char *>( command ) );
#ifdef MAPBASE
if (m_hEntity && m_hEntity->IsServerEntity())
{
KeyValues* pCommand = new KeyValues("EntityCommand");
pCommand->SetInt("entindex", m_hEntity->index);
pCommand->SetString("command_data", command);
engine->ServerCmdKeyValues(pCommand);
}
else
#endif
engine->ClientCmd(const_cast<char*>(command));
}

BaseClass::OnCommand(command);
Expand Down
4 changes: 4 additions & 0 deletions sp/src/game/client/c_vguiscreen.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,10 @@ class C_VGuiScreen : public C_BaseEntity
public:
DECLARE_CLIENTCLASS();

#ifdef MAPBASE
C_VGuiScreen* m_pNext;
#endif // MAPBASE

C_VGuiScreen();
~C_VGuiScreen();

Expand Down
10 changes: 10 additions & 0 deletions sp/src/game/server/baseentity.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -606,6 +606,9 @@ class CBaseEntity : public IServerEntity

void ValidateEntityConnections();
void FireNamedOutput( const char *pszOutput, variant_t variant, CBaseEntity *pActivator, CBaseEntity *pCaller, float flDelay = 0.0f );
#ifdef MAPBASE
virtual
#endif
CBaseEntityOutput *FindNamedOutput( const char *pszOutput );
#ifdef MAPBASE_VSCRIPT
void ScriptFireOutput( const char *pszOutput, HSCRIPT hActivator, HSCRIPT hCaller, const char *szValue, float flDelay );
Expand DownExpand Up@@ -864,6 +867,13 @@ class CBaseEntity : public IServerEntity

void SetAIWalkable( bool bBlocksLOS );
bool IsAIWalkable( void );

#ifdef MAPBASE
// Handle a potentially complex command from a client.
// Returns true if the command was handled successfully.
virtual bool HandleEntityCommand(CBasePlayer* pClient, KeyValues* pKeyValues) { return false; }
#endif // MAPBASE

private:
int SaveDataDescBlock( ISave &save, datamap_t *dmap );
int RestoreDataDescBlock( IRestore &restore, datamap_t *dmap );
Expand Down
14 changes: 14 additions & 0 deletions sp/src/game/server/hl2/hl2_player.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3617,6 +3617,20 @@ void CHL2_Player::UpdateWeaponPosture( void )
{
m_LowerWeaponTimer.Set( .3 );
VPROF( "CHL2_Player::UpdateWeaponPosture-CheckLower" );

#ifdef MAPBASE
if (m_nButtons & IN_VGUIMODE)
{
//We're over a friendly, drop our weapon
if (Weapon_Lower() == false)
{
//FIXME: We couldn't lower our weapon!
}

return;
}
#endif // MAPBASE

Vector vecAim = BaseClass::GetAutoaimVector( AUTOAIM_SCALE_DIRECT_ONLY );

const float CHECK_FRIENDLY_RANGE = 50 * 12;
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions sp/src/game/client/c_baseplayer.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -1133,6 +1133,9 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2 | IN_VALIDVGUIINPUT);
#ifdef MAPBASE
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
return;
}
#else
Expand All@@ -1142,6 +1145,10 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
#ifdef MAPBASE
pCmd->buttons &= ~(IN_USE | IN_ATTACK3);
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
return;
}
#endif
Expand DownExpand Up@@ -1206,6 +1213,10 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
#ifdef MAPBASE
pCmd->buttons &= ~(IN_USE | IN_ATTACK3);
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
}
}

Expand Down
129 changes: 100 additions & 29 deletions sp/src/game/client/c_vguiscreen.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,14 @@ extern vgui::IInputInternal *g_InputInternal;
#define VGUI_SCREEN_MODE_RADIUS 80

//Precache the materials
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectVGuiScreen)
CLIENTEFFECT_MATERIAL("engine/writez")
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectVGuiScreen)
CLIENTEFFECT_MATERIAL("engine/writez")
CLIENTEFFECT_REGISTER_END()

#ifdef MAPBASE
C_EntityClassList<C_VGuiScreen> g_VGUIScreenList;
template <> C_VGuiScreen* C_EntityClassList<C_VGuiScreen>::m_pClassList = NULL;
#endif // MAPBASE

// ----------------------------------------------------------------------------- //
// This is a cache of preloaded keyvalues.
Expand DownExpand Up@@ -102,11 +106,19 @@ C_VGuiScreen::C_VGuiScreen()

m_WriteZMaterial.Init( "engine/writez", TEXTURE_GROUP_VGUI );
m_OverlayMaterial.Init( m_WriteZMaterial );

#ifdef MAPBASE
g_VGUIScreenList.Insert(this);
#endif // MAPBASE
}

C_VGuiScreen::~C_VGuiScreen()
{
DestroyVguiScreen();

#ifdef MAPBASE
g_VGUIScreenList.Remove(this);
#endif // MAPBASE
}

//-----------------------------------------------------------------------------
Expand DownExpand Up@@ -416,35 +428,70 @@ void C_VGuiScreen::ClientThink( void )
int px = (int)(u * m_nPixelWidth + 0.5f);
int py = (int)(v * m_nPixelHeight + 0.5f);

#ifndef MAPBASE
// Generate mouse input commands
if ((px != m_nOldPx) || (py != m_nOldPy))
{
g_InputInternal->InternalCursorMoved( px, py );
g_InputInternal->InternalCursorMoved(px, py);

m_nOldPx = px;
m_nOldPy = py;
}

if (m_nButtonPressed & IN_ATTACK)
{
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_PRESSED);
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_LEFT);
}
if (m_nButtonPressed & IN_ATTACK2)
{
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_RIGHT);
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_RIGHT);
}
if ((m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus
if ((m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus
{
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_LEFT);
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_LEFT);
}
if (m_nButtonReleased & IN_ATTACK2)
{
g_InputInternal->SetMouseCodeState( MOUSE_RIGHT, vgui::BUTTON_RELEASED );
g_InputInternal->InternalMouseReleased( MOUSE_RIGHT );
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_RIGHT);
}
#else
vgui::VPANEL focus = g_InputInternal->GetMouseOver();
// Generate mouse input commands
if ((px != m_nOldPx) || (py != m_nOldPy))
{
g_InputInternal->UpdateCursorPosInternal(px, py);

m_nOldPx = px;
m_nOldPy = py;

focus = pPanel->IsWithinTraverse(px, py, true);
g_InputInternal->SetMouseFocus(focus);
vgui::ivgui()->PostMessage(focus, new KeyValues("CursorMoved", "xpos", px, "ypos", py), NULL);
}

for (int i = 0; i < 2; i++)
{
const int nBit = i ? IN_ATTACK2 : (IN_ATTACK | IN_USE);
const vgui::MouseCode nButton = i ? MOUSE_RIGHT : MOUSE_LEFT;

if ((m_nButtonReleased & nBit) || ((m_nButtonState & nBit) && m_bLoseThinkNextFrame)) // for a button release on loosing focus
{
g_InputInternal->SetMouseCodeState(nButton, vgui::BUTTON_RELEASED);
vgui::ivgui()->PostMessage(focus, new KeyValues("MouseReleased", "code", nButton), NULL);
}
else if (m_nButtonPressed & nBit)
{
g_InputInternal->SetMouseCodeState(nButton, vgui::BUTTON_PRESSED);
vgui::ivgui()->PostMessage(focus, new KeyValues("MousePressed", "code", nButton), NULL);
}
}
#endif // !MAPBASE


if ( m_bLoseThinkNextFrame == true )
{
m_bLoseThinkNextFrame = false;
Expand DownExpand Up@@ -627,36 +674,37 @@ bool C_VGuiScreen::IsInputOnlyToOwner( void )
return (m_fScreenFlags & VGUI_SCREEN_ONLY_USABLE_BY_OWNER) != 0;
}

#ifndef MAPBASE
//-----------------------------------------------------------------------------
//
// Enumator class for finding vgui screens close to the local player
//
//-----------------------------------------------------------------------------
class CVGuiScreenEnumerator : public IPartitionEnumerator
{
DECLARE_CLASS_GAMEROOT(CVGuiScreenEnumerator, IPartitionEnumerator);
DECLARE_CLASS_GAMEROOT(CVGuiScreenEnumerator, IPartitionEnumerator);
public:
virtual IterationRetval_t EnumElement(IHandleEntity *pHandleEntity );
virtual IterationRetval_t EnumElement(IHandleEntity* pHandleEntity);

int GetScreenCount();
C_VGuiScreen *GetVGuiScreen(int index);
C_VGuiScreen* GetVGuiScreen(int index);

private:
CUtlVector< CHandle< C_VGuiScreen > > m_VguiScreens;
};

IterationRetval_t CVGuiScreenEnumerator::EnumElement(IHandleEntity *pHandleEntity )
IterationRetval_t CVGuiScreenEnumerator::EnumElement(IHandleEntity* pHandleEntity)
{
C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle(pHandleEntity->GetRefEHandle());
if (pEnt == NULL)
C_BaseEntity* pEnt = ClientEntityList().GetBaseEntityFromHandle(pHandleEntity->GetRefEHandle());
if (pEnt == NULL)
return ITERATION_CONTINUE;

// FIXME.. pretty expensive...
C_VGuiScreen *pScreen = dynamic_cast<C_VGuiScreen*>(pEnt);
if (pScreen)
C_VGuiScreen* pScreen = dynamic_cast<C_VGuiScreen*>(pEnt);
if (pScreen)
{
int i = m_VguiScreens.AddToTail();
m_VguiScreens[i].Set(pScreen);
int i = m_VguiScreens.AddToTail();
m_VguiScreens[i].Set(pScreen);
}

return ITERATION_CONTINUE;
Expand All@@ -667,10 +715,12 @@ int CVGuiScreenEnumerator::GetScreenCount()
return m_VguiScreens.Count();
}

C_VGuiScreen *CVGuiScreenEnumerator::GetVGuiScreen(int index)
C_VGuiScreen* CVGuiScreenEnumerator::GetVGuiScreen(int index)
{
return m_VguiScreens[index].Get();
}
}
#endif // !MAPBASE



//-----------------------------------------------------------------------------
Expand DownExpand Up@@ -704,18 +754,29 @@ C_BaseEntity *FindNearbyVguiScreen( const Vector &viewPosition, const QAngle &vi
Ray_t lookRay;
lookRay.Init( viewPosition, lookEnd );

#ifndef MAPBASE
// Look for vgui screens that are close to the player
CVGuiScreenEnumerator localScreens;
partition->EnumerateElementsInSphere( PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens );
partition->EnumerateElementsInSphere(PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens);
#endif // !MAPBASE

Vector vecOut, vecViewDelta;

float flBestDist = 2.0f;
C_VGuiScreen *pBestScreen = NULL;
#ifndef MAPBASE
for (int i = localScreens.GetScreenCount(); --i >= 0; )
#else
for (C_VGuiScreen* pScreen = g_VGUIScreenList.m_pClassList; pScreen != NULL; pScreen = pScreen->m_pNext)
#endif // !MAPBASE
{
C_VGuiScreen *pScreen = localScreens.GetVGuiScreen(i);

#ifndef MAPBASE
C_VGuiScreen* pScreen = localScreens.GetVGuiScreen(i);
#else
// Skip if out of PVS
if (pScreen->IsDormant())
continue;
#endif
if ( pScreen->IsAttachedToViewModel() )
continue;

Expand DownExpand Up@@ -865,11 +926,21 @@ vgui::Panel *CVGuiScreenPanel::CreateControlByName(const char *controlName)
//-----------------------------------------------------------------------------
// Purpose: Called when the user presses a button
//-----------------------------------------------------------------------------
void CVGuiScreenPanel::OnCommand(const char *command)
void CVGuiScreenPanel::OnCommand(const char* command)
{
if (Q_stricmp(command, "vguicancel" ) )
if (Q_stricmp(command, "vguicancel"))
{
engine->ClientCmd( const_cast<char *>( command ) );
#ifdef MAPBASE
if (m_hEntity && m_hEntity->IsServerEntity())
{
KeyValues* pCommand = new KeyValues("EntityCommand");
pCommand->SetInt("entindex", m_hEntity->index);
pCommand->SetString("command_data", command);
engine->ServerCmdKeyValues(pCommand);
}
else
#endif
engine->ClientCmd(const_cast<char*>(command));
}

BaseClass::OnCommand(command);
Expand Down
4 changes: 4 additions & 0 deletions sp/src/game/client/c_vguiscreen.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,10 @@ class C_VGuiScreen : public C_BaseEntity
public:
DECLARE_CLIENTCLASS();

#ifdef MAPBASE
C_VGuiScreen* m_pNext;
#endif // MAPBASE

C_VGuiScreen();
~C_VGuiScreen();

Expand Down
10 changes: 10 additions & 0 deletions sp/src/game/server/baseentity.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -606,6 +606,9 @@ class CBaseEntity : public IServerEntity

void ValidateEntityConnections();
void FireNamedOutput( const char *pszOutput, variant_t variant, CBaseEntity *pActivator, CBaseEntity *pCaller, float flDelay = 0.0f );
#ifdef MAPBASE
virtual
#endif
CBaseEntityOutput *FindNamedOutput( const char *pszOutput );
#ifdef MAPBASE_VSCRIPT
void ScriptFireOutput( const char *pszOutput, HSCRIPT hActivator, HSCRIPT hCaller, const char *szValue, float flDelay );
Expand DownExpand Up@@ -864,6 +867,13 @@ class CBaseEntity : public IServerEntity

void SetAIWalkable( bool bBlocksLOS );
bool IsAIWalkable( void );

#ifdef MAPBASE
// Handle a potentially complex command from a client.
// Returns true if the command was handled successfully.
virtual bool HandleEntityCommand(CBasePlayer* pClient, KeyValues* pKeyValues) { return false; }
#endif // MAPBASE

private:
int SaveDataDescBlock( ISave &save, datamap_t *dmap );
int RestoreDataDescBlock( IRestore &restore, datamap_t *dmap );
Expand Down
14 changes: 14 additions & 0 deletions sp/src/game/server/hl2/hl2_player.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3617,6 +3617,20 @@ void CHL2_Player::UpdateWeaponPosture( void )
{
m_LowerWeaponTimer.Set( .3 );
VPROF( "CHL2_Player::UpdateWeaponPosture-CheckLower" );

#ifdef MAPBASE
if (m_nButtons & IN_VGUIMODE)
{
//We're over a friendly, drop our weapon
if (Weapon_Lower() == false)
{
//FIXME: We couldn't lower our weapon!
}

return;
}
#endif // MAPBASE

Vector vecAim = BaseClass::GetAutoaimVector( AUTOAIM_SCALE_DIRECT_ONLY );

const float CHECK_FRIENDLY_RANGE = 50 * 12;
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions sp/src/game/client/c_baseplayer.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -1133,6 +1133,9 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2 | IN_VALIDVGUIINPUT);
#ifdef MAPBASE
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
return;
}
#else
Expand All@@ -1142,6 +1145,10 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
#ifdef MAPBASE
pCmd->buttons &= ~(IN_USE | IN_ATTACK3);
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
return;
}
#endif
Expand DownExpand Up@@ -1206,6 +1213,10 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
#ifdef MAPBASE
pCmd->buttons &= ~(IN_USE | IN_ATTACK3);
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
}
}

Expand Down
129 changes: 100 additions & 29 deletions sp/src/game/client/c_vguiscreen.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,14 @@ extern vgui::IInputInternal *g_InputInternal;
#define VGUI_SCREEN_MODE_RADIUS 80

//Precache the materials
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectVGuiScreen)
CLIENTEFFECT_MATERIAL("engine/writez")
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectVGuiScreen)
CLIENTEFFECT_MATERIAL("engine/writez")
CLIENTEFFECT_REGISTER_END()

#ifdef MAPBASE
C_EntityClassList<C_VGuiScreen> g_VGUIScreenList;
template <> C_VGuiScreen* C_EntityClassList<C_VGuiScreen>::m_pClassList = NULL;
#endif // MAPBASE

// ----------------------------------------------------------------------------- //
// This is a cache of preloaded keyvalues.
Expand DownExpand Up@@ -102,11 +106,19 @@ C_VGuiScreen::C_VGuiScreen()

m_WriteZMaterial.Init( "engine/writez", TEXTURE_GROUP_VGUI );
m_OverlayMaterial.Init( m_WriteZMaterial );

#ifdef MAPBASE
g_VGUIScreenList.Insert(this);
#endif // MAPBASE
}

C_VGuiScreen::~C_VGuiScreen()
{
DestroyVguiScreen();

#ifdef MAPBASE
g_VGUIScreenList.Remove(this);
#endif // MAPBASE
}

//-----------------------------------------------------------------------------
Expand DownExpand Up@@ -416,35 +428,70 @@ void C_VGuiScreen::ClientThink( void )
int px = (int)(u * m_nPixelWidth + 0.5f);
int py = (int)(v * m_nPixelHeight + 0.5f);

#ifndef MAPBASE
// Generate mouse input commands
if ((px != m_nOldPx) || (py != m_nOldPy))
{
g_InputInternal->InternalCursorMoved( px, py );
g_InputInternal->InternalCursorMoved(px, py);

m_nOldPx = px;
m_nOldPy = py;
}

if (m_nButtonPressed & IN_ATTACK)
{
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_PRESSED);
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_LEFT);
}
if (m_nButtonPressed & IN_ATTACK2)
{
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_RIGHT);
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_RIGHT);
}
if ((m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus
if ((m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus
{
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_LEFT);
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_LEFT);
}
if (m_nButtonReleased & IN_ATTACK2)
{
g_InputInternal->SetMouseCodeState( MOUSE_RIGHT, vgui::BUTTON_RELEASED );
g_InputInternal->InternalMouseReleased( MOUSE_RIGHT );
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_RIGHT);
}
#else
vgui::VPANEL focus = g_InputInternal->GetMouseOver();
// Generate mouse input commands
if ((px != m_nOldPx) || (py != m_nOldPy))
{
g_InputInternal->UpdateCursorPosInternal(px, py);

m_nOldPx = px;
m_nOldPy = py;

focus = pPanel->IsWithinTraverse(px, py, true);
g_InputInternal->SetMouseFocus(focus);
vgui::ivgui()->PostMessage(focus, new KeyValues("CursorMoved", "xpos", px, "ypos", py), NULL);
}

for (int i = 0; i < 2; i++)
{
const int nBit = i ? IN_ATTACK2 : (IN_ATTACK | IN_USE);
const vgui::MouseCode nButton = i ? MOUSE_RIGHT : MOUSE_LEFT;

if ((m_nButtonReleased & nBit) || ((m_nButtonState & nBit) && m_bLoseThinkNextFrame)) // for a button release on loosing focus
{
g_InputInternal->SetMouseCodeState(nButton, vgui::BUTTON_RELEASED);
vgui::ivgui()->PostMessage(focus, new KeyValues("MouseReleased", "code", nButton), NULL);
}
else if (m_nButtonPressed & nBit)
{
g_InputInternal->SetMouseCodeState(nButton, vgui::BUTTON_PRESSED);
vgui::ivgui()->PostMessage(focus, new KeyValues("MousePressed", "code", nButton), NULL);
}
}
#endif // !MAPBASE


if ( m_bLoseThinkNextFrame == true )
{
m_bLoseThinkNextFrame = false;
Expand DownExpand Up@@ -627,36 +674,37 @@ bool C_VGuiScreen::IsInputOnlyToOwner( void )
return (m_fScreenFlags & VGUI_SCREEN_ONLY_USABLE_BY_OWNER) != 0;
}

#ifndef MAPBASE
//-----------------------------------------------------------------------------
//
// Enumator class for finding vgui screens close to the local player
//
//-----------------------------------------------------------------------------
class CVGuiScreenEnumerator : public IPartitionEnumerator
{
DECLARE_CLASS_GAMEROOT(CVGuiScreenEnumerator, IPartitionEnumerator);
DECLARE_CLASS_GAMEROOT(CVGuiScreenEnumerator, IPartitionEnumerator);
public:
virtual IterationRetval_t EnumElement(IHandleEntity *pHandleEntity );
virtual IterationRetval_t EnumElement(IHandleEntity* pHandleEntity);

int GetScreenCount();
C_VGuiScreen *GetVGuiScreen(int index);
C_VGuiScreen* GetVGuiScreen(int index);

private:
CUtlVector< CHandle< C_VGuiScreen > > m_VguiScreens;
};

IterationRetval_t CVGuiScreenEnumerator::EnumElement(IHandleEntity *pHandleEntity )
IterationRetval_t CVGuiScreenEnumerator::EnumElement(IHandleEntity* pHandleEntity)
{
C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle(pHandleEntity->GetRefEHandle());
if (pEnt == NULL)
C_BaseEntity* pEnt = ClientEntityList().GetBaseEntityFromHandle(pHandleEntity->GetRefEHandle());
if (pEnt == NULL)
return ITERATION_CONTINUE;

// FIXME.. pretty expensive...
C_VGuiScreen *pScreen = dynamic_cast<C_VGuiScreen*>(pEnt);
if (pScreen)
C_VGuiScreen* pScreen = dynamic_cast<C_VGuiScreen*>(pEnt);
if (pScreen)
{
int i = m_VguiScreens.AddToTail();
m_VguiScreens[i].Set(pScreen);
int i = m_VguiScreens.AddToTail();
m_VguiScreens[i].Set(pScreen);
}

return ITERATION_CONTINUE;
Expand All@@ -667,10 +715,12 @@ int CVGuiScreenEnumerator::GetScreenCount()
return m_VguiScreens.Count();
}

C_VGuiScreen *CVGuiScreenEnumerator::GetVGuiScreen(int index)
C_VGuiScreen* CVGuiScreenEnumerator::GetVGuiScreen(int index)
{
return m_VguiScreens[index].Get();
}
}
#endif // !MAPBASE



//-----------------------------------------------------------------------------
Expand DownExpand Up@@ -704,18 +754,29 @@ C_BaseEntity *FindNearbyVguiScreen( const Vector &viewPosition, const QAngle &vi
Ray_t lookRay;
lookRay.Init( viewPosition, lookEnd );

#ifndef MAPBASE
// Look for vgui screens that are close to the player
CVGuiScreenEnumerator localScreens;
partition->EnumerateElementsInSphere( PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens );
partition->EnumerateElementsInSphere(PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens);
#endif // !MAPBASE

Vector vecOut, vecViewDelta;

float flBestDist = 2.0f;
C_VGuiScreen *pBestScreen = NULL;
#ifndef MAPBASE
for (int i = localScreens.GetScreenCount(); --i >= 0; )
#else
for (C_VGuiScreen* pScreen = g_VGUIScreenList.m_pClassList; pScreen != NULL; pScreen = pScreen->m_pNext)
#endif // !MAPBASE
{
C_VGuiScreen *pScreen = localScreens.GetVGuiScreen(i);

#ifndef MAPBASE
C_VGuiScreen* pScreen = localScreens.GetVGuiScreen(i);
#else
// Skip if out of PVS
if (pScreen->IsDormant())
continue;
#endif
if ( pScreen->IsAttachedToViewModel() )
continue;

Expand DownExpand Up@@ -865,11 +926,21 @@ vgui::Panel *CVGuiScreenPanel::CreateControlByName(const char *controlName)
//-----------------------------------------------------------------------------
// Purpose: Called when the user presses a button
//-----------------------------------------------------------------------------
void CVGuiScreenPanel::OnCommand(const char *command)
void CVGuiScreenPanel::OnCommand(const char* command)
{
if (Q_stricmp(command, "vguicancel" ) )
if (Q_stricmp(command, "vguicancel"))
{
engine->ClientCmd( const_cast<char *>( command ) );
#ifdef MAPBASE
if (m_hEntity && m_hEntity->IsServerEntity())
{
KeyValues* pCommand = new KeyValues("EntityCommand");
pCommand->SetInt("entindex", m_hEntity->index);
pCommand->SetString("command_data", command);
engine->ServerCmdKeyValues(pCommand);
}
else
#endif
engine->ClientCmd(const_cast<char*>(command));
}

BaseClass::OnCommand(command);
Expand Down
4 changes: 4 additions & 0 deletions sp/src/game/client/c_vguiscreen.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,10 @@ class C_VGuiScreen : public C_BaseEntity
public:
DECLARE_CLIENTCLASS();

#ifdef MAPBASE
C_VGuiScreen* m_pNext;
#endif // MAPBASE

C_VGuiScreen();
~C_VGuiScreen();

Expand Down
10 changes: 10 additions & 0 deletions sp/src/game/server/baseentity.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -606,6 +606,9 @@ class CBaseEntity : public IServerEntity

void ValidateEntityConnections();
void FireNamedOutput( const char *pszOutput, variant_t variant, CBaseEntity *pActivator, CBaseEntity *pCaller, float flDelay = 0.0f );
#ifdef MAPBASE
virtual
#endif
CBaseEntityOutput *FindNamedOutput( const char *pszOutput );
#ifdef MAPBASE_VSCRIPT
void ScriptFireOutput( const char *pszOutput, HSCRIPT hActivator, HSCRIPT hCaller, const char *szValue, float flDelay );
Expand DownExpand Up@@ -864,6 +867,13 @@ class CBaseEntity : public IServerEntity

void SetAIWalkable( bool bBlocksLOS );
bool IsAIWalkable( void );

#ifdef MAPBASE
// Handle a potentially complex command from a client.
// Returns true if the command was handled successfully.
virtual bool HandleEntityCommand(CBasePlayer* pClient, KeyValues* pKeyValues) { return false; }
#endif // MAPBASE

private:
int SaveDataDescBlock( ISave &save, datamap_t *dmap );
int RestoreDataDescBlock( IRestore &restore, datamap_t *dmap );
Expand Down
14 changes: 14 additions & 0 deletions sp/src/game/server/hl2/hl2_player.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3617,6 +3617,20 @@ void CHL2_Player::UpdateWeaponPosture( void )
{
m_LowerWeaponTimer.Set( .3 );
VPROF( "CHL2_Player::UpdateWeaponPosture-CheckLower" );

#ifdef MAPBASE
if (m_nButtons & IN_VGUIMODE)
{
//We're over a friendly, drop our weapon
if (Weapon_Lower() == false)
{
//FIXME: We couldn't lower our weapon!
}

return;
}
#endif // MAPBASE

Vector vecAim = BaseClass::GetAutoaimVector( AUTOAIM_SCALE_DIRECT_ONLY );

const float CHECK_FRIENDLY_RANGE = 50 * 12;
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions sp/src/game/client/c_baseplayer.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -1133,6 +1133,9 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2 | IN_VALIDVGUIINPUT);
#ifdef MAPBASE
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
return;
}
#else
Expand All@@ -1142,6 +1145,10 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
#ifdef MAPBASE
pCmd->buttons &= ~(IN_USE | IN_ATTACK3);
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
return;
}
#endif
Expand DownExpand Up@@ -1206,6 +1213,10 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
#ifdef MAPBASE
pCmd->buttons &= ~(IN_USE | IN_ATTACK3);
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
}
}

Expand Down
129 changes: 100 additions & 29 deletions sp/src/game/client/c_vguiscreen.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,14 @@ extern vgui::IInputInternal *g_InputInternal;
#define VGUI_SCREEN_MODE_RADIUS 80

//Precache the materials
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectVGuiScreen)
CLIENTEFFECT_MATERIAL("engine/writez")
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectVGuiScreen)
CLIENTEFFECT_MATERIAL("engine/writez")
CLIENTEFFECT_REGISTER_END()

#ifdef MAPBASE
C_EntityClassList<C_VGuiScreen> g_VGUIScreenList;
template <> C_VGuiScreen* C_EntityClassList<C_VGuiScreen>::m_pClassList = NULL;
#endif // MAPBASE

// ----------------------------------------------------------------------------- //
// This is a cache of preloaded keyvalues.
Expand DownExpand Up@@ -102,11 +106,19 @@ C_VGuiScreen::C_VGuiScreen()

m_WriteZMaterial.Init( "engine/writez", TEXTURE_GROUP_VGUI );
m_OverlayMaterial.Init( m_WriteZMaterial );

#ifdef MAPBASE
g_VGUIScreenList.Insert(this);
#endif // MAPBASE
}

C_VGuiScreen::~C_VGuiScreen()
{
DestroyVguiScreen();

#ifdef MAPBASE
g_VGUIScreenList.Remove(this);
#endif // MAPBASE
}

//-----------------------------------------------------------------------------
Expand DownExpand Up@@ -416,35 +428,70 @@ void C_VGuiScreen::ClientThink( void )
int px = (int)(u * m_nPixelWidth + 0.5f);
int py = (int)(v * m_nPixelHeight + 0.5f);

#ifndef MAPBASE
// Generate mouse input commands
if ((px != m_nOldPx) || (py != m_nOldPy))
{
g_InputInternal->InternalCursorMoved( px, py );
g_InputInternal->InternalCursorMoved(px, py);

m_nOldPx = px;
m_nOldPy = py;
}

if (m_nButtonPressed & IN_ATTACK)
{
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_PRESSED);
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_LEFT);
}
if (m_nButtonPressed & IN_ATTACK2)
{
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_RIGHT);
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_RIGHT);
}
if ((m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus
if ((m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus
{
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_LEFT);
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_LEFT);
}
if (m_nButtonReleased & IN_ATTACK2)
{
g_InputInternal->SetMouseCodeState( MOUSE_RIGHT, vgui::BUTTON_RELEASED );
g_InputInternal->InternalMouseReleased( MOUSE_RIGHT );
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_RIGHT);
}
#else
vgui::VPANEL focus = g_InputInternal->GetMouseOver();
// Generate mouse input commands
if ((px != m_nOldPx) || (py != m_nOldPy))
{
g_InputInternal->UpdateCursorPosInternal(px, py);

m_nOldPx = px;
m_nOldPy = py;

focus = pPanel->IsWithinTraverse(px, py, true);
g_InputInternal->SetMouseFocus(focus);
vgui::ivgui()->PostMessage(focus, new KeyValues("CursorMoved", "xpos", px, "ypos", py), NULL);
}

for (int i = 0; i < 2; i++)
{
const int nBit = i ? IN_ATTACK2 : (IN_ATTACK | IN_USE);
const vgui::MouseCode nButton = i ? MOUSE_RIGHT : MOUSE_LEFT;

if ((m_nButtonReleased & nBit) || ((m_nButtonState & nBit) && m_bLoseThinkNextFrame)) // for a button release on loosing focus
{
g_InputInternal->SetMouseCodeState(nButton, vgui::BUTTON_RELEASED);
vgui::ivgui()->PostMessage(focus, new KeyValues("MouseReleased", "code", nButton), NULL);
}
else if (m_nButtonPressed & nBit)
{
g_InputInternal->SetMouseCodeState(nButton, vgui::BUTTON_PRESSED);
vgui::ivgui()->PostMessage(focus, new KeyValues("MousePressed", "code", nButton), NULL);
}
}
#endif // !MAPBASE


if ( m_bLoseThinkNextFrame == true )
{
m_bLoseThinkNextFrame = false;
Expand DownExpand Up@@ -627,36 +674,37 @@ bool C_VGuiScreen::IsInputOnlyToOwner( void )
return (m_fScreenFlags & VGUI_SCREEN_ONLY_USABLE_BY_OWNER) != 0;
}

#ifndef MAPBASE
//-----------------------------------------------------------------------------
//
// Enumator class for finding vgui screens close to the local player
//
//-----------------------------------------------------------------------------
class CVGuiScreenEnumerator : public IPartitionEnumerator
{
DECLARE_CLASS_GAMEROOT(CVGuiScreenEnumerator, IPartitionEnumerator);
DECLARE_CLASS_GAMEROOT(CVGuiScreenEnumerator, IPartitionEnumerator);
public:
virtual IterationRetval_t EnumElement(IHandleEntity *pHandleEntity );
virtual IterationRetval_t EnumElement(IHandleEntity* pHandleEntity);

int GetScreenCount();
C_VGuiScreen *GetVGuiScreen(int index);
C_VGuiScreen* GetVGuiScreen(int index);

private:
CUtlVector< CHandle< C_VGuiScreen > > m_VguiScreens;
};

IterationRetval_t CVGuiScreenEnumerator::EnumElement(IHandleEntity *pHandleEntity )
IterationRetval_t CVGuiScreenEnumerator::EnumElement(IHandleEntity* pHandleEntity)
{
C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle(pHandleEntity->GetRefEHandle());
if (pEnt == NULL)
C_BaseEntity* pEnt = ClientEntityList().GetBaseEntityFromHandle(pHandleEntity->GetRefEHandle());
if (pEnt == NULL)
return ITERATION_CONTINUE;

// FIXME.. pretty expensive...
C_VGuiScreen *pScreen = dynamic_cast<C_VGuiScreen*>(pEnt);
if (pScreen)
C_VGuiScreen* pScreen = dynamic_cast<C_VGuiScreen*>(pEnt);
if (pScreen)
{
int i = m_VguiScreens.AddToTail();
m_VguiScreens[i].Set(pScreen);
int i = m_VguiScreens.AddToTail();
m_VguiScreens[i].Set(pScreen);
}

return ITERATION_CONTINUE;
Expand All@@ -667,10 +715,12 @@ int CVGuiScreenEnumerator::GetScreenCount()
return m_VguiScreens.Count();
}

C_VGuiScreen *CVGuiScreenEnumerator::GetVGuiScreen(int index)
C_VGuiScreen* CVGuiScreenEnumerator::GetVGuiScreen(int index)
{
return m_VguiScreens[index].Get();
}
}
#endif // !MAPBASE



//-----------------------------------------------------------------------------
Expand DownExpand Up@@ -704,18 +754,29 @@ C_BaseEntity *FindNearbyVguiScreen( const Vector &viewPosition, const QAngle &vi
Ray_t lookRay;
lookRay.Init( viewPosition, lookEnd );

#ifndef MAPBASE
// Look for vgui screens that are close to the player
CVGuiScreenEnumerator localScreens;
partition->EnumerateElementsInSphere( PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens );
partition->EnumerateElementsInSphere(PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens);
#endif // !MAPBASE

Vector vecOut, vecViewDelta;

float flBestDist = 2.0f;
C_VGuiScreen *pBestScreen = NULL;
#ifndef MAPBASE
for (int i = localScreens.GetScreenCount(); --i >= 0; )
#else
for (C_VGuiScreen* pScreen = g_VGUIScreenList.m_pClassList; pScreen != NULL; pScreen = pScreen->m_pNext)
#endif // !MAPBASE
{
C_VGuiScreen *pScreen = localScreens.GetVGuiScreen(i);

#ifndef MAPBASE
C_VGuiScreen* pScreen = localScreens.GetVGuiScreen(i);
#else
// Skip if out of PVS
if (pScreen->IsDormant())
continue;
#endif
if ( pScreen->IsAttachedToViewModel() )
continue;

Expand DownExpand Up@@ -865,11 +926,21 @@ vgui::Panel *CVGuiScreenPanel::CreateControlByName(const char *controlName)
//-----------------------------------------------------------------------------
// Purpose: Called when the user presses a button
//-----------------------------------------------------------------------------
void CVGuiScreenPanel::OnCommand(const char *command)
void CVGuiScreenPanel::OnCommand(const char* command)
{
if (Q_stricmp(command, "vguicancel" ) )
if (Q_stricmp(command, "vguicancel"))
{
engine->ClientCmd( const_cast<char *>( command ) );
#ifdef MAPBASE
if (m_hEntity && m_hEntity->IsServerEntity())
{
KeyValues* pCommand = new KeyValues("EntityCommand");
pCommand->SetInt("entindex", m_hEntity->index);
pCommand->SetString("command_data", command);
engine->ServerCmdKeyValues(pCommand);
}
else
#endif
engine->ClientCmd(const_cast<char*>(command));
}

BaseClass::OnCommand(command);
Expand Down
4 changes: 4 additions & 0 deletions sp/src/game/client/c_vguiscreen.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,10 @@ class C_VGuiScreen : public C_BaseEntity
public:
DECLARE_CLIENTCLASS();

#ifdef MAPBASE
C_VGuiScreen* m_pNext;
#endif // MAPBASE

C_VGuiScreen();
~C_VGuiScreen();

Expand Down
10 changes: 10 additions & 0 deletions sp/src/game/server/baseentity.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -606,6 +606,9 @@ class CBaseEntity : public IServerEntity

void ValidateEntityConnections();
void FireNamedOutput( const char *pszOutput, variant_t variant, CBaseEntity *pActivator, CBaseEntity *pCaller, float flDelay = 0.0f );
#ifdef MAPBASE
virtual
#endif
CBaseEntityOutput *FindNamedOutput( const char *pszOutput );
#ifdef MAPBASE_VSCRIPT
void ScriptFireOutput( const char *pszOutput, HSCRIPT hActivator, HSCRIPT hCaller, const char *szValue, float flDelay );
Expand DownExpand Up@@ -864,6 +867,13 @@ class CBaseEntity : public IServerEntity

void SetAIWalkable( bool bBlocksLOS );
bool IsAIWalkable( void );

#ifdef MAPBASE
// Handle a potentially complex command from a client.
// Returns true if the command was handled successfully.
virtual bool HandleEntityCommand(CBasePlayer* pClient, KeyValues* pKeyValues) { return false; }
#endif // MAPBASE

private:
int SaveDataDescBlock( ISave &save, datamap_t *dmap );
int RestoreDataDescBlock( IRestore &restore, datamap_t *dmap );
Expand Down
14 changes: 14 additions & 0 deletions sp/src/game/server/hl2/hl2_player.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3617,6 +3617,20 @@ void CHL2_Player::UpdateWeaponPosture( void )
{
m_LowerWeaponTimer.Set( .3 );
VPROF( "CHL2_Player::UpdateWeaponPosture-CheckLower" );

#ifdef MAPBASE
if (m_nButtons & IN_VGUIMODE)
{
//We're over a friendly, drop our weapon
if (Weapon_Lower() == false)
{
//FIXME: We couldn't lower our weapon!
}

return;
}
#endif // MAPBASE

Vector vecAim = BaseClass::GetAutoaimVector( AUTOAIM_SCALE_DIRECT_ONLY );

const float CHECK_FRIENDLY_RANGE = 50 * 12;
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions sp/src/game/client/c_baseplayer.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -1133,6 +1133,9 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2 | IN_VALIDVGUIINPUT);
#ifdef MAPBASE
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
return;
}
#else
Expand All@@ -1142,6 +1145,10 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
#ifdef MAPBASE
pCmd->buttons &= ~(IN_USE | IN_ATTACK3);
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
return;
}
#endif
Expand DownExpand Up@@ -1206,6 +1213,10 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
#ifdef MAPBASE
pCmd->buttons &= ~(IN_USE | IN_ATTACK3);
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
}
}

Expand Down
129 changes: 100 additions & 29 deletions sp/src/game/client/c_vguiscreen.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,14 @@ extern vgui::IInputInternal *g_InputInternal;
#define VGUI_SCREEN_MODE_RADIUS 80

//Precache the materials
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectVGuiScreen)
CLIENTEFFECT_MATERIAL("engine/writez")
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectVGuiScreen)
CLIENTEFFECT_MATERIAL("engine/writez")
CLIENTEFFECT_REGISTER_END()

#ifdef MAPBASE
C_EntityClassList<C_VGuiScreen> g_VGUIScreenList;
template <> C_VGuiScreen* C_EntityClassList<C_VGuiScreen>::m_pClassList = NULL;
#endif // MAPBASE

// ----------------------------------------------------------------------------- //
// This is a cache of preloaded keyvalues.
Expand DownExpand Up@@ -102,11 +106,19 @@ C_VGuiScreen::C_VGuiScreen()

m_WriteZMaterial.Init( "engine/writez", TEXTURE_GROUP_VGUI );
m_OverlayMaterial.Init( m_WriteZMaterial );

#ifdef MAPBASE
g_VGUIScreenList.Insert(this);
#endif // MAPBASE
}

C_VGuiScreen::~C_VGuiScreen()
{
DestroyVguiScreen();

#ifdef MAPBASE
g_VGUIScreenList.Remove(this);
#endif // MAPBASE
}

//-----------------------------------------------------------------------------
Expand DownExpand Up@@ -416,35 +428,70 @@ void C_VGuiScreen::ClientThink( void )
int px = (int)(u * m_nPixelWidth + 0.5f);
int py = (int)(v * m_nPixelHeight + 0.5f);

#ifndef MAPBASE
// Generate mouse input commands
if ((px != m_nOldPx) || (py != m_nOldPy))
{
g_InputInternal->InternalCursorMoved( px, py );
g_InputInternal->InternalCursorMoved(px, py);

m_nOldPx = px;
m_nOldPy = py;
}

if (m_nButtonPressed & IN_ATTACK)
{
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_PRESSED);
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_LEFT);
}
if (m_nButtonPressed & IN_ATTACK2)
{
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_RIGHT);
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_RIGHT);
}
if ((m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus
if ((m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus
{
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_LEFT);
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_LEFT);
}
if (m_nButtonReleased & IN_ATTACK2)
{
g_InputInternal->SetMouseCodeState( MOUSE_RIGHT, vgui::BUTTON_RELEASED );
g_InputInternal->InternalMouseReleased( MOUSE_RIGHT );
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_RIGHT);
}
#else
vgui::VPANEL focus = g_InputInternal->GetMouseOver();
// Generate mouse input commands
if ((px != m_nOldPx) || (py != m_nOldPy))
{
g_InputInternal->UpdateCursorPosInternal(px, py);

m_nOldPx = px;
m_nOldPy = py;

focus = pPanel->IsWithinTraverse(px, py, true);
g_InputInternal->SetMouseFocus(focus);
vgui::ivgui()->PostMessage(focus, new KeyValues("CursorMoved", "xpos", px, "ypos", py), NULL);
}

for (int i = 0; i < 2; i++)
{
const int nBit = i ? IN_ATTACK2 : (IN_ATTACK | IN_USE);
const vgui::MouseCode nButton = i ? MOUSE_RIGHT : MOUSE_LEFT;

if ((m_nButtonReleased & nBit) || ((m_nButtonState & nBit) && m_bLoseThinkNextFrame)) // for a button release on loosing focus
{
g_InputInternal->SetMouseCodeState(nButton, vgui::BUTTON_RELEASED);
vgui::ivgui()->PostMessage(focus, new KeyValues("MouseReleased", "code", nButton), NULL);
}
else if (m_nButtonPressed & nBit)
{
g_InputInternal->SetMouseCodeState(nButton, vgui::BUTTON_PRESSED);
vgui::ivgui()->PostMessage(focus, new KeyValues("MousePressed", "code", nButton), NULL);
}
}
#endif // !MAPBASE


if ( m_bLoseThinkNextFrame == true )
{
m_bLoseThinkNextFrame = false;
Expand DownExpand Up@@ -627,36 +674,37 @@ bool C_VGuiScreen::IsInputOnlyToOwner( void )
return (m_fScreenFlags & VGUI_SCREEN_ONLY_USABLE_BY_OWNER) != 0;
}

#ifndef MAPBASE
//-----------------------------------------------------------------------------
//
// Enumator class for finding vgui screens close to the local player
//
//-----------------------------------------------------------------------------
class CVGuiScreenEnumerator : public IPartitionEnumerator
{
DECLARE_CLASS_GAMEROOT(CVGuiScreenEnumerator, IPartitionEnumerator);
DECLARE_CLASS_GAMEROOT(CVGuiScreenEnumerator, IPartitionEnumerator);
public:
virtual IterationRetval_t EnumElement(IHandleEntity *pHandleEntity );
virtual IterationRetval_t EnumElement(IHandleEntity* pHandleEntity);

int GetScreenCount();
C_VGuiScreen *GetVGuiScreen(int index);
C_VGuiScreen* GetVGuiScreen(int index);

private:
CUtlVector< CHandle< C_VGuiScreen > > m_VguiScreens;
};

IterationRetval_t CVGuiScreenEnumerator::EnumElement(IHandleEntity *pHandleEntity )
IterationRetval_t CVGuiScreenEnumerator::EnumElement(IHandleEntity* pHandleEntity)
{
C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle(pHandleEntity->GetRefEHandle());
if (pEnt == NULL)
C_BaseEntity* pEnt = ClientEntityList().GetBaseEntityFromHandle(pHandleEntity->GetRefEHandle());
if (pEnt == NULL)
return ITERATION_CONTINUE;

// FIXME.. pretty expensive...
C_VGuiScreen *pScreen = dynamic_cast<C_VGuiScreen*>(pEnt);
if (pScreen)
C_VGuiScreen* pScreen = dynamic_cast<C_VGuiScreen*>(pEnt);
if (pScreen)
{
int i = m_VguiScreens.AddToTail();
m_VguiScreens[i].Set(pScreen);
int i = m_VguiScreens.AddToTail();
m_VguiScreens[i].Set(pScreen);
}

return ITERATION_CONTINUE;
Expand All@@ -667,10 +715,12 @@ int CVGuiScreenEnumerator::GetScreenCount()
return m_VguiScreens.Count();
}

C_VGuiScreen *CVGuiScreenEnumerator::GetVGuiScreen(int index)
C_VGuiScreen* CVGuiScreenEnumerator::GetVGuiScreen(int index)
{
return m_VguiScreens[index].Get();
}
}
#endif // !MAPBASE



//-----------------------------------------------------------------------------
Expand DownExpand Up@@ -704,18 +754,29 @@ C_BaseEntity *FindNearbyVguiScreen( const Vector &viewPosition, const QAngle &vi
Ray_t lookRay;
lookRay.Init( viewPosition, lookEnd );

#ifndef MAPBASE
// Look for vgui screens that are close to the player
CVGuiScreenEnumerator localScreens;
partition->EnumerateElementsInSphere( PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens );
partition->EnumerateElementsInSphere(PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens);
#endif // !MAPBASE

Vector vecOut, vecViewDelta;

float flBestDist = 2.0f;
C_VGuiScreen *pBestScreen = NULL;
#ifndef MAPBASE
for (int i = localScreens.GetScreenCount(); --i >= 0; )
#else
for (C_VGuiScreen* pScreen = g_VGUIScreenList.m_pClassList; pScreen != NULL; pScreen = pScreen->m_pNext)
#endif // !MAPBASE
{
C_VGuiScreen *pScreen = localScreens.GetVGuiScreen(i);

#ifndef MAPBASE
C_VGuiScreen* pScreen = localScreens.GetVGuiScreen(i);
#else
// Skip if out of PVS
if (pScreen->IsDormant())
continue;
#endif
if ( pScreen->IsAttachedToViewModel() )
continue;

Expand DownExpand Up@@ -865,11 +926,21 @@ vgui::Panel *CVGuiScreenPanel::CreateControlByName(const char *controlName)
//-----------------------------------------------------------------------------
// Purpose: Called when the user presses a button
//-----------------------------------------------------------------------------
void CVGuiScreenPanel::OnCommand(const char *command)
void CVGuiScreenPanel::OnCommand(const char* command)
{
if (Q_stricmp(command, "vguicancel" ) )
if (Q_stricmp(command, "vguicancel"))
{
engine->ClientCmd( const_cast<char *>( command ) );
#ifdef MAPBASE
if (m_hEntity && m_hEntity->IsServerEntity())
{
KeyValues* pCommand = new KeyValues("EntityCommand");
pCommand->SetInt("entindex", m_hEntity->index);
pCommand->SetString("command_data", command);
engine->ServerCmdKeyValues(pCommand);
}
else
#endif
engine->ClientCmd(const_cast<char*>(command));
}

BaseClass::OnCommand(command);
Expand Down
4 changes: 4 additions & 0 deletions sp/src/game/client/c_vguiscreen.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,10 @@ class C_VGuiScreen : public C_BaseEntity
public:
DECLARE_CLIENTCLASS();

#ifdef MAPBASE
C_VGuiScreen* m_pNext;
#endif // MAPBASE

C_VGuiScreen();
~C_VGuiScreen();

Expand Down
10 changes: 10 additions & 0 deletions sp/src/game/server/baseentity.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -606,6 +606,9 @@ class CBaseEntity : public IServerEntity

void ValidateEntityConnections();
void FireNamedOutput( const char *pszOutput, variant_t variant, CBaseEntity *pActivator, CBaseEntity *pCaller, float flDelay = 0.0f );
#ifdef MAPBASE
virtual
#endif
CBaseEntityOutput *FindNamedOutput( const char *pszOutput );
#ifdef MAPBASE_VSCRIPT
void ScriptFireOutput( const char *pszOutput, HSCRIPT hActivator, HSCRIPT hCaller, const char *szValue, float flDelay );
Expand DownExpand Up@@ -864,6 +867,13 @@ class CBaseEntity : public IServerEntity

void SetAIWalkable( bool bBlocksLOS );
bool IsAIWalkable( void );

#ifdef MAPBASE
// Handle a potentially complex command from a client.
// Returns true if the command was handled successfully.
virtual bool HandleEntityCommand(CBasePlayer* pClient, KeyValues* pKeyValues) { return false; }
#endif // MAPBASE

private:
int SaveDataDescBlock( ISave &save, datamap_t *dmap );
int RestoreDataDescBlock( IRestore &restore, datamap_t *dmap );
Expand Down
14 changes: 14 additions & 0 deletions sp/src/game/server/hl2/hl2_player.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3617,6 +3617,20 @@ void CHL2_Player::UpdateWeaponPosture( void )
{
m_LowerWeaponTimer.Set( .3 );
VPROF( "CHL2_Player::UpdateWeaponPosture-CheckLower" );

#ifdef MAPBASE
if (m_nButtons & IN_VGUIMODE)
{
//We're over a friendly, drop our weapon
if (Weapon_Lower() == false)
{
//FIXME: We couldn't lower our weapon!
}

return;
}
#endif // MAPBASE

Vector vecAim = BaseClass::GetAutoaimVector( AUTOAIM_SCALE_DIRECT_ONLY );

const float CHECK_FRIENDLY_RANGE = 50 * 12;
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions sp/src/game/client/c_baseplayer.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -1133,6 +1133,9 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2 | IN_VALIDVGUIINPUT);
#ifdef MAPBASE
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
return;
}
#else
Expand All@@ -1142,6 +1145,10 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
#ifdef MAPBASE
pCmd->buttons &= ~(IN_USE | IN_ATTACK3);
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
return;
}
#endif
Expand DownExpand Up@@ -1206,6 +1213,10 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
#ifdef MAPBASE
pCmd->buttons &= ~(IN_USE | IN_ATTACK3);
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
}
}

Expand Down
129 changes: 100 additions & 29 deletions sp/src/game/client/c_vguiscreen.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,14 @@ extern vgui::IInputInternal *g_InputInternal;
#define VGUI_SCREEN_MODE_RADIUS 80

//Precache the materials
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectVGuiScreen)
CLIENTEFFECT_MATERIAL("engine/writez")
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectVGuiScreen)
CLIENTEFFECT_MATERIAL("engine/writez")
CLIENTEFFECT_REGISTER_END()

#ifdef MAPBASE
C_EntityClassList<C_VGuiScreen> g_VGUIScreenList;
template <> C_VGuiScreen* C_EntityClassList<C_VGuiScreen>::m_pClassList = NULL;
#endif // MAPBASE

// ----------------------------------------------------------------------------- //
// This is a cache of preloaded keyvalues.
Expand DownExpand Up@@ -102,11 +106,19 @@ C_VGuiScreen::C_VGuiScreen()

m_WriteZMaterial.Init( "engine/writez", TEXTURE_GROUP_VGUI );
m_OverlayMaterial.Init( m_WriteZMaterial );

#ifdef MAPBASE
g_VGUIScreenList.Insert(this);
#endif // MAPBASE
}

C_VGuiScreen::~C_VGuiScreen()
{
DestroyVguiScreen();

#ifdef MAPBASE
g_VGUIScreenList.Remove(this);
#endif // MAPBASE
}

//-----------------------------------------------------------------------------
Expand DownExpand Up@@ -416,35 +428,70 @@ void C_VGuiScreen::ClientThink( void )
int px = (int)(u * m_nPixelWidth + 0.5f);
int py = (int)(v * m_nPixelHeight + 0.5f);

#ifndef MAPBASE
// Generate mouse input commands
if ((px != m_nOldPx) || (py != m_nOldPy))
{
g_InputInternal->InternalCursorMoved( px, py );
g_InputInternal->InternalCursorMoved(px, py);

m_nOldPx = px;
m_nOldPy = py;
}

if (m_nButtonPressed & IN_ATTACK)
{
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_PRESSED);
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_LEFT);
}
if (m_nButtonPressed & IN_ATTACK2)
{
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_RIGHT);
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_RIGHT);
}
if ((m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus
if ((m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus
{
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_LEFT);
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_LEFT);
}
if (m_nButtonReleased & IN_ATTACK2)
{
g_InputInternal->SetMouseCodeState( MOUSE_RIGHT, vgui::BUTTON_RELEASED );
g_InputInternal->InternalMouseReleased( MOUSE_RIGHT );
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_RIGHT);
}
#else
vgui::VPANEL focus = g_InputInternal->GetMouseOver();
// Generate mouse input commands
if ((px != m_nOldPx) || (py != m_nOldPy))
{
g_InputInternal->UpdateCursorPosInternal(px, py);

m_nOldPx = px;
m_nOldPy = py;

focus = pPanel->IsWithinTraverse(px, py, true);
g_InputInternal->SetMouseFocus(focus);
vgui::ivgui()->PostMessage(focus, new KeyValues("CursorMoved", "xpos", px, "ypos", py), NULL);
}

for (int i = 0; i < 2; i++)
{
const int nBit = i ? IN_ATTACK2 : (IN_ATTACK | IN_USE);
const vgui::MouseCode nButton = i ? MOUSE_RIGHT : MOUSE_LEFT;

if ((m_nButtonReleased & nBit) || ((m_nButtonState & nBit) && m_bLoseThinkNextFrame)) // for a button release on loosing focus
{
g_InputInternal->SetMouseCodeState(nButton, vgui::BUTTON_RELEASED);
vgui::ivgui()->PostMessage(focus, new KeyValues("MouseReleased", "code", nButton), NULL);
}
else if (m_nButtonPressed & nBit)
{
g_InputInternal->SetMouseCodeState(nButton, vgui::BUTTON_PRESSED);
vgui::ivgui()->PostMessage(focus, new KeyValues("MousePressed", "code", nButton), NULL);
}
}
#endif // !MAPBASE


if ( m_bLoseThinkNextFrame == true )
{
m_bLoseThinkNextFrame = false;
Expand DownExpand Up@@ -627,36 +674,37 @@ bool C_VGuiScreen::IsInputOnlyToOwner( void )
return (m_fScreenFlags & VGUI_SCREEN_ONLY_USABLE_BY_OWNER) != 0;
}

#ifndef MAPBASE
//-----------------------------------------------------------------------------
//
// Enumator class for finding vgui screens close to the local player
//
//-----------------------------------------------------------------------------
class CVGuiScreenEnumerator : public IPartitionEnumerator
{
DECLARE_CLASS_GAMEROOT(CVGuiScreenEnumerator, IPartitionEnumerator);
DECLARE_CLASS_GAMEROOT(CVGuiScreenEnumerator, IPartitionEnumerator);
public:
virtual IterationRetval_t EnumElement(IHandleEntity *pHandleEntity );
virtual IterationRetval_t EnumElement(IHandleEntity* pHandleEntity);

int GetScreenCount();
C_VGuiScreen *GetVGuiScreen(int index);
C_VGuiScreen* GetVGuiScreen(int index);

private:
CUtlVector< CHandle< C_VGuiScreen > > m_VguiScreens;
};

IterationRetval_t CVGuiScreenEnumerator::EnumElement(IHandleEntity *pHandleEntity )
IterationRetval_t CVGuiScreenEnumerator::EnumElement(IHandleEntity* pHandleEntity)
{
C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle(pHandleEntity->GetRefEHandle());
if (pEnt == NULL)
C_BaseEntity* pEnt = ClientEntityList().GetBaseEntityFromHandle(pHandleEntity->GetRefEHandle());
if (pEnt == NULL)
return ITERATION_CONTINUE;

// FIXME.. pretty expensive...
C_VGuiScreen *pScreen = dynamic_cast<C_VGuiScreen*>(pEnt);
if (pScreen)
C_VGuiScreen* pScreen = dynamic_cast<C_VGuiScreen*>(pEnt);
if (pScreen)
{
int i = m_VguiScreens.AddToTail();
m_VguiScreens[i].Set(pScreen);
int i = m_VguiScreens.AddToTail();
m_VguiScreens[i].Set(pScreen);
}

return ITERATION_CONTINUE;
Expand All@@ -667,10 +715,12 @@ int CVGuiScreenEnumerator::GetScreenCount()
return m_VguiScreens.Count();
}

C_VGuiScreen *CVGuiScreenEnumerator::GetVGuiScreen(int index)
C_VGuiScreen* CVGuiScreenEnumerator::GetVGuiScreen(int index)
{
return m_VguiScreens[index].Get();
}
}
#endif // !MAPBASE



//-----------------------------------------------------------------------------
Expand DownExpand Up@@ -704,18 +754,29 @@ C_BaseEntity *FindNearbyVguiScreen( const Vector &viewPosition, const QAngle &vi
Ray_t lookRay;
lookRay.Init( viewPosition, lookEnd );

#ifndef MAPBASE
// Look for vgui screens that are close to the player
CVGuiScreenEnumerator localScreens;
partition->EnumerateElementsInSphere( PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens );
partition->EnumerateElementsInSphere(PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens);
#endif // !MAPBASE

Vector vecOut, vecViewDelta;

float flBestDist = 2.0f;
C_VGuiScreen *pBestScreen = NULL;
#ifndef MAPBASE
for (int i = localScreens.GetScreenCount(); --i >= 0; )
#else
for (C_VGuiScreen* pScreen = g_VGUIScreenList.m_pClassList; pScreen != NULL; pScreen = pScreen->m_pNext)
#endif // !MAPBASE
{
C_VGuiScreen *pScreen = localScreens.GetVGuiScreen(i);

#ifndef MAPBASE
C_VGuiScreen* pScreen = localScreens.GetVGuiScreen(i);
#else
// Skip if out of PVS
if (pScreen->IsDormant())
continue;
#endif
if ( pScreen->IsAttachedToViewModel() )
continue;

Expand DownExpand Up@@ -865,11 +926,21 @@ vgui::Panel *CVGuiScreenPanel::CreateControlByName(const char *controlName)
//-----------------------------------------------------------------------------
// Purpose: Called when the user presses a button
//-----------------------------------------------------------------------------
void CVGuiScreenPanel::OnCommand(const char *command)
void CVGuiScreenPanel::OnCommand(const char* command)
{
if (Q_stricmp(command, "vguicancel" ) )
if (Q_stricmp(command, "vguicancel"))
{
engine->ClientCmd( const_cast<char *>( command ) );
#ifdef MAPBASE
if (m_hEntity && m_hEntity->IsServerEntity())
{
KeyValues* pCommand = new KeyValues("EntityCommand");
pCommand->SetInt("entindex", m_hEntity->index);
pCommand->SetString("command_data", command);
engine->ServerCmdKeyValues(pCommand);
}
else
#endif
engine->ClientCmd(const_cast<char*>(command));
}

BaseClass::OnCommand(command);
Expand Down
4 changes: 4 additions & 0 deletions sp/src/game/client/c_vguiscreen.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,10 @@ class C_VGuiScreen : public C_BaseEntity
public:
DECLARE_CLIENTCLASS();

#ifdef MAPBASE
C_VGuiScreen* m_pNext;
#endif // MAPBASE

C_VGuiScreen();
~C_VGuiScreen();

Expand Down
10 changes: 10 additions & 0 deletions sp/src/game/server/baseentity.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -606,6 +606,9 @@ class CBaseEntity : public IServerEntity

void ValidateEntityConnections();
void FireNamedOutput( const char *pszOutput, variant_t variant, CBaseEntity *pActivator, CBaseEntity *pCaller, float flDelay = 0.0f );
#ifdef MAPBASE
virtual
#endif
CBaseEntityOutput *FindNamedOutput( const char *pszOutput );
#ifdef MAPBASE_VSCRIPT
void ScriptFireOutput( const char *pszOutput, HSCRIPT hActivator, HSCRIPT hCaller, const char *szValue, float flDelay );
Expand DownExpand Up@@ -864,6 +867,13 @@ class CBaseEntity : public IServerEntity

void SetAIWalkable( bool bBlocksLOS );
bool IsAIWalkable( void );

#ifdef MAPBASE
// Handle a potentially complex command from a client.
// Returns true if the command was handled successfully.
virtual bool HandleEntityCommand(CBasePlayer* pClient, KeyValues* pKeyValues) { return false; }
#endif // MAPBASE

private:
int SaveDataDescBlock( ISave &save, datamap_t *dmap );
int RestoreDataDescBlock( IRestore &restore, datamap_t *dmap );
Expand Down
14 changes: 14 additions & 0 deletions sp/src/game/server/hl2/hl2_player.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3617,6 +3617,20 @@ void CHL2_Player::UpdateWeaponPosture( void )
{
m_LowerWeaponTimer.Set( .3 );
VPROF( "CHL2_Player::UpdateWeaponPosture-CheckLower" );

#ifdef MAPBASE
if (m_nButtons & IN_VGUIMODE)
{
//We're over a friendly, drop our weapon
if (Weapon_Lower() == false)
{
//FIXME: We couldn't lower our weapon!
}

return;
}
#endif // MAPBASE

Vector vecAim = BaseClass::GetAutoaimVector( AUTOAIM_SCALE_DIRECT_ONLY );

const float CHECK_FRIENDLY_RANGE = 50 * 12;
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions sp/src/game/client/c_baseplayer.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -1133,6 +1133,9 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2 | IN_VALIDVGUIINPUT);
#ifdef MAPBASE
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
return;
}
#else
Expand All@@ -1142,6 +1145,10 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
#ifdef MAPBASE
pCmd->buttons &= ~(IN_USE | IN_ATTACK3);
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
return;
}
#endif
Expand DownExpand Up@@ -1206,6 +1213,10 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
#ifdef MAPBASE
pCmd->buttons &= ~(IN_USE | IN_ATTACK3);
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
}
}

Expand Down
129 changes: 100 additions & 29 deletions sp/src/game/client/c_vguiscreen.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,14 @@ extern vgui::IInputInternal *g_InputInternal;
#define VGUI_SCREEN_MODE_RADIUS 80

//Precache the materials
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectVGuiScreen)
CLIENTEFFECT_MATERIAL("engine/writez")
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectVGuiScreen)
CLIENTEFFECT_MATERIAL("engine/writez")
CLIENTEFFECT_REGISTER_END()

#ifdef MAPBASE
C_EntityClassList<C_VGuiScreen> g_VGUIScreenList;
template <> C_VGuiScreen* C_EntityClassList<C_VGuiScreen>::m_pClassList = NULL;
#endif // MAPBASE

// ----------------------------------------------------------------------------- //
// This is a cache of preloaded keyvalues.
Expand DownExpand Up@@ -102,11 +106,19 @@ C_VGuiScreen::C_VGuiScreen()

m_WriteZMaterial.Init( "engine/writez", TEXTURE_GROUP_VGUI );
m_OverlayMaterial.Init( m_WriteZMaterial );

#ifdef MAPBASE
g_VGUIScreenList.Insert(this);
#endif // MAPBASE
}

C_VGuiScreen::~C_VGuiScreen()
{
DestroyVguiScreen();

#ifdef MAPBASE
g_VGUIScreenList.Remove(this);
#endif // MAPBASE
}

//-----------------------------------------------------------------------------
Expand DownExpand Up@@ -416,35 +428,70 @@ void C_VGuiScreen::ClientThink( void )
int px = (int)(u * m_nPixelWidth + 0.5f);
int py = (int)(v * m_nPixelHeight + 0.5f);

#ifndef MAPBASE
// Generate mouse input commands
if ((px != m_nOldPx) || (py != m_nOldPy))
{
g_InputInternal->InternalCursorMoved( px, py );
g_InputInternal->InternalCursorMoved(px, py);

m_nOldPx = px;
m_nOldPy = py;
}

if (m_nButtonPressed & IN_ATTACK)
{
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_PRESSED);
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_LEFT);
}
if (m_nButtonPressed & IN_ATTACK2)
{
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_RIGHT);
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_RIGHT);
}
if ((m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus
if ((m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus
{
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_LEFT);
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_LEFT);
}
if (m_nButtonReleased & IN_ATTACK2)
{
g_InputInternal->SetMouseCodeState( MOUSE_RIGHT, vgui::BUTTON_RELEASED );
g_InputInternal->InternalMouseReleased( MOUSE_RIGHT );
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_RIGHT);
}
#else
vgui::VPANEL focus = g_InputInternal->GetMouseOver();
// Generate mouse input commands
if ((px != m_nOldPx) || (py != m_nOldPy))
{
g_InputInternal->UpdateCursorPosInternal(px, py);

m_nOldPx = px;
m_nOldPy = py;

focus = pPanel->IsWithinTraverse(px, py, true);
g_InputInternal->SetMouseFocus(focus);
vgui::ivgui()->PostMessage(focus, new KeyValues("CursorMoved", "xpos", px, "ypos", py), NULL);
}

for (int i = 0; i < 2; i++)
{
const int nBit = i ? IN_ATTACK2 : (IN_ATTACK | IN_USE);
const vgui::MouseCode nButton = i ? MOUSE_RIGHT : MOUSE_LEFT;

if ((m_nButtonReleased & nBit) || ((m_nButtonState & nBit) && m_bLoseThinkNextFrame)) // for a button release on loosing focus
{
g_InputInternal->SetMouseCodeState(nButton, vgui::BUTTON_RELEASED);
vgui::ivgui()->PostMessage(focus, new KeyValues("MouseReleased", "code", nButton), NULL);
}
else if (m_nButtonPressed & nBit)
{
g_InputInternal->SetMouseCodeState(nButton, vgui::BUTTON_PRESSED);
vgui::ivgui()->PostMessage(focus, new KeyValues("MousePressed", "code", nButton), NULL);
}
}
#endif // !MAPBASE


if ( m_bLoseThinkNextFrame == true )
{
m_bLoseThinkNextFrame = false;
Expand DownExpand Up@@ -627,36 +674,37 @@ bool C_VGuiScreen::IsInputOnlyToOwner( void )
return (m_fScreenFlags & VGUI_SCREEN_ONLY_USABLE_BY_OWNER) != 0;
}

#ifndef MAPBASE
//-----------------------------------------------------------------------------
//
// Enumator class for finding vgui screens close to the local player
//
//-----------------------------------------------------------------------------
class CVGuiScreenEnumerator : public IPartitionEnumerator
{
DECLARE_CLASS_GAMEROOT(CVGuiScreenEnumerator, IPartitionEnumerator);
DECLARE_CLASS_GAMEROOT(CVGuiScreenEnumerator, IPartitionEnumerator);
public:
virtual IterationRetval_t EnumElement(IHandleEntity *pHandleEntity );
virtual IterationRetval_t EnumElement(IHandleEntity* pHandleEntity);

int GetScreenCount();
C_VGuiScreen *GetVGuiScreen(int index);
C_VGuiScreen* GetVGuiScreen(int index);

private:
CUtlVector< CHandle< C_VGuiScreen > > m_VguiScreens;
};

IterationRetval_t CVGuiScreenEnumerator::EnumElement(IHandleEntity *pHandleEntity )
IterationRetval_t CVGuiScreenEnumerator::EnumElement(IHandleEntity* pHandleEntity)
{
C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle(pHandleEntity->GetRefEHandle());
if (pEnt == NULL)
C_BaseEntity* pEnt = ClientEntityList().GetBaseEntityFromHandle(pHandleEntity->GetRefEHandle());
if (pEnt == NULL)
return ITERATION_CONTINUE;

// FIXME.. pretty expensive...
C_VGuiScreen *pScreen = dynamic_cast<C_VGuiScreen*>(pEnt);
if (pScreen)
C_VGuiScreen* pScreen = dynamic_cast<C_VGuiScreen*>(pEnt);
if (pScreen)
{
int i = m_VguiScreens.AddToTail();
m_VguiScreens[i].Set(pScreen);
int i = m_VguiScreens.AddToTail();
m_VguiScreens[i].Set(pScreen);
}

return ITERATION_CONTINUE;
Expand All@@ -667,10 +715,12 @@ int CVGuiScreenEnumerator::GetScreenCount()
return m_VguiScreens.Count();
}

C_VGuiScreen *CVGuiScreenEnumerator::GetVGuiScreen(int index)
C_VGuiScreen* CVGuiScreenEnumerator::GetVGuiScreen(int index)
{
return m_VguiScreens[index].Get();
}
}
#endif // !MAPBASE



//-----------------------------------------------------------------------------
Expand DownExpand Up@@ -704,18 +754,29 @@ C_BaseEntity *FindNearbyVguiScreen( const Vector &viewPosition, const QAngle &vi
Ray_t lookRay;
lookRay.Init( viewPosition, lookEnd );

#ifndef MAPBASE
// Look for vgui screens that are close to the player
CVGuiScreenEnumerator localScreens;
partition->EnumerateElementsInSphere( PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens );
partition->EnumerateElementsInSphere(PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens);
#endif // !MAPBASE

Vector vecOut, vecViewDelta;

float flBestDist = 2.0f;
C_VGuiScreen *pBestScreen = NULL;
#ifndef MAPBASE
for (int i = localScreens.GetScreenCount(); --i >= 0; )
#else
for (C_VGuiScreen* pScreen = g_VGUIScreenList.m_pClassList; pScreen != NULL; pScreen = pScreen->m_pNext)
#endif // !MAPBASE
{
C_VGuiScreen *pScreen = localScreens.GetVGuiScreen(i);

#ifndef MAPBASE
C_VGuiScreen* pScreen = localScreens.GetVGuiScreen(i);
#else
// Skip if out of PVS
if (pScreen->IsDormant())
continue;
#endif
if ( pScreen->IsAttachedToViewModel() )
continue;

Expand DownExpand Up@@ -865,11 +926,21 @@ vgui::Panel *CVGuiScreenPanel::CreateControlByName(const char *controlName)
//-----------------------------------------------------------------------------
// Purpose: Called when the user presses a button
//-----------------------------------------------------------------------------
void CVGuiScreenPanel::OnCommand(const char *command)
void CVGuiScreenPanel::OnCommand(const char* command)
{
if (Q_stricmp(command, "vguicancel" ) )
if (Q_stricmp(command, "vguicancel"))
{
engine->ClientCmd( const_cast<char *>( command ) );
#ifdef MAPBASE
if (m_hEntity && m_hEntity->IsServerEntity())
{
KeyValues* pCommand = new KeyValues("EntityCommand");
pCommand->SetInt("entindex", m_hEntity->index);
pCommand->SetString("command_data", command);
engine->ServerCmdKeyValues(pCommand);
}
else
#endif
engine->ClientCmd(const_cast<char*>(command));
}

BaseClass::OnCommand(command);
Expand Down
4 changes: 4 additions & 0 deletions sp/src/game/client/c_vguiscreen.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,10 @@ class C_VGuiScreen : public C_BaseEntity
public:
DECLARE_CLIENTCLASS();

#ifdef MAPBASE
C_VGuiScreen* m_pNext;
#endif // MAPBASE

C_VGuiScreen();
~C_VGuiScreen();

Expand Down
10 changes: 10 additions & 0 deletions sp/src/game/server/baseentity.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -606,6 +606,9 @@ class CBaseEntity : public IServerEntity

void ValidateEntityConnections();
void FireNamedOutput( const char *pszOutput, variant_t variant, CBaseEntity *pActivator, CBaseEntity *pCaller, float flDelay = 0.0f );
#ifdef MAPBASE
virtual
#endif
CBaseEntityOutput *FindNamedOutput( const char *pszOutput );
#ifdef MAPBASE_VSCRIPT
void ScriptFireOutput( const char *pszOutput, HSCRIPT hActivator, HSCRIPT hCaller, const char *szValue, float flDelay );
Expand DownExpand Up@@ -864,6 +867,13 @@ class CBaseEntity : public IServerEntity

void SetAIWalkable( bool bBlocksLOS );
bool IsAIWalkable( void );

#ifdef MAPBASE
// Handle a potentially complex command from a client.
// Returns true if the command was handled successfully.
virtual bool HandleEntityCommand(CBasePlayer* pClient, KeyValues* pKeyValues) { return false; }
#endif // MAPBASE

private:
int SaveDataDescBlock( ISave &save, datamap_t *dmap );
int RestoreDataDescBlock( IRestore &restore, datamap_t *dmap );
Expand Down
14 changes: 14 additions & 0 deletions sp/src/game/server/hl2/hl2_player.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3617,6 +3617,20 @@ void CHL2_Player::UpdateWeaponPosture( void )
{
m_LowerWeaponTimer.Set( .3 );
VPROF( "CHL2_Player::UpdateWeaponPosture-CheckLower" );

#ifdef MAPBASE
if (m_nButtons & IN_VGUIMODE)
{
//We're over a friendly, drop our weapon
if (Weapon_Lower() == false)
{
//FIXME: We couldn't lower our weapon!
}

return;
}
#endif // MAPBASE

Vector vecAim = BaseClass::GetAutoaimVector( AUTOAIM_SCALE_DIRECT_ONLY );

const float CHECK_FRIENDLY_RANGE = 50 * 12;
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions sp/src/game/client/c_baseplayer.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -1133,6 +1133,9 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2 | IN_VALIDVGUIINPUT);
#ifdef MAPBASE
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
return;
}
#else
Expand All@@ -1142,6 +1145,10 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
#ifdef MAPBASE
pCmd->buttons &= ~(IN_USE | IN_ATTACK3);
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
return;
}
#endif
Expand DownExpand Up@@ -1206,6 +1213,10 @@ void C_BasePlayer::DetermineVguiInputMode( CUserCmd *pCmd )

// Kill all attack inputs if we're in vgui screen mode
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
#ifdef MAPBASE
pCmd->buttons &= ~(IN_USE | IN_ATTACK3);
pCmd->buttons |= IN_VGUIMODE;
#endif // MAPBASE
}
}

Expand Down
129 changes: 100 additions & 29 deletions sp/src/game/client/c_vguiscreen.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,10 +38,14 @@ extern vgui::IInputInternal *g_InputInternal;
#define VGUI_SCREEN_MODE_RADIUS 80

//Precache the materials
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectVGuiScreen)
CLIENTEFFECT_MATERIAL("engine/writez")
CLIENTEFFECT_REGISTER_BEGIN(PrecacheEffectVGuiScreen)
CLIENTEFFECT_MATERIAL("engine/writez")
CLIENTEFFECT_REGISTER_END()

#ifdef MAPBASE
C_EntityClassList<C_VGuiScreen> g_VGUIScreenList;
template <> C_VGuiScreen* C_EntityClassList<C_VGuiScreen>::m_pClassList = NULL;
#endif // MAPBASE

// ----------------------------------------------------------------------------- //
// This is a cache of preloaded keyvalues.
Expand DownExpand Up@@ -102,11 +106,19 @@ C_VGuiScreen::C_VGuiScreen()

m_WriteZMaterial.Init( "engine/writez", TEXTURE_GROUP_VGUI );
m_OverlayMaterial.Init( m_WriteZMaterial );

#ifdef MAPBASE
g_VGUIScreenList.Insert(this);
#endif // MAPBASE
}

C_VGuiScreen::~C_VGuiScreen()
{
DestroyVguiScreen();

#ifdef MAPBASE
g_VGUIScreenList.Remove(this);
#endif // MAPBASE
}

//-----------------------------------------------------------------------------
Expand DownExpand Up@@ -416,35 +428,70 @@ void C_VGuiScreen::ClientThink( void )
int px = (int)(u * m_nPixelWidth + 0.5f);
int py = (int)(v * m_nPixelHeight + 0.5f);

#ifndef MAPBASE
// Generate mouse input commands
if ((px != m_nOldPx) || (py != m_nOldPy))
{
g_InputInternal->InternalCursorMoved( px, py );
g_InputInternal->InternalCursorMoved(px, py);

m_nOldPx = px;
m_nOldPy = py;
}

if (m_nButtonPressed & IN_ATTACK)
{
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_PRESSED);
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_LEFT);
}
if (m_nButtonPressed & IN_ATTACK2)
{
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_RIGHT);
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_PRESSED);
g_InputInternal->InternalMousePressed(MOUSE_RIGHT);
}
if ((m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus
if ((m_nButtonReleased & IN_ATTACK) || m_bLoseThinkNextFrame) // for a button release on loosing focus
{
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_LEFT);
g_InputInternal->SetMouseCodeState(MOUSE_LEFT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_LEFT);
}
if (m_nButtonReleased & IN_ATTACK2)
{
g_InputInternal->SetMouseCodeState( MOUSE_RIGHT, vgui::BUTTON_RELEASED );
g_InputInternal->InternalMouseReleased( MOUSE_RIGHT );
g_InputInternal->SetMouseCodeState(MOUSE_RIGHT, vgui::BUTTON_RELEASED);
g_InputInternal->InternalMouseReleased(MOUSE_RIGHT);
}
#else
vgui::VPANEL focus = g_InputInternal->GetMouseOver();
// Generate mouse input commands
if ((px != m_nOldPx) || (py != m_nOldPy))
{
g_InputInternal->UpdateCursorPosInternal(px, py);

m_nOldPx = px;
m_nOldPy = py;

focus = pPanel->IsWithinTraverse(px, py, true);
g_InputInternal->SetMouseFocus(focus);
vgui::ivgui()->PostMessage(focus, new KeyValues("CursorMoved", "xpos", px, "ypos", py), NULL);
}

for (int i = 0; i < 2; i++)
{
const int nBit = i ? IN_ATTACK2 : (IN_ATTACK | IN_USE);
const vgui::MouseCode nButton = i ? MOUSE_RIGHT : MOUSE_LEFT;

if ((m_nButtonReleased & nBit) || ((m_nButtonState & nBit) && m_bLoseThinkNextFrame)) // for a button release on loosing focus
{
g_InputInternal->SetMouseCodeState(nButton, vgui::BUTTON_RELEASED);
vgui::ivgui()->PostMessage(focus, new KeyValues("MouseReleased", "code", nButton), NULL);
}
else if (m_nButtonPressed & nBit)
{
g_InputInternal->SetMouseCodeState(nButton, vgui::BUTTON_PRESSED);
vgui::ivgui()->PostMessage(focus, new KeyValues("MousePressed", "code", nButton), NULL);
}
}
#endif // !MAPBASE


if ( m_bLoseThinkNextFrame == true )
{
m_bLoseThinkNextFrame = false;
Expand DownExpand Up@@ -627,36 +674,37 @@ bool C_VGuiScreen::IsInputOnlyToOwner( void )
return (m_fScreenFlags & VGUI_SCREEN_ONLY_USABLE_BY_OWNER) != 0;
}

#ifndef MAPBASE
//-----------------------------------------------------------------------------
//
// Enumator class for finding vgui screens close to the local player
//
//-----------------------------------------------------------------------------
class CVGuiScreenEnumerator : public IPartitionEnumerator
{
DECLARE_CLASS_GAMEROOT(CVGuiScreenEnumerator, IPartitionEnumerator);
DECLARE_CLASS_GAMEROOT(CVGuiScreenEnumerator, IPartitionEnumerator);
public:
virtual IterationRetval_t EnumElement(IHandleEntity *pHandleEntity );
virtual IterationRetval_t EnumElement(IHandleEntity* pHandleEntity);

int GetScreenCount();
C_VGuiScreen *GetVGuiScreen(int index);
C_VGuiScreen* GetVGuiScreen(int index);

private:
CUtlVector< CHandle< C_VGuiScreen > > m_VguiScreens;
};

IterationRetval_t CVGuiScreenEnumerator::EnumElement(IHandleEntity *pHandleEntity )
IterationRetval_t CVGuiScreenEnumerator::EnumElement(IHandleEntity* pHandleEntity)
{
C_BaseEntity *pEnt = ClientEntityList().GetBaseEntityFromHandle(pHandleEntity->GetRefEHandle());
if (pEnt == NULL)
C_BaseEntity* pEnt = ClientEntityList().GetBaseEntityFromHandle(pHandleEntity->GetRefEHandle());
if (pEnt == NULL)
return ITERATION_CONTINUE;

// FIXME.. pretty expensive...
C_VGuiScreen *pScreen = dynamic_cast<C_VGuiScreen*>(pEnt);
if (pScreen)
C_VGuiScreen* pScreen = dynamic_cast<C_VGuiScreen*>(pEnt);
if (pScreen)
{
int i = m_VguiScreens.AddToTail();
m_VguiScreens[i].Set(pScreen);
int i = m_VguiScreens.AddToTail();
m_VguiScreens[i].Set(pScreen);
}

return ITERATION_CONTINUE;
Expand All@@ -667,10 +715,12 @@ int CVGuiScreenEnumerator::GetScreenCount()
return m_VguiScreens.Count();
}

C_VGuiScreen *CVGuiScreenEnumerator::GetVGuiScreen(int index)
C_VGuiScreen* CVGuiScreenEnumerator::GetVGuiScreen(int index)
{
return m_VguiScreens[index].Get();
}
}
#endif // !MAPBASE



//-----------------------------------------------------------------------------
Expand DownExpand Up@@ -704,18 +754,29 @@ C_BaseEntity *FindNearbyVguiScreen( const Vector &viewPosition, const QAngle &vi
Ray_t lookRay;
lookRay.Init( viewPosition, lookEnd );

#ifndef MAPBASE
// Look for vgui screens that are close to the player
CVGuiScreenEnumerator localScreens;
partition->EnumerateElementsInSphere( PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens );
partition->EnumerateElementsInSphere(PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens);
#endif // !MAPBASE

Vector vecOut, vecViewDelta;

float flBestDist = 2.0f;
C_VGuiScreen *pBestScreen = NULL;
#ifndef MAPBASE
for (int i = localScreens.GetScreenCount(); --i >= 0; )
#else
for (C_VGuiScreen* pScreen = g_VGUIScreenList.m_pClassList; pScreen != NULL; pScreen = pScreen->m_pNext)
#endif // !MAPBASE
{
C_VGuiScreen *pScreen = localScreens.GetVGuiScreen(i);

#ifndef MAPBASE
C_VGuiScreen* pScreen = localScreens.GetVGuiScreen(i);
#else
// Skip if out of PVS
if (pScreen->IsDormant())
continue;
#endif
if ( pScreen->IsAttachedToViewModel() )
continue;

Expand DownExpand Up@@ -865,11 +926,21 @@ vgui::Panel *CVGuiScreenPanel::CreateControlByName(const char *controlName)
//-----------------------------------------------------------------------------
// Purpose: Called when the user presses a button
//-----------------------------------------------------------------------------
void CVGuiScreenPanel::OnCommand(const char *command)
void CVGuiScreenPanel::OnCommand(const char* command)
{
if (Q_stricmp(command, "vguicancel" ) )
if (Q_stricmp(command, "vguicancel"))
{
engine->ClientCmd( const_cast<char *>( command ) );
#ifdef MAPBASE
if (m_hEntity && m_hEntity->IsServerEntity())
{
KeyValues* pCommand = new KeyValues("EntityCommand");
pCommand->SetInt("entindex", m_hEntity->index);
pCommand->SetString("command_data", command);
engine->ServerCmdKeyValues(pCommand);
}
else
#endif
engine->ClientCmd(const_cast<char*>(command));
}

BaseClass::OnCommand(command);
Expand Down
4 changes: 4 additions & 0 deletions sp/src/game/client/c_vguiscreen.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,6 +66,10 @@ class C_VGuiScreen : public C_BaseEntity
public:
DECLARE_CLIENTCLASS();

#ifdef MAPBASE
C_VGuiScreen* m_pNext;
#endif // MAPBASE

C_VGuiScreen();
~C_VGuiScreen();

Expand Down
10 changes: 10 additions & 0 deletions sp/src/game/server/baseentity.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -606,6 +606,9 @@ class CBaseEntity : public IServerEntity

void ValidateEntityConnections();
void FireNamedOutput( const char *pszOutput, variant_t variant, CBaseEntity *pActivator, CBaseEntity *pCaller, float flDelay = 0.0f );
#ifdef MAPBASE
virtual
#endif
CBaseEntityOutput *FindNamedOutput( const char *pszOutput );
#ifdef MAPBASE_VSCRIPT
void ScriptFireOutput( const char *pszOutput, HSCRIPT hActivator, HSCRIPT hCaller, const char *szValue, float flDelay );
Expand DownExpand Up@@ -864,6 +867,13 @@ class CBaseEntity : public IServerEntity

void SetAIWalkable( bool bBlocksLOS );
bool IsAIWalkable( void );

#ifdef MAPBASE
// Handle a potentially complex command from a client.
// Returns true if the command was handled successfully.
virtual bool HandleEntityCommand(CBasePlayer* pClient, KeyValues* pKeyValues) { return false; }
#endif // MAPBASE

private:
int SaveDataDescBlock( ISave &save, datamap_t *dmap );
int RestoreDataDescBlock( IRestore &restore, datamap_t *dmap );
Expand Down
14 changes: 14 additions & 0 deletions sp/src/game/server/hl2/hl2_player.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3617,6 +3617,20 @@ void CHL2_Player::UpdateWeaponPosture( void )
{
m_LowerWeaponTimer.Set( .3 );
VPROF( "CHL2_Player::UpdateWeaponPosture-CheckLower" );

#ifdef MAPBASE
if (m_nButtons & IN_VGUIMODE)
{
//We're over a friendly, drop our weapon
if (Weapon_Lower() == false)
{
//FIXME: We couldn't lower our weapon!
}

return;
}
#endif // MAPBASE

Vector vecAim = BaseClass::GetAutoaimVector( AUTOAIM_SCALE_DIRECT_ONLY );

const float CHECK_FRIENDLY_RANGE = 50 * 12;
Expand Down
Loading