uid issue

This commit is contained in:
KittenPopo
2021-07-24 21:11:47 -07:00
commit c2130ba4e9
13850 changed files with 6241419 additions and 0 deletions

457
vguimatsurface/Clip2D.cpp Normal file
View File

@ -0,0 +1,457 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Contains 2D clipping routines
//
// $Revision: $
// $NoKeywords: $
//=============================================================================//
#include <vgui/ISurface.h>
#include "Clip2D.h"
#include "tier0/dbg.h"
#include "utlvector.h"
#if defined( _GAMECONSOLE )
#include "materialsystem/imaterialsystem.h"
#endif
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
//-----------------------------------------------------------------------------
// Stretch texture to fit window ( before scissoring )
//-----------------------------------------------------------------------------
static bool g_bStretchTexture = false;
//-----------------------------------------------------------------------------
// Max # of vertices for clipping
//-----------------------------------------------------------------------------
enum
{
VGUI_VERTEX_TEMP_COUNT = 48,
};
//-----------------------------------------------------------------------------
// For simulated scissor tests...
//-----------------------------------------------------------------------------
struct ScissorRect_t
{
int left;
int top;
int right;
int bottom;
};
static ScissorRect_t g_ScissorRect;
static bool g_bScissor = false;
static bool g_bFullScreenScissor = false;
//-----------------------------------------------------------------------------
// Enable/disable scissoring...
//-----------------------------------------------------------------------------
void EnableScissor( bool enable )
{
g_bScissor = enable;
}
void SetScissorRect( int left, int top, int right, int bottom )
{
// Check for a valid rectangle...
Assert( left <= right );
Assert( top <= bottom );
if ( g_ScissorRect.left == left && g_ScissorRect.right == right &&
g_ScissorRect.top == top && g_ScissorRect.bottom == bottom )
return;
g_ScissorRect.left = left;
g_ScissorRect.top = top;
g_ScissorRect.right = right;
g_ScissorRect.bottom = bottom;
#if defined( _GAMECONSOLE )
// no reason to waste cpu on full screen scissor, gpu does it
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
int vx, vy, vw, vh;
pRenderContext->GetViewport( vx, vy, vw, vh );
g_bFullScreenScissor = (left <= vx && top <= vy && right >= vw && bottom >= vh );
#endif
}
void GetScissorRect( int &left, int &top, int &right, int &bottom, bool &enabled )
{
left = g_ScissorRect.left;
top = g_ScissorRect.top;
right = g_ScissorRect.right;
bottom = g_ScissorRect.bottom;
enabled = g_bScissor;
}
//-----------------------------------------------------------------------------
// Used to clip the shadow decals
//-----------------------------------------------------------------------------
struct PolygonClipState_t
{
int m_CurrVert;
int m_TempCount;
int m_ClipCount;
vgui::Vertex_t m_pTempVertices[VGUI_VERTEX_TEMP_COUNT];
vgui::Vertex_t* m_ppClipVertices[2][VGUI_VERTEX_TEMP_COUNT];
};
//-----------------------------------------------------------------------------
// Clipping methods for 2D
//-----------------------------------------------------------------------------
class CClipTop
{
public:
static inline bool Inside( vgui::Vertex_t const& vert )
{
return vert.m_Position.y >= g_ScissorRect.top;
}
static inline float Clip( const Vector2D& one, const Vector2D& two )
{
return (g_ScissorRect.top - one.y) / (two.y - one.y);
}
};
class CClipLeft
{
public:
static inline bool Inside( vgui::Vertex_t const& vert )
{
return vert.m_Position.x >= g_ScissorRect.left;
}
static inline float Clip( const Vector2D& one, const Vector2D& two )
{
return (one.x - g_ScissorRect.left) / (one.x - two.x);
}
};
class CClipRight
{
public:
static inline bool Inside( vgui::Vertex_t const& vert )
{
return vert.m_Position.x < g_ScissorRect.right;
}
static inline float Clip( const Vector2D& one, const Vector2D& two )
{
return (g_ScissorRect.right - one.x) / (two.x - one.x);
}
};
class CClipBottom
{
public:
static inline bool Inside( vgui::Vertex_t const& vert )
{
return vert.m_Position.y < g_ScissorRect.bottom;
}
static inline float Clip( const Vector2D& one, const Vector2D& two )
{
return (one.y - g_ScissorRect.bottom) / (one.y - two.y);
}
};
template <class Clipper>
static inline void Intersect( const vgui::Vertex_t& start, const vgui::Vertex_t& end, vgui::Vertex_t* pOut, Clipper& clipper )
{
// Clip to the scissor rectangle
float t = Clipper::Clip( start.m_Position, end.m_Position );
Vector2DLerp( start.m_Position, end.m_Position, t, pOut->m_Position );
Vector2DLerp( start.m_TexCoord, end.m_TexCoord, t, pOut->m_TexCoord );
}
//-----------------------------------------------------------------------------
// Clips a line segment to a single plane
//-----------------------------------------------------------------------------
template< class Clipper >
bool ClipLineToPlane( Clipper &clipper, const vgui::Vertex_t *pInVerts, vgui::Vertex_t* pOutVerts )
{
bool startInside = Clipper::Inside( pInVerts[0] );
bool endInside = Clipper::Inside( pInVerts[1] );
// Cull
if (!startInside && !endInside)
return false;
if (startInside && endInside)
{
pOutVerts[0] = pInVerts[0];
pOutVerts[1] = pInVerts[1];
}
else
{
int inIndex = startInside ? 0 : 1;
pOutVerts[inIndex] = pInVerts[inIndex];
Intersect( pInVerts[0], pInVerts[1], &pOutVerts[1 - inIndex], clipper );
}
return true;
}
//-----------------------------------------------------------------------------
// Clips a line segment to the current scissor rectangle
//-----------------------------------------------------------------------------
bool ClipLine( const vgui::Vertex_t *pInVerts, vgui::Vertex_t* pOutVerts )
{
if ( g_bScissor && !g_bFullScreenScissor )
{
// Clippers...
CClipTop top;
CClipBottom bottom;
CClipLeft left;
CClipRight right;
// Sutherland-hodgman clip, not particularly efficient but that's ok for now
vgui::Vertex_t tempVerts[2];
if (!ClipLineToPlane( top, pInVerts, tempVerts ))
return false;
if (!ClipLineToPlane( bottom, tempVerts, pOutVerts ))
return false;
if (!ClipLineToPlane( left, pOutVerts, tempVerts ))
return false;
if (!ClipLineToPlane( right, tempVerts, pOutVerts ))
return false;
return true;
}
else
{
pOutVerts[0] = pInVerts[0];
pOutVerts[1] = pInVerts[1];
return true;
}
}
//-----------------------------------------------------------------------------
// Methods associated with clipping 2D polygons
//-----------------------------------------------------------------------------
struct ScreenClipState_t
{
int m_iCurrVert;
int m_iTempCount;
int m_iClipCount;
CUtlVector<vgui::Vertex_t> m_pTempVertices;
CUtlVector<vgui::Vertex_t*> m_ppClipVertices[2];
};
template <class Clipper>
static void ScreenClip( ScreenClipState_t& clip, Clipper& clipper )
{
if (clip.m_iClipCount < 3)
return;
// Ye Olde Sutherland-Hodgman clipping algorithm
int numOutVerts = 0;
vgui::Vertex_t** pSrcVert = clip.m_ppClipVertices[clip.m_iCurrVert].Base();
vgui::Vertex_t** pDestVert = clip.m_ppClipVertices[!clip.m_iCurrVert].Base();
int numVerts = clip.m_iClipCount;
vgui::Vertex_t* pStart = pSrcVert[numVerts-1];
bool startInside = Clipper::Inside( *pStart );
for (int i = 0; i < numVerts; ++i)
{
vgui::Vertex_t* pEnd = pSrcVert[i];
bool endInside = Clipper::Inside( *pEnd );
if (endInside)
{
if (!startInside)
{
// Started outside, ended inside, need to clip the edge
Assert( clip.m_iTempCount <= clip.m_pTempVertices.Count() );
// Allocate a new clipped vertex
pDestVert[numOutVerts] = &clip.m_pTempVertices[clip.m_iTempCount++];
// Clip the edge to the clip plane
Intersect( *pStart, *pEnd, pDestVert[numOutVerts], clipper );
++numOutVerts;
}
pDestVert[numOutVerts++] = pEnd;
}
else
{
if (startInside)
{
// Started inside, ended outside, need to clip the edge
Assert( clip.m_iTempCount <= clip.m_pTempVertices.Count() );
// Allocate a new clipped vertex
pDestVert[numOutVerts] = &clip.m_pTempVertices[clip.m_iTempCount++];
// Clip the edge to the clip plane
Intersect( *pStart, *pEnd, pDestVert[numOutVerts], clipper );
++numOutVerts;
}
}
pStart = pEnd;
startInside = endInside;
}
// Switch source lists
clip.m_iCurrVert = 1 - clip.m_iCurrVert;
clip.m_iClipCount = numOutVerts;
}
//-----------------------------------------------------------------------------
// Clips a polygon to the screen area
//-----------------------------------------------------------------------------
int ClipPolygon( int iCount, vgui::Vertex_t *pVerts, int iTranslateX, int iTranslateY, vgui::Vertex_t ***pppOutVertex )
{
static ScreenClipState_t clip;
// Allocate enough room in the clip state...
// Having no reallocations during clipping
clip.m_pTempVertices.EnsureCount( iCount * 4 );
clip.m_ppClipVertices[0].EnsureCount( iCount * 4 );
clip.m_ppClipVertices[1].EnsureCount( iCount * 4 );
// Copy the initial verts in...
for (int i = 0; i < iCount; ++i)
{
// NOTE: This only works because we EnsuredCount above
clip.m_pTempVertices[i] = pVerts[i];
clip.m_pTempVertices[i].m_Position.x += iTranslateX;
clip.m_pTempVertices[i].m_Position.y += iTranslateY;
clip.m_ppClipVertices[0][i] = &clip.m_pTempVertices[i];
}
if ( !g_bScissor || g_bFullScreenScissor )
{
Assert(pppOutVertex);
*pppOutVertex = clip.m_ppClipVertices[0].Base();
return iCount;
}
clip.m_iClipCount = iCount;
clip.m_iTempCount = iCount;
clip.m_iCurrVert = 0;
// Clippers...
CClipTop top;
CClipBottom bottom;
CClipLeft left;
CClipRight right;
// Sutherland-hodgman clip
ScreenClip( clip, top );
ScreenClip( clip, bottom );
ScreenClip( clip, left );
ScreenClip( clip, right );
if (clip.m_iClipCount < 3)
return 0;
// Return a pointer to the array of clipped vertices...
Assert(pppOutVertex);
*pppOutVertex = clip.m_ppClipVertices[clip.m_iCurrVert].Base();
return clip.m_iClipCount;
}
//-----------------------------------------------------------------------------
// Purpose: Used for clipping, produces an interpolated texture coordinate
//-----------------------------------------------------------------------------
inline float InterpTCoord(float val, float mins, float maxs, float tMin, float tMax)
{
float flPercent;
if (mins != maxs)
flPercent = (float)(val - mins) / (maxs - mins);
else
flPercent = 0.5f;
return tMin + (tMax - tMin) * flPercent;
}
//-----------------------------------------------------------------------------
// Purpose: Does a scissor clip of the input rectangle.
// Returns false if it is completely clipped off.
//-----------------------------------------------------------------------------
bool ClipRect( const vgui::Vertex_t &inUL, const vgui::Vertex_t &inLR,
vgui::Vertex_t *pOutUL, vgui::Vertex_t *pOutLR )
{
// Check for a valid rectangle...
// Assert( inUL.m_Position.x <= inLR.m_Position.x );
// Assert( inUL.m_Position.y <= inLR.m_Position.y );
if ( IsGameConsole() && ( !g_bScissor || g_bFullScreenScissor ||
( inUL.m_Position.x >= g_ScissorRect.left && inLR.m_Position.x <= g_ScissorRect.right && inUL.m_Position.y >= g_ScissorRect.top && inLR.m_Position.y <= g_ScissorRect.bottom ) ) )
{
// clipping is not needed
// either full screen, and hw will do it or rect is inscribed, and operation is meaningless
*pOutUL = inUL;
*pOutLR = inLR;
return true;
}
if ( g_bScissor )
{
// Pick whichever left side is larger
if (g_ScissorRect.left > inUL.m_Position.x)
pOutUL->m_Position.x = g_ScissorRect.left;
else
pOutUL->m_Position.x = inUL.m_Position.x;
// Pick whichever right side is smaller
if (g_ScissorRect.right <= inLR.m_Position.x)
pOutLR->m_Position.x = g_ScissorRect.right;
else
pOutLR->m_Position.x = inLR.m_Position.x;
// Pick whichever top side is larger
if (g_ScissorRect.top > inUL.m_Position.y)
pOutUL->m_Position.y = g_ScissorRect.top;
else
pOutUL->m_Position.y = inUL.m_Position.y;
// Pick whichever bottom side is smaller
if (g_ScissorRect.bottom <= inLR.m_Position.y)
pOutLR->m_Position.y = g_ScissorRect.bottom;
else
pOutLR->m_Position.y = inLR.m_Position.y;
// Check for non-intersecting
if ( (pOutUL->m_Position.x > pOutLR->m_Position.x) ||
(pOutUL->m_Position.y > pOutLR->m_Position.y) )
{
return false;
}
if ( !g_bStretchTexture )
{
pOutUL->m_TexCoord.x = InterpTCoord(pOutUL->m_Position.x,
inUL.m_Position.x, inLR.m_Position.x, inUL.m_TexCoord.x, inLR.m_TexCoord.x);
pOutLR->m_TexCoord.x = InterpTCoord(pOutLR->m_Position.x,
inUL.m_Position.x, inLR.m_Position.x, inUL.m_TexCoord.x, inLR.m_TexCoord.x);
pOutUL->m_TexCoord.y = InterpTCoord(pOutUL->m_Position.y,
inUL.m_Position.y, inLR.m_Position.y, inUL.m_TexCoord.y, inLR.m_TexCoord.y);
pOutLR->m_TexCoord.y = InterpTCoord(pOutLR->m_Position.y,
inUL.m_Position.y, inLR.m_Position.y, inUL.m_TexCoord.y, inLR.m_TexCoord.y);
}
else
{
// FIXME, this isn't right
pOutUL->m_TexCoord = inUL.m_TexCoord;
pOutLR->m_TexCoord = inLR.m_TexCoord;
}
}
else
{
*pOutUL = inUL;
*pOutLR = inLR;
}
return true;
}

