Merge branch 'master' into windows

This commit is contained in:
HappyDOGE
2022-07-27 12:58:56 +03:00
3089 changed files with 38639 additions and 844820 deletions
+4 -4
View File
@@ -320,13 +320,13 @@ CQCGenerator::CQCGenerator( vgui::Panel *pParent, const char *pszPath, const cha
SetParent( pParent );
char szGamePath[1024] = "\0";
char szSearchPath[1024] = "\0";
char szSearchPath[2048] = "\0";
// Get the currently set game configuration
GetVConfigRegistrySetting( GAMEDIR_TOKEN, szGamePath, sizeof( szGamePath ) );
static const char *pSurfacePropFilename = "\\scripts\\surfaceproperties.txt";
sprintf( szSearchPath, "%s%s", szGamePath, pSurfacePropFilename );
snprintf( szSearchPath, sizeof(szSearchPath), "%s%s", szGamePath, pSurfacePropFilename );
FileHandle_t fp = g_pFullFileSystem->Open( szSearchPath, "rb" );
@@ -338,7 +338,7 @@ CQCGenerator::CQCGenerator( vgui::Panel *pParent, const char *pszPath, const cha
char *pszEndGamePath = Q_strrchr( szGamePath, '\\' );
pszEndGamePath[0] = 0;
V_strcat_safe( szGamePath, "\\hl2" );
sprintf( szSearchPath, "%s%s", szGamePath, pSurfacePropFilename );
snprintf( szSearchPath, sizeof(szSearchPath), "%s%s", szGamePath, pSurfacePropFilename );
fp = g_pFullFileSystem->Open( szSearchPath, "rb" );
}
@@ -720,4 +720,4 @@ void CQCGenerator::OnNewLODText()
m_pLODPanel->LeaveEditMode();
m_pLODPanel->InvalidateLayout();
return;
}
}
+6 -6
View File
@@ -671,7 +671,7 @@ bool CAssetCache::AddFilesInDirectory( CachedAssetList_t& list, const char *pSta
//-----------------------------------------------------------------------------
bool CAssetCache::ContinueSearchForAssets( AssetList_t hList, float flDuration )
{
CachedAssetList_t& list = m_CachedAssets[ (int)hList ];
CachedAssetList_t& list = m_CachedAssets[ (intp)hList ];
float flStartTime = Plat_FloatTime();
while ( list.m_DirectoriesToCheck.Count() )
@@ -710,7 +710,7 @@ bool CAssetCache::ContinueSearchForAssets( AssetList_t hList, float flDuration )
//-----------------------------------------------------------------------------
bool CAssetCache::BeginAssetScan( AssetList_t hList, bool bForceRescan )
{
CachedAssetList_t& list = m_CachedAssets[ (int)hList ];
CachedAssetList_t& list = m_CachedAssets[ (intp)hList ];
if ( bForceRescan )
{
list.m_bAssetScanComplete = false;
@@ -758,27 +758,27 @@ AssetList_t CAssetCache::FindAssetList( const char *pAssetType, const char *pSub
list.m_pFileTree = new CAssetTreeView( NULL, "FolderFilter", pAssetType, pSubDir );
}
return (AssetList_t)nIndex;
return (AssetList_t)(intp)nIndex;
}
CAssetTreeView* CAssetCache::GetFileTree( AssetList_t hList )
{
if ( hList == ASSET_LIST_INVALID )
return NULL;
return m_CachedAssets[ (int)hList ].m_pFileTree;
return m_CachedAssets[ (intp)hList ].m_pFileTree;
}
int CAssetCache::GetAssetCount( AssetList_t hList ) const
{
if ( hList == ASSET_LIST_INVALID )
return 0;
return m_CachedAssets[ (int)hList ].m_AssetList.Count();
return m_CachedAssets[ (intp)hList ].m_AssetList.Count();
}
const CAssetCache::CachedAssetInfo_t& CAssetCache::GetAsset( AssetList_t hList, int nIndex ) const
{
Assert( nIndex < GetAssetCount(hList) );
return m_CachedAssets[ (int)hList ].m_AssetList[ nIndex ];
return m_CachedAssets[ (intp)hList ].m_AssetList[ nIndex ];
}
+8
View File
@@ -30,6 +30,8 @@
#ifdef OSX
#include <Carbon/Carbon.h>
#include <sys/param.h>
#include <sys/mount.h>
#elif defined(LINUX)
#include <sys/vfs.h>
#endif
@@ -583,8 +585,14 @@ int CSystem::GetAvailableDrives(char *buf, int bufLen)
//-----------------------------------------------------------------------------
double CSystem::GetFreeDiskSpace(const char *path)
{
#if __DARWIN_ONLY_64_BIT_INO_T
// MoeMod: newer macOS only support 64bit, so no statfs64 is provided
struct statfs buf;
int ret = statfs( path, &buf );
#else
struct statfs64 buf;
int ret = statfs64( path, &buf );
#endif
if ( ret < 0 )
return 0.0;
return (double) ( buf.f_bsize * buf.f_bfree );
+4
View File
@@ -26,7 +26,11 @@
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
#ifdef OSX
#include <malloc/malloc.h>
#else
#include <malloc.h>
#endif
#include <tier0/dbg.h>
#include <tier1/utlhandletable.h>
#include "vgui_internal.h"
+2 -2
View File
@@ -330,7 +330,7 @@ bool AnimationController::ParseScriptFile(char *pMem, int length)
// get the open brace or a conditional
pMem = ParseFile(pMem, token, NULL);
if ( Q_stristr( token, "[$" ) )
if ( Q_stristr( token, "[$" ) || Q_stristr( token, "[!$" ) )
{
bAccepted = EvaluateConditional( token );
@@ -655,7 +655,7 @@ bool AnimationController::ParseScriptFile(char *pMem, int length)
// Look ahead one token for a conditional
char *peek = ParseFile(pMem, token, NULL);
if ( Q_stristr( token, "[$" ) )
if ( Q_stristr( token, "[$" ) || Q_stristr( token, "[!$" ) )
{
if ( !EvaluateConditional( token ) )
{
+2 -1
View File
@@ -41,6 +41,7 @@
#include "filesystem.h"
#include "tier0/icommandline.h"
#include "const.h"
#include "vprof.h"
#if defined( _X360 )
#include "xbox/xbox_win32stubs.h"
@@ -1541,4 +1542,4 @@ void BuildGroup::ClearResFileCache()
nIndex = m_dictCachedResFiles.Next( nIndex );
}
m_dictCachedResFiles.Purge();
}
}
+5 -5
View File
@@ -862,7 +862,7 @@ int ListPanel::FindColumn(const char *columnName)
// data->GetName() is used to uniquely identify an item
// data sub items are matched against column header name to be used in the table
//-----------------------------------------------------------------------------
int ListPanel::AddItem( const KeyValues *item, unsigned int userData, bool bScrollToItem, bool bSortOnAdd)
int ListPanel::AddItem( const KeyValues *item, uintp userData, bool bScrollToItem, bool bSortOnAdd)
{
FastSortListPanelItem *newitem = new FastSortListPanelItem;
newitem->kv = item->MakeCopy();
@@ -898,7 +898,7 @@ int ListPanel::AddItem( const KeyValues *item, unsigned int userData, bool bScro
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void ListPanel::SetUserData( int itemID, unsigned int userData )
void ListPanel::SetUserData( int itemID, uintp userData )
{
if ( !m_DataItems.IsValidIndex(itemID) )
return;
@@ -909,7 +909,7 @@ void ListPanel::SetUserData( int itemID, unsigned int userData )
//-----------------------------------------------------------------------------
// Purpose: Finds the first itemID with a matching userData
//-----------------------------------------------------------------------------
int ListPanel::GetItemIDFromUserData( unsigned int userData )
int ListPanel::GetItemIDFromUserData( uintp userData )
{
FOR_EACH_LL( m_DataItems, itemID )
{
@@ -1064,7 +1064,7 @@ ListPanelItem *ListPanel::GetItemData( int itemID )
//-----------------------------------------------------------------------------
// Purpose: returns user data for itemID
//-----------------------------------------------------------------------------
unsigned int ListPanel::GetItemUserData(int itemID)
uintp ListPanel::GetItemUserData(int itemID)
{
if ( !m_DataItems.IsValidIndex(itemID) )
return 0;
@@ -2828,7 +2828,7 @@ void ListPanel::SortList( void )
//-----------------------------------------------------------------------------
void ListPanel::SetFont(HFont font)
{
Assert( font );
Assert( font );
if ( !font )
return;
+2 -4
View File
@@ -2365,9 +2365,8 @@ int Menu::GetCurrentlyHighlightedItem()
//-----------------------------------------------------------------------------
// Purpose: Respond to cursor entering a menuItem.
//-----------------------------------------------------------------------------
void Menu::OnCursorEnteredMenuItem(int VPanel)
void Menu::OnCursorEnteredMenuItem(VPANEL menuItem)
{
VPANEL menuItem = (VPANEL)VPanel;
// if we are in mouse mode
if (m_iInputMode == MOUSE)
{
@@ -2389,9 +2388,8 @@ void Menu::OnCursorEnteredMenuItem(int VPanel)
//-----------------------------------------------------------------------------
// Purpose: Respond to cursor exiting a menuItem
//-----------------------------------------------------------------------------
void Menu::OnCursorExitedMenuItem(int VPanel)
void Menu::OnCursorExitedMenuItem(VPANEL menuItem)
{
VPANEL menuItem = (VPANEL)VPanel;
// only care if we are in mouse mode
if (m_iInputMode == MOUSE)
{
+2 -2
View File
@@ -222,7 +222,7 @@ void MenuItem::OnCursorEntered()
// forward the message on to the parent of this menu.
KeyValues *msg = new KeyValues ("CursorEnteredMenuItem");
// tell the parent this menuitem is the one that was entered so it can highlight it
msg->SetInt("VPanel", GetVPanel());
msg->SetInt("menuItem", ToHandle() );
ivgui()->PostMessage(GetVParent(), msg, NULL);
}
@@ -236,7 +236,7 @@ void MenuItem::OnCursorExited()
// forward the message on to the parent of this menu.
KeyValues *msg = new KeyValues ("CursorExitedMenuItem");
// tell the parent this menuitem is the one that was entered so it can unhighlight it
msg->SetInt("VPanel", GetVPanel());
msg->SetInt("menuItem", ToHandle() );
ivgui()->PostMessage(GetVParent(), msg, NULL);
}
+24 -18
View File
@@ -226,7 +226,6 @@ KeyBindingMap_t::~KeyBindingMap_t()
class CKeyBindingsMgr
{
public:
CKeyBindingsMgr() :
m_Bindings( 0, 0, KeyBindingContextHandleLessFunc ),
m_nKeyBindingContexts( 0 )
@@ -881,7 +880,7 @@ const char *Panel::GetClassName()
{
// loop up the panel map name
PanelMessageMap *panelMap = GetMessageMap();
if ( panelMap )
if ( panelMap && panelMap->pfnClassName )
{
return panelMap->pfnClassName();
}
@@ -1450,8 +1449,10 @@ void Panel::SetParent(Panel *newParent)
//-----------------------------------------------------------------------------
void Panel::SetParent(VPANEL newParent)
{
if (newParent)
{
ipanel()->SetParent(GetVPanel(), newParent);
}
else
@@ -1459,19 +1460,19 @@ void Panel::SetParent(VPANEL newParent)
ipanel()->SetParent(GetVPanel(), NULL);
}
if (GetVParent() && !IsPopup())
if (GetVParent() )
{
SetProportional(ipanel()->IsProportional(GetVParent()));
if( ipanel()->IsProportional(GetVParent()) )
SetProportional(true);
// most of the time KBInput == parents kbinput
if (ipanel()->IsKeyBoardInputEnabled(GetVParent()) != IsKeyBoardInputEnabled())
if( IsPopup() )
{
SetKeyBoardInputEnabled(ipanel()->IsKeyBoardInputEnabled(GetVParent()));
}
// most of the time KBInput == parents kbinput
if (ipanel()->IsKeyBoardInputEnabled(GetVParent()) != IsKeyBoardInputEnabled())
SetKeyBoardInputEnabled(ipanel()->IsKeyBoardInputEnabled(GetVParent()));
if (ipanel()->IsMouseInputEnabled(GetVParent()) != IsMouseInputEnabled())
{
SetMouseInputEnabled(ipanel()->IsMouseInputEnabled(GetVParent()));
if (ipanel()->IsMouseInputEnabled(GetVParent()) != IsMouseInputEnabled())
SetMouseInputEnabled(ipanel()->IsMouseInputEnabled(GetVParent()));
}
}
@@ -3574,7 +3575,7 @@ void Panel::RequestFocus(int direction)
//-----------------------------------------------------------------------------
void Panel::OnRequestFocus(VPANEL subFocus, VPANEL defaultPanel)
{
CallParentFunction(new KeyValues("OnRequestFocus", "subFocus", subFocus, "defaultPanel", defaultPanel));
CallParentFunction(new KeyValues("OnRequestFocus", "subFocus", ivgui()->PanelToHandle( subFocus ), "defaultPanel", ivgui()->PanelToHandle( defaultPanel )));
}
//-----------------------------------------------------------------------------
@@ -3801,11 +3802,9 @@ void Panel::SetBuildGroup(BuildGroup* buildGroup)
{
//TODO: remove from old group
Assert(buildGroup != NULL);
_buildGroup = buildGroup;
_buildGroup->PanelAdded(this);
Assert(buildGroup != NULL);
_buildGroup = buildGroup;
_buildGroup->PanelAdded(this);
}
bool Panel::IsBuildGroupEnabled()
@@ -5133,6 +5132,13 @@ void Panel::OnMessage(const KeyValues *params, VPANEL ifromPanel)
VPANEL vp = ivgui()->HandleToPanel( param1->GetInt() );
(this->*((MessageFunc_HandleConstCharPtr_t)pMap->func))( vp, param2->GetWString() );
}
else if ( (DATATYPE_HANDLE == pMap->firstParamType) && (DATATYPE_HANDLE == pMap->secondParamType) )
{
typedef void (Panel::*MessageFunc_HandleConstCharPtr_t)(VPANEL, VPANEL);
VPANEL vp1 = ivgui()->HandleToPanel( param1->GetInt() );
VPANEL vp2 = ivgui()->HandleToPanel( param2->GetInt() );
(this->*((MessageFunc_HandleConstCharPtr_t)pMap->func))( vp1, vp2 );
}
else
{
// the message isn't handled
@@ -5514,7 +5520,7 @@ void Panel::OnDelete()
// Purpose: Panel handle implementation
// Returns a pointer to a valid panel, NULL if the panel has been deleted
//-----------------------------------------------------------------------------
Panel *PHandle::Get()
Panel *PHandle::Get() const
{
if (m_iPanelID != INVALID_PANEL)
{
+2 -2
View File
@@ -2547,12 +2547,12 @@ int RichText::ParseTextStringForUrls( const char *text, int startPos, char *pchU
// get the url
i += Q_strlen( "<a href=" );
const char *pchURLEnd = Q_strstr( text + i, ">" );
Q_strncpy( pchURL, text + i, min( pchURLEnd - text - i + 1, cchURL ) );
Q_strncpy( pchURL, text + i, min( (int)(pchURLEnd - text) - i + 1, cchURL ) );
i += ( pchURLEnd - text - i + 1 );
// get the url text
pchURLEnd = Q_strstr( text, "</a>" );
Q_strncpy( pchURLText, text + i, min( pchURLEnd - text - i + 1, cchURLText ) );
Q_strncpy( pchURLText, text + i, min( (int)(pchURLEnd - text) - i + 1, cchURLText ) );
i += ( pchURLEnd - text - i );
i += Q_strlen( "</a>" );
+4 -2
View File
@@ -149,6 +149,8 @@ ScrollBar::ScrollBar(Panel *parent, const char *panelName, bool vertical) : Pane
m_pOverriddenButtons[0] = NULL;
m_pOverriddenButtons[1] = NULL;
int width = IsProportional() ? scheme()->GetProportionalScaledValue(SCROLLBAR_DEFAULT_WIDTH) : SCROLLBAR_DEFAULT_WIDTH;
if (vertical)
{
// FIXME: proportional changes needed???
@@ -158,7 +160,7 @@ ScrollBar::ScrollBar(Panel *parent, const char *panelName, bool vertical) : Pane
_button[0]->SetTextInset(0, 1);
_button[1]->SetTextInset(0, -1);
SetSize(SCROLLBAR_DEFAULT_WIDTH, 64);
SetSize(width, 64);
}
else
{
@@ -168,7 +170,7 @@ ScrollBar::ScrollBar(Panel *parent, const char *panelName, bool vertical) : Pane
_button[0]->SetTextInset(0, 0);
_button[1]->SetTextInset(0, 0);
SetSize(64, SCROLLBAR_DEFAULT_WIDTH);
SetSize(64, width);
}
Panel::SetPaintBorderEnabled(true);
+4 -5
View File
@@ -230,7 +230,6 @@ void Slider::SetInverted( bool bInverted )
m_bInverted = bInverted;
}
//-----------------------------------------------------------------------------
// Purpose: Send a message to interested parties when the slider moves
//-----------------------------------------------------------------------------
@@ -386,9 +385,9 @@ void Slider::GetTrackRect( int& x, int& y, int& w, int& h )
GetPaintSize( wide, tall );
x = 0;
y = 8;
y = IsProportional() ? scheme()->GetProportionalScaledValue( 8.f ) : 8;;
w = wide - (int)_nobSize;
h = 4;
h = IsProportional() ? scheme()->GetProportionalScaledValue( 4.f ) : 4;
}
//-----------------------------------------------------------------------------
@@ -524,7 +523,7 @@ void Slider::DrawNob()
#endif
surface()->DrawSetColor(col);
int nobheight = 16;
int nobheight = IsProportional() ? scheme()->GetProportionalScaledValue( 16.f ) : 16.f;
surface()->DrawFilledRect(
_nobPos[0],
@@ -941,7 +940,7 @@ void Slider::SetButtonOffset(int buttonOffset)
void Slider::SetThumbWidth( int width )
{
_nobSize = (float)width;
_nobSize = IsProportional() ? scheme()->GetProportionalScaledValue( (float)width) : (float)width;
}
+4
View File
@@ -9,7 +9,11 @@
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
#ifdef OSX
#include <malloc/malloc.h>
#else
#include <malloc.h>
#endif
#include <vgui/IPanel.h>
#include <vgui/ISurface.h>
+4
View File
@@ -10,7 +10,11 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
#ifdef OSX
#include <malloc/malloc.h>
#else
#include <malloc.h>
#endif
#include "vgui_surfacelib/BitmapFont.h"
#include "vgui_surfacelib/FontManager.h"
#include <tier0/dbg.h>
+6 -6
View File
@@ -43,7 +43,7 @@ CFontManager::CFontManager()
m_FontAmalgams.AddToTail();
m_Win32Fonts.EnsureCapacity( MAX_INITIAL_FONTS );
#ifdef LINUX
#if defined(LINUX) || defined(OSX)
FT_Error error = FT_Init_FreeType( &library );
if ( error )
Error( "Unable to initalize freetype library, is it installed?" );
@@ -75,7 +75,7 @@ CFontManager::~CFontManager()
{
ClearAllFonts();
m_FontAmalgams.RemoveAll();
#ifdef LINUX
#if defined(LINUX) || defined(OSX)
FT_Done_FreeType( library );
#endif
}
@@ -280,7 +280,7 @@ font_t *CFontManager::CreateOrFindWin32Font(const char *windowsFontName, int tal
i = m_Win32Fonts.AddToTail();
m_Win32Fonts[i] = NULL;
#ifdef LINUX
#if defined(LINUX) || defined(OSX)
int memSize = 0;
void *pchFontData = m_pFontDataHelper( windowsFontName, memSize, NULL );
@@ -730,7 +730,7 @@ void CFontManager::GetKernedCharWidth( vgui::HFont font, wchar_t ch, wchar_t chB
{
wide = 0.0f;
flabcA = 0.0f;
Assert( font != vgui::INVALID_FONT );
if ( font == vgui::INVALID_FONT )
return;
@@ -749,8 +749,8 @@ void CFontManager::GetKernedCharWidth( vgui::HFont font, wchar_t ch, wchar_t chB
if ( m_FontAmalgams[font].GetFontForChar( chAfter ) != pFont )
chAfter = 0;
#if defined(LINUX)
#if defined(LINUX) || defined(OSX)
pFont->GetKernedCharWidth( ch, chBefore, chAfter, wide, flabcA, flabcC );
#else
pFont->GetKernedCharWidth( ch, chBefore, chAfter, wide, flabcA );
+16 -18
View File
@@ -12,7 +12,11 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
#ifdef OSX
#include <malloc/malloc.h>
#else
#include <malloc.h>
#endif
#include <tier0/dbg.h>
#include <vgui/ISurface.h>
#include <utlbuffer.h>
@@ -42,8 +46,6 @@ inline int32_t INT_2FIXED6(int32_t x) { return x << 6; }
bool CLinuxFont::ms_bSetFriendlyNameCacheLessFunc = false;
CUtlRBTree< CLinuxFont::font_name_entry > CLinuxFont::m_FriendlyNameCache;
#define ANDROID 1
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
@@ -168,44 +170,40 @@ void CLinuxFont::CreateFontList()
}
#ifndef ANDROID
static FcPattern* FontMatch(const char* type, FcType vtype, const void* value,
...)
static FcPattern* FontMatch(const char* type, ...)
{
FcValue fcvalue;
va_list ap;
va_start(ap, value);
va_start(ap, type);
FcPattern* pattern = FcPatternCreate();
for (;;)
{
FcValue fcvalue;
fcvalue.type = vtype;
switch (vtype) {
for (;;) {
// FcType is promoted to int when passed through ...
fcvalue.type = static_cast<FcType>(va_arg(ap, int));
switch (fcvalue.type) {
case FcTypeString:
fcvalue.u.s = (FcChar8*) value;
fcvalue.u.s = va_arg(ap, const FcChar8 *);
break;
case FcTypeInteger:
fcvalue.u.i = (int) value;
fcvalue.u.i = va_arg(ap, int);
break;
default:
Assert(!"FontMatch unhandled type");
}
FcPatternAdd(pattern, type, fcvalue, 0);
FcPatternAdd(pattern, type, fcvalue, FcFalse);
type = va_arg(ap, const char *);
if (!type)
break;
// FcType is promoted to int when passed through ...
vtype = static_cast<FcType>(va_arg(ap, int));
value = va_arg(ap, const void *);
};
va_end(ap);
FcConfigSubstitute(0, pattern, FcMatchPattern);
FcConfigSubstitute(NULL, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);
FcResult result;
FcPattern* match = FcFontMatch(0, pattern, &result);
FcPattern* match = FcFontMatch(NULL, pattern, &result);
FcPatternDestroy(pattern);
return match;