mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-25 08:16:16 +00:00
CHANGED: #1471 Moved CSheetSelectionGroup and CSheetSelection to the GUI library.
This commit is contained in:
parent
aebd31f22a
commit
8a18798b71
9 changed files with 185 additions and 189 deletions
83
code/nel/include/nel/gui/ctrl_sheet_selection.h
Normal file
83
code/nel/include/nel/gui/ctrl_sheet_selection.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef CL_SHEET_CTRL_SELECTION_H
|
||||
#define CL_SHEET_CTRL_SELECTION_H
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class IActionHandler;
|
||||
|
||||
/** Infos about a selection group
|
||||
*/
|
||||
class CSheetSelectionGroup
|
||||
{
|
||||
public:
|
||||
CSheetSelectionGroup(std::string name) : _Name(name), _Active(false), _TextureIndex(-1), _Color(NLMISC::CRGBA::White), _GlobalColorEnabled(true) {}
|
||||
void setTexture(const std::string &texName);
|
||||
sint32 getTextureIndex() const { return _TextureIndex; }
|
||||
sint32 getTextureWidth() const { return _TextureWidth; }
|
||||
sint32 getTextureHeight() const { return _TextureHeight; }
|
||||
void setColor(NLMISC::CRGBA color) { _Color = color; }
|
||||
NLMISC::CRGBA getColor() const { return _Color; }
|
||||
void setActive(bool active) { _Active = active; }
|
||||
bool isActive() const { return _Active; }
|
||||
const std::string &getName() const { return _Name; }
|
||||
void enableGlobalColor(bool enabled) { _GlobalColorEnabled = enabled; }
|
||||
bool isGlobalColorEnabled() const { return _GlobalColorEnabled; }
|
||||
private:
|
||||
std::string _Name;
|
||||
bool _Active;
|
||||
sint32 _TextureIndex; // index for the selection texture
|
||||
sint32 _TextureWidth;
|
||||
sint32 _TextureHeight;
|
||||
NLMISC::CRGBA _Color; // color that modulate the texture of selection
|
||||
bool _GlobalColorEnabled;
|
||||
};
|
||||
|
||||
/** Class to manage selection of sheet.
|
||||
* Sheet are managed by groups, identified by their ID.
|
||||
*/
|
||||
class CCtrlSheetSelection
|
||||
{
|
||||
public:
|
||||
// Add a group, and returns its index, or -1 if already created.
|
||||
sint addGroup(const std::string &name);
|
||||
// Get a group by its name (must exist)
|
||||
CSheetSelectionGroup *getGroup(const std::string &name);
|
||||
const CSheetSelectionGroup *getGroup(const std::string &name) const;
|
||||
// Get a group by its index
|
||||
CSheetSelectionGroup *getGroup(uint index);
|
||||
const CSheetSelectionGroup *getGroup(uint index) const;
|
||||
// Get the index of a group from its name, return -1 if not a group
|
||||
sint getGroupIndex(const std::string &name) const;
|
||||
// Deactivate all groups
|
||||
void deactivateAll();
|
||||
// delete all groups
|
||||
void deleteGroups();
|
||||
private:
|
||||
//
|
||||
typedef std::vector<CSheetSelectionGroup> TGroupVect;
|
||||
typedef std::map<std::string, uint> TGroupNameToIndex;
|
||||
private:
|
||||
TGroupVect _Groups;
|
||||
TGroupNameToIndex _GroupNameToIndex;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
98
code/nel/src/gui/ctrl_sheet_selection.cpp
Normal file
98
code/nel/src/gui/ctrl_sheet_selection.cpp
Normal file
|
@ -0,0 +1,98 @@
|
|||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/misc/rgba.h"
|
||||
#include "nel/gui/ctrl_sheet_selection.h"
|
||||
#include "nel/gui/view_renderer.h"
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
|
||||
//=============================================================
|
||||
void CSheetSelectionGroup::setTexture(const std::string &texName)
|
||||
{
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
_TextureIndex = rVR.getTextureIdFromName(texName);
|
||||
rVR.getTextureSizeFromId(_TextureIndex, _TextureWidth, _TextureHeight);
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
void CCtrlSheetSelection::deleteGroups()
|
||||
{
|
||||
_Groups.clear();
|
||||
_GroupNameToIndex.clear();
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
sint CCtrlSheetSelection::addGroup(const std::string &name)
|
||||
{
|
||||
if (getGroupIndex(name) != -1)
|
||||
{
|
||||
nlwarning("<CCtrlSheetSelection::addGroup> Group inserted twice : %s", name.c_str());
|
||||
return - 1;
|
||||
}
|
||||
_Groups.push_back(CSheetSelectionGroup(name));
|
||||
_GroupNameToIndex[name] = (uint)_Groups.size() - 1;
|
||||
return (sint)_Groups.size() - 1;
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
sint CCtrlSheetSelection::getGroupIndex(const std::string &name) const
|
||||
{
|
||||
TGroupNameToIndex::const_iterator it = _GroupNameToIndex.find(name);
|
||||
return it == _GroupNameToIndex.end() ? - 1 : (sint) it->second;
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
CSheetSelectionGroup *CCtrlSheetSelection::getGroup(const std::string &name)
|
||||
{
|
||||
return getGroup(getGroupIndex(name));
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
const CSheetSelectionGroup *CCtrlSheetSelection::getGroup(const std::string &name) const
|
||||
{
|
||||
return getGroup(getGroupIndex(name));
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
CSheetSelectionGroup *CCtrlSheetSelection::getGroup(uint index)
|
||||
{
|
||||
if (index > _Groups.size())
|
||||
{
|
||||
// nlwarning("<CCtrlSheetSelection::getGroup> invalid group index");
|
||||
return NULL;
|
||||
}
|
||||
return &_Groups[index];
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
const CSheetSelectionGroup *CCtrlSheetSelection::getGroup(uint index) const
|
||||
{
|
||||
if (index > _Groups.size())
|
||||
{
|
||||
nlwarning("<CCtrlSheetSelection::getGroup> invalid group index");
|
||||
return NULL;
|
||||
}
|
||||
return &_Groups[index];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
#include "bot_chat_page_dynamic_mission.h"
|
||||
#include "bot_chat_page_ring_sessions.h"
|
||||
#include "dbctrl_sheet.h"
|
||||
#include "ctrl_sheet_selection.h"
|
||||
#include "nel/gui/ctrl_sheet_selection.h"
|
||||
#include "nel/gui/interface_expr.h"
|
||||
#include "nel/gui/group_menu.h"
|
||||
#include "nel/gui/group_container.h"
|
||||
|
|
|
@ -1,95 +0,0 @@
|
|||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
#include "stdpch.h"
|
||||
#include "ctrl_sheet_selection.h"
|
||||
#include "interface_manager.h"
|
||||
|
||||
//=============================================================
|
||||
void CSheetSelectionGroup::setTexture(const std::string &texName)
|
||||
{
|
||||
CInterfaceManager *pIM = CInterfaceManager::getInstance();
|
||||
CViewRenderer &rVR = *CViewRenderer::getInstance();
|
||||
_TextureIndex = rVR.getTextureIdFromName(texName);
|
||||
rVR.getTextureSizeFromId(_TextureIndex, _TextureWidth, _TextureHeight);
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
void CCtrlSheetSelection::deleteGroups()
|
||||
{
|
||||
_Groups.clear();
|
||||
_GroupNameToIndex.clear();
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
sint CCtrlSheetSelection::addGroup(const std::string &name)
|
||||
{
|
||||
if (getGroupIndex(name) != -1)
|
||||
{
|
||||
nlwarning("<CCtrlSheetSelection::addGroup> Group inserted twice : %s", name.c_str());
|
||||
return - 1;
|
||||
}
|
||||
_Groups.push_back(CSheetSelectionGroup(name));
|
||||
_GroupNameToIndex[name] = (uint)_Groups.size() - 1;
|
||||
return (sint)_Groups.size() - 1;
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
sint CCtrlSheetSelection::getGroupIndex(const std::string &name) const
|
||||
{
|
||||
TGroupNameToIndex::const_iterator it = _GroupNameToIndex.find(name);
|
||||
return it == _GroupNameToIndex.end() ? - 1 : (sint) it->second;
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
CSheetSelectionGroup *CCtrlSheetSelection::getGroup(const std::string &name)
|
||||
{
|
||||
return getGroup(getGroupIndex(name));
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
const CSheetSelectionGroup *CCtrlSheetSelection::getGroup(const std::string &name) const
|
||||
{
|
||||
return getGroup(getGroupIndex(name));
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
CSheetSelectionGroup *CCtrlSheetSelection::getGroup(uint index)
|
||||
{
|
||||
if (index > _Groups.size())
|
||||
{
|
||||
// nlwarning("<CCtrlSheetSelection::getGroup> invalid group index");
|
||||
return NULL;
|
||||
}
|
||||
return &_Groups[index];
|
||||
}
|
||||
|
||||
//=============================================================
|
||||
const CSheetSelectionGroup *CCtrlSheetSelection::getGroup(uint index) const
|
||||
{
|
||||
if (index > _Groups.size())
|
||||
{
|
||||
nlwarning("<CCtrlSheetSelection::getGroup> invalid group index");
|
||||
return NULL;
|
||||
}
|
||||
return &_Groups[index];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
#ifndef CL_SHEET_CTRL_SELECTION_H
|
||||
#define CL_SHEET_CTRL_SELECTION_H
|
||||
|
||||
namespace NLGUI
|
||||
{
|
||||
class IActionHandler;
|
||||
}
|
||||
|
||||
/** Infos about a selection group
|
||||
*/
|
||||
class CSheetSelectionGroup
|
||||
{
|
||||
public:
|
||||
CSheetSelectionGroup(std::string name) : _Name(name), _Active(false), _TextureIndex(-1), _Color(NLMISC::CRGBA::White), _GlobalColorEnabled(true) {}
|
||||
void setTexture(const std::string &texName);
|
||||
sint32 getTextureIndex() const { return _TextureIndex; }
|
||||
sint32 getTextureWidth() const { return _TextureWidth; }
|
||||
sint32 getTextureHeight() const { return _TextureHeight; }
|
||||
void setColor(NLMISC::CRGBA color) { _Color = color; }
|
||||
NLMISC::CRGBA getColor() const { return _Color; }
|
||||
void setActive(bool active) { _Active = active; }
|
||||
bool isActive() const { return _Active; }
|
||||
const std::string &getName() const { return _Name; }
|
||||
void enableGlobalColor(bool enabled) { _GlobalColorEnabled = enabled; }
|
||||
bool isGlobalColorEnabled() const { return _GlobalColorEnabled; }
|
||||
private:
|
||||
std::string _Name;
|
||||
bool _Active;
|
||||
sint32 _TextureIndex; // index for the selection texture
|
||||
sint32 _TextureWidth;
|
||||
sint32 _TextureHeight;
|
||||
NLMISC::CRGBA _Color; // color that modulate the texture of selection
|
||||
bool _GlobalColorEnabled;
|
||||
};
|
||||
|
||||
/** Class to manage selection of sheet.
|
||||
* Sheet are managed by groups, identified by their ID.
|
||||
*/
|
||||
class CCtrlSheetSelection
|
||||
{
|
||||
public:
|
||||
// Add a group, and returns its index, or -1 if already created.
|
||||
sint addGroup(const std::string &name);
|
||||
// Get a group by its name (must exist)
|
||||
CSheetSelectionGroup *getGroup(const std::string &name);
|
||||
const CSheetSelectionGroup *getGroup(const std::string &name) const;
|
||||
// Get a group by its index
|
||||
CSheetSelectionGroup *getGroup(uint index);
|
||||
const CSheetSelectionGroup *getGroup(uint index) const;
|
||||
// Get the index of a group from its name, return -1 if not a group
|
||||
sint getGroupIndex(const std::string &name) const;
|
||||
// Deactivate all groups
|
||||
void deactivateAll();
|
||||
// delete all groups
|
||||
void deleteGroups();
|
||||
private:
|
||||
//
|
||||
typedef std::vector<CSheetSelectionGroup> TGroupVect;
|
||||
typedef std::map<std::string, uint> TGroupNameToIndex;
|
||||
private:
|
||||
TGroupVect _Groups;
|
||||
TGroupNameToIndex _GroupNameToIndex;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -22,7 +22,7 @@
|
|||
#include "../sheet_manager.h"
|
||||
#include "nel/gui/interface_expr.h"
|
||||
#include "dbctrl_sheet.h"
|
||||
#include "ctrl_sheet_selection.h"
|
||||
#include "nel/gui/ctrl_sheet_selection.h"
|
||||
#include "dbgroup_list_sheet.h"
|
||||
#include "interface_manager.h"
|
||||
#include "sbrick_manager.h"
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
// InterfaceV3
|
||||
#include "interface_parser.h"
|
||||
#include "ctrl_sheet_selection.h"
|
||||
#include "nel/gui/ctrl_sheet_selection.h"
|
||||
#include "nel/gui/interface_options.h"
|
||||
#include "interface_config.h"
|
||||
#include "interface_pointer.h"
|
||||
|
|
|
@ -642,13 +642,6 @@ bool CInterfaceParser::parseXMLDocument(xmlNodePtr root, bool reload)
|
|||
// todo hulud interface syntax error
|
||||
nlwarning ("could not parse sheet selection");
|
||||
}
|
||||
// Special Magic/Combat auto-generation
|
||||
else if ( !strcmp((char*)root->name,"career_generator") )
|
||||
{
|
||||
if (!parseCareerGenerator(root))
|
||||
// todo hulud interface syntax error
|
||||
nlwarning ("could not parse 'career_generator'");
|
||||
}
|
||||
else if ( !strcmp((char*)root->name,"anim") )
|
||||
{
|
||||
if (!parseAnim(root,rootGroup))
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "nel/misc/types_nl.h"
|
||||
#include "nel/3d/u_texture.h"
|
||||
#include "ctrl_sheet_selection.h"
|
||||
#include "nel/gui/ctrl_sheet_selection.h"
|
||||
#include "nel/gui/interface_link.h"
|
||||
#include "nel/misc/smart_ptr.h"
|
||||
#include "game_share/brick_types.h"
|
||||
|
|
Loading…
Reference in a new issue