43
vguimatsurface/Clip2D.h Normal file
View File

@ -0,0 +1,43 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Contains 2D clipping routines
//
// $Revision: $
// $NoKeywords: $
//=============================================================================//
#ifndef CLIP2D_H
#define CLIP2D_H
#include "vgui/ISurface.h"
//-----------------------------------------------------------------------------
// Enable/disable scissoring...
//-----------------------------------------------------------------------------
void EnableScissor( bool enable );
//-----------------------------------------------------------------------------
// For simulated scissor tests...
//-----------------------------------------------------------------------------
void SetScissorRect( int left, int top, int right, int bottom );
void GetScissorRect( int &left, int &top, int &right, int &bottom, bool &enabled );
//-----------------------------------------------------------------------------
// Clips a line segment to the current scissor rectangle
//-----------------------------------------------------------------------------
bool ClipLine( const vgui::Vertex_t *pInVerts, vgui::Vertex_t* pOutVerts );
//-----------------------------------------------------------------------------
// Purpose: Does a scissor clip of the input rectangle.
// Returns false if it is completely clipped off.
//-----------------------------------------------------------------------------
bool ClipRect( const vgui::Vertex_t &inUL, const vgui::Vertex_t &inLR,
vgui::Vertex_t *pOutUL, vgui::Vertex_t *pOutLR );
//-----------------------------------------------------------------------------
// Clips a polygon to the screen area
//-----------------------------------------------------------------------------
int ClipPolygon( int iCount, vgui::Vertex_t *pVerts, int iTranslateX, int iTranslateY, vgui::Vertex_t ***pppOutVertex );
#endif // CLIP2D_H

544
vguimatsurface/Cursor.cpp Normal file
View File

