1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
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"
34 class CCtrlBaseButton
;
41 // ***************************************************************************
45 // ***************************************************************************
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
53 class CDBGroupBuildPhrase
: public CInterfaceGroup
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 BrickIconSelectionModal
;
62 static const std::string BrickMandatoryAHRightClick
;
63 static const std::string BrickBuildDB
;
64 enum {MaxSelection
= 256};
69 * NB: A Slot can exist at runtime only if Brick and Back are setuped.
77 // The Parameter families setuped for this slot (ie if != from Brick->ParameterFamilies, must update display)
78 std::vector
<uint16
> ViewParamFamilies
;
83 // set default with a family
93 /** Descriptor of a word of the builded sentence
94 * NB: A Word can exist at runtime only if all his slots can exist (Brick and Back are setuped.)
101 CSlot ParamSlot
[MaxParam
];
102 // the total number of parameters (params and their possible son)
103 uint32 NumTotalParams
;
105 // The Cost View for this line.
107 CViewText
*CreditView
;
112 // reset only all params
114 // enable disaply and set the brick
115 void setBrick(uint32 sheetId
);
116 void setParamBrick(uint param
, uint32 sheetId
);
117 // for optional delete, copy state from another word
118 void copySetup(const CWord
&w
);
133 CDBGroupBuildPhrase(const TCtorParam
¶m
);
134 virtual ~CDBGroupBuildPhrase();
136 /// CInterfaceGroup Interface
137 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
138 virtual void updateCoords ();
139 virtual void draw ();
141 // Get the Validate Button if possible
142 CCtrlBaseButton
*getValidateButton() const {return _ValidateButton
;}
145 void clearBuildingPhrase();
146 // call after clearBuildingPhrase(), to copy a phrase, or empty phrase to init new Name.
147 void startComposition(const CSPhraseCom
&phrase
);
149 // build the current composed phrase (result of the edition).
150 void buildCurrentPhrase(CSPhraseCom
&newPhrase
);
152 /** For edition, can set a brickType filter for the root. if !Unknown, only root of this type will match
153 * Second and more filter are ORed with the root brick, if unknown, not ored.
155 void setRootBrickTypeFilter(BRICK_TYPE::EBrickType rootBtFilter
,
156 BRICK_TYPE::EBrickType rootBtFilter2
= BRICK_TYPE::UNKNOWN
,
157 BRICK_TYPE::EBrickType rootBtFilter3
= BRICK_TYPE::UNKNOWN
,
158 BRICK_TYPE::EBrickType rootBtFilter4
= BRICK_TYPE::UNKNOWN
);
160 /// \name Brick Selection
162 void fillSelectionRoot();
163 // if index==0, you must call fillSelectionRoot(). It can be a Mandatory/Optional/Credit
164 void fillSelectionMain(uint index
);
165 void fillSelectionParam(uint index
, uint paramIndex
);
166 void fillSelectionNewOp();
167 void fillSelectionNewCredit();
168 void validateRoot(const CSBrickSheet
*sheet
);
169 // if index==0, you must call validateRoot()
170 void validateMain(uint index
, const CSBrickSheet
*sheet
);
171 void validateParam(uint index
, uint paramIndex
, const CSBrickSheet
*sheet
);
172 void validateNewOpCredit(const CSBrickSheet
*sheet
);
173 // NB: the index is the index of the brick
174 void deleteOpCredit(uint index
);
175 // select which icon phrase is using
176 void setPhraseIcon(uint8 index
);
179 /// Call this when the name or the root brick change, to update the view of the spell edited only.
180 void updateSpellView();
182 /// Call this whill update all the view
183 void updateAllDisplay();
187 // In this array comes in Order Root/Mandatories/Optionals/Credits
188 std::vector
<CWord
> _MainWords
;
189 CCtrlBaseButton
*_ValidateButton
;
190 CViewText
*_TextPhraseDesc
;
191 // The number of mandatories, not including the root.
192 uint32 _NumMandatories
;
193 // The number of activated optional
194 uint32 _NumOptionals
;
195 // The number of activated credit
202 // the color of an unknown color brick
203 sint32 _TextureIdSlotDisabled
;
205 // filter for the root
206 enum {MaxRootBrickTypeFilter
= 4};
207 BRICK_TYPE::EBrickType _RootBrickTypeFilter
[MaxRootBrickTypeFilter
];
210 void setupBuildSentence();
212 // reset the sentence with a sheet.
213 void resetSentence(sint32 rootSheetId
);
214 void updateDisplayFromRootBrick();
216 // update the parameters of the indexed main brick
217 void updateParams(uint index
);
218 // reset the parameter hierarchy of the indexed main brick.
219 void updateParamHrc(uint index
);
220 void updateNewButtons();
221 void updateAllDisplay(const CSPhraseCom
&phrase
);
223 // fill array of bricks possible for a new optional brick.
224 void fillNewOptionalBricks(std::vector
<NLMISC::CSheetId
> &bricks
);
225 void fillNewCreditBricks(std::vector
<NLMISC::CSheetId
> &bricks
);
226 void resetSelection();
227 void fillSelection(const std::vector
<NLMISC::CSheetId
> &bricks
);
228 void filterKnownBricks(std::vector
<NLMISC::CSheetId
> &bricks
);
229 void filterBrickExclusion(std::vector
<NLMISC::CSheetId
> &bricks
, uint16 indexToSkip
= 0xffff);
230 void filterFamilySetuped(std::vector
<uint16
> &families
);
231 void filterBrickSetuped(std::vector
<NLMISC::CSheetId
> &bricks
);
232 /// Filter bricks so only one that are compatible with skill of the current setuped one are filtered.
233 void filterSkillSetuped(std::vector
<NLMISC::CSheetId
> &bricks
, bool checkOptional
, bool checkCredit
, sint avoidCheckIndex
= -1);
234 /// for special root edition
235 void filterRootBrickType(std::vector
<NLMISC::CSheetId
> &bricks
);
236 void filterRootPossibles(std::vector
<NLMISC::CSheetId
> &bricks
);
238 // return the current number of main brick setuped. at least 1 with the root
239 uint
getNumMainBricks() const {return 1+_NumMandatories
+_NumOptionals
+_NumCredits
;}
241 // get the current rootBrick
242 const CSBrickSheet
*getRootBrick();
245 CGroupEditBox
*_UserSentenceName
;
246 sint _NewSpellNumber
;
247 // The spell icon builded.
248 CDBCtrlSheet
*_SpellView
;
250 // For weapon restriction
251 std::vector
<SKILLS::ESkills
> _WeaponSkills
;
255 #endif // NL_DBGROUP_BUILD_PHRASE_H
257 /* End of dbgroup_build_phrase.h */