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 "IBlockSkin.h" 23 #include <Core/Debug.h> 24 25 namespace spades{ 26 namespace client { ScriptIBlockSkin(asIScriptObject * obj)27 ScriptIBlockSkin::ScriptIBlockSkin(asIScriptObject *obj): 28 obj(obj){} 29 SetReadyState(float v)30 void ScriptIBlockSkin::SetReadyState(float v) { 31 SPADES_MARK_FUNCTION_DEBUG(); 32 static ScriptFunction func("IBlockSkin", 33 "void set_ReadyState(float)"); 34 ScriptContextHandle ctx = func.Prepare(); 35 int r; 36 r = ctx->SetObject((void *)obj); 37 ScriptManager::CheckError(r); 38 r = ctx->SetArgFloat(0, v); 39 ScriptManager::CheckError(r); 40 ctx.ExecuteChecked(); 41 } 42 SetBlockColor(Vector3 v)43 void ScriptIBlockSkin::SetBlockColor(Vector3 v) { 44 SPADES_MARK_FUNCTION_DEBUG(); 45 static ScriptFunction func("IBlockSkin", 46 "void set_BlockColor(Vector3)"); 47 ScriptContextHandle ctx = func.Prepare(); 48 int r; 49 r = ctx->SetObject((void *)obj); 50 ScriptManager::CheckError(r); 51 r = ctx->SetArgObject(0, &v); 52 ScriptManager::CheckError(r); 53 ctx.ExecuteChecked(); 54 } 55 56 class IBlockSkinRegistrar: public ScriptObjectRegistrar { 57 public: IBlockSkinRegistrar()58 IBlockSkinRegistrar(): 59 ScriptObjectRegistrar("IBlockSkin"){ 60 61 } Register(ScriptManager * manager,Phase phase)62 virtual void Register(ScriptManager *manager, Phase phase) { 63 asIScriptEngine *eng = manager->GetEngine(); 64 int r; 65 eng->SetDefaultNamespace("spades"); 66 switch(phase){ 67 case PhaseObjectType: 68 r = eng->RegisterInterface("IBlockSkin"); 69 manager->CheckError(r); 70 break; 71 case PhaseObjectMember: 72 r = eng->RegisterInterfaceMethod("IBlockSkin", 73 "void set_ReadyState(float)"); 74 manager->CheckError(r); 75 r = eng->RegisterInterfaceMethod("IBlockSkin", 76 "void set_BlockColor(Vector3)"); 77 manager->CheckError(r); 78 break; 79 default: 80 81 break; 82 } 83 } 84 }; 85 86 static IBlockSkinRegistrar registrar; 87 } 88 } 89 90