Add infos into target window
[ryzomcore.git] / ryzom / client / src / animation_fx_id_array.cpp
blobb3c07bbd7915680fe46fc3179fdd59c52a8dd76b
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
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/>.
19 #include "stdpch.h"
20 #include "animation_fx_id_array.h"
21 #include "sheet_manager.h"
22 #include "global.h"
24 #include "nel/3d/u_scene.h"
26 #ifdef DEBUG_NEW
27 #define new DEBUG_NEW
28 #endif
30 extern NL3D::UScene *Scene;
32 // *********************************************************************
33 CAnimationFXIDArray::CAnimationFXIDArray()
35 _AnimSet = NULL;
38 // *********************************************************************
39 void CAnimationFXIDArray::release()
41 _IDToFXArray.clear();
42 if (Scene && _AnimSet)
44 Driver->deleteAnimationSet(_AnimSet);
46 _AnimSet = NULL;
49 // *********************************************************************
50 void CAnimationFXIDArray::init(const CIDToStringArraySheet &sheet, NL3D::UAnimationSet *animSet, bool mustDeleteAnimSet /* = false*/)
52 release();
53 // retrieve pointer on all fxs
54 for(uint k = 0; k < sheet.Array.size(); ++k)
56 const CAnimationFXSheet *afs = dynamic_cast<const CAnimationFXSheet *>(SheetMngr.get(NLMISC::CSheetId(sheet.Array[k].String)));
57 if (afs)
59 CIDToFX idToFX;
60 idToFX.FX.init(afs, animSet);
61 idToFX.ID = sheet.Array[k].ID;
62 _IDToFXArray.push_back(idToFX);
65 // sort by ids
66 std::sort(_IDToFXArray.begin(), _IDToFXArray.end());
67 if (mustDeleteAnimSet)
69 _AnimSet = animSet;
73 // *********************************************************************
74 void CAnimationFXIDArray::init(const std::string &sheetName, NL3D::UAnimationSet *animSet, bool mustDeleteAnimSet /*= false*/)
76 CIDToStringArraySheet *array = dynamic_cast<CIDToStringArraySheet *>(SheetMngr.get(NLMISC::CSheetId(sheetName)));
77 if (array)
79 init(*array, animSet, mustDeleteAnimSet);
84 // *********************************************************************
85 const CAnimationFX *CAnimationFXIDArray::getFX(uint32 id) const
87 // after init, element are sorted by ids
88 CIDToFX comp;
89 comp.ID = id;
90 std::vector<CIDToFX>::const_iterator it = std::lower_bound(_IDToFXArray.begin(), _IDToFXArray.end(), comp);
91 if (it == _IDToFXArray.end()) return NULL;
92 if (it->ID != id) return NULL;
93 return &(it->FX);