Change Encyclo button name and macros icon
[ryzomcore.git] / nel / src / gui / ctrl_sheet_selection.cpp
blob3885786b8433bf319627f812540a356751dc94ba
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "stdpch.h"
22 #include <string>
23 #include <map>
24 #include "nel/misc/types_nl.h"
25 #include "nel/misc/rgba.h"
26 #include "nel/gui/ctrl_sheet_selection.h"
27 #include "nel/gui/view_renderer.h"
29 #ifdef DEBUG_NEW
30 #define new DEBUG_NEW
31 #endif
33 namespace NLGUI
36 //=============================================================
37 void CSheetSelectionGroup::setTexture(const std::string &texName)
39 CViewRenderer &rVR = *CViewRenderer::getInstance();
40 _TextureIndex = rVR.getTextureIdFromName(texName);
41 rVR.getTextureSizeFromId(_TextureIndex, _TextureWidth, _TextureHeight);
44 //=============================================================
45 void CCtrlSheetSelection::deleteGroups()
47 _Groups.clear();
48 _GroupNameToIndex.clear();
51 //=============================================================
52 sint CCtrlSheetSelection::addGroup(const std::string &name)
54 if (getGroupIndex(name) != -1)
56 nlwarning("<CCtrlSheetSelection::addGroup> Group inserted twice : %s", name.c_str());
57 return - 1;
59 _Groups.push_back(CSheetSelectionGroup(name));
60 _GroupNameToIndex[name] = (uint)_Groups.size() - 1;
61 return (sint)_Groups.size() - 1;
64 //=============================================================
65 sint CCtrlSheetSelection::getGroupIndex(const std::string &name) const
67 TGroupNameToIndex::const_iterator it = _GroupNameToIndex.find(name);
68 return it == _GroupNameToIndex.end() ? - 1 : (sint) it->second;
71 //=============================================================
72 CSheetSelectionGroup *CCtrlSheetSelection::getGroup(const std::string &name)
74 return getGroup(getGroupIndex(name));
77 //=============================================================
78 const CSheetSelectionGroup *CCtrlSheetSelection::getGroup(const std::string &name) const
80 return getGroup(getGroupIndex(name));
83 //=============================================================
84 CSheetSelectionGroup *CCtrlSheetSelection::getGroup(uint index)
86 if (index > _Groups.size())
88 // nlwarning("<CCtrlSheetSelection::getGroup> invalid group index");
89 return NULL;
91 return &_Groups[index];
94 //=============================================================
95 const CSheetSelectionGroup *CCtrlSheetSelection::getGroup(uint index) const
97 if (index > _Groups.size())
99 nlwarning("<CCtrlSheetSelection::getGroup> invalid group index");
100 return NULL;
102 return &_Groups[index];