@ -0,0 +1,544 @@
//===== Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose: Methods associated with the cursor
//
// $Revision: $
// $NoKeywords: $
//===========================================================================//
#if !defined( _X360 )
#define OEMRESOURCE //for OCR_* cursor junk
#include "winlite.h"
#endif
#include "tier0/dbg.h"
#include "tier1/utldict.h"
#include "Cursor.h"
#include "vguimatsurface.h"
#include "filesystem.h"
#if defined( PLATFORM_OSX )
#include <Carbon/Carbon.h>
#endif
#include <appframework/ilaunchermgr.h>
#if (USE_SDL)
#include "SDL.h"
#endif
#if defined( DX_TO_GL_ABSTRACTION )
#include "materialsystem/imaterialsystem.h"
#endif
#include "inputsystem/iinputsystem.h"
#include "inputsystem/iinputstacksystem.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
using namespace vgui;
#if defined( USE_SDL )
static SDL_Cursor *s_pDefaultCursor[ dc_last ];
static SDL_Cursor *s_hCurrentCursor = NULL;
static SDL_Cursor *s_hCurrentlySetCursor = NULL;
#elif defined( WIN32 )
static InputCursorHandle_t s_pDefaultCursor[20];
static InputCursorHandle_t s_hCurrentCursor = NULL;
#endif
static bool s_bCursorLocked = false;
static bool s_bCursorVisible = true;
//-----------------------------------------------------------------------------
// Initializes cursors
//-----------------------------------------------------------------------------
void InitCursors()
{
// load up all default cursors
#if defined( USE_SDL )
s_pDefaultCursor[ dc_none ] = NULL;
s_pDefaultCursor[ dc_arrow ] = SDL_CreateSystemCursor( SDL_SYSTEM_CURSOR_ARROW );
s_pDefaultCursor[ dc_ibeam ] = SDL_CreateSystemCursor( SDL_SYSTEM_CURSOR_IBEAM );
s_pDefaultCursor[ dc_hourglass ]= SDL_CreateSystemCursor( SDL_SYSTEM_CURSOR_WAIT );
s_pDefaultCursor[ dc_crosshair ]= SDL_CreateSystemCursor( SDL_SYSTEM_CURSOR_CROSSHAIR );
s_pDefaultCursor[ dc_waitarrow ]= SDL_CreateSystemCursor( SDL_SYSTEM_CURSOR_WAITARROW );
s_pDefaultCursor[ dc_sizenwse ] = SDL_CreateSystemCursor( SDL_SYSTEM_CURSOR_SIZENWSE );
s_pDefaultCursor[ dc_sizenesw ] = SDL_CreateSystemCursor( SDL_SYSTEM_CURSOR_SIZENESW );
s_pDefaultCursor[ dc_sizewe ] = SDL_CreateSystemCursor( SDL_SYSTEM_CURSOR_SIZEWE );
s_pDefaultCursor[ dc_sizens ] = SDL_CreateSystemCursor( SDL_SYSTEM_CURSOR_SIZENS );
s_pDefaultCursor[ dc_sizeall ] = SDL_CreateSystemCursor( SDL_SYSTEM_CURSOR_SIZEALL );
s_pDefaultCursor[ dc_no ] = SDL_CreateSystemCursor( SDL_SYSTEM_CURSOR_NO );
s_pDefaultCursor[ dc_hand ] = SDL_CreateSystemCursor( SDL_SYSTEM_CURSOR_HAND );
s_hCurrentCursor = s_pDefaultCursor[ dc_arrow ];
#elif defined( WIN32 )
s_pDefaultCursor[dc_none] = INPUT_CURSOR_HANDLE_INVALID;
s_pDefaultCursor[dc_arrow] = g_pInputSystem->GetStandardCursor( INPUT_CURSOR_ARROW );
s_pDefaultCursor[dc_ibeam] = g_pInputSystem->GetStandardCursor( INPUT_CURSOR_IBEAM );
s_pDefaultCursor[dc_hourglass]= g_pInputSystem->GetStandardCursor( INPUT_CURSOR_HOURGLASS );
s_pDefaultCursor[dc_crosshair]= g_pInputSystem->GetStandardCursor( INPUT_CURSOR_CROSSHAIR );
s_pDefaultCursor[dc_waitarrow]= g_pInputSystem->GetStandardCursor( INPUT_CURSOR_WAITARROW );
s_pDefaultCursor[dc_up] = g_pInputSystem->GetStandardCursor( INPUT_CURSOR_UP );
s_pDefaultCursor[dc_sizenwse] = g_pInputSystem->GetStandardCursor( INPUT_CURSOR_SIZE_NW_SE );
s_pDefaultCursor[dc_sizenesw] = g_pInputSystem->GetStandardCursor( INPUT_CURSOR_SIZE_NE_SW );
s_pDefaultCursor[dc_sizewe] = g_pInputSystem->GetStandardCursor( INPUT_CURSOR_SIZE_W_E );
s_pDefaultCursor[dc_sizens] = g_pInputSystem->GetStandardCursor( INPUT_CURSOR_SIZE_N_S );
s_pDefaultCursor[dc_sizeall] = g_pInputSystem->GetStandardCursor( INPUT_CURSOR_SIZE_ALL );
s_pDefaultCursor[dc_no] = g_pInputSystem->GetStandardCursor( INPUT_CURSOR_NO );
s_pDefaultCursor[dc_hand] = g_pInputSystem->GetStandardCursor( INPUT_CURSOR_HAND );
s_hCurrentCursor = s_pDefaultCursor[dc_arrow];
#endif
s_bCursorLocked = false;
s_bCursorVisible = true;
}
#define USER_CURSOR_MASK 0x80000000
#ifdef WIN32
//-----------------------------------------------------------------------------
// Purpose: Simple manager for user loaded windows cursors in vgui
//-----------------------------------------------------------------------------
class CUserCursorManager
{
public:
void Shutdown();
vgui::HCursor CreateCursorFromFile( char const *curOrAniFile, char const *pPathID );
bool LookupCursor( vgui::HCursor cursor, InputCursorHandle_t& handle );
private:
CUtlDict< InputCursorHandle_t, int > m_UserCursors;
};
void CUserCursorManager::Shutdown()
{
m_UserCursors.RemoveAll();
}
vgui::HCursor CUserCursorManager::CreateCursorFromFile( char const *curOrAniFile, char const *pPathID )
{
char fn[ 512 ];
Q_strncpy( fn, curOrAniFile, sizeof( fn ) );
Q_strlower( fn );
Q_FixSlashes( fn );
int cursorIndex = m_UserCursors.Find( fn );
if ( cursorIndex != m_UserCursors.InvalidIndex() )
{
return cursorIndex | USER_CURSOR_MASK;
}
InputCursorHandle_t newCursor = g_pInputSystem->LoadCursorFromFile( fn, pPathID );
cursorIndex = m_UserCursors.Insert( fn, newCursor );
return cursorIndex | USER_CURSOR_MASK;
}
bool CUserCursorManager::LookupCursor( vgui::HCursor cursor, InputCursorHandle_t& handle )
{
if ( !( (int)cursor & USER_CURSOR_MASK ) )
{
handle = 0;
return false;
}
int cursorIndex = (int)cursor & ~USER_CURSOR_MASK;
if ( !m_UserCursors.IsValidIndex( cursorIndex ) )
{
handle = 0;
return false;
}
handle = m_UserCursors[ cursorIndex ];
return true;
}
static CUserCursorManager g_UserCursors;
#endif
vgui::HCursor Cursor_CreateCursorFromFile( char const *curOrAniFile, char const *pPathID )
{
#ifdef WIN32
return g_UserCursors.CreateCursorFromFile( curOrAniFile, pPathID );
#else
return dc_user;
#endif
}
void Cursor_ClearUserCursors()
{
}
#ifdef OSX
static HCursor s_hCursor = dc_arrow;
#if defined( PLATFORM_64BITS )
// MCCLEANUP
OSStatus SetThemeCursor(ThemeCursor inCursor)
{
return OSStatus(0);
}
#endif
#endif
//-----------------------------------------------------------------------------
// Selects a cursor
//-----------------------------------------------------------------------------
void CursorSelect( InputContextHandle_t hContext, HCursor hCursor )
{
if ( s_bCursorLocked )
return;
static ConVarRef cv_vguipanel_active( "vgui_panel_active" );
#if defined( USE_SDL )
switch (hCursor)
{
case dc_user:
case dc_none:
case dc_blank:
// Make sure we have the latest blank cursor handle.
// s_pDefaultCursor[dc_none] = (Cursor) g_pLauncherMgr->GetBlankCursor();
s_bCursorVisible = false;
break;
case dc_arrow:
case dc_waitarrow:
case dc_ibeam:
case dc_hourglass:
case dc_crosshair:
case dc_up:
case dc_sizenwse:
case dc_sizenesw:
case dc_sizewe:
case dc_sizens:
case dc_sizeall:
case dc_no:
case dc_hand:
s_bCursorVisible = true;
s_hCurrentCursor = s_pDefaultCursor[hCursor];
break;
default:
s_bCursorVisible = false; // we don't support custom cursors at the moment (but could, if necessary).
Assert(0);
break;
}
ActivateCurrentCursor( hContext );
#elif defined( WIN32 )
// [jason] When the console window is raised, keep the cursor active even if the mouse focus is not on the console window.
// This makes it easier track where the cursor is on-screen when the user moves off of the console.
if ( cv_vguipanel_active.GetBool() == true && hCursor == dc_none )
{
hCursor = dc_arrow;
}
s_bCursorVisible = true;
switch ( hCursor )
{
case dc_user:
case dc_none:
case dc_blank:
s_bCursorVisible = false;
break;
case dc_arrow:
case dc_waitarrow:
case dc_ibeam:
case dc_hourglass:
case dc_crosshair:
case dc_up:
case dc_sizenwse:
case dc_sizenesw:
case dc_sizewe:
case dc_sizens:
case dc_sizeall:
case dc_no:
case dc_hand:
s_hCurrentCursor = s_pDefaultCursor[hCursor];
break;
default:
{
InputCursorHandle_t custom = 0;
#ifdef WIN32
if ( g_UserCursors.LookupCursor( hCursor, custom ) && custom != 0 )
{
s_hCurrentCursor = custom;
}
else
#endif // WIN32
{
s_bCursorVisible = false;
Assert(0);
}
}
break;
}
ActivateCurrentCursor( hContext );
g_pInputSystem->SetMouseCursorVisible( s_bCursorVisible );
#elif defined( PLATFORM_OSX )
// @wge: Copied from window's section above
// [jason] When the console window is raised, keep the cursor active even if the mouse focus is not on the console window.
// This makes it easier track where the cursor is on-screen when the user moves off of the console.
if ( cv_vguipanel_active.GetBool() == true && hCursor == dc_none )
{
if (!CommandLine()->FindParm("-keepmousehooked"))
{
CGAssociateMouseAndMouseCursorPosition( false );
if ( CGCursorIsVisible() )
{
CGDisplayHideCursor(kCGDirectMainDisplay);
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
int rx, ry, width, height;
pRenderContext->GetViewport( rx, ry, width, height );
CursorSetPos( NULL, width/2, height/2 ); // we are hiding the cursor so move it to the middle of our window
}
}
s_bCursorVisible = false;
}
else
{
if (!CommandLine()->FindParm("-keepmousehooked"))
{
CGAssociateMouseAndMouseCursorPosition( true );
if ( !CGCursorIsVisible() )
{
CGDisplayShowCursor(kCGDirectMainDisplay);
}
}
s_bCursorVisible = true;
}
s_hCursor = hCursor;
s_bCursorVisible = true;
switch (hCursor)
{
case dc_none:
case dc_user:
case dc_blank:
s_bCursorVisible = false;
break;
case dc_arrow:
SetThemeCursor( kThemeArrowCursor );
break;
case dc_ibeam:
SetThemeCursor( kThemeIBeamCursor );
break;
case dc_hourglass:
SetThemeCursor( kThemeSpinningCursor );
break;
case dc_waitarrow:
SetThemeCursor( kThemeSpinningCursor );
break;
case dc_crosshair:
SetThemeCursor( kThemeCrossCursor );
break;
case dc_up:
SetThemeCursor( kThemeResizeUpCursor );
break;
case dc_sizenwse:
SetThemeCursor( kThemeCountingUpAndDownHandCursor );
break;
case dc_sizenesw:
SetThemeCursor( kThemeResizeUpDownCursor );
break;
case dc_sizewe:
SetThemeCursor( kThemeResizeLeftRightCursor );
break;
case dc_sizens:
SetThemeCursor( kThemeResizeUpDownCursor );
break;
case dc_sizeall:
SetThemeCursor( kThemeContextualMenuArrowCursor );
break;
case dc_no:
SetThemeCursor( kThemeNotAllowedCursor );
break;
case dc_hand:
SetThemeCursor( kThemePointingHandCursor );
break;
};
g_pInputSystem->SetMouseCursorVisible( s_bCursorVisible );
#elif defined( _PS3 )
#elif defined( LINUX )
#error
#else
#error
#endif
}
//-----------------------------------------------------------------------------
// Activates the current cursor
//-----------------------------------------------------------------------------
void ActivateCurrentCursor( InputContextHandle_t hContext )
{
if (s_bCursorVisible)
{
#if defined( USE_SDL )
if (s_hCurrentlySetCursor != s_hCurrentCursor)
{
s_hCurrentlySetCursor = s_hCurrentCursor;
g_pLauncherMgr->SetMouseCursor( s_hCurrentlySetCursor );
g_pLauncherMgr->SetMouseVisible( true );
}
#elif defined( WIN32 )
g_pInputStackSystem->SetCursorIcon( hContext, s_hCurrentCursor );
#elif defined( OSX )
if ( !CGCursorIsVisible() && !CommandLine()->FindParm("-keepmousehooked") )
{
CGDisplayShowCursor(kCGDirectMainDisplay);
}
#else
#error
#endif
}
else
{
#if defined( USE_SDL )
if (s_hCurrentlySetCursor != s_pDefaultCursor[dc_none])
{
s_hCurrentlySetCursor = s_pDefaultCursor[dc_none];
g_pLauncherMgr->SetMouseCursor( s_hCurrentlySetCursor );
g_pLauncherMgr->SetMouseVisible( false );
}
#elif defined( WIN32 )
g_pInputStackSystem->SetCursorIcon( hContext, INPUT_CURSOR_HANDLE_INVALID );
#elif defined( OSX )
if ( CGCursorIsVisible() && !CommandLine()->FindParm("-keepmousehooked") )
{
CGDisplayHideCursor(kCGDirectMainDisplay);
}
#else
#error
#endif
}
}
//-----------------------------------------------------------------------------
// Purpose: prevents vgui from changing the cursor
//-----------------------------------------------------------------------------
void LockCursor( InputContextHandle_t hContext, bool bEnable )
{
s_bCursorLocked = bEnable;
ActivateCurrentCursor( hContext );
}
//-----------------------------------------------------------------------------
// Purpose: unlocks the cursor state
//-----------------------------------------------------------------------------
bool IsCursorLocked()
{
return s_bCursorLocked;
}
//-----------------------------------------------------------------------------
// handles mouse movement
//-----------------------------------------------------------------------------
void CursorSetPos( InputContextHandle_t hContext, int x, int y )
{
Assert( hContext != INPUT_CONTEXT_HANDLE_INVALID );
#if defined( DX_TO_GL_ABSTRACTION )
if ( s_bCursorVisible )
#endif
g_pInputStackSystem->SetCursorPosition( hContext, x, y );
}
void CursorGetPos( InputContextHandle_t hContext, int &x, int &y )
{
// Should I add GetCursorPosition to InputStackSystem?
Assert( hContext != INPUT_CONTEXT_HANDLE_INVALID );
g_pInputSystem->GetCursorPosition( &x, &y );
}
#ifdef OSX
void CursorRunFrame()
{
static HCursor hCursorLast = dc_none;
if ( hCursorLast == s_hCursor )
return;
hCursorLast = s_hCursor;
if ( s_hCursor == dc_none || s_hCursor == dc_user || s_hCursor == dc_blank )
{
if (!CommandLine()->FindParm("-keepmousehooked"))
{
// @wge Removed. After this is called, all mouse coordinates will be locked (returning only delta). We need coordinates for Scaleform.
//CGAssociateMouseAndMouseCursorPosition( false );
if ( CGCursorIsVisible() )
CGDisplayHideCursor(kCGDirectMainDisplay);
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
int rx, ry, width, height;
pRenderContext->GetViewport( rx, ry, width, height );
// we are hiding the cursor so move it to the middle of our window
g_pInputSystem->SetCursorPosition( width/2, height/2 );
}
s_bCursorVisible = false;
}
else
{
if (!CommandLine()->FindParm("-keepmousehooked"))
{
// @wge Removed, see above comment.
//CGAssociateMouseAndMouseCursorPosition( true );
if ( !CGCursorIsVisible() )
{
CGDisplayShowCursor( kCGDirectMainDisplay );
}
}
s_bCursorVisible = true;
}
}
#endif

