diff --git a/assets/Textures/GUI/Loading.png b/assets/Textures/GUI/Loading.png new file mode 100644 index 0000000..870bee9 Binary files /dev/null and b/assets/Textures/GUI/Loading.png differ diff --git a/assets/Textures/GUI/Spacebar.png b/assets/Textures/GUI/Spacebar.png new file mode 100644 index 0000000..5f37a49 Binary files /dev/null and b/assets/Textures/GUI/Spacebar.png differ diff --git a/assets/Textures/GUI/SpacebarSkip.png b/assets/Textures/GUI/SpacebarSkip.png new file mode 100644 index 0000000..b0e96fe Binary files /dev/null and b/assets/Textures/GUI/SpacebarSkip.png differ diff --git a/assets/Textures/Story/Black.png b/assets/Textures/Story/Black.png new file mode 100644 index 0000000..c49ef04 Binary files /dev/null and b/assets/Textures/Story/Black.png differ diff --git a/assets/Textures/Story/Brunn1.png b/assets/Textures/Story/Brunn1.png new file mode 100644 index 0000000..aec0013 Binary files /dev/null and b/assets/Textures/Story/Brunn1.png differ diff --git a/assets/Textures/Story/Brunn2.png b/assets/Textures/Story/Brunn2.png new file mode 100644 index 0000000..031fedc Binary files /dev/null and b/assets/Textures/Story/Brunn2.png differ diff --git a/assets/Textures/Story/Brunn3.png b/assets/Textures/Story/Brunn3.png new file mode 100644 index 0000000..f6a0e7d Binary files /dev/null and b/assets/Textures/Story/Brunn3.png differ diff --git a/assets/Textures/Story/Brunn4.png b/assets/Textures/Story/Brunn4.png new file mode 100644 index 0000000..aec0013 Binary files /dev/null and b/assets/Textures/Story/Brunn4.png differ diff --git a/assets/Textures/Story/Brunn5.png b/assets/Textures/Story/Brunn5.png new file mode 100644 index 0000000..e497b78 Binary files /dev/null and b/assets/Textures/Story/Brunn5.png differ diff --git a/assets/Textures/Story/SubScene1.png b/assets/Textures/Story/SubScene1.png new file mode 100644 index 0000000..ce2d4d1 Binary files /dev/null and b/assets/Textures/Story/SubScene1.png differ diff --git a/assets/Textures/Story/SubScene10.png b/assets/Textures/Story/SubScene10.png new file mode 100644 index 0000000..8aee473 Binary files /dev/null and b/assets/Textures/Story/SubScene10.png differ diff --git a/assets/Textures/Story/SubScene11.png b/assets/Textures/Story/SubScene11.png new file mode 100644 index 0000000..885e850 Binary files /dev/null and b/assets/Textures/Story/SubScene11.png differ diff --git a/assets/Textures/Story/SubScene12.png b/assets/Textures/Story/SubScene12.png new file mode 100644 index 0000000..ada64e4 Binary files /dev/null and b/assets/Textures/Story/SubScene12.png differ diff --git a/assets/Textures/Story/SubScene13.png b/assets/Textures/Story/SubScene13.png new file mode 100644 index 0000000..8248209 Binary files /dev/null and b/assets/Textures/Story/SubScene13.png differ diff --git a/assets/Textures/Story/SubScene14.png b/assets/Textures/Story/SubScene14.png new file mode 100644 index 0000000..ada64e4 Binary files /dev/null and b/assets/Textures/Story/SubScene14.png differ diff --git a/assets/Textures/Story/SubScene15.png b/assets/Textures/Story/SubScene15.png new file mode 100644 index 0000000..96fd295 Binary files /dev/null and b/assets/Textures/Story/SubScene15.png differ diff --git a/assets/Textures/Story/SubScene16.png b/assets/Textures/Story/SubScene16.png new file mode 100644 index 0000000..053c33d Binary files /dev/null and b/assets/Textures/Story/SubScene16.png differ diff --git a/assets/Textures/Story/SubScene17.png b/assets/Textures/Story/SubScene17.png new file mode 100644 index 0000000..433e941 Binary files /dev/null and b/assets/Textures/Story/SubScene17.png differ diff --git a/assets/Textures/Story/SubScene18.png b/assets/Textures/Story/SubScene18.png new file mode 100644 index 0000000..8d638a8 Binary files /dev/null and b/assets/Textures/Story/SubScene18.png differ diff --git a/assets/Textures/Story/SubScene19.png b/assets/Textures/Story/SubScene19.png new file mode 100644 index 0000000..671c390 Binary files /dev/null and b/assets/Textures/Story/SubScene19.png differ diff --git a/assets/Textures/Story/SubScene2.png b/assets/Textures/Story/SubScene2.png new file mode 100644 index 0000000..5ce68a8 Binary files /dev/null and b/assets/Textures/Story/SubScene2.png differ diff --git a/assets/Textures/Story/SubScene3.png b/assets/Textures/Story/SubScene3.png new file mode 100644 index 0000000..ce2d4d1 Binary files /dev/null and b/assets/Textures/Story/SubScene3.png differ diff --git a/assets/Textures/Story/SubScene4.png b/assets/Textures/Story/SubScene4.png new file mode 100644 index 0000000..675bd2d Binary files /dev/null and b/assets/Textures/Story/SubScene4.png differ diff --git a/assets/Textures/Story/SubScene5.png b/assets/Textures/Story/SubScene5.png new file mode 100644 index 0000000..70a609e Binary files /dev/null and b/assets/Textures/Story/SubScene5.png differ diff --git a/assets/Textures/Story/SubScene6.png b/assets/Textures/Story/SubScene6.png new file mode 100644 index 0000000..675bd2d Binary files /dev/null and b/assets/Textures/Story/SubScene6.png differ diff --git a/assets/Textures/Story/SubScene7.png b/assets/Textures/Story/SubScene7.png new file mode 100644 index 0000000..885e850 Binary files /dev/null and b/assets/Textures/Story/SubScene7.png differ diff --git a/assets/Textures/Story/SubScene8.png b/assets/Textures/Story/SubScene8.png new file mode 100644 index 0000000..8aee473 Binary files /dev/null and b/assets/Textures/Story/SubScene8.png differ diff --git a/assets/Textures/Story/SubScene9.png b/assets/Textures/Story/SubScene9.png new file mode 100644 index 0000000..2d47e68 Binary files /dev/null and b/assets/Textures/Story/SubScene9.png differ diff --git a/include/Game/GUI/MainMenuMain.h b/include/Game/GUI/MainMenuMain.h index 7c951b6..a033c3d 100644 --- a/include/Game/GUI/MainMenuMain.h +++ b/include/Game/GUI/MainMenuMain.h @@ -3,8 +3,7 @@ #include "GUI/TextureFrame.h" #include "GUI/Button.h" -#include "Game/EGameStart.h" -#include "Game/GUI/HUD.h" +#include "Game/GUI/Story1.h" namespace dd { @@ -57,10 +56,8 @@ private: virtual bool OnButtonRelease(const Events::ButtonRelease& event) { if (event.Button == m_SquidoutButton) { - Events::GameStart e; - EventBroker->Publish(e); m_Parent->Hide(); - auto hud = new GUI::HUD(BaseFrame, "HUD"); + auto story = new GUI::Story1(BaseFrame, "Story1"); } return true; diff --git a/include/Game/GUI/Story1.h b/include/Game/GUI/Story1.h index 89b39e2..ea6f463 100644 --- a/include/Game/GUI/Story1.h +++ b/include/Game/GUI/Story1.h @@ -5,6 +5,9 @@ #include "Game/GUI/StoryboardFrame.h" #include "Game/GUI/ELoadingFrameComplete.h" #include "Game/GUI/LoadingFrame.h" +#include "Game/EGameStart.h" +#include "Core/EKeyDown.h" +#include "Game/GUI/HUD.h" namespace dd { @@ -18,6 +21,41 @@ public: : StoryboardFrame(parent, name) { EVENT_SUBSCRIBE_MEMBER(m_ELoadingFrameComplete, &Story1::OnLoadingFrameComplete); + EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, &Story1::OnKeyDown); + + m_LoadingFrame = new GUI::LoadingFrame(this, "Story1LoadingFrame"); + m_LoadingFrame->SetTexture("Textures/GUI/Loading.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/Brunn1.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/Brunn2.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/Brunn3.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/Brunn4.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/Brunn5.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene1.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene2.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene3.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene4.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene5.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene6.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene7.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene8.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene9.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene10.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene11.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene12.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene13.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene14.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene15.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene16.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene17.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene18.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene19.png"); + m_LoadingFrame->Preload(); + + m_Spacebar = new TextureFrame(this, "ZZZSpacebar"); + m_Spacebar->SetTexture("Textures/GUI/SpacebarSkip.png"); + m_Spacebar->SetRight(Right() - 10); + m_Spacebar->SetBottom(Bottom() - 10); + m_Spacebar->DisableScissor(); Transition t; @@ -157,12 +195,42 @@ public: t.Texture = "Textures/Story/SubScene19.png"; AddTransition(t); } + + void Update(double dt) override + { + StoryboardFrame::Update(dt); + + if (m_Spacebar == nullptr) { + } + } + void OnComplete() override + { + m_Spacebar->Show(); + } + private: + GUI::LoadingFrame* m_LoadingFrame = nullptr; + TextureFrame* m_Spacebar = nullptr; + + EventRelay m_EKeyDown; + bool OnKeyDown(const Events::KeyDown& event) + { + if (event.KeyCode == GLFW_KEY_SPACE) { + m_LoadingFrame->CancelPreload(); + Events::GameStart e; + EventBroker->Publish(e); + Hide(); + auto hud = new GUI::HUD(BaseFrame, "HUD"); + } + return true; + } + EventRelay m_ELoadingFrameComplete; bool OnLoadingFrameComplete(const Events::LoadingFrameComplete& event) { if (event.FrameName == "Story1LoadingFrame") { event.Frame->Hide(); + m_Spacebar->Hide(); Play(); } return true; diff --git a/include/Game/GUI/StoryboardFrame.h b/include/Game/GUI/StoryboardFrame.h index ccf49c1..d5f2d0a 100644 --- a/include/Game/GUI/StoryboardFrame.h +++ b/include/Game/GUI/StoryboardFrame.h @@ -22,7 +22,9 @@ public: StoryboardFrame(Frame* parent, std::string name) : TextureFrame(parent, name) { + m_TextureFrame = new TextureFrame(this, "StoryboardFrameHelper"); + //m_TextureFrame->DisableScissor(); } @@ -33,44 +35,55 @@ public: void Play() { - m_Playing = 1; + m_Playing = true; + } + + void Skip() + { + m_Playing = false; + OnComplete(); } void Update(double dt) { - if (!m_Playing) { + if (Hidden()) { return; } - m_Time += (double)m_Playing * dt; + if (m_Playing) { + m_Time += dt; - if (m_NextIndex < m_Timeline.size()) { - if (m_Time >= m_Timeline.at(m_NextIndex).Time) { - m_CurrentIndex = m_NextIndex; - Transition& t = m_Timeline.at(m_CurrentIndex); + if (m_NextIndex < m_Timeline.size()) { + if (m_Time >= m_Timeline.at(m_NextIndex).Time) { + m_CurrentIndex = m_NextIndex; + Transition& t = m_Timeline.at(m_CurrentIndex); - m_TextureFrame->FadeToTexture(t.Texture, t.Duration); - //m_TextureFrame->SetTexture(t.Texture); - m_TextureFrame->SizeToTexture(); + m_TextureFrame->FadeToTexture(t.Texture, t.Duration); + //m_TextureFrame->SetTexture(t.Texture); + m_TextureFrame->SizeToTexture(); - if (m_StartRect == Rectangle()) { - m_StartRect = Rectangle(0, 0, m_TextureFrame->Width, m_TextureFrame->Height); - } else { - m_StartRect = m_TargetRect; + if (m_StartRect == Rectangle()) { + m_StartRect = Rectangle(0, 0, m_TextureFrame->Width, m_TextureFrame->Height); + } + else { + m_StartRect = m_TargetRect; + } + + double wScaleParent = Width / (double)m_TextureFrame->Width; + double wScale = m_TextureFrame->Width / (double)t.Viewport.Width; + LOG_DEBUG("wScale: %f", wScale); + double hScaleParent = Height / (double)m_TextureFrame->Height; + double hScale = m_TextureFrame->Height / (double)t.Viewport.Height; + LOG_DEBUG("hScale: %f", hScale); + m_TargetRect.X = -t.Viewport.X * wScale * wScaleParent; + m_TargetRect.Y = -t.Viewport.Y * hScale * hScaleParent; + m_TargetRect.Width = m_TextureFrame->Width * wScale * wScaleParent; + m_TargetRect.Height = m_TextureFrame->Height * hScale * hScaleParent; + + m_NextIndex++; } - - double wScaleParent = Width / (double)m_TextureFrame->Width; - double wScale = m_TextureFrame->Width / (double)t.Viewport.Width; - LOG_DEBUG("wScale: %f", wScale); - double hScaleParent = Height / (double)m_TextureFrame->Height; - double hScale = m_TextureFrame->Height / (double)t.Viewport.Height; - LOG_DEBUG("hScale: %f", hScale); - m_TargetRect.X = -t.Viewport.X * wScale * wScaleParent; - m_TargetRect.Y = -t.Viewport.Y * hScale * hScaleParent; - m_TargetRect.Width = m_TextureFrame->Width * wScale * wScaleParent; - m_TargetRect.Height = m_TextureFrame->Height * hScale * hScaleParent; - - m_NextIndex++; + } else { + OnComplete(); } } @@ -82,8 +95,13 @@ public: m_TextureFrame->Height = (int)easeSine(progress, m_StartRect.Height, (m_TargetRect.Height - m_StartRect.Height), 1.0); } -public: - int m_Playing = 0; + virtual void OnComplete() { } + +protected: + TextureFrame* m_TextureFrame = nullptr; + +private: + bool m_Playing = false; double m_Time = 0; int m_CurrentIndex = 0; int m_NextIndex = 0; @@ -91,8 +109,6 @@ public: Rectangle m_StartRect; Rectangle m_TargetRect; - TextureFrame* m_TextureFrame = nullptr; - double easeSine(double t, double b, double c, double d) { return -c / 2 * (glm::cos(glm::pi()*t / d) - 1) + b;