1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "tool_choose_pos_lua.h"
22 #include "nel/misc/vectord.h"
28 using namespace NLPACS
;
29 using namespace NLMISC
;
34 // ***************************************************************
35 CToolChoosePosLua::CToolChoosePosLua(uint ghostSlot
,
36 const CLuaObject
&validFunc
,
37 const CLuaObject
&cancelFunc
,
38 const std::string
&toolName
,
39 const std::string
&cursValid
,
40 const std::string
&cursInvalid
,
41 const std::vector
<CPolygon2D
> &polyList
,
42 const CPrimLook
&polyValidLook
,
43 const CPrimLook
&polyInvalidLook
44 ) : CToolChoosePos(ghostSlot
,
53 _ValidFunc
= validFunc
;
54 _CancelFunc
= cancelFunc
;
58 // ***************************************************************
59 void CToolChoosePosLua::commit(const NLMISC::CVector
&createPosition
, float /* createAngle */)
61 //H_AUTO(R2_CToolChoosePosLua_commit)
63 if (_ValidFunc
.isFunction())
65 CLuaState
&lua
= *_ValidFunc
.getLuaState();
66 lua
.push(createPosition
.x
);
67 lua
.push(createPosition
.y
);
68 lua
.push(createPosition
.z
);
69 _ValidFunc
.callNoThrow(3, 0);
74 // *********************************************************************************************************
75 void CToolChoosePosLua::cancel()
77 //H_AUTO(R2_CToolChoosePosLua_cancel)
78 if (_Commited
) return;
79 if (_CancelFunc
.isFunction())
81 _CancelFunc
.callNoThrow(0, 0);