71
vguimatsurface/Cursor.h Normal file
View File

@ -0,0 +1,71 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Methods associated with the cursor
//
// $Revision: $
// $NoKeywords: $
//=============================================================================//
#ifndef MATSURFACE_CURSOR_H
#define MATSURFACE_CURSOR_H
#ifdef _WIN32
#pragma once
#endif
#include "VGuiMatSurface/IMatSystemSurface.h"
#include <vgui/Cursor.h>
FORWARD_DECLARE_HANDLE( InputContextHandle_t );
//-----------------------------------------------------------------------------
// Initializes cursors
//-----------------------------------------------------------------------------
void InitCursors();
//-----------------------------------------------------------------------------
// Selects a cursor
//-----------------------------------------------------------------------------
void CursorSelect( InputContextHandle_t hContext, vgui::HCursor hCursor );
//-----------------------------------------------------------------------------
// Activates the current cursor
//-----------------------------------------------------------------------------
void ActivateCurrentCursor( InputContextHandle_t hContext );
//-----------------------------------------------------------------------------
// handles mouse movement
//-----------------------------------------------------------------------------
void CursorSetPos( InputContextHandle_t hContext, int x, int y );
void CursorGetPos( InputContextHandle_t hContext, int &x, int &y );
//-----------------------------------------------------------------------------
// Purpose: prevents vgui from changing the cursor
//-----------------------------------------------------------------------------
void LockCursor( InputContextHandle_t hContext, bool bEnable );
//-----------------------------------------------------------------------------
// Purpose: unlocks the cursor state
//-----------------------------------------------------------------------------
bool IsCursorLocked();
//-----------------------------------------------------------------------------
// Purpose: loads a custom cursor file from the file system
//-----------------------------------------------------------------------------
vgui::HCursor Cursor_CreateCursorFromFile( char const *curOrAniFile, char const *pPathID );
// Helper for shutting down cursors
void Cursor_ClearUserCursors();
#endif // MATSURFACE_CURSOR_H

234
vguimatsurface/Input.cpp Normal file
View File

@ -0,0 +1,234 @@
//===== Copyright 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose: Implementation of the VGUI ISurface interface using the
// material system to implement it
//
//===========================================================================//
#if defined( WIN32 ) && !defined( _X360 )
#include <windows.h>
#include <zmouse.h>
#endif
#include "inputsystem/iinputsystem.h"
#include "tier2/tier2.h"
#include "Input.h"
#include "vguimatsurface.h"
#include "../vgui2/src/VPanel.h"
#include <vgui/KeyCode.h>
#include <vgui/MouseCode.h>
#include <vgui/IVGui.h>
#include <vgui/IPanel.h>
#include <vgui/ISurface.h>
#include <vgui/IClientPanel.h>
#include "inputsystem/ButtonCode.h"
#include "Cursor.h"
#include "tier0/dbg.h"
#include "../vgui2/src/vgui_key_translation.h"
#include <vgui/IInputInternal.h>
#include "tier0/icommandline.h"
#ifdef _X360
#include "xbox/xbox_win32stubs.h"
#endif
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
using namespace vgui;
//-----------------------------------------------------------------------------
// Converts an input system button code to a vgui key code
// FIXME: Remove notion of vgui::KeyCode + vgui::MouseCode altogether
//-----------------------------------------------------------------------------
static vgui::KeyCode ButtonCodeToKeyCode( ButtonCode_t buttonCode )
{
return ( vgui::KeyCode )buttonCode;
}
static vgui::MouseCode ButtonCodeToMouseCode( ButtonCode_t buttonCode )
{
return ( vgui::MouseCode )buttonCode;
}
//-----------------------------------------------------------------------------
// Handles an input event, returns true if the event should be filtered
// from the rest of the game
//-----------------------------------------------------------------------------
bool InputHandleInputEvent( InputContextHandle_t hContext, const InputEvent_t &event )
{
switch( event.m_nType )
{
case IE_ButtonPressed:
{
// NOTE: data2 is the virtual key code (data1 contains the scan-code one)
ButtonCode_t code = (ButtonCode_t)event.m_nData2;
if ( IsKeyCode( code ) || IsJoystickCode( code ) )
{
vgui::KeyCode keyCode = ButtonCodeToKeyCode( code );
return g_pIInput->InternalKeyCodePressed( keyCode );
}
if ( IsJoystickCode( code ) )
{
vgui::KeyCode keyCode = ButtonCodeToKeyCode( code );
return g_pIInput->InternalKeyCodePressed( keyCode );
}
if ( IsMouseCode( code ) )
{
vgui::MouseCode mouseCode = ButtonCodeToMouseCode( code );
return g_pIInput->InternalMousePressed( mouseCode );
}
}
break;
case IE_ButtonReleased:
{
// NOTE: data2 is the virtual key code (data1 contains the scan-code one)
ButtonCode_t code = (ButtonCode_t)event.m_nData2;
if ( IsKeyCode( code ) || IsJoystickCode( code ) )
{
vgui::KeyCode keyCode = ButtonCodeToKeyCode( code );
return g_pIInput->InternalKeyCodeReleased( keyCode );
}
if ( IsJoystickCode( code ) )
{
vgui::KeyCode keyCode = ButtonCodeToKeyCode( code );
return g_pIInput->InternalKeyCodeReleased( keyCode );
}
if ( IsMouseCode( code ) )
{
vgui::MouseCode mouseCode = ButtonCodeToMouseCode( code );
return g_pIInput->InternalMouseReleased( mouseCode );
}
}
break;
case IE_ButtonDoubleClicked:
{
// NOTE: data2 is the virtual key code (data1 contains the scan-code one)
ButtonCode_t code = (ButtonCode_t)event.m_nData2;
if ( IsMouseCode( code ) )
{
vgui::MouseCode mouseCode = ButtonCodeToMouseCode( code );
return g_pIInput->InternalMouseDoublePressed( mouseCode );
}
}
break;
case IE_AnalogValueChanged:
{
if ( event.m_nData == MOUSE_WHEEL )
return g_pIInput->InternalMouseWheeled( event.m_nData3 );
if ( event.m_nData == MOUSE_XY )
return g_pIInput->InternalCursorMoved( event.m_nData2, event.m_nData3 );
//=============================================================================
// HPE_BEGIN
// [dwenger] Handle gamepad joystick movement.
//=============================================================================
if ( event.m_nData == JOYSTICK_AXIS(0, JOY_AXIS_X ))
{
return g_pIInput->InternalJoystickMoved ( 0, event.m_nData2 );
}
if ( event.m_nData == JOYSTICK_AXIS(0, JOY_AXIS_Y ) )
{
return g_pIInput->InternalJoystickMoved ( 1, event.m_nData2 );
}
if ( event.m_nData == JOYSTICK_AXIS(0, JOY_AXIS_U ))
{
return g_pIInput->InternalJoystickMoved ( 2, event.m_nData2 );
}
if ( event.m_nData == JOYSTICK_AXIS(0, JOY_AXIS_R ) )
{
return g_pIInput->InternalJoystickMoved ( 3, event.m_nData2 );
}
//=============================================================================
// HPE_END
//=============================================================================
}
break;
case IE_KeyCodeTyped:
{
vgui::KeyCode code = (vgui::KeyCode)event.m_nData;
g_pIInput->InternalKeyCodeTyped( code );
}
return true;
case IE_KeyTyped:
{
wchar_t code = (wchar_t)event.m_nData;
g_pIInput->InternalKeyTyped( code );
}
// return false so scaleform can use this
break;
case IE_Quit:
g_pVGui->Stop();
#if defined( USE_SDL ) || defined( OSX )
return false; // also let higher layers consume it
#else
return true;
#endif
case IE_Close:
// FIXME: Change this so we don't stop until 'save' occurs, etc.
g_pVGui->Stop();
return true;
case IE_SetCursor:
ActivateCurrentCursor( hContext );
return true;
case IE_IMESetWindow:
g_pIInput->SetIMEWindow( (void *)event.m_nData );
return true;
case IE_LocateMouseClick:
g_pIInput->InternalCursorMoved( event.m_nData, event.m_nData2 );
return true;
case IE_InputLanguageChanged:
g_pIInput->OnInputLanguageChanged();
return true;
case IE_IMEStartComposition:
g_pIInput->OnIMEStartComposition();
return true;
case IE_IMEComposition:
g_pIInput->OnIMEComposition( event.m_nData );
return true;
case IE_IMEEndComposition:
g_pIInput->OnIMEEndComposition();
return true;
case IE_IMEShowCandidates:
g_pIInput->OnIMEShowCandidates();
return true;
case IE_IMEChangeCandidates:
g_pIInput->OnIMEChangeCandidates();
return true;
case IE_IMECloseCandidates:
g_pIInput->OnIMECloseCandidates();
return true;
case IE_IMERecomputeModes:
g_pIInput->OnIMERecomputeModes();
return true;
}
return false;
}

48
vguimatsurface/Input.h Normal file
View File

