1 /*
2  Copyright (c) 2013 yvt
3 
4  This file is part of OpenSpades.
5 
6  OpenSpades is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OpenSpades is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OpenSpades.  If not, see <http://www.gnu.org/licenses/>.
18 
19  */
20 
21 #include "ScriptManager.h"
22 #include "IThirdPersonToolSkin.h"
23 #include <Core/Debug.h>
24 
25 namespace spades{
26 	namespace client {
ScriptIThirdPersonToolSkin(asIScriptObject * obj)27 		ScriptIThirdPersonToolSkin::ScriptIThirdPersonToolSkin(asIScriptObject *obj):
28 		obj(obj){}
29 
SetOriginMatrix(Matrix4 m)30 		void ScriptIThirdPersonToolSkin::SetOriginMatrix(Matrix4 m) {
31 			SPADES_MARK_FUNCTION_DEBUG();
32 			static ScriptFunction func("IThirdPersonToolSkin",
33 									   "void set_OriginMatrix(Matrix4)");
34 			ScriptContextHandle ctx = func.Prepare();
35 			int r;
36 			r = ctx->SetObject((void *)obj);
37 			ScriptManager::CheckError(r);
38 			r = ctx->SetArgObject(0, &m);
39 			ScriptManager::CheckError(r);
40 			ctx.ExecuteChecked();
41 		}
42 
GetPitchBias()43 		float ScriptIThirdPersonToolSkin::GetPitchBias() {
44 			SPADES_MARK_FUNCTION_DEBUG();
45 			static ScriptFunction func("IThirdPersonToolSkin",
46 									   "float get_PitchBias()");
47 			ScriptContextHandle ctx = func.Prepare();
48 			int r;
49 			r = ctx->SetObject((void *)obj);
50 			ScriptManager::CheckError(r);
51 			ctx.ExecuteChecked();
52 			return ctx->GetReturnFloat();
53 		}
54 
55 		class IThirdPersonToolSkinRegistrar: public ScriptObjectRegistrar {
56 		public:
IThirdPersonToolSkinRegistrar()57 			IThirdPersonToolSkinRegistrar():
58 			ScriptObjectRegistrar("IThirdPersonToolSkin"){
59 
60 			}
Register(ScriptManager * manager,Phase phase)61 			virtual void Register(ScriptManager *manager, Phase phase) {
62 				asIScriptEngine *eng = manager->GetEngine();
63 				int r;
64 				eng->SetDefaultNamespace("spades");
65 				switch(phase){
66 					case PhaseObjectType:
67 						r = eng->RegisterInterface("IThirdPersonToolSkin");
68 						manager->CheckError(r);
69 
70 
71 						break;
72 					case PhaseObjectMember:
73 						r = eng->RegisterInterfaceMethod("IThirdPersonToolSkin",
74 														 "void set_OriginMatrix(Matrix4)");
75 						manager->CheckError(r);
76 						r = eng->RegisterInterfaceMethod("IThirdPersonToolSkin",
77 														 "float get_PitchBias()");
78 						manager->CheckError(r);
79 						break;
80 					default:
81 
82 						break;
83 				}
84 			}
85 		};
86 
87 		static IThirdPersonToolSkinRegistrar registrar;
88 	}
89 }
90 
91