1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2021 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2011-2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 // Copyright (C) 2012 Matt RAYKOWSKI (sfb) <matt.raykowski@gmail.com>
7 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
9 // This program is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU Affero General Public License as
11 // published by the Free Software Foundation, either version 3 of the
12 // License, or (at your option) any later version.
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU Affero General Public License for more details.
19 // You should have received a copy of the GNU Affero General Public License
20 // along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef RZ_DBCTRL_SHEET_H
25 #define RZ_DBCTRL_SHEET_H
28 #include "nel/misc/types_nl.h"
29 #include "nel/misc/smart_ptr.h"
31 #include "nel/gui/reflect.h"
32 #include "nel/gui/ctrl_draggable.h"
33 #include "nel/gui/interface_expr.h"
34 #include "nel/gui/action_handler.h"
35 #include "sphrase_manager.h"
37 #include "game_share/brick_types.h"
38 #include "game_share/trade_slot_type.h"
39 #include "game_share/skills.h"
40 #include "game_share/slot_types.h"
41 #include "game_share/rm_family.h"
42 #include "game_share/item_family.h"
44 #include "../time_client.h"
45 #include "item_info_waiter.h"
54 class COutpostBuildingSheet
;
64 // ***************************************************************************
65 // Item info request from server
66 class CControlSheetInfoWaiter
: public IItemInfoWaiter
69 CDBCtrlSheet
* CtrlSheet
;
72 CControlSheetInfoWaiter()
73 : IItemInfoWaiter(), Requesting(false)
76 std::string
infoValidated() const;
78 virtual void infoReceived();
82 // ***************************************************************************
83 /** Common info for CDBCtrlSheet and CDBGroupListSheet
91 // Items. sheetId points to a CItemSheet via SheetMngr
97 // Special : the type of the sheet is automatically deduced from its sheet, it drawn like an item
99 // A macro (ie:'open window inventory + dock bag1')
107 // New Sabrina Phrase. Index in the PhraseBook
109 // New Sabrina Phrase. Complete phrase used for bot chat sentence (sheet id represent a CSPhraseSheet)
111 // A teleport location (just the slot bitmap)
112 SheetType_Teleport_Location
,
113 // A guild teleport type
114 SheetType_ElevatorDestination
,
115 // An outpost building
116 SheetType_OutpostBuilding
,
124 BrickSheetHeight
= 24,
132 // If it is a brick or a spell, give all the brick type this slot accepts.
133 // Each bit is for the associated BRICK_TYPE::EBrickType enum (unnknown bit 0 etc...)
134 // Default is ALL (ie 0xFFFFFFFF)
135 uint32 _BrickTypeBitField
;
138 sint32 _DispNoSheetBmpId
; // Texture to display when no sheet (==0)
139 sint32 _SheetSelectionGroup
; // group for sheet selection, or -1 if none
142 IActionHandler
*_AHOnLeftClick
;
143 CStringShared _AHLeftClickParams
;
144 IActionHandler
*_AHOnRightClick
;
145 CStringShared _AHRightClickParams
;
147 IActionHandler
*_AHOnCanDrag
;
148 CStringShared _AHCanDragParams
;
149 IActionHandler
*_AHOnDrag
;
150 CStringShared _AHDragParams
;
151 IActionHandler
*_AHOnCanDrop
;
152 CStringShared _AHCanDropParams
;
153 IActionHandler
*_AHOnDrop
;
154 CStringShared _AHDropParams
;
155 IActionHandler
*_AHOnCannotDrop
;
156 CStringShared _AHCannotDropParams
;
158 CStringShared _ListMenuLeft
;
159 CStringShared _ListMenuRight
;
160 CStringShared _ListMenuRightEmptySlot
;
163 bool _InterfaceColor
: 1; // Color given by the interface ?
164 bool _UseQuantity
: 1; // is the quantity read and displayed ?
165 bool _ReadQuantityFromSheet
: 1; // Read quantity from sheet rather than from database
166 bool _UseQuality
: 1; // is the quality read and displayed ?
167 bool _DuplicateOnDrag
: 1; // when dragged, the item is shown twice : one version at the mouse position.
168 // and another in the source slot. Useful for items to buy that are in infinite quantity.
169 bool _AutoGrayed
: 1; // if true then gray the ctrlSheeet if: 1/ Items: Is the Item Locked. 2/ Bricks: is the brick Latent.
170 bool _HasTradeSlotType
: 1; // true is the SLOT_TYPE DB field should be taken in account
172 bool _BrickOverable
: 1; // if Type is Brick, display like a button (because LeftClickable).
174 bool _DragCopy
: 1; // true if support copy drag
176 bool _ForceItemBackGroundGeneric
: 1;
178 // For an Item only, this tells what item type this slot accept. Undefined means ALL
179 SLOTTYPE::TSlotType _ItemSlot
;
183 bool parseCtrlInfo(xmlNodePtr cur
, CInterfaceGroup
* parentGroup
);
185 // Context menu accessor/ One for each button
186 void setListMenuLeft (const std::string
&cm
) { _ListMenuLeft
= cm
; }
187 void setListMenuRight (const std::string
&cm
) { _ListMenuRight
= cm
; }
188 void setListMenuBoth (const std::string
&cm
) { _ListMenuLeft
= _ListMenuRight
= cm
; }
189 const std::string
&getListMenuLeft () { return _ListMenuLeft
; }
190 const std::string
&getListMenuRight () { return _ListMenuRight
; }
191 const std::string
&getListMenuRightEmptySlot () {return _ListMenuRightEmptySlot
;}
194 // ***************************************************************************
196 * Class representing base for items that are described in Georges forms
197 * \author Matthieu 'TrapII' Besson
198 * \author Nevrax France
201 class CDBCtrlSheet
: public CCtrlDraggable
, protected CCtrlSheetInfo
204 DECLARE_UI_CLASS(CDBCtrlSheet
)
206 // Release fucking statics
207 static void release ();
209 enum TSheetCategory
{ Item
= 0, Pact
, Skill
, GuildFlag
, Mission
, Phrase
, DontKnow
};
212 CDBCtrlSheet(const TCtorParam
¶m
);
215 virtual bool parse(xmlNodePtr cur
, CInterfaceGroup
* parentGroup
);
217 virtual void updateCoords();
219 void drawSheet (sint32 scrX
, sint32 scrY
, bool draging
, bool showSelectionBorder
= true);
221 virtual bool handleEvent (const NLGUI::CEventDescriptor
&event
);
223 void setActionOnLeftClick (const std::string
&ActionHandlerName
) { _AHOnLeftClick
= CAHManager::getInstance()->getAH(ActionHandlerName
, _AHLeftClickParams
); }
224 void setActionOnRightClick (const std::string
&ActionHandlerName
) { _AHOnRightClick
= CAHManager::getInstance()->getAH(ActionHandlerName
, _AHRightClickParams
); }
225 void setActionOnDrop (const std::string
&ActionHandlerName
) { _AHOnDrop
= CAHManager::getInstance()->getAH(ActionHandlerName
, _AHDropParams
); }
226 void setActionOnCanDrop (const std::string
&ActionHandlerName
) { _AHOnCanDrop
= CAHManager::getInstance()->getAH(ActionHandlerName
, _AHCanDropParams
); }
227 void setParamsOnLeftClick (const std::string
&ParamsHandlerName
) { _AHLeftClickParams
= ParamsHandlerName
; }
228 void setParamsOnRightClick (const std::string
&ParamsHandlerName
) { _AHRightClickParams
= ParamsHandlerName
; }
229 void setParamsOnDrop (const std::string
&ParamsHandlerName
) { _AHDropParams
= ParamsHandlerName
; }
230 void setParamsOnCanDrop (const std::string
&ParamsHandlerName
) { _AHCanDropParams
= ParamsHandlerName
; }
232 const std::string
&getActionOnLeftClick () const { return CAHManager::getInstance()->getAHName(_AHOnLeftClick
); }
233 const std::string
&getActionOnRightClick () const { return CAHManager::getInstance()->getAHName(_AHOnRightClick
); }
234 const std::string
&getActionOnDrop () const { return CAHManager::getInstance()->getAHName(_AHOnDrop
); }
235 const std::string
&getActionOnCanDrop () const { return CAHManager::getInstance()->getAHName(_AHOnCanDrop
); }
236 const std::string
&getParamsOnLeftClick () const { return _AHLeftClickParams
; }
237 const std::string
&getParamsOnRightClick () const { return _AHRightClickParams
; }
238 const std::string
&getParamsOnDrop () const { return _AHDropParams
; }
239 const std::string
&getParamsOnCanDrop () const { return _AHCanDropParams
; }
241 void setListMenuLeft (const std::string
&cm
) { CCtrlSheetInfo::setListMenuLeft(cm
); }
242 void setListMenuRight (const std::string
&cm
) { CCtrlSheetInfo::setListMenuRight(cm
); }
243 void setListMenuBoth (const std::string
&cm
) { CCtrlSheetInfo::setListMenuBoth(cm
); }
244 const std::string
&getListMenuLeft () { return CCtrlSheetInfo::getListMenuLeft(); }
245 const std::string
&getListMenuRight () { return CCtrlSheetInfo::getListMenuRight(); }
246 const std::string
&getListMenuRightEmptySlot () {return CCtrlSheetInfo::getListMenuRightEmptySlot();}
248 void setCanDrop (bool cd
) { _CanDrop
= cd
; }
249 bool getCanDrop () const { return _CanDrop
; }
250 sint32
getDeltaDragX() {return _DeltaDragX
;}
251 sint32
getDeltaDragY() {return _DeltaDragY
;}
252 // For "oncandrag" action handlers only, which would want to avoid the drag
253 void setTempCanDrag(bool cd
) {_TempCanDrag
= cd
;}
254 // called when a setCapturePointerLeft(NULL) is made for instance
256 CCtrlSheetInfo::TSheetType
getType () const;
257 void setType (CCtrlSheetInfo::TSheetType type
);
259 // Swap the content with another ctrl_sheet (debug): SheetId, Quantity and Quality
260 void swapSheet(CDBCtrlSheet
*other
);
261 void setSheetId(sint32 val
) {_SheetId
.setSInt32(val
);}
262 void setQuality(sint32 val
) {_Quality
.setSInt32(val
);}
263 void setQuantity(sint32 val
) {_Quantity
.setSInt32(val
);}
264 void setItemNameId(uint32 val
) {_NameId
.setSInt32(val
);}
265 void setEnchant(sint32 val
) {_Enchant
.setSInt32(val
);}
268 sint32
getSheetId() const { return (sint32
)_SheetId
.getSInt32(); }
269 sint32
getQuality() const { return _UseQuality
? (sint32
)_Quality
.getSInt32() : 0; }
270 sint32
getEnchant() const { return _Enchant
.getSInt32(); }
271 sint32
getQuantity() const { return (sint32
)_Quantity
.getSInt32(); }
272 uint32
getItemNameId() const { return (uint32
)_NameId
.getSInt32();}
274 sint32
getStackable() const { return (_Stackable
>1) ? 999 : 1; }
276 // get non locked quantity (can be zero)
277 sint32
getNonLockedQuantity() const;
279 const CItemSheet
*asItemSheet() const;
280 const CPactSheet
*asPactSheet() const;
281 const CSBrickSheet
*asSBrickSheet() const;
282 const CSPhraseSheet
*asSPhraseSheet() const;
283 const COutpostBuildingSheet
*asOutpostBuildingSheet() const;
285 // Operation on the link between the sheet and database. the string is the branch root of SHEET....
286 std::string
getSheet() const;
287 void setSheet (const std::string
&dbBranchId
);
288 void setSheetFast( const std::string
&dbParentBranchId
, int sheetNum
, int slotNum
);
290 REFLECT_EXPORT_START(CDBCtrlSheet
, CCtrlDraggable
)
291 REFLECT_STRING("sheet", getSheet
, setSheet
);
292 REFLECT_RGBA("color", getSheetColor
, setSheetColor
);
293 REFLECT_RGBA("color1", getGuildColor1
, setGuildColor1
);
294 REFLECT_RGBA("color2", getGuildColor2
, setGuildColor2
);
295 REFLECT_SINT32("back", getGuildBack
, setGuildBack
);
296 REFLECT_SINT32("symbol", getGuildSymbol
, setGuildSymbol
);
297 REFLECT_BOOL("invert_symbol", getInvertGuildSymbol
, setInvertGuildSymbol
);
298 REFLECT_BOOL("can_drop", getCanDrop
, setCanDrop
);
299 REFLECT_STRING_REF ("left_click", getActionOnLeftClick
, setActionOnLeftClick
);
300 REFLECT_STRING_REF ("right_click", getActionOnRightClick
, setActionOnRightClick
);
301 REFLECT_STRING_REF ("left_click_params", getParamsOnLeftClick
, setParamsOnLeftClick
);
302 REFLECT_STRING_REF ("right_click_params", getParamsOnRightClick
, setParamsOnRightClick
);
303 REFLECT_STRING_REF ("on_drop", getActionOnDrop
, setActionOnDrop
);
304 REFLECT_STRING_REF ("on_drop_params", getParamsOnDrop
, setParamsOnDrop
);
305 REFLECT_STRING_REF ("on_can_drop", getActionOnCanDrop
, setActionOnCanDrop
);
306 REFLECT_STRING_REF ("on_can_drop_params", getParamsOnCanDrop
, setParamsOnCanDrop
);
307 REFLECT_LUA_METHOD("getDraggedSheet", luaGetDraggedSheet
);
308 REFLECT_LUA_METHOD("getItemInfo", luaGetItemInfo
);
309 REFLECT_LUA_METHOD("getName", luaGetName
);
310 REFLECT_LUA_METHOD("getCreatorName", luaGetCreatorName
);
311 REFLECT_LUA_METHOD("waitInfo", luaWaitInfo
);
312 REFLECT_LUA_METHOD("buildCrystallizedSpellListBrick", luaBuildCrystallizedSpellListBrick
);
315 int luaGetDraggedSheet(CLuaState
&ls
);
316 int luaGetItemInfo(CLuaState
&ls
);
317 int luaGetName(CLuaState
&ls
);
318 int luaGetCreatorName(CLuaState
&ls
);
319 int luaWaitInfo(CLuaState
&ls
);
320 int luaBuildCrystallizedSpellListBrick(CLuaState
&ls
);
322 // hardcode creation. User must setup other CtrlBase value (parent etc...)
323 void initSheet(const std::string
&dbValue
, const CCtrlSheetInfo
&ctrlInfo
);
324 void initSheetFast( const std::string
&dbParentBranchId
, int sheetNum
, int slotNum
,
325 const CCtrlSheetInfo
&ctrlInfo
);
327 // get the selection group for this ctrl sheet, or -1 if none
328 sint
getSelectionGroup() const { return _SheetSelectionGroup
; }
329 // get the selection group for this ctrl sheet as a string, or "" if none
330 const std::string
&getSelectionGroupAsString() const;
332 // get the currently selected sheet (only one at a time)
333 static CDBCtrlSheet
*getCurrSelection() { return _CurrSelection
; }
335 // set the currently selected sheet.
336 static void setCurrSelection(CDBCtrlSheet
*selected
);
338 // get the root branch containing the properties for that sheet
339 NLMISC::CCDBNodeBranch
*getRootBranch() const;
341 /** If the branch in setSheet(branch) is of the form ...:# (where # is a number), return this number.
342 * The value is hence modified by setSheet(). return 0 if not of this form.
344 uint32
getIndexInDB() const {return _IndexInDB
;}
345 /** If the branch in setSheet(branch) is of the form ...:#:# (where # are numbers), return this number.
346 * The value is hence modified by setSheet(). return 0 if not of this form.
348 uint32
getSecondIndexInDB() const {return _SecondIndexInDB
;}
350 // synonym for getSecondIndexInDB().
351 uint32
getInventoryIndex() const {return getSecondIndexInDB();}
353 // determine the inventory slot from the database branch id
354 static uint
getInventorySlot( const std::string
&dbBranchId
);
356 // Get the last dropped sheet. The pointer is only valid during the call of the event handler
357 //static CDBCtrlSheet *getDraggedSheet() { return _LastDraggedSheet; }
359 /* Get the last selected sheet that have been draged or right clicked (should be use by menu to get their caller)
360 * It is used by the item actions like destroy, move etc..
362 static CDBCtrlSheet
*getCurrSelSheet() { return _CurrMenuSheet
; }
363 static void setCurrSelSheet(CDBCtrlSheet
*sheet
) { _CurrMenuSheet
= sheet
; }
366 /// \name SBrick / SPhrase
368 // true if the ctrl_sheet is a Sabrina brick
369 bool isSBrick() const {return getType() ==SheetType_SBrick
;}
370 // true if magic sentence is a Sabrina phrase
371 bool isSPhraseId() const {return getType()==SheetType_SPhraseId
;}
372 // true if magic sentence is a Sabrina phrase
373 bool isSPhrase() const {return getType()==SheetType_SPhrase
;}
374 // true if brick or magic sentence
375 bool isSBrickOrSPhraseId() const
377 CCtrlSheetInfo::TSheetType type
= getType();
378 return type
==SheetType_SBrick
|| type
==SheetType_SPhraseId
;
380 bool isSPhraseIdMemory() const;
381 // special for macro and Memories
382 bool isMacroMemory() const;
383 // return the phrase slot from database.
384 sint32
getSPhraseId() const;
385 /// true if it is a shortcut
386 bool isShortCut() const {return _ShortCut
;}
390 /// Setup the alpha of the sheet drawn
391 void setSheetColor(NLMISC::CRGBA color
) {_SheetColor
= color
;}
392 NLMISC::CRGBA
getSheetColor() const {return _SheetColor
;}
394 /// Special ContextHelp for ctrl sheet.
395 virtual void getContextHelp(std::string
&help
) const;
397 virtual void getContextHelpToolTip(std::string
&help
) const;
400 /** true if an item of another ctrlSheet can be dropped on this slot.
401 * also return true if src is 0, or if _ItemSlot==UNDEFINED
403 bool canDropItem(CDBCtrlSheet
*src
) const;
405 /// Force the item/brick to be grayed. NB: no effect if "auto_grayed" is true
406 void setGrayed(bool state
) { _Grayed
= state
;}
407 bool getGrayed() const
409 // If The Item sheet or phrase is 0, assume never grayed
410 if(_SheetId
.getNodePtr() && getSheetId() == 0)
412 // NB: if a macro, getNodePtr()==NULL
416 // Additional gray for items. The item is finally grayed if one of this
417 void setItemWeared(bool state
) {_ItemWeared
= state
;}
418 bool getItemWeared() const { return _ItemWeared
;}
419 void setItemBeastGrayed(bool state
) {_ItemBeastGrayed
= state
;}
420 bool getItemBeastGrayed() const { return _ItemBeastGrayed
;}
422 void setUseQuality(bool use
) { if(use
!=_UseQuality
) { _UseQuality
= use
; _NeedSetup
= true;} }
423 void setUseQuantity(bool use
) { if(use
!=_UseQuantity
) { _UseQuantity
= use
; _NeedSetup
= true;} }
424 bool getUseQuality() const { return _UseQuality
; }
425 bool getUseQuantity() const { return _UseQuantity
; }
427 void setReadQuantityFromSheetFlag(bool on
) { _ReadQuantityFromSheet
= on
; }
428 bool getReadQuantityFromSheetFlag() const { return _ReadQuantityFromSheet
; }
430 // test if the sheet is a skill sheet
431 bool isSkill() const { return _HasTradeSlotType
? _TradeSlotType
.getSInt32() == TRADE_SLOT_TYPE::Skill
: false; }
433 // test if the sheet is a mission sheet
434 bool isMission() const;
436 // If the sheet is a skill, just get it
437 SKILLS::ESkills
getSkill() const { return isSkill() ? (SKILLS::ESkills
) getSheetId() : SKILLS::unknown
; }
440 // set special behaviour
441 void setBehaviour(TRADE_SLOT_TYPE::TTradeSlotType type
);
442 TRADE_SLOT_TYPE::TTradeSlotType
getBehaviour() const { return _HasTradeSlotType
? (TRADE_SLOT_TYPE::TTradeSlotType
) _TradeSlotType
.getSInt32() : TRADE_SLOT_TYPE::StandardBehaviour
; }
444 SLOTTYPE::TSlotType
getItemSlot() { return _ItemSlot
; }
445 void setItemSlot(SLOTTYPE::TSlotType slot
) { _ItemSlot
= slot
; }
446 void setTextureNoItem(sint32 nTxID
) { _DispNoSheetBmpId
= nTxID
; }
447 sint32
getTextureNoItem() { return _DispNoSheetBmpId
; }
449 // copy the aspect of this sheet (not the handlers)
450 void copyAspect(CDBCtrlSheet
*dest
);
451 // true if same aspects.
452 bool sameAspect(CDBCtrlSheet
*dest
) const;
454 // get the sheet category
455 TSheetCategory
getSheetCategory() const;
457 // get the ListSheet parent. NB: different code from CDBGroupListSheet and CDBGroupListSheetTrade. NULL if not found
458 IListSheetBase
*getListSheetParent() const;
460 // get the index of this sheet in its parent list, or -1 if there's no such list
461 sint
getIndexInParent() const;
463 // get the 'LOCKED' field in the db
464 NLMISC::CCDBNodeLeaf
*getLockValuePtr() { return _GrayedLink
; }
468 void readFromMacro(const CMacroCmd
&mc
); // Macro To ControlSheet
469 void writeToMacro(CMacroCmd
&mc
); // ControlSheet To Macro
470 void setMacroBack(uint8 nb
);
471 void setMacroIcon(uint8 nb
);
472 void setMacroOver(uint8 nb
);
473 void setMacroText(const std::string
&mcText
);
474 sint32
getMacroId() const {return _MacroID
;}
475 bool isMacro() const {return getType()==SheetType_Macro
;}
478 /** According to ActualType, return true if the sheet is valid. eg: getSheetId()!=0 and brick exist
479 * for sheet type brucks. Always for Macros and skills.
481 bool isSheetValid() const;
485 NLMISC::CRGBA
getGuildColor1() const;
486 NLMISC::CRGBA
getGuildColor2() const;
487 sint32
getGuildBack() const;
488 sint32
getGuildSymbol() const;
489 bool getInvertGuildSymbol() const;
491 void setGuildColor1(NLMISC::CRGBA col
);
492 void setGuildColor2(NLMISC::CRGBA col
);
493 void setGuildBack(sint32 n
);
494 void setGuildSymbol(sint32 n
);
495 void setInvertGuildSymbol(bool b
);
498 /// \name For teleport location
500 void setSlot(const std::string
&textureName
);
501 void initSheetSize();
504 NLMISC::CCDBNodeLeaf
*getSlotType() const { return _TradeSlotType
.getNodePtr(); }
507 uint16
getItemWeight() const;
508 NLMISC::CCDBNodeLeaf
*getItemWeightPtr() const;
510 void setItemWeight(uint16 weight
);
512 // get item info version
513 uint8
getItemInfoVersion() const;
514 NLMISC::CCDBNodeLeaf
*getItemInfoVersionPtr() const;
515 // set item info version
516 void setItemInfoVersion(uint8 infoVersion
);
518 // get item Locked state
519 uint16
getItemLocked() const;
520 NLMISC::CCDBNodeLeaf
*getItemLockedPtr() const;
521 // set item locked state
522 void setItemLocked(uint16 lock
);
524 // get item PRICE. 0 if no DB
525 sint32
getItemPrice() const;
526 NLMISC::CCDBNodeLeaf
*getItemPricePtr() const;
528 void setItemPrice(sint32 price
);
530 // get item RESALE_FLAG. 0 if no DB
531 sint32
getItemResaleFlag() const;
532 NLMISC::CCDBNodeLeaf
*getItemResaleFlagPtr() const;
533 // set item RESALE_FLAG
534 void setItemResaleFlag(sint32 rf
);
536 //get item CREATE_TIME. 0 if no DB
537 sint32
getItemCreateTime() const;
538 NLMISC::CCDBNodeLeaf
*getItemCreateTimePtr() const;
539 // set item CREATE_TIME
540 void setItemCreateTime(sint32 ct
);
542 //get item SERIAL. 0 if no DB
543 sint32
getItemSerial() const;
544 NLMISC::CCDBNodeLeaf
*getItemSerialPtr() const;
545 // set item CREATE_TIME
546 void setItemSerial(sint32 serial
);
548 // get item locked by owner
549 bool getLockedByOwner() const;
551 // true if the inventory supports owner locking
552 bool canOwnerLock() const;
554 // get item SELLER_TYPE. 0 if no DB
555 sint32
getItemSellerType() const;
556 NLMISC::CCDBNodeLeaf
*getItemSellerTypePtr() const;
557 // set item SELLER_TYPE
558 void setItemSellerType(sint32 rf
);
560 // get item FABER_QUALITY. 0 if no DB
561 RM_CLASS_TYPE::TRMClassType
getItemRMClassType() const;
562 NLMISC::CCDBNodeLeaf
*getItemRMClassTypePtr() const {return _ItemRMClassType
;}
563 // set item FABER_QUALITY
564 void setItemRMClassType(sint32 fq
);
566 // get item FABER_STAT_TYPE. 0 if no DB
567 RM_FABER_STAT_TYPE::TRMStatType
getItemRMFaberStatType() const;
568 NLMISC::CCDBNodeLeaf
*getItemRMFaberStatTypePtr() const {return _ItemRMFaberStatType
;}
569 // set item FABER_STAT_TYPE
570 void setItemRMFaberStatType(sint32 fss
);
572 // get item PREREQUISIT_VALID. true of no DB
573 bool getItemPrerequisitValid() const;
574 NLMISC::CCDBNodeLeaf
*getItemPrerequisitValidPtr() const;
575 // set item PREREQUISIT_VALID
576 void setItemPrerequisitValid(bool prv
);
578 // get color index of item (return -1 if no color available)
579 sint32
getItemColor() const {if(_UserColor
) return _UserColor
->getValue32(); else return -1;}
580 // set item color (if possible)
581 void setItemColor(sint32 val
) {if(_UserColor
) _UserColor
->setValue32(val
);}
583 // Get the Actual item name. Localized version of SheetId, or given by server through NAMEID.
584 std::string
getItemActualName() const;
586 /// true if support drag copy (with CTRL). action handler has to check control.
587 bool canDragCopy() const {return _DragCopy
;}
589 // special for items, call it at initInGame()
590 static void initArmourColors();
592 // true if an item that respect Carac requirement. NB: still return true if not an item
593 bool checkItemRequirement();
595 virtual void serial(NLMISC::IStream
&f
);
597 // From CCtrlBase, for phrases, we use a special, enhanced tooltip window
598 virtual std::string
getContextHelpWindowName() const;
600 // For auras, powers, etc. set the range of ticks during which regen occurs
601 void setRegenTickRange(const CTickRange
&tickRange
);
602 const CTickRange
&getRegenTickRange() const { return _RegenTickRange
; }
604 // Default regen text is displayed on bottom of icon.
605 void setRegenText(bool b
) { _RegenTextEnabled
= b
; }
606 // Allow to override default formatter.
607 // First parameter will be replaced with current timer value (always >= 0)
608 // If its a lua function, then parameters are
609 // 1: current timer value; can be negative
610 // 2: DB path for ctrl root (ie UI:VARIABLES:BONUSES:0), or nil
612 // ie: "secondsToTimeStringShort" -> CInterfaceExpr::evalAsString("secondsToTimeStringShort(123)", ret)
613 // ie: "lua:secondsToTimeStringShort" -> CInterfaceExpr::evalAsString("lua:secondsToTimeStringShort(123, 'UI:VARIABLES:BONUSES:0')", ret)
614 void setRegenTextFct(const std::string
&s
);
615 void setRegenTextY(sint32 y
) { _RegenTextY
= y
; }
616 void setRegenTextShadow(bool b
) { _RegenTextShadow
= b
; }
617 void setRegenTextShadowColor(NLMISC::CRGBA c
) { _RegenTextShadowColor
= c
; }
618 void setRegenTextOutline(bool b
) { _RegenTextOutline
= b
; }
619 void setRegenTextOutlineColor(NLMISC::CRGBA c
) { _RegenTextOutlineColor
= c
; }
620 void setRegenTextFontSize(uint32 s
) { _RegenTextFontSize
= s
; }
621 void setRegenTextColor(NLMISC::CRGBA c
) { _RegenTextColor
= c
; }
623 // start notify anim (at the end of regen usually)
624 void startNotifyAnim();
626 // callback from info waiter
629 // do the sheets point to the same item in the DB ?
630 bool isSheetEqual(CDBCtrlSheet
*pCS
) const;
632 // set enchant/buff marker visiblility
633 static void setShowIconBuffs(bool b
) { _ShowIconBuffs
= b
; }
636 inline bool useItemInfoForFamily(ITEMFAMILY::EItemFamily family
) const;
641 void setupGuildFlag();
645 void setupSPhraseId();
646 void setupOutpostBuilding();
647 // optSheet is for special faber
648 void setupDisplayAsSBrick(sint32 sheet
, sint32 optSheet
= 0, bool force
= false);
649 // setup icon from phrases
650 void setupDisplayAsPhrase(const std::vector
<NLMISC::CSheetId
> &bricks
, const std::string
&phraseName
, uint8 phraseIconIndex
= std::numeric_limits
<uint8
>::max());
652 // draw a number and returns the width of the drawn number
653 sint32
drawNumber(sint32 x
, sint32 y
, sint32 wSheet
, sint32 hSheet
, NLMISC::CRGBA color
, sint32 value
, bool rightAlign
=true);
658 // Root branch of the DB
659 std::string _DbBranchName
;
662 CInterfaceProperty _SheetId
;
663 CInterfaceProperty _NameId
;
664 CInterfaceProperty _Quantity
;
665 CInterfaceProperty _Quality
;
666 CInterfaceProperty _TradeSlotType
;
667 CInterfaceProperty _Enchant
;
668 CInterfaceProperty _PrerequisitValid
;
669 CInterfaceProperty _Worned
; // if true means that item is worned (red cross, no longer usable unless it's a tool)
671 // As node leaf for backward compatibilities
672 NLMISC::CCDBNodeLeaf
*_ItemRMClassType
;
673 NLMISC::CCDBNodeLeaf
*_ItemRMFaberStatType
;
675 mutable sint32 _LastSheetId
;
676 sint32 _LastItemInfoVersion
;
677 sint32 _LastItemCreateTime
;
678 sint32 _LastItemSerial
;
679 bool _ItemInfoChanged
;
682 sint32 _DispSlotBmpId
; // Display slot bitmap id
683 sint32 _DispSelSlotId
;
685 sint32 _DispBackBmpId
; // Back Icon
686 sint32 _DispSheetBmpId
; // Main Icon
687 sint32 _DispOverBmpId
; // Over Icon
688 sint32 _DispOver2BmpId
; // Over Icon N0 2 for bricks / items. Useful for items when _DispOverBmpId is used to paint user color on the item.
690 std::string _HpBuffIcon
;
691 std::string _SapBuffIcon
;
692 std::string _StaBuffIcon
;
693 std::string _FocusBuffIcon
;
695 // texture ids to show
698 SBuffIcon(sint32 txid
, NLMISC::CRGBA col
=NLMISC::CRGBA::White
)
699 :TextureId(txid
), Color(col
), IconW(0), IconH(0)
707 std::vector
<SBuffIcon
> _BuffIcons
;
708 std::vector
<SBuffIcon
> _EnchantIcons
;
709 std::vector
<SBuffIcon
> _BoostIcons
;
711 // Level Brick or Quality
717 // Quantity for items
718 sint32 _DispQuantity
;
721 sint32 _TextureIdOver
;
724 uint32 _SecondIndexInDB
;
726 // For SBrick only. Display level?
727 bool _MustDisplayLevel
: 1;
734 /// Is a TaskBar shortcut
740 /// Is the Item/Brick as to be grayed?
741 bool _ItemBeastGrayed
: 1; // This is an item in a pack animal / beast, that is unavailable
742 bool _ItemWeared
: 1; // Item weared (for bags item)
744 bool _Useable
: 1; // if false, means more than grayed: "red-ed" we cannot get or use it. SBrick, SPhrase and SItem
746 /// Init after parse()
749 /// true if need a full setup in setupItem() ...
750 mutable bool _NeedSetup
: 1;
752 // Temp for oncandrag AH
753 bool _TempCanDrag
: 1;
755 // For ArmourColorFromDB
756 bool _ArmourColorFromDB
: 1;
758 // True if the Armour Color Bitmaps have been setuped
759 bool _ArmourColorBmpOk
: 1;
761 // Bkup of Armour Color index. -1 or 0..7
762 sint8 _ArmourColorIndex
;
764 CTickRange _RegenTickRange
;
765 NLGUI::CViewText
*_RegenText
;
766 sint32 _RegenTextValue
;
768 std::string _RegenTextFct
;
769 bool _RegenTextFctLua
;
770 bool _RegenTextEnabled
;
771 bool _RegenTextShadow
;
772 bool _RegenTextOutline
;
774 uint32 _RegenTextFontSize
;
775 NLMISC::CRGBA _RegenTextShadowColor
;
776 NLMISC::CRGBA _RegenTextOutlineColor
;
777 NLMISC::CRGBA _RegenTextColor
;
781 sint32 _DragX
, _DragY
;
782 sint32 _DeltaDragX
, _DeltaDragY
;
783 sint32 _IconW
, _IconH
;
785 // Global color of the control.
786 NLMISC::CRGBA _SheetColor
;
788 // Special colors (item/bricks)
789 NLMISC::CRGBA _IconBackColor
;
790 NLMISC::CRGBA _IconColor
;
791 NLMISC::CRGBA _IconOverColor
;
792 NLMISC::CRGBA _IconOver2Color
;
793 // Item only: Special armour color. black(0) if is not an armour
794 uint32 _PackedArmourColor
;
797 // For an Item only. Useful for LeftHand Filtering: must have a pointer to the right hand
798 CDBCtrlSheet
*_OtherHandItemFilter
;
800 // This String is optional and usage dependent for Item, Macro, or Sentence
801 std::string _OptString
;
803 NLMISC::CCDBNodeLeaf
*_GrayedLink
;
805 // Macro or sentence String compiled as texture Ids and positions, from the _OptString.
811 std::vector
<CCharBitmap
> _CharBitmaps
;
817 NL3D::UTextureFile
*_GuildBack
;
818 NL3D::UTextureFile
*_GuildSymb
;
819 static NL3D::UMaterial _GuildMat
;
821 NLMISC::CSheetId _GuildIcon
;
824 sint32 _LastPhraseVersion
;
826 // special for items : colour of armour
827 static NLMISC::CRGBA _ArmourColor
[8];
829 // special for items. Carac Requirement
830 CHARACTERISTICS::TCharacteristics _ItemCaracReqType
;
831 sint32 _ItemCaracReqValue
;
833 // Special for Armour
834 NLMISC::CCDBNodeLeaf
*_UserColor
;
836 // keep pointer on item sheet
837 const CItemSheet
*_ItemSheet
;
839 // unique persistent phrase exposed to lua script
840 static NLMISC::CSmartPtr
<CSPhraseComAdpater
> _PhraseAdapter
;
842 sint64 _NotifyAnimEndTime
;
844 mutable CControlSheetInfoWaiter _ItemInfoWaiter
;
846 mutable TSheetType _ActualType
;
848 static CDBCtrlSheet
*_CurrSelection
;
849 static CDBCtrlSheet
*_CurrMenuSheet
;
851 static bool _ShowIconBuffs
;
853 void updateActualType() const;
854 void updateIconSize();
855 void resetAllTexIDs();
857 // update/remove enchant and buff markers from item icon
858 void clearIconBuffs();
859 void updateIconBuffs();
861 void setupCharBitmaps(sint32 maxW
, sint32 maxLine
, bool topDown
= false);
862 void resetCharBitmaps();
863 void displayCharBitmaps(sint32 rdrLayer
, sint32 x
, sint32 y
, NLMISC::CRGBA color
);
866 void updateItemCharacRequirement(sint32 sheetId
);
868 // Send ITEM_INFO:GET request to server to fetch Buffs, Enchant info
869 void setupItemInfoWaiter();
871 // update armour color, and cache
872 void updateArmourColor(sint8 col
);
874 // setup sheet DB. _DbBranchName must be ok, and _SecondIndexInDb and _IndexInDb as well
875 void setupSheetDbLinks ();
879 // convert from uv coordinates in the [0, 1] x [0, 1] range to screen coords
880 inline void uvToScreen(float x
, float y
, NLMISC::CVector
&screenPos
, uint texSize
) const;
881 // from an angle in the [0, 1] range, return both uv & screen coords for that angle
882 // (angle is projected on the side of rectangle of the 'regen' texture)
883 void buildPieCorner(float angle
, NLMISC::CUV
&uv
, NLMISC::CVector
&pos
, uint texSize
) const;
884 // from a start and end angle in the [0, 1] range, build the set of uv mapped triangles necessary
885 // to display that 'pie'
886 // NB : output are indeed quads, at the time ofthis writing, uv mappedtri randering not available ...
887 // so we turn them into quad for conveniency ...
888 uint
buildPie(NLMISC::CQuadUV
*quv
, float startAngle
, float endAngle
, uint texSize
);
890 // gelper to draw the notify animation
891 void drawRotatedQuad(CViewRenderer
&vr
, float angle
, float scale
, uint renderLayer
, uint32 textureId
, sint32 texWidth
, sint32 texHeight
);
893 // create and draw regen text over icon
894 void drawRegenText();
898 /** User type (used with expression system of the interface, see interface_expr.h, that contains a pointer to a CDBCtrlSheet
900 struct CDBCtrlSheetPtrUserType
: public CInterfaceExprUserType
902 CDBCtrlSheet
*Sheet
; // pointer to a sheet
904 CDBCtrlSheetPtrUserType(CDBCtrlSheet
*sheet
= NULL
) : Sheet(sheet
) {}
905 // from CInterfaceExprUserType
906 virtual CInterfaceExprUserType
*clone() const { return new CDBCtrlSheetPtrUserType(*this); }
910 #endif // RZ_DBCTRL_SHEET_H
912 /* End of dbctrl_sheet.h */