diff --git a/src/game/client/components/mapimages.cpp b/src/game/client/components/mapimages.cpp index 1f37cd80f..5fe8d8829 100644 --- a/src/game/client/components/mapimages.cpp +++ b/src/game/client/components/mapimages.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "mapimages.h" @@ -13,6 +14,70 @@ CMapImages::CMapImages() { m_Count = 0; m_EntitiesTextures = -1; + m_OverlayBottomTexture = -1; + m_OverlayTopTexture = -1; + m_OverlayCenterTexture = -1; +} + +void CMapImages::OnInit(){ + //TODO: improve this a bit -- with better fron sizes etc. + if(m_OverlayBottomTexture == -1){ + void *pMem = mem_alloc(1024*1024, 1); + mem_zero(pMem, 1024*1024); + m_OverlayBottomTexture = Graphics()->LoadTextureRaw(1024, 1024, CImageInfo::FORMAT_ALPHA, pMem, CImageInfo::FORMAT_ALPHA, IGraphics::TEXLOAD_NOMIPMAPS); + + for(int i = 0; i < 256; ++i){ + char buff[4]; + str_format(buff, 4, "%d", i); + int len = str_length(buff); + + float x = (i%16) * 64; + float y = (int)(i/16)* 64; + Graphics()->LoadTextureRawSub(m_OverlayBottomTexture, x, y, 64, 64, CImageInfo::FORMAT_ALPHA, pMem); + TextRender()->UploadText(m_OverlayBottomTexture, buff, -1, x, y + 12 + 32, 20); + } + mem_free(pMem); + } + if(m_OverlayTopTexture == -1){ + void *pMem = mem_alloc(1024*1024, 1); + mem_zero(pMem, 1024*1024); + m_OverlayTopTexture = Graphics()->LoadTextureRaw(1024, 1024, CImageInfo::FORMAT_ALPHA, pMem, CImageInfo::FORMAT_ALPHA, IGraphics::TEXLOAD_NOMIPMAPS); + + for(int i = 0; i < 256; ++i){ + char buff[4]; + str_format(buff, 4, "%d", i); + int len = str_length(buff); + + float x = (i%16) * 64; + float y = (int)(i/16)* 64; + Graphics()->LoadTextureRawSub(m_OverlayTopTexture, x, y, 64, 64, CImageInfo::FORMAT_ALPHA, pMem); + TextRender()->UploadText(m_OverlayTopTexture, buff, -1, x, y, 20); + } + mem_free(pMem); + } + if(m_OverlayCenterTexture == -1){ + void *pMem = mem_alloc(1024*1024, 1); + mem_zero(pMem, 1024*1024); + m_OverlayCenterTexture = Graphics()->LoadTextureRaw(1024, 1024, CImageInfo::FORMAT_ALPHA, pMem, CImageInfo::FORMAT_ALPHA, IGraphics::TEXLOAD_NOMIPMAPS); + + for(int i = 0; i < 256; ++i){ + char buff[4]; + str_format(buff, 4, "%d", i); + int len = str_length(buff); + + float x = (i%16) * 64; + float y = (int)(i/16)* 64; + + int Size = (len == 3 ? 20 : 64); + int Width = (len == 3 ? 15 : 32); + int OffY = (len == 3 ? 10 : 5); + int OffX = (len == 3 ? 10 : 0); + + Graphics()->LoadTextureRawSub(m_OverlayCenterTexture, x, y, 64, 64, CImageInfo::FORMAT_ALPHA, pMem); + TextRender()->UploadText(m_OverlayCenterTexture, buff, -1, x + OffX, y + OffY, Size); + } + mem_free(pMem); + } } void CMapImages::OnMapLoad() @@ -118,3 +183,15 @@ int CMapImages::GetEntities() } return m_EntitiesTextures; } + +int CMapImages::GetOverlayBottom(){ + return m_OverlayBottomTexture; +} + +int CMapImages::GetOverlayTop(){ + return m_OverlayTopTexture; +} + +int CMapImages::GetOverlayCenter(){ + return m_OverlayCenterTexture; +} diff --git a/src/game/client/components/mapimages.h b/src/game/client/components/mapimages.h index ee5b278fc..e6e6276e5 100644 --- a/src/game/client/components/mapimages.h +++ b/src/game/client/components/mapimages.h @@ -19,15 +19,23 @@ public: int Num() const { return m_Count; } virtual void OnMapLoad(); + virtual void OnInit(); void LoadBackground(class IMap *pMap); // DDRace int GetEntities(); + + int GetOverlayBottom(); + int GetOverlayTop(); + int GetOverlayCenter(); private: int m_EntitiesTextures; + int m_OverlayBottomTexture; + int m_OverlayTopTexture; + int m_OverlayCenterTexture; }; #endif