mirror of
https://github.com/FWGS/hlsdk-xash3d
synced 2024-11-22 01:47:45 +01:00
ba2cab60df
* Get VGUI back (optionally) * Add some missing VGUI invocations * Update CMakeLists.txt to build with vgui for Windows * Move windows.h inclusions only to those places where it's really needed * Try fix mingw build * Update hud_spectator * Merge nekonomicon's vgui branch * Don't include vgui panel and app in cdll_int.cpp if vgui is real * Deduplicate scoreboard global variables * Add options to prefer non-vgui motd and scoreboard when vgui is enabled * Add vgui-dev as a submodule. Add building vith vgui to CI * Fix artifact uploading * Don't use global variable when not necessary * char* to const char* in CMenuHandler_StringCommand constructor * Fix 'format string is not a literal string' warnings * Fix 'always evaluate to true' warnings * Team Fortress classes to const char* * CreateCommandMenu accepts const char* * Fix printf formats. Turn some unsigned longs into unsigned ints since they use only 32 bits anyway * Explicit assignment result as condition * Prevent memory leak on menu reading * Localize button text * Create FileInputStream on stack avoiding the leak * Remove Servers Browser code * Arrow file names to const char* * Fix assignment to the wrong variable
113 lines
2.3 KiB
C++
113 lines
2.3 KiB
C++
//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
|
|
//
|
|
// Purpose:
|
|
//
|
|
// $NoKeywords: $
|
|
//=============================================================================
|
|
|
|
#include "../cl_dll/wrect.h"
|
|
#include "../cl_dll/cl_dll.h"
|
|
#include "VGUI.h"
|
|
#include "vgui_loadtga.h"
|
|
#include "VGUI_InputStream.h"
|
|
|
|
// ---------------------------------------------------------------------- //
|
|
// Helper class for loading tga files.
|
|
// ---------------------------------------------------------------------- //
|
|
class MemoryInputStream : public vgui::InputStream
|
|
{
|
|
public:
|
|
MemoryInputStream()
|
|
{
|
|
m_pData = NULL;
|
|
m_DataLen = m_ReadPos = 0;
|
|
}
|
|
|
|
virtual void seekStart( bool &success )
|
|
{
|
|
m_ReadPos = 0;
|
|
success = true;
|
|
}
|
|
|
|
virtual void seekRelative( int count, bool &success )
|
|
{
|
|
m_ReadPos += count;
|
|
success = true;
|
|
}
|
|
|
|
virtual void seekEnd( bool &success )
|
|
{
|
|
m_ReadPos = m_DataLen;
|
|
success = true;
|
|
}
|
|
|
|
virtual int getAvailable( bool &success )
|
|
{
|
|
// This is what vgui does for files...
|
|
success = false;
|
|
return 0;
|
|
}
|
|
|
|
virtual uchar readUChar( bool & success )
|
|
{
|
|
if( m_ReadPos >= 0 && m_ReadPos < m_DataLen )
|
|
{
|
|
success = true;
|
|
uchar ret = m_pData[m_ReadPos];
|
|
++m_ReadPos;
|
|
return ret;
|
|
}
|
|
else
|
|
{
|
|
success = false;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
virtual void readUChar( uchar *buf, int count, bool &success )
|
|
{
|
|
for( int i = 0; i < count; i++)
|
|
buf[i] = readUChar( success );
|
|
}
|
|
|
|
virtual void close( bool &success)
|
|
{
|
|
m_pData = NULL;
|
|
m_DataLen = m_ReadPos = 0;
|
|
}
|
|
|
|
uchar *m_pData;
|
|
int m_DataLen;
|
|
int m_ReadPos;
|
|
};
|
|
|
|
vgui::BitmapTGA *vgui_LoadTGA( char const *pFilename )
|
|
{
|
|
MemoryInputStream stream;
|
|
|
|
stream.m_pData = gEngfuncs.COM_LoadFile( (char*)pFilename, 5, &stream.m_DataLen );
|
|
if( !stream.m_pData )
|
|
return NULL;
|
|
|
|
stream.m_ReadPos = 0;
|
|
vgui::BitmapTGA *pRet = new vgui::BitmapTGA( &stream, true );
|
|
gEngfuncs.COM_FreeFile( stream.m_pData );
|
|
|
|
return pRet;
|
|
}
|
|
|
|
vgui::BitmapTGA *vgui_LoadTGANoInvertAlpha( char const *pFilename )
|
|
{
|
|
MemoryInputStream stream;
|
|
|
|
stream.m_pData = gEngfuncs.COM_LoadFile( (char*)pFilename, 5, &stream.m_DataLen );
|
|
if( !stream.m_pData )
|
|
return NULL;
|
|
|
|
stream.m_ReadPos = 0;
|
|
vgui::BitmapTGA *pRet = new vgui::BitmapTGA( &stream, false );
|
|
gEngfuncs.COM_FreeFile( stream.m_pData );
|
|
|
|
return pRet;
|
|
}
|