// 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(); }
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()); } }
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(); }
void ClientUI::CloseUI() { SPADES_MARK_FUNCTION(); if(!ui){ return; } static ScriptFunction func("ClientUI", "void CloseUI()"); ScriptContextHandle c = func.Prepare(); c->SetObject(&*ui); c.ExecuteChecked(); }
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(); }
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; }
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()); }
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; }
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()); }
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(); }
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; }
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(); }
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(); }
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(); }
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(); }
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(); }
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; }
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(); }
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(); }
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(); }
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()); } }
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()); } }
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(); }
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(); }
// 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(); }