Esempio n. 1
0
		// Restores renderer's state (game map, fog color)
		// after returning from the game client.
		void StartupScreen::RestoreRenderer() {
			ScopedPrivilegeEscalation privilege;
			static ScriptFunction func("StartupScreenUI", "void SetupRenderer()");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c.ExecuteChecked();
		}
Esempio n. 2
0
		ClientUI::ClientUI(client::IRenderer *r, client::IAudioDevice *a, IFont *font, Client *client) :
		renderer(r),
		audioDevice(a),
		font(font),client(client){
			SPADES_MARK_FUNCTION();
			if(r == NULL)
				SPInvalidArgument("r");
			if(a == NULL)
				SPInvalidArgument("a");
			
			helper.Set(new ClientUIHelper(this), false);
			
			static ScriptFunction uiFactory("ClientUI@ CreateClientUI(Renderer@, AudioDevice@, Font@, ClientUIHelper@)");
			{
				ScriptContextHandle ctx = uiFactory.Prepare();
				ctx->SetArgObject(0, renderer);
				ctx->SetArgObject(1, audioDevice);
				ctx->SetArgObject(2, font);
				ctx->SetArgObject(3, &*helper);
				
				ctx.ExecuteChecked();
				ui = reinterpret_cast<asIScriptObject *>(ctx->GetReturnObject());
			}
			
		}
Esempio n. 3
0
		void ClientUI::RunFrame(float dt) {
			SPADES_MARK_FUNCTION();
			static ScriptFunction func("ClientUI", "void RunFrame(float)");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c->SetArgFloat(0, dt);
			c.ExecuteChecked();
		}
Esempio n. 4
0
		void ClientUI::CloseUI() {
			SPADES_MARK_FUNCTION();
			if(!ui){
				return;
			}
			static ScriptFunction func("ClientUI", "void CloseUI()");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c.ExecuteChecked();
		}
Esempio n. 5
0
		void StartupScreen::RunFrame(float dt) {
			SPADES_MARK_FUNCTION();

			ScopedPrivilegeEscalation privilege;
			static ScriptFunction func("StartupScreenUI", "void RunFrame(float)");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c->SetArgFloat(0, dt);
			c.ExecuteChecked();
		}
Esempio n. 6
0
		bool ClientUI::NeedsInput() {
			SPADES_MARK_FUNCTION();
			if(!ui){
				return false;
			}
			static ScriptFunction func("ClientUI", "bool NeedsInput()");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c.ExecuteChecked();
			return c->GetReturnByte() != 0;
		}
Esempio n. 7
0
		AABB2 ClientUI::GetTextInputRect() {
			SPADES_MARK_FUNCTION();
			if(!ui){
				return AABB2();
			}
			static ScriptFunction func("ClientUI", "AABB2 GetTextInputRect()");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c.ExecuteChecked();
			return *reinterpret_cast<AABB2*>(c->GetReturnObject());
		}
Esempio n. 8
0
		bool MainScreen::WantsToBeClosed() {
			SPADES_MARK_FUNCTION();
			if(!ui){
				return false;
			}
			static ScriptFunction func("MainScreenUI", "bool WantsToBeClosed()");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c.ExecuteChecked();
			return c->GetReturnByte() != 0;
		}
Esempio n. 9
0
		AABB2 StartupScreen::GetTextInputRect() {
			SPADES_MARK_FUNCTION();
			if (!ui) {
				return AABB2();
			}
			ScopedPrivilegeEscalation privilege;
			static ScriptFunction func("StartupScreenUI", "AABB2 GetTextInputRect()");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c.ExecuteChecked();
			return *reinterpret_cast<AABB2 *>(c->GetReturnObject());
		}
Esempio n. 10
0
		void StartupScreen::Closing() {
			SPADES_MARK_FUNCTION();

			if (!ui) {
				return;
			}
			ScopedPrivilegeEscalation privilege;
			static ScriptFunction func("StartupScreenUI", "void Closing()");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c.ExecuteChecked();
		}
