Fix css style order when using external css files
[ryzomcore.git] / ryzom / client / src / interface_v3 / dbgroup_build_phrase.h
blob4bbe750c087e80559ec5510cdf29b75a189753cc
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/>.
22 #ifndef NL_DBGROUP_BUILD_PHRASE_H
23 #define NL_DBGROUP_BUILD_PHRASE_H
25 #include "nel/misc/types_nl.h"
26 #include "nel/gui/interface_group.h"
27 #include "game_share/sphrase_com.h"
28 #include "game_share/brick_types.h"
29 #include "game_share/skills.h"
32 namespace NLGUI
34 class CCtrlBaseButton;
35 class CViewText;
36 class CViewBitmap;
37 class CGroupEditBox;
41 // ***************************************************************************
42 class CDBCtrlSheet;
43 class CSBrickSheet;
45 // ***************************************************************************
46 /**
47 * Widget to handle building sentence.
48 * A Main Brick is a Root/Mandatory/Optional/Credit brick. ie everything but a Param
49 * \author Lionel Berenguier
50 * \author Nevrax France
51 * \date 2003
53 class CDBGroupBuildPhrase : public CInterfaceGroup
55 public:
56 enum {MaxParam= 4};
57 static const std::string BrickSelectionModal;
58 static const std::string BrickSelectionViewNotUsed;
59 static const std::string BrickSelectionDB;
60 static const std::string BrickOptionalMenu;
61 static const std::string BrickMandatoryAHRightClick;
62 static const std::string BrickBuildDB;
63 enum {MaxSelection= 256};
64 enum {MaxBricks= 64};
67 /** A Brick slot.
68 * NB: A Slot can exist at runtime only if Brick and Back are setuped.
70 class CSlot
72 public:
73 CDBCtrlSheet *Brick;
74 CViewBitmap *Back;
75 bool Valid;
76 // The Parameter families setuped for this slot (ie if != from Brick->ParameterFamilies, must update display)
77 std::vector<uint16> ViewParamFamilies;
79 // reset display.
80 void reset();
82 // set default with a family
84 CSlot()
86 Brick= NULL;
87 Back= NULL;
88 Valid= false;
92 /** Descriptor of a word of the builded sentence
93 * NB: A Word can exist at runtime only if all his slots can exist (Brick and Back are setuped.)
94 * But for Credits...
96 class CWord
98 public:
99 CSlot Slot;
100 CSlot ParamSlot[MaxParam];
101 // the total number of parameters (params and their possible son)
102 uint32 NumTotalParams;
103 bool ParamError;
104 // The Cost View for this line.
105 CViewText *CostView;
106 CViewText *CreditView;
107 CViewText *InfoView;
109 // reset display.
110 void reset();
111 // reset only all params
112 void resetParams();
113 // enable disaply and set the brick
114 void setBrick(uint32 sheetId);
115 void setParamBrick(uint param, uint32 sheetId);
116 // for optional delete, copy state from another word
117 void copySetup(const CWord &w);
119 CWord()
121 NumTotalParams= 0;
122 ParamError= false;
123 CostView= NULL;
124 CreditView= NULL;
125 InfoView= NULL;
129 public:
131 /// Constructor
132 CDBGroupBuildPhrase(const TCtorParam &param);
133 virtual ~CDBGroupBuildPhrase();
135 /// CInterfaceGroup Interface
136 virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
137 virtual void updateCoords ();
138 virtual void draw ();
140 // Get the Validate Button if possible
141 CCtrlBaseButton *getValidateButton() const {return _ValidateButton;}
143 // clear the phrase
144 void clearBuildingPhrase();
145 // call after clearBuildingPhrase(), to copy a phrase, or empty phrase to init new Name.
146 void startComposition(const CSPhraseCom &phrase);
148 // build the current composed phrase (result of the edition).
149 void buildCurrentPhrase(CSPhraseCom &newPhrase);
151 /** For edition, can set a brickType filter for the root. if !Unknown, only root of this type will match
152 * Second and more filter are ORed with the root brick, if unknown, not ored.
154 void setRootBrickTypeFilter(BRICK_TYPE::EBrickType rootBtFilter,
155 BRICK_TYPE::EBrickType rootBtFilter2= BRICK_TYPE::UNKNOWN,
156 BRICK_TYPE::EBrickType rootBtFilter3= BRICK_TYPE::UNKNOWN,
157 BRICK_TYPE::EBrickType rootBtFilter4= BRICK_TYPE::UNKNOWN);
159 /// \name Brick Selection
160 // @{
161 void fillSelectionRoot();
162 // if index==0, you must call fillSelectionRoot(). It can be a Mandatory/Optional/Credit
163 void fillSelectionMain(uint index);
164 void fillSelectionParam(uint index, uint paramIndex);
165 void fillSelectionNewOp();
166 void fillSelectionNewCredit();
167 void validateRoot(const CSBrickSheet *sheet);
168 // if index==0, you must call validateRoot()
169 void validateMain(uint index, const CSBrickSheet *sheet);
170 void validateParam(uint index, uint paramIndex, const CSBrickSheet *sheet);
171 void validateNewOpCredit(const CSBrickSheet *sheet);
172 // NB: the index is the index of the brick
173 void deleteOpCredit(uint index);
174 // @}
176 /// Call this when the name or the root brick change, to update the view of the spell edited only.
177 void updateSpellView();
179 /// Call this whill update all the view
180 void updateAllDisplay();
182 protected:
183 bool _GroupValid;
184 // In this array comes in Order Root/Mandatories/Optionals/Credits
185 std::vector<CWord> _MainWords;
186 CCtrlBaseButton *_ValidateButton;
187 CViewText *_TextPhraseDesc;
188 // The number of mandatories, not including the root.
189 uint32 _NumMandatories;
190 // The number of activated optional
191 uint32 _NumOptionals;
192 // The number of activated credit
193 uint32 _NumCredits;
195 bool _Setuped;
197 // the color of an unknown color brick
198 sint32 _TextureIdSlotDisabled;
200 // filter for the root
201 enum {MaxRootBrickTypeFilter= 4};
202 BRICK_TYPE::EBrickType _RootBrickTypeFilter[MaxRootBrickTypeFilter];
204 protected:
205 void setupBuildSentence();
207 // reset the sentence with a sheet.
208 void resetSentence(sint32 rootSheetId);
209 void updateDisplayFromRootBrick();
211 // update the parameters of the indexed main brick
212 void updateParams(uint index);
213 // reset the parameter hierarchy of the indexed main brick.
214 void updateParamHrc(uint index);
215 void updateNewButtons();
216 void updateAllDisplay(const CSPhraseCom &phrase);
218 // fill array of bricks possible for a new optional brick.
219 void fillNewOptionalBricks(std::vector<NLMISC::CSheetId> &bricks);
220 void fillNewCreditBricks(std::vector<NLMISC::CSheetId> &bricks);
221 void resetSelection();
222 void fillSelection(const std::vector<NLMISC::CSheetId> &bricks);
223 void filterKnownBricks(std::vector<NLMISC::CSheetId> &bricks);
224 void filterBrickExclusion(std::vector<NLMISC::CSheetId> &bricks, uint16 indexToSkip = 0xffff);
225 void filterFamilySetuped(std::vector<uint16> &families);
226 void filterBrickSetuped(std::vector<NLMISC::CSheetId> &bricks);
227 /// Filter bricks so only one that are compatible with skill of the current setuped one are filtered.
228 void filterSkillSetuped(std::vector<NLMISC::CSheetId> &bricks, bool checkOptional, bool checkCredit, sint avoidCheckIndex= -1);
229 /// for special root edition
230 void filterRootBrickType(std::vector<NLMISC::CSheetId> &bricks);
231 void filterRootPossibles(std::vector<NLMISC::CSheetId> &bricks);
233 // return the current number of main brick setuped. at least 1 with the root
234 uint getNumMainBricks() const {return 1+_NumMandatories+_NumOptionals+_NumCredits;}
236 // get the current rootBrick
237 const CSBrickSheet *getRootBrick();
239 protected:
240 CGroupEditBox *_UserSentenceName;
241 sint _NewSpellNumber;
242 // The spell icon builded.
243 CDBCtrlSheet *_SpellView;
245 // For weapon restriction
246 std::vector<SKILLS::ESkills> _WeaponSkills;
250 #endif // NL_DBGROUP_BUILD_PHRASE_H
252 /* End of dbgroup_build_phrase.h */