@ -0,0 +1,48 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose: Methods related to input
//
// $Revision: $
// $NoKeywords: $
//===========================================================================//
#ifndef INPUT_H
#define INPUT_H
#ifdef _WIN32
#pragma once
#endif
struct InputEvent_t;
FORWARD_DECLARE_HANDLE( InputContextHandle_t );
//-----------------------------------------------------------------------------
// Initializes the input system
//-----------------------------------------------------------------------------
void InitInput();
//-----------------------------------------------------------------------------
// Hooks input listening up to a window
//-----------------------------------------------------------------------------
void InputAttachToWindow(void *hwnd);
void InputDetachFromWindow(void *hwnd);
// If input isn't hooked, this forwards messages to vgui.
void InputHandleWindowMessage( void *hwnd, unsigned int uMsg, unsigned int wParam, long lParam );
//-----------------------------------------------------------------------------
// Handles an input event, returns true if the event should be filtered
// from the rest of the game
//-----------------------------------------------------------------------------
bool InputHandleInputEvent( InputContextHandle_t hContext, const InputEvent_t &event );
//-----------------------------------------------------------------------------
// Enables/disables input (enabled by default)
//-----------------------------------------------------------------------------
void EnableInput( bool bEnable );
#endif // INPUT_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,745 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $NoKeywords: $
//===========================================================================//
#ifndef MATSYSTEMSURFACE_H
#define MATSYSTEMSURFACE_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui/vgui.h>
#include <vgui/ISurface.h>
#include <vgui/IPanel.h>
#include <vgui/IClientPanel.h>
#include <vgui_controls/Panel.h>
#include <vgui/IInput.h>
#include <vgui_controls/Controls.h>
#include <vgui/Point.h>
#include "materialsystem/imaterialsystem.h"
#include "VGuiMatSurface/IMatSystemSurface.h"
#include "materialsystem/imesh.h"
#include "materialsystem/imaterial.h"
#include "utlvector.h"
#include "utlsymbol.h"
#include "materialsystem/MaterialSystemUtil.h"
#include "tier1/utldict.h"
#include "tier3/tier3.h"
#include "inputsystem/iinputsystem.h"
#include "inputsystem/iinputstacksystem.h"
#include "vgui/ILocalize.h"
#ifdef LINUX
#include <ft2build.h>
#include FT_FREETYPE_H
#endif
using namespace vgui;
class IImage;
class HtmlWindow;
//-----------------------------------------------------------------------------
// The default material system embedded panel
//-----------------------------------------------------------------------------
class CMatEmbeddedPanel : public vgui::Panel
{
typedef vgui::Panel BaseClass;
public:
CMatEmbeddedPanel();
virtual void OnThink();
VPANEL IsWithinTraverse(int x, int y, bool traversePopups);
};
//-----------------------------------------------------------------------------
//
// Implementation of the VGUI surface on top of the material system
//
//-----------------------------------------------------------------------------
class CMatSystemSurface : public CTier3AppSystem< IMatSystemSurface >, public ISchemeSurface, public ILocalizeTextQuery
{
typedef CTier3AppSystem< IMatSystemSurface > BaseClass;
public:
CMatSystemSurface();
virtual ~CMatSystemSurface();
// Methods of IAppSystem
virtual bool Connect( CreateInterfaceFn factory );
virtual void Disconnect();
virtual void *QueryInterface( const char *pInterfaceName );
virtual InitReturnVal_t Init();
virtual void Shutdown();
virtual const AppSystemInfo_t* GetDependencies();
virtual AppSystemTier_t GetTier() { return BaseClass::GetTier(); }
virtual void Reconnect( CreateInterfaceFn factory, const char *pInterfaceName ) { BaseClass::Reconnect( factory, pInterfaceName ); }
// initialization
virtual void SetEmbeddedPanel(vgui::VPANEL pEmbeddedPanel);
// returns true if a panel is minimzed
bool IsMinimized(vgui::VPANEL panel);
// Sets the only panel to draw. Set to NULL to clear.
virtual void RestrictPaintToSinglePanel(vgui::VPANEL panel, bool bForceAllowNonModalSurface = false);
// frame
virtual void RunFrame();
// implementation of vgui::ISurface
virtual vgui::VPANEL GetEmbeddedPanel();
// drawing context
virtual void PushMakeCurrent(vgui::VPANEL panel,bool useInSets);
virtual void PopMakeCurrent(vgui::VPANEL panel);
// rendering functions
virtual void DrawSetColor(int r,int g,int b,int a);
virtual void DrawSetColor(Color col);
virtual void DrawSetApparentDepth( float flDepth );
virtual void DrawClearApparentDepth();
virtual void DrawLine( int x0, int y0, int x1, int y1 );
virtual void DrawTexturedLine( const Vertex_t &a, const Vertex_t &b );
virtual void DrawPolyLine(int *px, int *py, int numPoints);
virtual void DrawTexturedPolyLine( const Vertex_t *p, int n );
virtual void DrawFilledRect(int x0, int y0, int x1, int y1);
virtual void DrawFilledRectArray( IntRect *pRects, int numRects );
virtual void DrawFilledRectFastFade( int x0, int y0, int x1, int y1, int fadeStartPt, int fadeEndPt, unsigned int alpha0, unsigned int alpha1, bool bHorizontal );
virtual void DrawFilledRectFade( int x0, int y0, int x1, int y1, unsigned int alpha0, unsigned int alpha1, bool bHorizontal );
virtual void DrawOutlinedRect(int x0, int y0, int x1, int y1);
virtual void DrawOutlinedCircle(int x, int y, int radius, int segments);
// textured rendering functions
virtual int CreateNewTextureID( bool procedural = false );
virtual bool IsTextureIDValid(int id);
virtual bool DrawGetTextureFile(int id, char *filename, int maxlen );
virtual int DrawGetTextureId( char const *filename );
virtual void DrawSetTextureFile(int id, const char *filename, int hardwareFilter, bool forceReload);
virtual void DrawSetTexture(int id);
virtual void DrawGetTextureSize(int id, int &wide, int &tall);
virtual bool DeleteTextureByID(int id);
virtual IVguiMatInfo *DrawGetTextureMatInfoFactory( int id );
virtual void DrawSetTextureRGBA( int id, const unsigned char *rgba, int wide, int tall );
virtual void DrawSetTextureRGBALinear( int id, const unsigned char *rgba, int wide, int tall );
#if defined( _X360 )
//
// Local gamerpic
//
// Get the texture id for the local gamerpic.
virtual int GetLocalGamerpicTextureID( void );
// Update the local gamerpic texture. Use the given texture if a gamerpic cannot be loaded.
virtual bool SetLocalGamerpicTexture( DWORD userIndex, const char *pDefaultGamerpicFileName );
// Set the current texture to be the local gamerpic.
// Returns false if the local gamerpic texture has not been set.
virtual bool DrawSetTextureLocalGamerpic( void );
//
// Remote gamerpic
//
// Get the texture id for a remote gamerpic with the given xuid.
virtual int GetRemoteGamerpicTextureID( XUID xuid );
// Update the remote gamerpic texture for the given xuid. Use the given texture if a gamerpic cannot be loaded.
virtual bool SetRemoteGamerpicTextureID( XUID xuid, const char *pDefaultGamerpicFileName );
// Set the current texture to be the remote player's gamerpic.
// Returns false if the remote gamerpic texture has not been set for the given xuid.
virtual bool DrawSetTextureRemoteGamerpic( XUID xuid );
#endif // _X360
virtual void DrawTexturedRect( int x0, int y0, int x1, int y1 );
virtual void DrawTexturedSubRect( int x0, int y0, int x1, int y1, float texs0, float text0, float texs1, float text1 );
virtual void DrawTexturedSubRectGradient( int x0, int y0, int x1, int y1, float texs0, float text0, float texs1, float text1, Color colStart, Color colEnd, bool bHorizontal );
virtual void DrawTexturedPolygon(int n, Vertex_t *pVertices, bool bClipVertices = true );
virtual void DrawWordBubble( int x0, int y0, int x1, int y1, int nBorderThickness, Color rgbaBackground, Color rgbaBorder,
bool bPointer = false, int nPointerX = 0, int nPointerY = 0, int nPointerBaseThickness = 16 );
virtual void DrawPrintText(const wchar_t *text, int textLen, FontDrawType_t drawType = FONT_DRAW_DEFAULT);
virtual void DrawUnicodeChar(wchar_t wch, FontDrawType_t drawType = FONT_DRAW_DEFAULT );
virtual void DrawUnicodeString( const wchar_t *pwString, FontDrawType_t drawType = FONT_DRAW_DEFAULT );
virtual void DrawSetTextFont(vgui::HFont font);
virtual void DrawFlushText();
virtual void DrawSetTextColor(int r, int g, int b, int a);
virtual void DrawSetTextColor(Color col);
virtual void DrawSetTextScale(float sx, float sy);
virtual void DrawSetTextPos(int x, int y);
virtual void DrawGetTextPos(int& x,int& y);
virtual vgui::IHTML *CreateHTMLWindow(vgui::IHTMLEvents *events,vgui::VPANEL context);
virtual void PaintHTMLWindow(vgui::IHTML *htmlwin);
virtual void DeleteHTMLWindow(vgui::IHTML *htmlwin);
virtual bool BHTMLWindowNeedsPaint(IHTML *htmlwin);
virtual void GetScreenSize(int &wide, int &tall);
virtual void SetAsTopMost(vgui::VPANEL panel, bool state);
virtual void BringToFront(vgui::VPANEL panel);
virtual void SetForegroundWindow (vgui::VPANEL panel);
virtual void SetPanelVisible(vgui::VPANEL panel, bool state);
virtual void SetMinimized(vgui::VPANEL panel, bool state);
virtual void FlashWindow(vgui::VPANEL panel, bool state);
virtual void SetTitle(vgui::VPANEL panel, const wchar_t *title);
virtual const wchar_t *GetTitle( vgui::VPANEL panel );
virtual void SetAsToolBar(vgui::VPANEL panel, bool state); // removes the window's task bar entry (for context menu's, etc.)
// windows stuff
virtual void CreatePopup(VPANEL panel, bool minimized, bool showTaskbarIcon = true, bool disabled = false, bool mouseInput = true , bool kbInput = true);
virtual void SwapBuffers(vgui::VPANEL panel);
virtual void Invalidate(vgui::VPANEL panel);
virtual void SetCursor(vgui::HCursor cursor);
virtual bool IsCursorVisible();
virtual void ApplyChanges();
virtual bool IsWithin(int x, int y);
virtual bool HasFocus();
virtual bool SupportsFontFeature( FontFeature_t feature );
virtual bool SupportsFeature( SurfaceFeature_t feature );
// engine-only focus handling (replacing WM_FOCUS windows handling)
virtual void SetTopLevelFocus(vgui::VPANEL panel);
// fonts
virtual vgui::HFont CreateFont();
virtual bool SetFontGlyphSet(vgui::HFont font, const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags, int nRangeMin = 0, int nRangeMax = 0);
virtual bool SetBitmapFontGlyphSet(vgui::HFont font, const char *windowsFontName, float scalex, float scaley, int flags);
virtual int GetFontTall(HFont font);
virtual int GetFontAscent(HFont font, wchar_t wch);
virtual bool IsFontAdditive(HFont font);
virtual void GetCharABCwide(HFont font, int ch, int &a, int &b, int &c);
virtual void GetTextSize(HFont font, const wchar_t *text, int &wide, int &tall);
virtual int GetCharacterWidth(vgui::HFont font, int ch);
virtual bool AddCustomFontFile(const char *fontFileName);
virtual bool AddBitmapFontFile(const char *fontFileName);
virtual void SetBitmapFontName( const char *pName, const char *pFontFilename );
virtual const char *GetBitmapFontName( const char *pName );
virtual void PrecacheFontCharacters(HFont font, wchar_t *pCharacters);
virtual void ClearTemporaryFontCache( void );
virtual const char *GetFontName( HFont font );
// uploads a part of a texture, used for font rendering
void DrawSetSubTextureRGBA(int textureID, int drawX, int drawY, unsigned const char *rgba, int subTextureWide, int subTextureTall);
void DrawUpdateRegionTextureRGBA( int nTextureID, int x, int y, const unsigned char *pchData, int wide, int tall, ImageFormat imageFormat );
// helpers for web browser painting
int GetHTMLWindowCount() { return _htmlWindows.Count(); }
HtmlWindow *GetHTMLWindow(int i) { return _htmlWindows[i]; }
// notify icons?!?
virtual vgui::VPANEL GetNotifyPanel();
virtual void SetNotifyIcon(vgui::VPANEL context, vgui::HTexture icon, vgui::VPANEL panelToReceiveMessages, const char *text);
// plays a sound
virtual void PlaySound(const char *fileName);
//!! these functions Should not be accessed directly, but only through other vgui items
//!! need to move these to seperate interface
virtual int GetPopupCount();
virtual vgui::VPANEL GetPopup( int index );
virtual bool ShouldPaintChildPanel(vgui::VPANEL childPanel);
virtual bool RecreateContext(vgui::VPANEL panel);
virtual void AddPanel(vgui::VPANEL panel);
virtual void ReleasePanel(vgui::VPANEL panel);
virtual void MovePopupToFront(vgui::VPANEL panel);
virtual void SolveTraverse(vgui::VPANEL panel, bool forceApplySchemeSettings);
virtual void PaintTraverse(vgui::VPANEL panel);
virtual void EnableMouseCapture(vgui::VPANEL panel, bool state);
virtual void SetWorkspaceInsets( int left, int top, int right, int bottom );
virtual void GetWorkspaceBounds(int &x, int &y, int &wide, int &tall);
// Hook needed to Get input to work
virtual void SetAppDrivesInput( bool bLetAppDriveInput );
virtual bool HandleInputEvent( const InputEvent_t &event );
void InitFullScreenBuffer( const char *pszRenderTargetName );
virtual void Set3DPaintTempRenderTarget( const char *pRenderTargetName );
virtual void Reset3DPaintTempRenderTarget( void );
// Begins, ends 3D painting
virtual void Begin3DPaint( int iLeft, int iTop, int iRight, int iBottom, bool bSupersampleRT = false );
virtual void End3DPaint( bool bIgnoreAlphaWhenCompositing );
// Disable clipping during rendering
virtual void DisableClipping( bool bDisable );
// Prevents vgui from changing the cursor
virtual bool IsCursorLocked() const;
// Sets the mouse Get + Set callbacks
virtual void SetMouseCallbacks( GetMouseCallback_t GetFunc, SetMouseCallback_t SetFunc );
// Tells the surface to ignore windows messages
virtual void EnableWindowsMessages( bool bEnable );
// Installs a function to play sounds
virtual void InstallPlaySoundFunc( PlaySoundFunc_t soundFunc );
// Some drawing methods that cannot be accomplished under Win32
virtual void DrawColoredCircle( int centerx, int centery, float radius, int r, int g, int b, int a );
virtual void DrawColoredText( vgui::HFont font, int x, int y, int r, int g, int b, int a, const char *fmt, ... ) OVERRIDE;
virtual void DrawColoredTextRect( vgui::HFont font, int x, int y, int w, int h, int r, int g, int b, int a, const char *fmt, ... ) OVERRIDE;
virtual void DrawTextHeight( vgui::HFont font, int w, int& h, char *fmt, ... );
// Returns the length in pixels of the text
virtual int DrawTextLen( vgui::HFont font, const char *fmt, ... );
// Draws a panel in 3D space.
virtual void DrawPanelIn3DSpace( vgui::VPANEL pRootPanel, const VMatrix &panelCenterToWorld, int pw, int ph, float sw, float sh );
// Only visible within vguimatsurface
void DrawSetTextureMaterial(int id, IMaterial *pMaterial);
void ReferenceProceduralMaterial( int id, int referenceId, IMaterial *pMaterial );
// new stuff for Alfreds VGUI2 port!!
virtual bool InEngine() { return true; }
void GetProportionalBase( int &width, int &height ) { width = BASE_WIDTH; height = BASE_HEIGHT; }
virtual bool HasCursorPosFunctions() { return true; }
virtual void SetModalPanel(VPANEL );
virtual VPANEL GetModalPanel();
virtual void UnlockCursor();
virtual void LockCursor();
virtual void SetTranslateExtendedKeys(bool state);
virtual VPANEL GetTopmostPopup();
virtual void GetAbsoluteWindowBounds(int &x, int &y, int &wide, int &tall);
virtual void CalculateMouseVisible();
virtual bool NeedKBInput();
virtual void SurfaceGetCursorPos(int &x, int &y);
virtual void SurfaceSetCursorPos(int x, int y);
virtual void MovePopupToBack(VPANEL panel);
virtual bool IsInThink( VPANEL panel);
virtual bool DrawGetUnicodeCharRenderInfo( wchar_t ch, FontCharRenderInfo& info );
virtual void DrawRenderCharFromInfo( const FontCharRenderInfo& info );
// global alpha setting functions
// affect all subsequent draw calls - shouldn't normally be used directly, only in Panel::PaintTraverse()
virtual void DrawSetAlphaMultiplier( float alpha /* [0..1] */ );
virtual float DrawGetAlphaMultiplier();
// web browser
virtual void SetAllowHTMLJavaScript( bool state );
// video mode changing
virtual void OnScreenSizeChanged( int nOldWidth, int nOldHeight );
virtual vgui::HCursor CreateCursorFromFile( char const *curOrAniFile, char const *pPathID );
virtual void PaintTraverseEx(VPANEL panel, bool paintPopups = false );
virtual float GetZPos() const;
virtual void SetPanelForInput( VPANEL vpanel );
virtual vgui::IImage *GetIconImageForFullPath( char const *pFullPath );
virtual void DestroyTextureID( int id );
virtual void GetKernedCharWidth( HFont font, wchar_t ch, wchar_t chBefore, wchar_t chAfter, float &wide, float &flabcA, float &abcC );
virtual const char *GetWebkitHTMLUserAgentString() { return "Valve Client"; }
virtual void *Deprecated_AccessChromeHTMLController() OVERRIDE { return NULL; }
// Methods of ILocalizeTextQuery
//virtual int ComputeTextWidth( const wchar_t *pString );
virtual bool ForceScreenSizeOverride( bool bState, int wide, int tall );
// LocalToScreen, ParentLocalToScreen fixups for explicit PaintTraverse calls on Panels not at 0, 0 position
virtual bool ForceScreenPosOffset( bool bState, int x, int y );
virtual void OffsetAbsPos( int &x, int &y );
virtual void SetAbsPosForContext( int id, int x, int y );
virtual void GetAbsPosForContext( int id, int &x, int& y );
// Causes fonts to get reloaded, etc.
virtual void ResetFontCaches();
virtual bool IsScreenSizeOverrideActive( void );
virtual bool IsScreenPosOverrideActive( void );
virtual IMaterial *DrawGetTextureMaterial( int id );
virtual void SetInputContext( InputContextHandle_t hContext );
virtual int GetTextureNumFrames( int id );
virtual void DrawSetTextureFrame( int id, int nFrame, unsigned int *pFrameCache );
virtual void GetClipRect( int &x0, int &y0, int &x1, int &y1 );
virtual void SetClipRect( int x0, int y0, int x1, int y1 );
virtual void SetLanguage( const char *pLanguage );
virtual const char *GetLanguage();
InputContextHandle_t GetInputContext() const;
virtual void DrawTexturedRectEx( DrawTexturedRectParms_t *pDrawParms );
// Methods of ILocalizeTextQuery
public:
virtual int ComputeTextWidth( const wchar_t *pString );
private:
//void DrawRenderCharInternal( const FontCharRenderInfo& info );
void DrawRenderCharInternal( const FontCharRenderInfo& info );
private:
enum { BASE_HEIGHT = 480, BASE_WIDTH = 640 };
struct PaintState_t
{
vgui::VPANEL m_pPanel;
int m_iTranslateX;
int m_iTranslateY;
int m_iScissorLeft;
int m_iScissorRight;
int m_iScissorTop;
int m_iScissorBottom;
};
// material Setting method
void InternalSetMaterial( IMaterial *material = NULL );
// Draws the fullscreen buffer into the panel
void DrawFullScreenBuffer( int nLeft, int nTop, int nRight, int nBottom, int nOffscreenWidth, int nOffscreenHeight, bool bIgnoreAlphaWhenCompositing );
// Helper method to initialize vertices (transforms them into screen space too)
void InitVertex( Vertex_t &vertex, int x, int y, float u, float v );
// Draws a quad + quad array
void DrawQuad( const Vertex_t &ul, const Vertex_t &lr, unsigned char *pColor );
void DrawQuadArray( int numQuads, Vertex_t *pVerts, unsigned char *pColor, bool bShouldClip = true );
// Necessary to wrap the rendering
void StartDrawing( void );
void StartDrawingIn3DSpace( const VMatrix &screenToWorld, int pw, int ph, float sw, float sh );
void FinishDrawing( void );
// Sets up a particular painting state...
void SetupPaintState( const PaintState_t &paintState );
void ResetPopupList();
void AddPopup( vgui::VPANEL panel );
void RemovePopup( vgui::VPANEL panel );
void AddPopupsToList( vgui::VPANEL panel );
// Helper for drawing colored text
void DrawColoredText( vgui::HFont font, int x, int y, int r, int g, int b, int a, const char *fmt, va_list argptr );
void SearchForWordBreak( vgui::HFont font, char *text, int& chars, int& pixels );
void InternalThinkTraverse(VPANEL panel);
void InternalSolveTraverse(VPANEL panel);
void InternalSchemeSettingsTraverse(VPANEL panel, bool forceApplySchemeSettings);
// handles mouse movement
void SetCursorPos(int x, int y);
void GetCursorPos(int &x, int &y);
void DrawTexturedLineInternal( const Vertex_t &a, const Vertex_t &b );
// Gets texture coordinates for drawing the full screen buffer
void GetFullScreenTexCoords( int x, int y, int w, int h, float *pMinU, float *pMinV, float *pMaxU, float *pMaxV );
// Is a panel under the restricted panel?
bool IsPanelUnderRestrictedPanel( VPANEL panel );
// Returns the attached window
PlatWindow_t GetAttachedWindow() const;
void ReloadSchemes();
// Point Translation for current panel
int m_nTranslateX;
int m_nTranslateY;
// alpha multiplier for current panel [0..1]
float m_flAlphaMultiplier;
// the apparent depth we should draw the current object at.
// values <= STEREO_NOOP will be ignored, other values will scale by a matrix
float m_flApparentDepth;
// The size of the window to draw into
int m_pSurfaceExtents[4];
// Color for drawing all non-text things
unsigned char m_DrawColor[4];
// Color for drawing text
unsigned char m_DrawTextColor[4];
// Location of text rendering
int m_pDrawTextPos[2];
// Meshbuilder used for drawing
IMesh* m_pMesh;
CMeshBuilder meshBuilder;
// White material used for drawing non-textured things
CMaterialReference m_pWhite;
// Used for 3D-rendered images
CTextureReference m_FullScreenBuffer;
CMaterialReference m_FullScreenBufferMaterial;
CMaterialReference m_FullScreenBufferMaterialIgnoreAlpha;
int m_nFullScreenBufferMaterialId;
int m_nFullScreenBufferMaterialIgnoreAlphaId;
CUtlString m_FullScreenBufferName;
bool m_bUsingTempFullScreenBufferMaterial;
bool m_bRestrictedPanelOverrodeAppModalPanel;
// Root panel
vgui::VPANEL m_pEmbeddedPanel;
vgui::Panel *m_pDefaultEmbeddedPanel;
vgui::VPANEL m_pRestrictedPanel;
// List of pop-up panels based on the type enum above (draw order vs last clicked)
CUtlVector<VPANEL> m_PopupList;
// Stack of paint state...
CUtlVector< PaintState_t > m_PaintStateStack;
CUtlVector<HtmlWindow *> _htmlWindows;
vgui::HFont m_hCurrentFont;
vgui::HCursor _currentCursor;
// The input context for cursor control
InputContextHandle_t m_hInputContext;
// The currently bound texture
int m_iBoundTexture;
// font drawing batching code
enum { MAX_BATCHED_CHAR_VERTS = 4096 };
Vertex_t m_BatchedCharVerts[ MAX_BATCHED_CHAR_VERTS ];
int m_nBatchedCharVertCount;
// What's the rectangle we're drawing in 3D paint mode?
int m_n3DLeft, m_n3DRight, m_n3DTop, m_n3DBottom;
int m_n3DViewportWidth, m_n3DViewportHeight;
// Curr stencil value
int m_nCurrReferenceValue;
// Are we painting in 3D? (namely drawing 3D objects *inside* the vgui panel)
bool m_bIn3DPaintMode : 1;
// Are we drawing the vgui panel in the 3D world somewhere?
bool m_bDrawingIn3DWorld : 1;
// Is the app gonna call HandleInputEvent?
bool m_bAppDrivesInput : 1;
// Are we currently in the think() loop
bool m_bInThink : 1;
bool m_bNeedsKeyboard : 1;
bool m_bNeedsMouse : 1;
bool m_bAllowJavaScript : 1;
bool m_bEnableInput : 1;
int m_nLastInputPollCount;
VPANEL m_CurrentThinkPanel;
// Installed function to play sounds
PlaySoundFunc_t m_PlaySoundFunc;
int m_WorkSpaceInsets[4];
class TitleEntry
{
public:
TitleEntry()
{
panel = NULL;
title[0] = 0;
}
vgui::VPANEL panel;
wchar_t title[128];
};
CUtlVector< TitleEntry > m_Titles;
CUtlVector< CUtlSymbol > m_CustomFontFileNames;
CUtlVector< CUtlSymbol > m_BitmapFontFileNames;
CUtlDict< int, int > m_BitmapFontFileMapping;
float m_flZPos;
CUtlDict< vgui::IImage *, unsigned short > m_FileTypeImages;
int GetTitleEntry( vgui::VPANEL panel );
virtual void DrawSetTextureRGBAEx( int id, const unsigned char *rgba, int wide, int tall, ImageFormat format );
struct ScreenOverride_t
{
ScreenOverride_t() : m_bActive( false )
{
m_nValue[ 0 ] = m_nValue[ 1 ] = 0;
}
bool m_bActive;
int m_nValue[ 2 ];
};
ScreenOverride_t m_ScreenSizeOverride;
ScreenOverride_t m_ScreenPosOverride;
struct ContextAbsPos_t
{
ContextAbsPos_t() : id( -1 )
{
m_nPos[ 0 ] = m_nPos[ 1 ] = 0;
}
static bool Less( const ContextAbsPos_t &lhs, const ContextAbsPos_t &rhs )
{
return lhs.id < rhs.id;
}
int id;
int m_nPos[ 2 ];
};
CUtlRBTree< ContextAbsPos_t > m_ContextAbsPos;
#ifdef LINUX
struct font_entry
{
void *data;
int size;
};
static CUtlDict< font_entry, unsigned short > m_FontData;
static void *FontDataHelper( const char *pchFontName, int &size );
#endif
#if defined( PLATFORM_WINDOWS_PC )
CUtlVector< HANDLE > m_CustomFontHandles;
#endif
};
FORCEINLINE VPANEL CMatSystemSurface::GetPopup( int index )
{
return m_PopupList[ index ];
}
FORCEINLINE int CMatSystemSurface::GetPopupCount()
{
return m_PopupList.Count();
}
inline PlatWindow_t CMatSystemSurface::GetAttachedWindow() const
{
return g_pInputSystem->GetAttachedWindow();
}
inline InputContextHandle_t CMatSystemSurface::GetInputContext() const
{
Assert( m_hInputContext != INPUT_CONTEXT_HANDLE_INVALID );
return m_hInputContext;
}
#if GLMDEBUG
class MatSurfFuncLogger // rip off of GLMFuncLogger - figure out a way to reunify these soon
{
public:
// simple function log
MatSurfFuncLogger( char *funcName )
{
CMatRenderContextPtr prc( g_pMaterialSystem );
m_funcName = funcName;
m_earlyOut = false;
prc->Printf( ">%s", m_funcName );
};
// more advanced version lets you pass args (i.e. called parameters or anything else of interest)
// no macro for this one, since no easy way to pass through the args as well as the funcname
MatSurfFuncLogger( char *funcName, char *fmt, ... )
{
CMatRenderContextPtr prc( g_pMaterialSystem );
m_funcName = funcName;
m_earlyOut = false;
// this acts like GLMPrintf here
// all the indent policy is down in GLMPrintfVA
// which means we need to inject a ">" at the front of the format string to make this work... sigh.
char modifiedFmt[2000];
modifiedFmt[0] = '>';
strcpy( modifiedFmt+1, fmt );
va_list vargs;
va_start(vargs, fmt);
prc->PrintfVA( modifiedFmt, vargs );
va_end( vargs );
}
~MatSurfFuncLogger( )
{
CMatRenderContextPtr prc( g_pMaterialSystem );
if (m_earlyOut)
{
prc->Printf( "<%s (early out)", m_funcName );
}
else
{
prc->Printf( "<%s", m_funcName );
}
};
void EarlyOut( void )
{
m_earlyOut = true;
};
char *m_funcName; // set at construction time
bool m_earlyOut;
};
// handy macro to go with the helper class
#define MAT_FUNC MatSurfFuncLogger _logger_ ( __FUNCTION__ )
#else
#define MAT_FUNC
#endif
#endif // MATSYSTEMSURFACE_H

