mirror of
https://github.com/ENSL/NS.git
synced 2024-11-10 07:11:38 +00:00
Mantis 994:
o Fixed bug where the voice comm icon would not be displayed while using a mic The new MemoryInputStream class either contains a bug or doesn't match what the vgui::BitmapTGA class expects. I've inserted the old code to get this working till Karl can take a look at it, as it's a bit painstaking to sort it out when I don't even know what method(s) it fails in. I also fixed a bug in the constructor for the new MemoryInputStream where the length parameter would not be applied to the length member. git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@232 67975925-1194-0748-b3d5-c16f83f1a3a1
This commit is contained in:
parent
51d2e419bf
commit
577727d9a5
2 changed files with 69 additions and 3 deletions
|
@ -12,13 +12,79 @@
|
|||
#include "vgui_inputstream.h"
|
||||
|
||||
|
||||
#include "ui/MemoryInputStream.h"
|
||||
//#include "ui/MemoryInputStream.h"
|
||||
|
||||
// tankefugl: HACK
|
||||
// Implemented old MemoryInputStream to work around bugs(?) in the other implementation or in
|
||||
// the vgui's handling of the other one
|
||||
class MemoryInputStream2 : public vgui::InputStream
|
||||
{
|
||||
public:
|
||||
MemoryInputStream2()
|
||||
{
|
||||
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) {success=false; return 0;} // This is what vgui does for files...
|
||||
|
||||
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;
|
||||
};
|
||||
// :tankefugl
|
||||
|
||||
vgui::BitmapTGA* vgui_LoadTGANoInvertAlpha(char const *pFilename)
|
||||
{ return vgui_LoadTGA(pFilename,false); }
|
||||
|
||||
vgui::BitmapTGA* vgui_LoadTGA(char const *pFilename, bool bInvertAlpha)
|
||||
{
|
||||
// tankefugl:
|
||||
MemoryInputStream2 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, bInvertAlpha);
|
||||
gEngfuncs.COM_FreeFile(stream.m_pData);
|
||||
|
||||
return pRet;
|
||||
// :tankefugl
|
||||
|
||||
/* // New implementation:
|
||||
int nLength = 0;
|
||||
uchar* pData = gEngfuncs.COM_LoadFile((char*)pFilename, 5, &nLength);
|
||||
|
||||
|
@ -29,6 +95,6 @@ vgui::BitmapTGA* vgui_LoadTGA(char const *pFilename, bool bInvertAlpha)
|
|||
vgui::BitmapTGA *pRet = new vgui::BitmapTGA(&stream, bInvertAlpha);
|
||||
gEngfuncs.COM_FreeFile(pData);
|
||||
|
||||
return pRet;
|
||||
return pRet;*/
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
MemoryInputStream::MemoryInputStream(void) : m_pData(NULL), m_DataLen(0), m_ReadPos(0) {}
|
||||
MemoryInputStream::MemoryInputStream(uchar* pData, int nLength) : m_pData(pData), m_DataLen(0), m_ReadPos(0) {}
|
||||
MemoryInputStream::MemoryInputStream(uchar* pData, int nLength) : m_pData(pData), m_DataLen(nLength), m_ReadPos(0) {}
|
||||
|
||||
MemoryInputStream::~MemoryInputStream(void) {}
|
||||
|
||||
|
|
Loading…
Reference in a new issue