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 <Gui/MainScreenHelper.h> 23 24 namespace spades { 25 class MainScreenHelperRegistrar: public ScriptObjectRegistrar { 26 27 28 public: MainScreenHelperRegistrar()29 MainScreenHelperRegistrar(): 30 ScriptObjectRegistrar("MainScreenHelper") {} 31 Register(ScriptManager * manager,Phase phase)32 virtual void Register(ScriptManager *manager, Phase phase) { 33 asIScriptEngine *eng = manager->GetEngine(); 34 int r; 35 eng->SetDefaultNamespace("spades"); 36 switch(phase){ 37 case PhaseObjectType: 38 r = eng->RegisterObjectType("MainScreenHelper", 39 0, asOBJ_REF); 40 manager->CheckError(r); 41 42 r = eng->RegisterObjectType("MainScreenServerItem", 43 0, asOBJ_REF); 44 manager->CheckError(r); 45 break; 46 case PhaseObjectMember: 47 r = eng->RegisterObjectBehaviour("MainScreenHelper", 48 asBEHAVE_ADDREF, 49 "void f()", 50 asMETHOD(gui::MainScreenHelper, AddRef), 51 asCALL_THISCALL); 52 manager->CheckError(r); 53 r = eng->RegisterObjectBehaviour("MainScreenHelper", 54 asBEHAVE_RELEASE, 55 "void f()", 56 asMETHOD(gui::MainScreenHelper, Release), 57 asCALL_THISCALL); 58 manager->CheckError(r); 59 r = eng->RegisterObjectMethod("MainScreenHelper", 60 "void StartQuery()", 61 asMETHOD(gui::MainScreenHelper, StartQuery), 62 asCALL_THISCALL); 63 manager->CheckError(r); 64 r = eng->RegisterObjectMethod("MainScreenHelper", 65 "bool SetServerFavorite(string, bool)", 66 asMETHOD(gui::MainScreenHelper, SetServerFavorite), 67 asCALL_THISCALL); 68 manager->CheckError(r); 69 r = eng->RegisterObjectMethod("MainScreenHelper", 70 "bool PollServerListState()", 71 asMETHOD(gui::MainScreenHelper, PollServerListState), 72 asCALL_THISCALL); 73 manager->CheckError(r); 74 r = eng->RegisterObjectMethod("MainScreenHelper", 75 "string GetServerListQueryMessage()", 76 asMETHOD(gui::MainScreenHelper, GetServerListQueryMessage), 77 asCALL_THISCALL); 78 manager->CheckError(r); 79 r = eng->RegisterObjectMethod("MainScreenHelper", 80 "array<spades::MainScreenServerItem@>@ GetServerList(string, bool)", 81 asMETHOD(gui::MainScreenHelper, GetServerList), 82 asCALL_THISCALL); 83 manager->CheckError(r); 84 r = eng->RegisterObjectMethod("MainScreenHelper", 85 "string ConnectServer(string, int)", 86 asMETHOD(gui::MainScreenHelper, ConnectServer), 87 asCALL_THISCALL); 88 manager->CheckError(r); 89 r = eng->RegisterObjectMethod("MainScreenHelper", 90 "string GetPendingErrorMessage()", 91 asMETHOD(gui::MainScreenHelper, GetPendingErrorMessage), 92 asCALL_THISCALL); 93 manager->CheckError(r); 94 r = eng->RegisterObjectMethod("MainScreenHelper", 95 "string get_Credits()", 96 asMETHOD(gui::MainScreenHelper, GetCredits), 97 asCALL_THISCALL); 98 manager->CheckError(r); 99 r = eng->RegisterObjectMethod("MainScreenHelper", 100 "PackageUpdateManager@ get_PackageUpdateManager()", 101 asMETHOD(gui::MainScreenHelper, GetPackageUpdateManager), 102 asCALL_THISCALL); 103 manager->CheckError(r); 104 105 106 r = eng->RegisterObjectBehaviour("MainScreenServerItem", 107 asBEHAVE_ADDREF, 108 "void f()", 109 asMETHOD(gui::MainScreenServerItem, AddRef), 110 asCALL_THISCALL); 111 manager->CheckError(r); 112 r = eng->RegisterObjectBehaviour("MainScreenServerItem", 113 asBEHAVE_RELEASE, 114 "void f()", 115 asMETHOD(gui::MainScreenServerItem, Release), 116 asCALL_THISCALL); 117 manager->CheckError(r); 118 r = eng->RegisterObjectMethod("MainScreenServerItem", 119 "string get_Name()", 120 asMETHOD(gui::MainScreenServerItem, GetName), 121 asCALL_THISCALL); 122 manager->CheckError(r); 123 r = eng->RegisterObjectMethod("MainScreenServerItem", 124 "string get_Address()", 125 asMETHOD(gui::MainScreenServerItem, GetAddress), 126 asCALL_THISCALL); 127 manager->CheckError(r); 128 r = eng->RegisterObjectMethod("MainScreenServerItem", 129 "string get_MapName()", 130 asMETHOD(gui::MainScreenServerItem, GetMapName), 131 asCALL_THISCALL); 132 manager->CheckError(r); 133 r = eng->RegisterObjectMethod("MainScreenServerItem", 134 "string get_GameMode()", 135 asMETHOD(gui::MainScreenServerItem, GetGameMode), 136 asCALL_THISCALL); 137 manager->CheckError(r); 138 r = eng->RegisterObjectMethod("MainScreenServerItem", 139 "string get_Country()", 140 asMETHOD(gui::MainScreenServerItem, GetCountry), 141 asCALL_THISCALL); 142 manager->CheckError(r); 143 r = eng->RegisterObjectMethod("MainScreenServerItem", 144 "string get_Protocol()", 145 asMETHOD(gui::MainScreenServerItem, GetProtocol), 146 asCALL_THISCALL); 147 manager->CheckError(r); 148 r = eng->RegisterObjectMethod("MainScreenServerItem", 149 "int get_Ping()", 150 asMETHOD(gui::MainScreenServerItem, GetPing), 151 asCALL_THISCALL); 152 manager->CheckError(r); 153 r = eng->RegisterObjectMethod("MainScreenServerItem", 154 "int get_NumPlayers()", 155 asMETHOD(gui::MainScreenServerItem, GetNumPlayers), 156 asCALL_THISCALL); 157 manager->CheckError(r); 158 r = eng->RegisterObjectMethod("MainScreenServerItem", 159 "int get_MaxPlayers()", 160 asMETHOD(gui::MainScreenServerItem, GetMaxPlayers), 161 asCALL_THISCALL); 162 manager->CheckError(r); 163 r = eng->RegisterObjectMethod("MainScreenServerItem", 164 "bool get_Favorite()", 165 asMETHOD(gui::MainScreenServerItem, IsFavorite), 166 asCALL_THISCALL); 167 manager->CheckError(r); 168 break; 169 default: 170 break; 171 } 172 } 173 }; 174 175 static MainScreenHelperRegistrar registrar; 176 } 177 178