Add infos into target window
[ryzomcore.git] / ryzom / client / src / r2 / lua_event_forwarder.cpp
blobe904cb05812b878e6b203d7d1e9ad8c4a97a26d1
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 #include "stdpch.h"
21 #include "lua_event_forwarder.h"
22 #include "nel/gui/lua_object.h"
24 #ifdef DEBUG_NEW
25 #define new DEBUG_NEW
26 #endif
28 namespace R2
31 // events names
33 static CLuaString LuaStr_onActChanged("onActChanged");
34 static CLuaString LuaStr_onContinentChanged("onContinentChanged");
35 static CLuaString LuaStr_onCreate("onCreate");
36 static CLuaString LuaStr_onPostCreate("onPostCreate");
37 static CLuaString LuaStr_onErase("onErase");
38 static CLuaString LuaStr_onPreHrcMove("onPreHrcMove");
39 static CLuaString LuaStr_onPostHrcMove("onPostHrcMove");
40 static CLuaString LuaStr_onFocus("onFocus");
41 static CLuaString LuaStr_onSelect("onSelect");
42 static CLuaString LuaStr_onAttrModified("onAttrModified");
43 static CLuaString LuaStr_onTargetInstanceCreated("onTargetInstanceCreated");
44 static CLuaString LuaStr_onTargetInstanceErased("onTargetInstanceErased");
45 static CLuaString LuaStr_onTargetInstanceAttrModified("onTargetInstanceAttrModified");
46 static CLuaString LuaStr_onTargetInstanceEraseRequested("onTargetInstanceEraseRequested");
47 static CLuaString LuaStr_onTargetInstancePostHrcMove("onTargetInstancePostHrcMove");
48 static CLuaString LuaStr_onTargetInstancePreHrcMove("onTargetInstancePreHrcMove");
52 // *********************************************************************************************************
53 void CLuaEventForwarder::onActChanged()
55 //H_AUTO(R2_CLuaEventForwarder_onActChanged)
56 if (!getLua()) return;
57 executeHandler(LuaStr_onActChanged, 0);
60 // *********************************************************************************************************
61 void CLuaEventForwarder::onContinentChanged()
63 //H_AUTO(R2_CLuaEventForwarder_onContinentChanged)
64 if (!getLua()) return;
65 executeHandler(LuaStr_onContinentChanged, 0);
68 // *********************************************************************************************************
69 void CLuaEventForwarder::onCreate()
71 //H_AUTO(R2_CLuaEventForwarder_onCreate)
72 if (!getLua()) return;
73 executeHandler(LuaStr_onCreate, 0);
76 // *********************************************************************************************************
77 void CLuaEventForwarder::onPostCreate()
79 //H_AUTO(R2_CLuaEventForwarder_onPostCreate)
80 if (!getLua()) return;
81 executeHandler(LuaStr_onPostCreate, 0);
84 // *********************************************************************************************************
85 void CLuaEventForwarder::onErase()
87 //H_AUTO(R2_CLuaEventForwarder_onErase)
88 if (!getLua()) return;
89 executeHandler(LuaStr_onErase, 0);
92 // *********************************************************************************************************
93 void CLuaEventForwarder::onPreHrcMove()
95 //H_AUTO(R2_CLuaEventForwarder_onPreHrcMove)
96 if (!getLua()) return;
97 executeHandler(LuaStr_onPreHrcMove, 0);
100 // *********************************************************************************************************
101 void CLuaEventForwarder::onPostHrcMove()
103 //H_AUTO(R2_CLuaEventForwarder_onPostHrcMove)
104 if (!getLua()) return;
105 executeHandler(LuaStr_onPostHrcMove, 0);
108 // *********************************************************************************************************
109 void CLuaEventForwarder::onFocus(bool focused)
111 //H_AUTO(R2_CLuaEventForwarder_onFocus)
112 CLuaState *ls = getLua();
113 if (!ls) return;
114 ls->push(focused);
115 executeHandler(LuaStr_onFocus, 1);
118 // *********************************************************************************************************
119 void CLuaEventForwarder::onSelect(bool selected)
121 //H_AUTO(R2_CLuaEventForwarder_onSelect)
122 CLuaState *ls = getLua();
123 if (!ls) return;
124 ls->push(selected);
125 executeHandler(LuaStr_onSelect, 1);
128 // *********************************************************************************************************
129 void CLuaEventForwarder::onAttrModified(const std::string &attrName, sint32 index)
131 //H_AUTO(R2_CLuaEventForwarder_onAttrModified)
132 CLuaState *ls = getLua();
133 if (!ls) return;
134 ls->push(attrName);
135 ls->push((double) index);
136 executeHandler(LuaStr_onAttrModified, 2);
139 // *********************************************************************************************************
140 /*void CDisplayerLua::onTableModified(const std::string &tableName, const std::string &keyInTable, sint32 indexInTable)
142 //H_AUTO(R2_CDisplayerLua_onTableModified)
143 CLuaState *ls = getLua();
144 if (!ls) return;
145 ls->push(tableName);
146 ls->push(keyInTable);
147 ls->push((double) indexInTable);
148 executeHandler("onTableModified", 3);
151 // *********************************************************************************************************
152 void CLuaEventForwarder::onTargetInstanceCreated(const std::string &refMakerAttr, sint32 refMakerAttrIndex)
154 //H_AUTO(R2_CLuaEventForwarder_onTargetInstanceCreated)
155 CLuaState *ls = getLua();
156 if (!ls) return;
157 ls->push(refMakerAttr);
158 ls->push((double) refMakerAttrIndex);
159 executeHandler(LuaStr_onTargetInstanceCreated, 2);
162 // *********************************************************************************************************
163 void CLuaEventForwarder::onTargetInstanceErased(const std::string &refMakerAttr, sint32 refMakerAttrIndex)
165 //H_AUTO(R2_CLuaEventForwarder_onTargetInstanceErased)
166 CLuaState *ls = getLua();
167 if (!ls) return;
168 ls->push(refMakerAttr);
169 ls->push((double) refMakerAttrIndex);
170 executeHandler(LuaStr_onTargetInstanceErased, 2);
173 // *********************************************************************************************************
174 void CLuaEventForwarder::onTargetInstanceEraseRequested(const std::string &refMakerAttr, sint32 refMakerAttrIndex)
176 //H_AUTO(R2_CLuaEventForwarder_onTargetInstanceEraseRequested)
177 CLuaState *ls = getLua();
178 if (!ls) return;
179 ls->push(refMakerAttr);
180 ls->push((double) refMakerAttrIndex);
181 executeHandler(LuaStr_onTargetInstanceEraseRequested, 2);
184 // *********************************************************************************************************
185 void CLuaEventForwarder::onTargetInstanceAttrModified(const std::string &refMakerAttr, sint32 refMakerAttrIndex, const std::string &targetAttrName, sint32 targetAttrIndex)
187 //H_AUTO(R2_CLuaEventForwarder_onTargetInstanceAttrModified)
188 CLuaState *ls = getLua();
189 if (!ls) return;
190 ls->push(refMakerAttr);
191 ls->push((double) refMakerAttrIndex);
192 ls->push(targetAttrName);
193 ls->push((double) targetAttrIndex);
194 executeHandler(LuaStr_onTargetInstanceAttrModified, 4);
197 // *********************************************************************************************************
198 void CLuaEventForwarder::onTargetInstancePreHrcMove(const std::string &refMakerAttr, sint32 refMakerAttrIndex)
200 //H_AUTO(R2_CLuaEventForwarder_onTargetInstancePreHrcMove)
201 CLuaState *ls = getLua();
202 if (!ls) return;
203 ls->push(refMakerAttr);
204 ls->push((double) refMakerAttrIndex);
205 executeHandler(LuaStr_onTargetInstancePreHrcMove, 2);
208 // *********************************************************************************************************
209 void CLuaEventForwarder::onTargetInstancePostHrcMove(const std::string &refMakerAttr, sint32 refMakerAttrIndex)
211 //H_AUTO(R2_CLuaEventForwarder_onTargetInstancePostHrcMove)
212 CLuaState *ls = getLua();
213 if (!ls) return;
214 ls->push(refMakerAttr);
215 ls->push((double) refMakerAttrIndex);
216 executeHandler(LuaStr_onTargetInstancePostHrcMove, 2);