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/>.
20 #ifndef R2_DISPLAYER_BASE_H
21 #define R2_DISPLAYER_BASE_H
23 #include "nel/misc/smart_ptr.h"
24 #include "nel/misc/class_registry.h"
25 #include "nel/gui/interface_element.h"
38 /** Base class to display instances / editor objects
39 * Each instance may have several displayers attached to it :
40 * - a displayer for the 3D scene (derived from CDisplayerVisual...)
41 * - one for the ui (displaying instance in the object tree for example)
42 * - one for the property sheet of the instance
44 class CDisplayerBase
: public NLMISC::IClassable
, public NLGUI::CReflectableRefPtrTarget
47 typedef NLMISC::CSmartPtr
<CDisplayerBase
> TSmartPtr
;
49 virtual ~CDisplayerBase();
50 // Init parameters from script
51 virtual bool init(const CLuaObject
&/* parameters */) { return true; }
52 // Get the instance being displayed
53 CInstance
*getDisplayedInstance() const { return _DisplayedInstance
; }
54 // Push lua access to the displayer
55 virtual void pushLuaAccess(CLuaState
&ls
);
56 /////////////////////////////////////
57 // EVENTS (same than in CInstance) //
58 /////////////////////////////////////
59 virtual void onPreActChanged() {}
60 virtual void onActChanged() {}
61 virtual void onContinentChanged() {}
62 virtual void onCreate() {}
63 virtual void onPostCreate() {}
64 virtual void onErase() {}
65 virtual void onPreHrcMove() {} // instance is about to move in the hierarchy of objects
66 virtual void onPostHrcMove() {} // instance has moved in the hierarchy of objects
67 virtual void onFocus(bool /* focused */) {}
68 virtual void onSelect(bool /* selected */) {}
69 /** An single attribute / a table has been modified in the object
70 * This msg propagate to parent until the top of the hierarchy is reached.
72 virtual void onAttrModified(const std::string
&/* attrName */, sint32
/* attrIndex */) {}
73 //virtual void onTableModified(const std::string &tableName, const std::string &keyInTable, sint32 indexInTable) {}
75 ////////////////////////////////////////////////////////
76 // TARGETED INSTANCES EVENTS (same than in CInstance) //
77 ////////////////////////////////////////////////////////
78 virtual void onTargetInstancePreHrcMove(const std::string
&/* refMakerAttr */, sint32
/* refMakerAttrIndex */) {}
79 virtual void onTargetInstancePostHrcMove(const std::string
&/* refMakerAttr */, sint32
/* refMakerAttrIndex */) {}
80 virtual void onTargetInstanceCreated(const std::string
&/* refMakerAttr */, sint32
/* refMakerAttrIndex */) {}
81 virtual void onTargetInstanceErased(const std::string
&/* refMakerAttr */, sint32
/* refMakerAttrIndex */) {}
82 virtual void onTargetInstanceEraseRequested(const std::string
&/* refMakerAttr */, sint32
/* refMakerAttrIndex */) {}
83 virtual void onTargetInstanceAttrModified(const std::string
&/* refMakerAttr */, sint32
/* refMakerAttrIndex */,
84 const std::string
&/* targetAttrName */, sint32
/* targetAttrIndex */) {}
87 // shortcut to lua projection of displayed instance
88 CLuaObject
&getLuaProjection();
89 const CObjectTable
&getProps() const;
91 REFLECT_EXPORT_START(R2::CDisplayerBase
, CReflectable
)
96 virtual bool maxVisibleEntityExceeded() const { return false; }
99 ///////////////////////////////////////////////////////////////////////////////////////////////
101 CInstance
*_DisplayedInstance
;
103 // NB : with use a tierce function there because making CInstance::setVisualDisplayer a friend create a header cyclic dependency between CBaseDisplayer
105 friend void setDisplayedInstance(CDisplayerBase
*displayer
, CInstance
*displayedInstance
);
107 virtual void setDisplayedInstance(CInstance
*instance
) { _DisplayedInstance
= instance
; }
109 static uint ObjCount
;