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) 2012 Matt RAYKOWSKI (sfb) <matt.raykowski@gmail.com>
6 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #ifndef NL_ACTION_PHRASE_FABER_H
24 #define NL_ACTION_PHRASE_FABER_H
26 #include "nel/misc/types_nl.h"
27 #include "inventory_manager.h"
28 #include "game_share/rm_family.h"
29 #include "game_share/brick_families.h"
30 #include "game_share/item_origin.h"
31 #include "skill_change_callback.h"
34 // ***************************************************************************
38 // ***************************************************************************
39 // There is at max 10 requirement line: 5 item part, and 5 formula items
40 #define MAX_ITEM_REQ_LINE 10
41 #define MAX_MP_SLOT 36
44 // ***************************************************************************
46 * Faber Execution Manager
47 * \author Lionel Berenguier
48 * \author Nevrax France
51 class CActionPhraseFaber
59 void launchFaberCastWindow(sint32 memoryLine
, uint memoryIndex
, CSBrickSheet
*rootBrick
);
60 /// called when the window is closed
61 void onCloseFaberCastWindow();
64 /// Fill the Faber Plan selection DB (no window opened)
65 void fillFaberPlanSelection(const std::string
&brickDB
, uint maxSelection
);
66 /// Called when the user has selected the Plan. copy bag. the itemPlanBrick must have "FaberPlan" good infos.
67 void validateFaberPlanSelection(CSBrickSheet
*itemPlanBrick
);
70 /// Called when the user click on a slot (full or empty)
71 void startMpSelection(uint itemReqLine
, uint mpSlot
);
72 /// Called when the user validate click on a mp slot
73 void validateMpSelection(uint selectId
);
74 /// Called when the user selected the mp quantity to change
75 void validateMpSelectQuantity();
78 /// Validate the execution
79 void validateExecution();
87 uint16 InventoryId
; // INVENTORIES::TInventory
90 NLMISC::CSheetId Sheet
;
95 // BitField to know which itemReqLine has selected this Item
97 // This is the original quantity in inventory
98 sint32 OriginalQuantity
;
115 Sheet
= NLMISC::CSheetId::Unknown
;
125 // The observer in case of skill change
126 class CSkillObserver
: public ISkillChangeCallback
129 virtual void onSkillChange();
131 CSkillObserver _SkillObserver
;
132 friend class CSkillObserver
;
134 // For Selection/Validate
135 uint _MpSelectionItemReqLine
;
136 std::vector
<uint
> _MpCurrentSelection
;
137 // For Change Quantity/Validate
138 uint _MpChangeQuantitySlot
;
140 // the Launched Action
141 sint32 _ExecuteFromMemoryLine
;
142 uint _ExecuteFromMemoryIndex
;
143 CSBrickSheet
*_ExecuteFromItemPlanBrick
;
144 // The required brick family for the rootBrick
145 std::vector
<BRICK_FAMILIES::TBrickFamily
> _FaberPlanBrickFamilies
;
147 // The Inventory manipulated.
148 std::vector
<CItem
> _InventoryMirror
;
149 bool _InventoryObsSetup
;
150 class CDBInventoryObs
: public NLMISC::ICDBNode::IPropertyObserver
153 virtual void update(NLMISC::ICDBNode
* node
);
155 CDBInventoryObs _DBInventoryObs
;
156 friend class CDBInventoryObs
;
157 // The animals Status
158 class CDBAnimalObs
: public NLMISC::ICDBNode::IPropertyObserver
161 virtual void update(NLMISC::ICDBNode
* node
);
163 CDBAnimalObs _DBAnimalObs
;
164 friend class CDBAnimalObs
;
167 // The Current MP Construction for a Line of Item Requirement
171 // Different Type of requirement per line
174 ItemPartReq
=0, // The line requires MPs that can craft a particular ItemPart
175 SpecificItemReq
, // The line requires specific MP
180 TReqLineType RequirementType
;
181 // Bkup from BrickPlan
182 RM_FABER_TYPE::TRMFType FaberTypeRequired
; // valid if RequirementType==ItemPartReq
183 NLMISC::CSheetId SpecificItemRequired
; // valid if RequirementType==SpecificItemReq
184 // For each MpSlot, the Inventory index (points to _InventoryMirror), and the quantity selected
185 uint Id
[MAX_MP_SLOT
];
186 // For each MpSlot, the quantity selected
187 uint QuantitySelected
[MAX_MP_SLOT
];
188 // The quantity required for this line
190 // The number of mpSlot setuped (ie where quantity!=0)
201 RequirementType
= ItemPartReq
;
202 FaberTypeRequired
= RM_FABER_TYPE::Unknown
;
203 SpecificItemRequired
= NLMISC::CSheetId::Unknown
;
207 // For all slot, reset the quantities setuped
208 for(uint mpSlot
=0;mpSlot
<MAX_MP_SLOT
;mpSlot
++)
210 QuantitySelected
[mpSlot
]= 0;
211 Id
[mpSlot
]= 0; // useless, but for consistency
215 CMPBuild _MPBuild
[MAX_ITEM_REQ_LINE
];
216 uint _MPBuildNumItemPartReq
; // The number of different itempart lines requirement
217 uint _MPBuildNumSpecificItemReq
; // The number of different specific items lines requirement
218 uint _MPBuildNumTotalItemReq
; // Total of requirement
220 void fillDBWithMP(const std::string
&sheetBase
, const CItem
&item
);
222 void resetSelection();
223 void fillSelection(const std::vector
<uint
> &mps
);
224 void filterSelectionItemPart(std::vector
<uint
> &mps
, RM_FABER_TYPE::TRMFType itemPartFilter
, ITEM_ORIGIN::EItemOrigin originFilter
);
225 void filterSelectionItemSpecific(std::vector
<uint
> &mps
, NLMISC::CSheetId specificItemWanted
);
227 uint
getMaxQuantityChange(uint itemReqLine
, uint mpSlot
) const;
228 uint
getTotalQuantitySetuped(uint itemReqLine
) const;
230 void updateEmptySlot(uint itemReqLine
, CInterfaceGroup
*itemReqLineGroup
=NULL
);
231 void updateQuantityView(uint itemReqLine
);
232 void updateValidButton();
234 void deleteMpSlot(uint itemReqLine
, uint mpSlot
);
236 // When the inventory is modified, must do some checks on the current faber execution
237 void onInventoryChange();
238 void removeMpSlotThatUseInvSlot(uint invSlot
, uint quantityToRemove
);
240 // from an index in _InventoryMirror, get the ItemImage
241 CItemImage
*getInvMirrorItemImage(uint slotIndex
, uint
& invId
, uint
& indexInInv
);
242 bool isMpAvailable(CItemSheet
*mpSheet
, uint invId
, uint slotIndex
) const;
244 void updateItemResult();
248 // ***************************************************************************
249 // Called when click a Faber phrase
250 extern void launchFaberCastWindow(sint32 memoryLine
, uint memoryIndex
, CSBrickSheet
*rootBrick
);
251 // Called when select a Faber plan
252 extern void fillFaberPlanSelection(const std::string
&brickDB
, uint maxSelection
);
253 // Called when the Faber plan is selected
254 extern void validateFaberPlanSelection(CSBrickSheet
*itemPlanBrick
);
255 // Called when something needs to close the crafting window (does nothing if not open)
256 extern void closeFaberCastWindow();
258 #endif // NL_ACTION_PHRASE_FABER_H
260 /* End of action_phrase_faber.h */