Esempio n. 11
0
		bool StartupScreen::WantsToBeClosed() {
			SPADES_MARK_FUNCTION();
			if (!ui) {
				return false;
			}
			ScopedPrivilegeEscalation privilege;
			static ScriptFunction func("StartupScreenUI", "bool WantsToBeClosed()");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c.ExecuteChecked();
			return c->GetReturnByte() != 0;
		}
Esempio n. 12
0
		void ClientUI::TextInputEvent(const std::string &ch) {
			SPADES_MARK_FUNCTION();
			if(!ui){
				return;
			}
			static ScriptFunction func("ClientUI", "void TextInputEvent(string)");
			ScriptContextHandle c = func.Prepare();
			std::string k = ch;
			c->SetObject(&*ui);
			c->SetArgObject(0, reinterpret_cast<void*>(&k));
			c.ExecuteChecked();
		}
Esempio n. 13
0
		void ClientUI::KeyEvent(const std::string & key, bool down) {
			SPADES_MARK_FUNCTION();
			if(!ui){
				return;
			}
			static ScriptFunction func("ClientUI", "void KeyEvent(string, bool)");
			ScriptContextHandle c = func.Prepare();
			std::string k = key;
			c->SetObject(&*ui);
			c->SetArgObject(0, reinterpret_cast<void*>(&k));
			c->SetArgByte(1, down ? 1 : 0);
			c.ExecuteChecked();
		}
Esempio n. 14
0
		void StartupScreen::TextInputEvent(const std::string &ch) {
			SPADES_MARK_FUNCTION();
			if (!ui) {
				return;
			}
			ScopedPrivilegeEscalation privilege;
			static ScriptFunction func("StartupScreenUI", "void TextInputEvent(string)");
			ScriptContextHandle c = func.Prepare();
			std::string k = ch;
			c->SetObject(&*ui);
			c->SetArgObject(0, reinterpret_cast<void *>(&k));
			c.ExecuteChecked();
		}
Esempio n. 15
0
		void ClientUI::WheelEvent(float x, float y) {
			SPADES_MARK_FUNCTION();
			if(!ui){
				return;
			}
			
			static ScriptFunction func("ClientUI", "void WheelEvent(float, float)");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c->SetArgFloat(0, x);
			c->SetArgFloat(1, y);
			c.ExecuteChecked();
		}
Esempio n. 16
0
		void ClientUI::RecordChatLog(const std::string &msg,
									 Vector4 color) {
			SPADES_MARK_FUNCTION();
			if(!ui){
				return;
			}
			static ScriptFunction func("ClientUI", "void RecordChatLog(string, Vector4)");
			ScriptContextHandle c = func.Prepare();
			std::string k = msg;
			c->SetObject(&*ui);
			c->SetArgObject(0, reinterpret_cast<void*>(&k));
			c->SetArgObject(1, reinterpret_cast<void*>(&color));
			c.ExecuteChecked();
		}
Esempio n. 17
0
		bool MainScreen::AcceptsTextInput() {
			SPADES_MARK_FUNCTION();
			if(subview){
				return subview->AcceptsTextInput();
			}
			if(!ui){
				return false;
			}
			static ScriptFunction func("MainScreenUI", "bool AcceptsTextInput()");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c.ExecuteChecked();
			return c->GetReturnByte() != 0;
		}
Esempio n. 18
0
		void StartupScreen::WheelEvent(float x, float y) {
			SPADES_MARK_FUNCTION();
			if (!ui) {
				return;
			}

			ScopedPrivilegeEscalation privilege;
			static ScriptFunction func("StartupScreenUI", "void WheelEvent(float, float)");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c->SetArgFloat(0, x);
			c->SetArgFloat(1, y);
			c.ExecuteChecked();
		}
