Merge branch '138-toggle-free-look-with-hotkey' into main/gingo-test
[ryzomcore.git] / ryzom / client / src / r2 / object_factory_client.h
blobdbf4595b6ca47cafff48973b3e1fc2b88d995e89
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) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 //
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_OBJECT_FACTORY_CLIENT_H
21 #define R2_OBJECT_FACTORY_CLIENT_H
23 #include "game_share/object.h"
24 #include "editor.h"
25 #include "nel/gui/lua_object.h"
27 namespace R2
31 /** Reference Id object on the client.
32 * This object will trigger the right events on its parent when its target is created or erased.
33 * (creation is watched too. This is possible because we use instance id, not direct pointer on the object)
35 class CObjectRefIdClient : public CObjectRefId, public CEditor::IInstanceObserver
37 public:
38 CObjectRefIdClient(const std::string &value);
39 ~CObjectRefIdClient();
40 // from CObjectString
41 virtual bool set(const std::string& key, const std::string & value);
42 CObject* clone() const;
43 void enable(bool enabled);
44 protected:
45 // from CEditor::IInstanceObserver
46 virtual void onInstanceCreated(CInstance &instance);
47 virtual void onInstanceErased(CInstance &instance);
48 virtual void onPreHrcMove(CInstance &instance);
49 virtual void onPostHrcMove(CInstance &instance);
50 virtual void onInstanceEraseRequest(CInstance &instance);
51 virtual void onAttrModified(CInstance &instance, const std::string &attrName, sint32 attrIndex);
52 private:
53 // cache for the 'name' of this property in the parent
54 CEditor::TInstanceObserverHandle _ObserverHandle;
55 mutable sint32 _IndexInParent;
56 mutable sint32 _IndexInParentArray;
57 mutable CInstance::TRefPtr _ParentInstance;
58 bool _Enabled;
59 private:
60 void updateParentInstancePtr() const;
61 void getNameInParent(std::string &name, sint32 &indexInArray) const;
62 void addObserverHandle();
63 void removeObserverHandle();
67 // CObjectTable on client side
68 class CObjectTableClient : public CObjectTable
70 public:
71 CObjectTableClient();
72 void pushOnLuaStack(CLuaState &state, CLuaObject &metatable) const;
73 CObject* clone() const;
74 private:
75 mutable CLuaObject _Ref;
78 // the client factory redefine R2::CObjectRefId so that it can perform its observer job on the client
79 class CObjectFactoryClient : public CObjectFactory
81 public:
82 CObjectFactoryClient(const std::string &prefix);
83 // from CObjectFactory
84 virtual CObject* newBasic(const std::string & type);
89 } // R2
94 #endif