Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / client / src / interface_v3 / action_phrase_faber.h
blobba74ef0aab0a286bf2636a4e7fa2bd0586b2cfd8
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) 2012 Matt RAYKOWSKI (sfb) <matt.raykowski@gmail.com>
6 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
7 //
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 // ***************************************************************************
35 class CSBrickSheet;
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 // ***************************************************************************
45 /**
46 * Faber Execution Manager
47 * \author Lionel Berenguier
48 * \author Nevrax France
49 * \date 2003
51 class CActionPhraseFaber
53 public:
55 /// Constructor
56 CActionPhraseFaber();
58 /// open the window
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();
83 private:
84 struct CItem
86 // Item Origin
87 uint16 InventoryId; // INVENTORIES::TInventory
88 uint16 IdInInventory;
89 // Item State
90 NLMISC::CSheetId Sheet;
91 sint32 Quality;
92 sint32 Quantity;
93 sint32 UserColor;
94 sint32 Weight;
95 // BitField to know which itemReqLine has selected this Item
96 uint Selected;
97 // This is the original quantity in inventory
98 sint32 OriginalQuantity;
99 bool LockedByOwner;
101 CItem() : Sheet(0)
103 Quality= 0;
104 Quantity= 0;
105 UserColor= 0;
106 Weight= 0;
107 Selected= 0;
108 OriginalQuantity= 0;
111 void reset()
113 InventoryId= 0;
114 IdInInventory= 0;
115 Sheet= NLMISC::CSheetId::Unknown;
116 Quality= 0;
117 Quantity= 0;
118 UserColor= 0;
119 Weight= 0;
120 Selected= 0;
121 OriginalQuantity= 0;
125 // The observer in case of skill change
126 class CSkillObserver : public ISkillChangeCallback
128 public:
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
152 public:
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
160 public:
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
168 class CMPBuild
170 public:
171 // Different Type of requirement per line
172 enum TReqLineType
174 ItemPartReq=0, // The line requires MPs that can craft a particular ItemPart
175 SpecificItemReq, // The line requires specific MP
176 NumReqLineType
179 public:
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
189 uint QuantityReq;
190 // The number of mpSlot setuped (ie where quantity!=0)
191 uint NumMpSlot;
193 public:
194 CMPBuild()
196 reset();
199 void reset()
201 RequirementType= ItemPartReq;
202 FaberTypeRequired= RM_FABER_TYPE::Unknown;
203 SpecificItemRequired= NLMISC::CSheetId::Unknown;
204 QuantityReq= 0;
205 NumMpSlot= 0;
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 */