Esempio n. 19
0
		void ClientUI::TextEditingEvent(const std::string &ch,
										int start, int len) {
			SPADES_MARK_FUNCTION();
			if(!ui){
				return;
			}
			static ScriptFunction func("ClientUI", "void TextEditingEvent(string,int,int)");
			ScriptContextHandle c = func.Prepare();
			std::string k = ch;
			c->SetObject(&*ui);
			c->SetArgObject(0, reinterpret_cast<void*>(&k));
			c->SetArgDWord(1, static_cast<asDWORD>(start));
			c->SetArgDWord(2, static_cast<asDWORD>(len));
			c.ExecuteChecked();
		}
Esempio n. 20
0
		void MainScreen::Closing() {
			SPADES_MARK_FUNCTION();
			if(subview){
				subview->Closing();
				subview = NULL;
			}
			
			if(!ui){
				return;
			}
			static ScriptFunction func("MainScreenUI", "void Closing()");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c.ExecuteChecked();
		}
Esempio n. 21
0
		void MainScreen::DoInit() {
			SPADES_MARK_FUNCTION();
			renderer->Init();
			
			static ScriptFunction uiFactory("MainScreenUI@ CreateMainScreenUI(Renderer@, AudioDevice@, Font@, MainScreenHelper@)");
			{
				ScriptContextHandle ctx = uiFactory.Prepare();
				ctx->SetArgObject(0, renderer);
				ctx->SetArgObject(1, audioDevice);
				ctx->SetArgObject(2, font);
				ctx->SetArgObject(3, &*helper);
				
				ctx.ExecuteChecked();
				ui = reinterpret_cast<asIScriptObject *>(ctx->GetReturnObject());
			}

		}
Esempio n. 22
0
		void StartupScreen::DoInit() {
			SPADES_MARK_FUNCTION();

			ScopedPrivilegeEscalation privilege;
			static ScriptFunction uiFactory("StartupScreenUI@ CreateStartupScreenUI(Renderer@, "
			                                "AudioDevice@, FontManager@, StartupScreenHelper@)");
			{
				ScriptContextHandle ctx = uiFactory.Prepare();
				ctx->SetArgObject(0, renderer);
				ctx->SetArgObject(1, audioDevice);
				ctx->SetArgObject(2, fontManager);
				ctx->SetArgObject(3, &*helper);

				ctx.ExecuteChecked();
				ui = reinterpret_cast<asIScriptObject *>(ctx->GetReturnObject());
			}
		}
Esempio n. 23
0
		void MainScreen::WheelEvent(float x, float y) {
			SPADES_MARK_FUNCTION();
			if(subview){
				subview->WheelEvent(x, y);
				return;
			}
			if(!ui){
				return;
			}
			
			static ScriptFunction func("MainScreenUI", "void WheelEvent(float, float)");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c->SetArgFloat(0, x);
			c->SetArgFloat(1, y);
			c.ExecuteChecked();
		}
Esempio n. 24
0
		void MainScreen::RunFrame(float dt) {
			SPADES_MARK_FUNCTION();
			if(subview){
				try{
					subview->RunFrame(dt);
					if(subview->WantsToBeClosed()) {
						subview->Closing();
						subview = NULL;
						RestoreRenderer();
					}else{
						return;
					}
				}catch(const std::exception& ex) {
					SPLog("[!] Error while running a game client: %s", ex.what());
					subview->Closing();
					subview = NULL;
					RestoreRenderer();
					helper->errorMessage = ex.what();
				}
			}
			if(timeToStartInitialization > 100.f){
				timeToStartInitialization = 0.2f;
			}
			if(timeToStartInitialization > 0.f){
				DrawStartupScreen();
				timeToStartInitialization -= dt;
				if(timeToStartInitialization <= 0.f){
					// do init
					DoInit();
				}
				return;
			}
			
			static ScriptFunction func("MainScreenUI", "void RunFrame(float)");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c->SetArgFloat(0, dt);
			c.ExecuteChecked();
		}
Esempio n. 25
0
		// Restores renderer's state (game map, fog color)
		// after returning from the game client.
		void MainScreen::RestoreRenderer() {
			static ScriptFunction func("MainScreenUI", "void SetupRenderer()");
			ScriptContextHandle c = func.Prepare();
			c->SetObject(&*ui);
			c.ExecuteChecked();
		}