Skip to content

Commit

Permalink
🛣️ UI DEFINE
Browse files Browse the repository at this point in the history
  • Loading branch information
wobbier committed Feb 3, 2024
1 parent eaef678 commit f068364
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Engine
Submodule Engine updated 107 files
7 changes: 7 additions & 0 deletions Game/Source/Components/GameUIView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ GameUIView::GameUIView()
FilePath = Path("Assets/UI/GameUI.html");
}

#if USING( ME_UI )
void GameUIView::OnUILoad(ultralight::JSObject& GlobalWindow, ultralight::View* Caller)
{
GlobalWindow["GetScore"] = BindJSCallback(&GameUIView::GetScore);
Expand All @@ -17,10 +18,13 @@ void GameUIView::GetScore(const ultralight::JSObject& thisObject, const ultralig
{
//UpdateScore(Score);
}
#endif

void GameUIView::UpdateScore(unsigned int NewScore)
{
Score = NewScore;

#if USING( ME_UI )
ExecuteScript("document.getElementById('Score').innerHTML='" + ((Score == 0) ? "HEAP" : std::to_string(Score)) + "';");
if (Score == 0)
{
Expand All @@ -30,11 +34,14 @@ void GameUIView::UpdateScore(unsigned int NewScore)
{
ExecuteScript("document.getElementById('SpaceToPlay').style.display = 'none';");
}
#endif
}

void GameUIView::SetMessage(const std::string& NewMessage)
{
#if USING( ME_UI )
ExecuteScript("document.getElementById('Score').innerHTML='" + NewMessage + "';");
#endif
}

#if USING( ME_EDITOR )
Expand Down
6 changes: 5 additions & 1 deletion Game/Source/Components/GameUIView.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class GameUIView
public:
GameUIView();

#if USING( ME_UI )
virtual void OnUILoad(ultralight::JSObject& GlobalWindow, ultralight::View* Caller) final;
#endif

void UpdateScore(unsigned int NewScore);
void SetMessage(const std::string& NewMessage);
Expand All @@ -19,8 +21,10 @@ class GameUIView
#endif

private:
int Score = 0;
int Score = 0;
#if USING( ME_UI )
virtual void GetScore(const ultralight::JSObject& thisObject, const ultralight::JSArgs& args) final;
#endif
};

ME_REGISTER_COMPONENT(GameUIView)
2 changes: 2 additions & 0 deletions Game/Source/Components/IntroUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ IntroUI::IntroUI()
FilePath = Path("Assets/UI/IntroUI.html");
}

#if USING( ME_UI )
void IntroUI::OnUILoad(ultralight::JSObject& GlobalWindow, ultralight::View* Caller)
{
GlobalWindow["LoadGame"] = BindJSCallback(&IntroUI::LoadGame);
Expand All @@ -26,6 +27,7 @@ void IntroUI::LoadGame(const ultralight::JSObject& thisObject, const ultralight:
evt.Level = news;
evt.Fire();
}
#endif

#if USING( ME_EDITOR )

Expand Down
7 changes: 6 additions & 1 deletion Game/Source/Components/IntroUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@ class IntroUI
public:
IntroUI();

#if USING( ME_UI )

virtual void OnUILoad(ultralight::JSObject& GlobalWindow, ultralight::View* Caller) final;
#endif

#if USING( ME_EDITOR )
virtual void OnEditorInspect() override;
#endif

private:
int Score = 0;
int Score = 0;
#if USING( ME_UI )
virtual void LoadGame(const ultralight::JSObject& thisObject, const ultralight::JSArgs& args) final;
#endif
};

ME_REGISTER_COMPONENT(IntroUI)
Expand Down

0 comments on commit f068364

Please sign in to comment.