View File

@ -0,0 +1,70 @@
// ----------------------------------------- //
// File generated by VPC //
// ----------------------------------------- //
Source file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vguimatsurface\Clip2D.cpp
Debug output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vguimatsurface\Clip2D.cpp
Release output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vguimatsurface\Clip2D.cpp
Containing unity file:
PCH file:
Source file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vguimatsurface\Cursor.cpp
Debug output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vguimatsurface\Cursor.cpp
Release output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vguimatsurface\Cursor.cpp
Containing unity file:
PCH file:
Source file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\common\debug_dll_check.cpp
Debug output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\common\debug_dll_check.cpp
Release output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\common\debug_dll_check.cpp
Containing unity file:
PCH file:
Source file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\public\filesystem_helpers.cpp
Debug output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\public\filesystem_helpers.cpp
Release output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\public\filesystem_helpers.cpp
Containing unity file:
PCH file:
Source file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vgui2\src\htmlwindow.cpp
Debug output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vgui2\src\htmlwindow.cpp
Release output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vgui2\src\htmlwindow.cpp
Containing unity file:
PCH file:
Source file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vguimatsurface\Input.cpp
Debug output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vguimatsurface\Input.cpp
Release output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vguimatsurface\Input.cpp
Containing unity file:
PCH file:
Source file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vguimatsurface\MatSystemSurface.cpp
Debug output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vguimatsurface\MatSystemSurface.cpp
Release output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vguimatsurface\MatSystemSurface.cpp
Containing unity file:
PCH file:
Source file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vguimatsurface\memorybitmap.cpp
Debug output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vguimatsurface\memorybitmap.cpp
Release output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vguimatsurface\memorybitmap.cpp
Containing unity file:
PCH file:
Source file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\public\tier0\memoverride.cpp
Debug output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\public\tier0\memoverride.cpp
Release output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\public\tier0\memoverride.cpp
Containing unity file:
PCH file:
Source file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\public\vgui_controls\vgui_controls.cpp
Debug output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\public\vgui_controls\vgui_controls.cpp
Release output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\public\vgui_controls\vgui_controls.cpp
Containing unity file:
PCH file:
Source file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vgui2\src\vgui_key_translation.cpp
Debug output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vgui2\src\vgui_key_translation.cpp
Release output file: D:\Users\berta\Downloads\csgosourcecode\cstrike15_src\vgui2\src\vgui_key_translation.cpp
Containing unity file:
PCH file:

