Show bonus/malus timer text if available
[ryzomcore.git] / nel / src / 3d / hls_texture_manager.cpp
blob3f585eb6b9b8e1882dbf07a0e30838a8ec6a7df2
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "std3d.h"
18 #include "nel/3d/hls_texture_manager.h"
19 #include "nel/misc/common.h"
20 #include "nel/misc/algo.h"
22 using namespace std;
23 using namespace NLMISC;
25 #ifdef DEBUG_NEW
26 #define new DEBUG_NEW
27 #endif
29 namespace NL3D {
32 // ***************************************************************************
33 CHLSTextureManager::CHLSTextureManager()
37 // ***************************************************************************
38 CHLSTextureManager::~CHLSTextureManager()
40 reset();
43 // ***************************************************************************
44 void CHLSTextureManager::reset()
46 // delete instances.
47 contReset(_Instances);
49 // delete banks.
50 for(uint i=0;i<_Banks.size();i++)
52 delete _Banks[i];
54 contReset(_Banks);
57 // ***************************************************************************
58 void CHLSTextureManager::addBank(CHLSTextureBank *bank)
60 // add the bank to the list
61 _Banks.push_back(bank);
63 // Add the bank instance list to the main.
64 bank->fillHandleArray(_Instances);
66 // then re-sort this array.
67 sort(_Instances.begin(), _Instances.end());
71 // ***************************************************************************
72 sint CHLSTextureManager::findTexture(const std::string &name) const
74 // empty?
75 if(_Instances.empty())
76 return -1;
78 // Build a valid key.
79 string nameLwr= toLowerAscii(name);
80 CHLSTextureBank::CTextureInstance textKey;
81 CHLSTextureBank::CTextureInstanceHandle textKeyHandle;
82 textKey.buildAsKey(nameLwr.c_str());
83 textKeyHandle.Texture= &textKey;
85 // logN search it in the array
86 uint id= searchLowerBound(_Instances, textKeyHandle);
87 // verify if really same name (index must exist since 0 if error, and not empty here)
88 CHLSTextureBank::CTextureInstance &textInst= *_Instances[id].Texture;
89 if( textInst.sameName(nameLwr.c_str()) )
90 return id;
91 else
92 return -1;
95 // ***************************************************************************
96 bool CHLSTextureManager::buildTexture(sint textId, NLMISC::CBitmap &out) const
98 if(textId<0 || textId>=(sint)_Instances.size())
99 return false;
100 else
102 // Ok. build the bitmap
103 CHLSTextureBank::CTextureInstance &textInst= *_Instances[textId].Texture;
104 textInst.buildColorVersion(out);
105 return true;
110 // ***************************************************************************
111 const char *CHLSTextureManager::getTextureName(uint i) const
113 nlassert(i<_Instances.size());
114 return _Instances[i].Texture->getName();
118 } // NL3D