summaryrefslogtreecommitdiff
path: root/hammer/dummytexture.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /hammer/dummytexture.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'hammer/dummytexture.cpp')
-rw-r--r--hammer/dummytexture.cpp186
1 files changed, 186 insertions, 0 deletions
diff --git a/hammer/dummytexture.cpp b/hammer/dummytexture.cpp
new file mode 100644
index 0000000..644db73
--- /dev/null
+++ b/hammer/dummytexture.cpp
@@ -0,0 +1,186 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: Implementation of IEditorTexture interface for placeholder textures.
+// Placeholder textures are used for textures that are referenced in
+// the map file but not found in storage.
+//
+//=============================================================================//
+
+#include "stdafx.h"
+#include <process.h>
+#include <afxtempl.h>
+#include <io.h>
+#include <sys\stat.h>
+#include <fcntl.h>
+#include "DummyTexture.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include <tier0/memdbgon.h>
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Constructor.
+//-----------------------------------------------------------------------------
+CDummyTexture::CDummyTexture(const char *pszName, TEXTUREFORMAT eFormat)
+{
+ if (pszName != NULL)
+ {
+ strcpy(m_szName, pszName);
+ }
+ else
+ {
+ strcpy(m_szName, "Missing texture");
+ }
+
+ m_eTextureFormat = eFormat;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Destructor.
+//-----------------------------------------------------------------------------
+CDummyTexture::~CDummyTexture()
+{
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns an empty string, since we have no source file.
+//-----------------------------------------------------------------------------
+const char *CDummyTexture::GetFileName() const
+{
+ static char *pszEmpty = "";
+ return(pszEmpty);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns a string of comma delimited keywords associated with this
+// material.
+// Input : pszKeywords - Buffer to receive keywords, NULL to query string length.
+// Output : Returns the number of characters in the keyword string.
+//-----------------------------------------------------------------------------
+int CDummyTexture::GetKeywords(char *pszKeywords) const
+{
+ if (pszKeywords != NULL)
+ {
+ *pszKeywords = '\0';
+ }
+
+ return(0);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : *pszName -
+// Output :
+//-----------------------------------------------------------------------------
+// dvs: move into a common place for CWADTexture & CDummyTexture
+int CDummyTexture::GetShortName(char *pszName) const
+{
+ char szBuf[MAX_PATH];
+
+ if (pszName == NULL)
+ {
+ pszName = szBuf;
+ }
+
+ if (m_eTextureFormat == tfWAL)
+ {
+ const char *psz = strstr(m_szName, "textures");
+ if (psz == NULL)
+ {
+ psz = m_szName;
+ }
+ else
+ {
+ psz += strlen("textures\\");
+ }
+
+ strcpy(pszName, psz);
+
+ // remove extension
+ char *pszExtension = strstr(pszName, ".wal");
+ if (pszExtension)
+ {
+ *pszExtension = 0;
+ }
+ }
+ else
+ {
+ strcpy(pszName, m_szName);
+ }
+
+ return(strlen(pszName));
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: If the buffer pointer passed in is not NULL, copies the image data
+// in RGB format to the buffer
+// Input : pImageRGB - Pointer to buffer that receives the image data. If the
+// pointer is NULL, no data is copied, only the data size is returned.
+// Output : Returns a the size of the RGB image in bytes.
+//-----------------------------------------------------------------------------
+int CDummyTexture::GetImageDataRGB( void *pImageRGB )
+{
+ return(0);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: If the buffer pointer passed in is not NULL, copies the image data
+// in RGBA format to the buffer
+// Input : pImageRGBA - Pointer to buffer that receives the image data. If the
+// pointer is NULL, no data is copied, only the data size is returned.
+// Output : Returns a the size of the RGBA image in bytes.
+//-----------------------------------------------------------------------------
+int CDummyTexture::GetImageDataRGBA( void *pImageRGBA )
+{
+ return(0);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : size -
+//-----------------------------------------------------------------------------
+void CDummyTexture::GetSize( SIZE &size ) const
+{
+ size.cx = 0;
+ size.cy = 0;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Renders "No Image" into a device context as a placeholder for the
+// missing texture.
+// Input : pDC -
+// rect -
+// iFontHeight -
+// dwFlags -
+//-----------------------------------------------------------------------------
+void CDummyTexture::Draw(CDC *pDC, RECT &rect, int iFontHeight, int iIconHeight, DrawTexData_t &DrawTexData)
+{
+ CFont *pOldFont = (CFont *)pDC->SelectStockObject(ANSI_VAR_FONT);
+ COLORREF crText = pDC->SetTextColor(RGB(0xff, 0xff, 0xff));
+ COLORREF crBack = pDC->SetBkColor(RGB(0, 0, 0));
+
+ pDC->FillRect(&rect, CBrush::FromHandle(HBRUSH(GetStockObject(BLACK_BRUSH))));
+ pDC->TextOut(rect.left + 2, rect.top + 2, "No Image", 8);
+
+ pDC->SelectObject(pOldFont);
+ pDC->SetTextColor(crText);
+ pDC->SetBkColor(crBack);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Loads this texture from disk if it is not already loaded.
+// Output : Returns true on success, false on failure.
+//-----------------------------------------------------------------------------
+bool CDummyTexture::Load( void )
+{
+ return(true);
+}