View File

@ -0,0 +1,178 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include <vgui/ISurface.h>
#include "memorybitmap.h"
#include <string.h>
#include <stdlib.h>
#include "MatSystemSurface.h"
#include "materialsystem/IMaterialVar.h"
#include "materialsystem/ITexture.h"
#include "bitmap/imageformat.h"
#include "vtf/vtf.h"
#include "KeyValues.h"
#include "vgui_surfacelib/TextureDictionary.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
extern CMatSystemSurface g_MatSystemSurface;
using namespace vgui;
//-----------------------------------------------------------------------------
// Purpose: Constructor
// Input : *filename - image file to load
//-----------------------------------------------------------------------------
MemoryBitmap::MemoryBitmap(unsigned char *texture,int wide, int tall)
{
_texture=texture;
_uploaded = false;
_color = Color(255, 255, 255, 255);
_pos[0] = _pos[1] = 0;
_valid = true;
_w = wide;
_h = tall;
m_iTextureID = 0;
ForceUpload(texture,wide,tall);
}
//-----------------------------------------------------------------------------
// Purpose: Destructor
//-----------------------------------------------------------------------------
MemoryBitmap::~MemoryBitmap()
{
// Free the old texture ID.
if ( m_iTextureID != 0 )
TextureDictionary()->DestroyTexture( m_iTextureID );
}
//-----------------------------------------------------------------------------
// Purpose: data accessor
//-----------------------------------------------------------------------------
void MemoryBitmap::GetSize(int &wide, int &tall)
{
wide = 0;
tall = 0;
if (!_valid)
return;
g_MatSystemSurface.DrawGetTextureSize(m_iTextureID, wide, tall);
}
//-----------------------------------------------------------------------------
// Purpose: size of the bitmap
//-----------------------------------------------------------------------------
void MemoryBitmap::GetContentSize(int &wide, int &tall)
{
GetSize(wide, tall);
}
//-----------------------------------------------------------------------------
// Purpose: ignored
//-----------------------------------------------------------------------------
void MemoryBitmap::SetSize(int x, int y)
{
}
//-----------------------------------------------------------------------------
// Purpose: data accessor
//-----------------------------------------------------------------------------
void MemoryBitmap::SetPos(int x, int y)
{
_pos[0] = x;
_pos[1] = y;
}
//-----------------------------------------------------------------------------
// Purpose: data accessor
//-----------------------------------------------------------------------------
void MemoryBitmap::SetColor(Color col)
{
_color = col;
}
//-----------------------------------------------------------------------------
// Purpose: returns the file name of the bitmap
//-----------------------------------------------------------------------------
const char *MemoryBitmap::GetName()
{
return "MemoryBitmap";
}
//-----------------------------------------------------------------------------
// Purpose: Renders the loaded image, uploading it if necessary
// Assumes a valid image is always returned from uploading
//-----------------------------------------------------------------------------
void MemoryBitmap::Paint()
{
if (!_valid)
return;
// if we have not uploaded yet, lets go ahead and do so
if (!_uploaded)
{
ForceUpload(_texture,_w,_h);
}
//set the texture current, set the color, and draw the biatch
g_MatSystemSurface.DrawSetTexture(m_iTextureID);
g_MatSystemSurface.DrawSetColor(_color[0], _color[1], _color[2], _color[3]);
int wide, tall;
GetSize(wide, tall);
g_MatSystemSurface.DrawTexturedRect( _pos[0], _pos[1], _pos[0] + wide, _pos[1] + tall);
}
//-----------------------------------------------------------------------------
// Purpose: ensures the bitmap has been uploaded
//-----------------------------------------------------------------------------
void MemoryBitmap::ForceUpload(unsigned char *texture,int wide, int tall)
{
_texture=texture;
bool sizechanged = ( _w != wide || _h != tall );
_w = wide;
_h = tall;
if (!_valid)
return;
if(_w==0 || _h==0)
return;
// If size changed, or first time through, destroy and recreate texture id...
if ( sizechanged && m_iTextureID )
{
TextureDictionary()->DestroyTexture( m_iTextureID );
m_iTextureID = 0;
}
if ( !m_iTextureID )
{
m_iTextureID = g_MatSystemSurface.CreateNewTextureID( true );
}
g_MatSystemSurface.DrawSetTextureRGBA( m_iTextureID, texture, wide, tall );
_uploaded = true;
_valid = g_MatSystemSurface.IsTextureIDValid(m_iTextureID);
}
//-----------------------------------------------------------------------------
// Purpose: data accessor
//-----------------------------------------------------------------------------
HTexture MemoryBitmap::GetID()
{
return m_iTextureID;
}

