From 750b069ff7cb083a793d67aabaf0a0e55bd49ea8 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 7 Jul 2012 20:38:45 +0200 Subject: [PATCH] CHANGED: #1471 Moved CSheetSelectionGroup and CSheetSelection to the GUI library. --HG-- branch : gui-refactoring --- .../include/nel/gui/ctrl_sheet_selection.h | 83 ++++++++++++++++ code/nel/src/gui/ctrl_sheet_selection.cpp | 98 +++++++++++++++++++ .../src/interface_v3/action_handler_game.cpp | 2 +- .../src/interface_v3/ctrl_sheet_selection.cpp | 95 ------------------ .../src/interface_v3/ctrl_sheet_selection.h | 83 ---------------- .../interface_expr_user_fct_items.cpp | 2 +- .../src/interface_v3/interface_manager.h | 2 +- .../src/interface_v3/interface_parser.cpp | 7 -- .../src/interface_v3/interface_parser.h | 2 +- 9 files changed, 185 insertions(+), 189 deletions(-) create mode 100644 code/nel/include/nel/gui/ctrl_sheet_selection.h create mode 100644 code/nel/src/gui/ctrl_sheet_selection.cpp delete mode 100644 code/ryzom/client/src/interface_v3/ctrl_sheet_selection.cpp delete mode 100644 code/ryzom/client/src/interface_v3/ctrl_sheet_selection.h diff --git a/code/nel/include/nel/gui/ctrl_sheet_selection.h b/code/nel/include/nel/gui/ctrl_sheet_selection.h new file mode 100644 index 000000000..4ca52427e --- /dev/null +++ b/code/nel/include/nel/gui/ctrl_sheet_selection.h @@ -0,0 +1,83 @@ +// Ryzom - MMORPG Framework +// 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 . + + +#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 TGroupVect; + typedef std::map TGroupNameToIndex; + private: + TGroupVect _Groups; + TGroupNameToIndex _GroupNameToIndex; + }; + +} + +#endif diff --git a/code/nel/src/gui/ctrl_sheet_selection.cpp b/code/nel/src/gui/ctrl_sheet_selection.cpp new file mode 100644 index 000000000..ef63fc06a --- /dev/null +++ b/code/nel/src/gui/ctrl_sheet_selection.cpp @@ -0,0 +1,98 @@ +// Ryzom - MMORPG Framework +// 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 . + +#include +#include +#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(" 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(" invalid group index"); + return NULL; + } + return &_Groups[index]; + } + + //============================================================= + const CSheetSelectionGroup *CCtrlSheetSelection::getGroup(uint index) const + { + if (index > _Groups.size()) + { + nlwarning(" invalid group index"); + return NULL; + } + return &_Groups[index]; + } + +} + + diff --git a/code/ryzom/client/src/interface_v3/action_handler_game.cpp b/code/ryzom/client/src/interface_v3/action_handler_game.cpp index 4eb3a6cd7..6e6c3d2b8 100644 --- a/code/ryzom/client/src/interface_v3/action_handler_game.cpp +++ b/code/ryzom/client/src/interface_v3/action_handler_game.cpp @@ -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" diff --git a/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.cpp b/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.cpp deleted file mode 100644 index f4c9b5f9f..000000000 --- a/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.cpp +++ /dev/null @@ -1,95 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 . - - - -#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(" 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(" invalid group index"); - return NULL; - } - return &_Groups[index]; -} - -//============================================================= -const CSheetSelectionGroup *CCtrlSheetSelection::getGroup(uint index) const -{ - if (index > _Groups.size()) - { - nlwarning(" invalid group index"); - return NULL; - } - return &_Groups[index]; -} - - - - diff --git a/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.h b/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.h deleted file mode 100644 index febff220b..000000000 --- a/code/ryzom/client/src/interface_v3/ctrl_sheet_selection.h +++ /dev/null @@ -1,83 +0,0 @@ -// Ryzom - MMORPG Framework -// 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 . - - - -#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 TGroupVect; - typedef std::map TGroupNameToIndex; -private: - TGroupVect _Groups; - TGroupNameToIndex _GroupNameToIndex; -}; - -#endif diff --git a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp index 23807a361..64c2b5648 100644 --- a/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp +++ b/code/ryzom/client/src/interface_v3/interface_expr_user_fct_items.cpp @@ -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" diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index a142f4d17..121504846 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_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" diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 53798f910..7fb1bf405 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -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)) diff --git a/code/ryzom/client/src/interface_v3/interface_parser.h b/code/ryzom/client/src/interface_v3/interface_parser.h index 693b2e6da..e601b4058 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.h +++ b/code/ryzom/client/src/interface_v3/interface_parser.h @@ -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"