View File

@ -0,0 +1,68 @@
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef MEMORYBITMAP_H
#define MEMORYBITMAP_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui/vgui.h>
#include <vgui/IImage.h>
#include <color.h>
namespace vgui
{
typedef unsigned long HTexture;
//-----------------------------------------------------------------------------
// Purpose: Holds a single image created from a chunk of memory, internal to vgui only
//-----------------------------------------------------------------------------
class MemoryBitmap: public IImage
{
public:
MemoryBitmap(unsigned char *texture,int wide, int tall);
~MemoryBitmap();
// IImage implementation
virtual void Paint();
virtual void GetSize(int &wide, int &tall);
virtual void GetContentSize(int &wide, int &tall);
virtual void SetPos(int x, int y);
virtual void SetSize(int x, int y);
virtual void SetColor(Color col);
virtual bool Evict() OVERRIDE{ return false; }
virtual int GetNumFrames() OVERRIDE{ return 0; }
virtual void SetFrame(int nFrame) OVERRIDE{}
virtual void SetRotation(int iRotation) OVERRIDE{ return; };
// methods
void ForceUpload(unsigned char *texture,int wide, int tall); // ensures the bitmap has been uploaded
HTexture GetID(); // returns the texture id
const char *GetName();
bool IsValid()
{
return _valid;
}
private:
// HTexture _id;
bool _uploaded;
bool _valid;
unsigned char *_texture;
int _pos[2];
Color _color;
int _w,_h; // size of the texture
int m_iTextureID;
};
} // namespace vgui
#endif // MEMORYBITMAP_H

View File

@ -0,0 +1,30 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose: Implementation of the VGUI ISurface interface using the
// material system to implement it
//
// $Revision: $
// $NoKeywords: $
//===========================================================================//
#ifndef VGUIMATSURFACE_H
#define VGUIMATSURFACE_H
#include <vgui/vgui.h>
#include "tier3/tier3.h"
namespace vgui
{
class IInputInternal;
}
//-----------------------------------------------------------------------------
// Globals...
//-----------------------------------------------------------------------------
extern vgui::IInputInternal *g_pIInput;
#endif // VGUIMATSURFACE_H

View File

@ -0,0 +1,124 @@
//-----------------------------------------------------------------------------
// VGUIMATSURFACE.VPC
//
// Project Script
//-----------------------------------------------------------------------------
$macro SRCDIR ".."
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
$include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
$Configuration
{
$Compiler
{
$PreprocessorDefinitions "$BASE;BENCHMARK;VGUIMATSURFACE_DLL_EXPORT;GAMEUI_EXPORTS;DONT_PROTECT_FILEIO_FUNCTIONS;PROTECTED_THINGS_ENABLE"
$PreprocessorDefinitions "$BASE;fopen=dont_use_fopen" [$WINDOWS]
$PreprocessorDefinitions "$BASE;ENABLE_CHROMEHTMLWINDOW"
// $TreatWchar_tAsBuiltinType "No"
}
$Linker
{
$SystemLibraries "iconv" [$OSXALL]
$SystemFrameworks "Carbon" [$OSXALL]
$GCC_ExtraLinkerFlags "-L/usr/lib32 -L/usr/lib -L/usr/lib/i386-linux-gnu" [$LINUXALL]
$SystemLibraries "fontconfig;freetype;SDL2" [$LINUXALL]
$AdditionalDependencies "$BASE vgui_surfacelib_360.lib" [$X360]
$AdditionalDependencies "$BASE vgui_surfacelib.lib" [$WINDOWS]
}
}
$Configuration "Debug"
{
$Linker [$WINDOWS]
{
$AdditionalDependencies "$BASE $SRCDIR\lib\win32\debug\libcef.lib"
}
}
$Configuration "Release"
{
$Linker [$WINDOWS]
{
$AdditionalDependencies "$BASE $SRCDIR\lib\win32\release\libcef.lib"
}
}
$Project "vguimatsurface"
{
$Folder "Source Files"
{
$File "Clip2D.cpp"
$File "Cursor.cpp"
$File "$SRCDIR\public\filesystem_helpers.cpp"
$File "Input.cpp"
$File "MatSystemSurface.cpp"
$File "memorybitmap.cpp" [$WINDOWS]
$File "$SRCDIR\vgui2\src\htmlwindow.cpp" [$WINDOWS]
$File "$SRCDIR\vgui2\src\vgui_key_translation.cpp"
$File "$SRCDIR\public\vgui_controls\vgui_controls.cpp"
}
$Folder "Header Files"
{
$File "Clip2D.h"
$File "Cursor.h"
$File "Input.h"
$File "memorybitmap.h" [$WINDOWS]
$File "vguimatsurface.h"
$File "MatSystemSurface.h"
$File "$SRCDIR\vgui2\src\vgui_key_translation.h"
}
$Folder "Public Header Files"
{
$File "$SRCDIR\public\tier0\basetypes.h"
$File "$SRCDIR\public\tier1\characterset.h"
$File "$SRCDIR\public\tier1\checksum_crc.h"
$File "$SRCDIR\public\filesystem.h"
$File "$SRCDIR\public\filesystem_helpers.h"
$File "$SRCDIR\common\vgui_surfacelib\FontAmalgam.h"
$File "$SRCDIR\common\vgui_surfacelib\FontManager.h"
$File "$SRCDIR\common\vgui\HtmlWindow.h" [$WINDOWS]
$File "$SRCDIR\public\appframework\iappsystem.h"
$File "$SRCDIR\public\materialsystem\imaterial.h"
$File "$SRCDIR\public\materialsystem\imaterialsystem.h"
$File "$SRCDIR\public\materialsystem\imaterialvar.h"
$File "$SRCDIR\public\VGuiMatSurface\IMatSystemSurface.h"
$File "$SRCDIR\public\materialsystem\imesh.h"
$File "$SRCDIR\public\tier1\interface.h"
$File "$SRCDIR\public\materialsystem\itexture.h"
$File "$SRCDIR\public\pixelwriter.h"
$File "$SRCDIR\public\tier1\strtools.h"
$File "$SRCDIR\common\vgui_surfacelib\texturedictionary.h"
$File "$SRCDIR\public\tier1\utllinkedlist.h"
$File "$SRCDIR\public\tier1\utlmemory.h"
$File "$SRCDIR\public\tier1\utlrbtree.h"
$File "$SRCDIR\public\tier1\utlvector.h"
$File "$SRCDIR\public\mathlib\vector.h"
$File "$SRCDIR\public\mathlib\vector2d.h"
$File "$SRCDIR\public\mathlib\vector4d.h"
$File "$SRCDIR\public\vstdlib\vstdlib.h"
$File "$SRCDIR\public\vtf\vtf.h"
$File "$SRCDIR\common\vgui_surfacelib\Win32Font.h"
}
$Folder "Link Libraries"
{
$Lib bitmap
$Lib mathlib
$Lib tier2
$Lib tier3
$Lib vgui_controls
$Lib vgui_surfacelib
$Lib dmxloader
$Lib "$SRCDIR\lib\public\nvtc" [$WINDOWS && !$WIN64]
$Lib "$SRCDIR\lib\public\nvtc64" [$WIN64]
$ImpLib SDL2 [$SDL && !$LINUXALL]
}
}

View File

@ -0,0 +1,13 @@
"vpc_cache"
{
"CacheVersion" "1"
"win32"
{
"CRCFile" "vguimatsurface.vcxproj.vpc_crc"
"OutputFiles"
{
"0" "vguimatsurface.vcxproj"
"1" "vguimatsurface.vcxproj.filters"
}
}
}

2
vguimatsurface/vsi.nul Normal file
View File

@ -0,0 +1,2 @@
SN Visual Studio Integration
IMPORTANT: Do not remove the custom build step for this file

View File

@ -0,0 +1,3 @@
LIBRARY vguimatsurface_360.dll
EXPORTS
CreateInterface @1