Complete main menu without event bindings.
This commit is contained in:
+3
-24
@@ -54,6 +54,7 @@
|
||||
|
||||
#include "GUI/Frame.h"
|
||||
#include "GUI/Button.h"
|
||||
#include "Game/MainMenu.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -73,24 +74,7 @@ public:
|
||||
m_FrameStack = new GUI::Frame(m_EventBroker.get());
|
||||
m_FrameStack->Width = 1920;
|
||||
m_FrameStack->Height = 1080;
|
||||
{
|
||||
auto button = new GUI::Button(m_FrameStack, "SuperButt");
|
||||
button->TextureReleased = "Textures/Test/TestBrick_Specular.png";
|
||||
button->TexturePressed = "Textures/Test/TestBrick_Normal.png";
|
||||
button->TextureHover = "Textures/Test/TestBrick_Diffuse.png";
|
||||
button->X = 50;
|
||||
button->Y = 75;
|
||||
button->Width = 100;
|
||||
button->Height = 25;
|
||||
}
|
||||
{
|
||||
auto button = new GUI::TextureFrame(m_FrameStack, "BALLZ");
|
||||
button->SetTexture("Textures/Ball.png");
|
||||
button->X = 50;
|
||||
button->Y = 75;
|
||||
button->Width = 100;
|
||||
button->Height = 100;
|
||||
}
|
||||
auto menu = new GUI::MainMenu(m_FrameStack, "MainMenu");
|
||||
|
||||
m_InputManager = std::make_shared<InputManager>(m_Renderer->Window(), m_EventBroker);
|
||||
|
||||
@@ -265,7 +249,7 @@ public:
|
||||
// Update input
|
||||
m_InputManager->Update(dt);
|
||||
// Swap event queues to get fresh input data in the read queue
|
||||
m_EventBroker->Swap();
|
||||
//m_EventBroker->Swap();
|
||||
|
||||
ResourceManager::Update();
|
||||
|
||||
@@ -273,11 +257,6 @@ public:
|
||||
m_EventBroker->Process<GUI::Frame>();
|
||||
m_FrameStack->UpdateLayered(dt);
|
||||
|
||||
//
|
||||
// if (glfwGetKey(m_Renderer->Window(), GLFW_KEY_R)) {
|
||||
// ResourceManager::Reload("Shaders/Deferred/3/Fragment.glsl");
|
||||
// }
|
||||
|
||||
if (glfwGetKey(m_Renderer->Window(), GLFW_KEY_R)) {
|
||||
ResourceManager::Reload("Shaders/Deferred/3/Fragment.glsl");
|
||||
}
|
||||
|
||||
@@ -33,9 +33,6 @@ class PNG : public Image
|
||||
public:
|
||||
PNG(std::string path);
|
||||
~PNG();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ struct FrameJob : SpriteJob
|
||||
{
|
||||
Rectangle Scissor;
|
||||
Rectangle Viewport;
|
||||
std::string Name;
|
||||
|
||||
void CalculateHash() override
|
||||
{
|
||||
@@ -136,7 +137,7 @@ public:
|
||||
void Add(T &job)
|
||||
{
|
||||
job.CalculateHash();
|
||||
Jobs.push_front(std::shared_ptr<T>(new T(job)));
|
||||
Jobs.push_back(std::shared_ptr<T>(new T(job)));
|
||||
}
|
||||
|
||||
void Sort()
|
||||
@@ -149,17 +150,17 @@ public:
|
||||
Jobs.clear();
|
||||
}
|
||||
|
||||
std::forward_list<std::shared_ptr<RenderJob>>::const_iterator begin()
|
||||
std::list<std::shared_ptr<RenderJob>>::const_iterator begin()
|
||||
{
|
||||
return Jobs.begin();
|
||||
}
|
||||
|
||||
std::forward_list<std::shared_ptr<RenderJob>>::const_iterator end()
|
||||
std::list<std::shared_ptr<RenderJob>>::const_iterator end()
|
||||
{
|
||||
return Jobs.end();
|
||||
}
|
||||
|
||||
std::forward_list<std::shared_ptr<RenderJob>> Jobs;
|
||||
std::list<std::shared_ptr<RenderJob>> Jobs;
|
||||
};
|
||||
|
||||
struct RenderQueueCollection
|
||||
|
||||
@@ -43,6 +43,9 @@ public:
|
||||
|
||||
operator GLuint() const { return m_Texture; }
|
||||
|
||||
unsigned int Width = 0;
|
||||
unsigned int Height = 0;
|
||||
|
||||
private:
|
||||
GLuint m_Texture = 0;
|
||||
};
|
||||
|
||||
@@ -44,24 +44,24 @@ struct Rectangle
|
||||
int Height;
|
||||
|
||||
virtual int Left() const { return X; }
|
||||
void SetLeft(int left)
|
||||
virtual void SetLeft(int left)
|
||||
{
|
||||
Width += X - left;
|
||||
//Width += X - left;
|
||||
X = left;
|
||||
}
|
||||
virtual int Right() const { return X + Width; }
|
||||
void SetRight(int right)
|
||||
virtual void SetRight(int right)
|
||||
{
|
||||
Width = right - X;
|
||||
}
|
||||
virtual int Top() const { return Y; }
|
||||
void SetTop(int top)
|
||||
virtual void SetTop(int top)
|
||||
{
|
||||
Height += Y - top;
|
||||
//Height += Y - top;
|
||||
Y = top;
|
||||
}
|
||||
virtual int Bottom() const { return Y + Height; }
|
||||
int SetBottom(int bottom)
|
||||
virtual void SetBottom(int bottom)
|
||||
{
|
||||
Height = bottom - Y;
|
||||
}
|
||||
|
||||
+62
-17
@@ -2,6 +2,10 @@
|
||||
#define GUI_BUTTON_H__
|
||||
|
||||
#include "GUI/TextureFrame.h"
|
||||
#include "GUI/EButtonEnter.h"
|
||||
#include "GUI/EButtonLeave.h"
|
||||
#include "GUI/EButtonPress.h"
|
||||
#include "GUI/EButtonRelease.h"
|
||||
#include "Core/EMouseMove.h"
|
||||
#include "Core/EMousePress.h"
|
||||
#include "Core/EMouseRelease.h"
|
||||
@@ -22,19 +26,34 @@ public:
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMouseRelease, &Button::OnMouseRelease);
|
||||
}
|
||||
|
||||
std::string TextureHover;
|
||||
std::string TexturePressed;
|
||||
std::string TextureReleased;
|
||||
void SetTextureHover(std::string resourceName)
|
||||
{
|
||||
m_TextureHover = resourceName;
|
||||
}
|
||||
void SetTextureReleased(std::string resourceName)
|
||||
{
|
||||
m_TextureReleased = resourceName;
|
||||
SetTexture(resourceName);
|
||||
}
|
||||
void SetTexturePressed(std::string resourceName)
|
||||
{
|
||||
m_TexturePressed = resourceName;
|
||||
}
|
||||
|
||||
void Draw(RenderQueueCollection& rq) override
|
||||
{
|
||||
if (m_Texture == nullptr && !TextureReleased.empty()) {
|
||||
SetTexture(TextureReleased);
|
||||
if (m_Texture == nullptr && !m_TextureReleased.empty()) {
|
||||
SetTexture(m_TextureReleased);
|
||||
}
|
||||
|
||||
TextureFrame::Draw(rq);
|
||||
}
|
||||
|
||||
virtual void OnEnter() { }
|
||||
virtual void OnLeave() { }
|
||||
virtual void OnPress() { }
|
||||
virtual void OnRelease() { }
|
||||
|
||||
protected:
|
||||
bool m_MouseIsOver = false;
|
||||
bool m_IsDown = false;
|
||||
@@ -43,15 +62,25 @@ protected:
|
||||
{
|
||||
bool isOver = Rectangle::Intersects(AbsoluteRectangle(), Rectangle(event.X, event.Y, 1, 1));
|
||||
if (isOver && !m_MouseIsOver) { // Enter
|
||||
LOG_INFO("%s mouse enter", m_Name.c_str());
|
||||
if (!m_IsDown) {
|
||||
SetTexture(TextureHover);
|
||||
if (!m_TextureHover.empty()) {
|
||||
SetTexture(m_TextureHover);
|
||||
}
|
||||
}
|
||||
OnEnter();
|
||||
Events::ButtonEnter e;
|
||||
e.FrameName = m_Name;
|
||||
EventBroker->Publish(e);
|
||||
} else if (!isOver && m_MouseIsOver) { // Leave
|
||||
LOG_INFO("%s mouse left", m_Name.c_str());
|
||||
if (!m_IsDown) {
|
||||
SetTexture(TextureReleased);
|
||||
if (!m_TextureReleased.empty()) {
|
||||
SetTexture(m_TextureReleased);
|
||||
}
|
||||
}
|
||||
OnLeave();
|
||||
Events::ButtonLeave e;
|
||||
e.FrameName = m_Name;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
m_MouseIsOver = isOver;
|
||||
|
||||
@@ -63,13 +92,16 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!TexturePressed.empty()) {
|
||||
SetTexture(TexturePressed);
|
||||
if (!m_TexturePressed.empty()) {
|
||||
SetTexture(m_TexturePressed);
|
||||
}
|
||||
|
||||
LOG_INFO("%s mouse pressed", m_Name.c_str());
|
||||
|
||||
m_IsDown = true;
|
||||
OnPress();
|
||||
Events::ButtonPress e;
|
||||
e.FrameName = m_Name;
|
||||
e.Button = this;
|
||||
EventBroker->Publish(e);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -80,13 +112,22 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!TextureReleased.empty()) {
|
||||
SetTexture(TextureReleased);
|
||||
if (m_MouseIsOver) {
|
||||
if (!m_TextureHover.empty()) {
|
||||
SetTexture(m_TextureHover);
|
||||
}
|
||||
} else {
|
||||
if (!m_TextureReleased.empty()) {
|
||||
SetTexture(m_TextureReleased);
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO("%s mouse released", m_Name.c_str());
|
||||
|
||||
m_IsDown = false;
|
||||
OnRelease();
|
||||
Events::ButtonRelease e;
|
||||
e.FrameName = m_Name;
|
||||
e.Button = this;
|
||||
EventBroker->Publish(e);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -95,6 +136,10 @@ private:
|
||||
EventRelay<Frame, Events::MouseMove> m_EMouseMove;
|
||||
EventRelay<Frame, Events::MousePress> m_EMousePress;
|
||||
EventRelay<Frame, Events::MouseRelease> m_EMouseRelease;
|
||||
|
||||
std::string m_TextureHover;
|
||||
std::string m_TexturePressed;
|
||||
std::string m_TextureReleased;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef Events_ButtonEnter_h__
|
||||
#define Events_ButtonEnter_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
/** Thrown on GUI button hover. */
|
||||
struct ButtonEnter : Event
|
||||
{
|
||||
std::string FrameName;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // Events_ButtonEnter_h__
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef Events_ButtonLeave_h__
|
||||
#define Events_ButtonLeave_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
/** Thrown on GUI button hover. */
|
||||
struct ButtonLeave : Event
|
||||
{
|
||||
std::string FrameName;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // Events_ButtonLeave_h__
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef Events_ButtonPress_h__
|
||||
#define Events_ButtonPress_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace GUI { class Button; }
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
/** Thrown on GUI button press. */
|
||||
struct ButtonPress : Event
|
||||
{
|
||||
std::string FrameName;
|
||||
GUI::Button* Button;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // Events_ButtonPress_h__
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef Events_ButtonRelease_h__
|
||||
#define Events_ButtonRelease_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace GUI { class Button; }
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
/** Thrown on GUI button release. */
|
||||
struct ButtonRelease : Event
|
||||
{
|
||||
std::string FrameName;
|
||||
GUI::Button* Button;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // Events_ButtonRelease_h__
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
This file is part of Daydream Engine.
|
||||
Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung
|
||||
|
||||
Daydream Engine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Daydream Engine is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with Daydream Engine. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef Events_SliderUpdate_h__
|
||||
#define Events_SliderUpdate_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace GUI { class Slider; }
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
/** Thrown when GUI slider is moved. */
|
||||
struct SliderUpdate : Event
|
||||
{
|
||||
std::string FrameName;
|
||||
GUI::Slider* Slider;
|
||||
float Percentage;
|
||||
float DeltaPercentage;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // Events_SliderUpdate_h__
|
||||
+34
-10
@@ -73,8 +73,6 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
Width = parent->Width;
|
||||
Height = parent->Height;
|
||||
m_Layer = parent->Layer() + 1;
|
||||
parent->AddChild(this);
|
||||
m_Parent = parent;
|
||||
@@ -128,12 +126,25 @@ public:
|
||||
else
|
||||
return X;
|
||||
}
|
||||
void SetLeft(int absLeft) override
|
||||
{
|
||||
if (m_Parent) {
|
||||
X = absLeft - m_Parent->Left();
|
||||
} else {
|
||||
X = absLeft;
|
||||
}
|
||||
}
|
||||
int Right() const override
|
||||
{
|
||||
if (m_Parent)
|
||||
return std::min(m_Parent->Right(), Left() + Width);
|
||||
else
|
||||
return Left() + Width;
|
||||
return Left() + Width;
|
||||
}
|
||||
void SetRight(int absRight) override
|
||||
{
|
||||
if (m_Parent) {
|
||||
X = absRight - Width - m_Parent->Left();
|
||||
} else {
|
||||
X = absRight - Width;
|
||||
}
|
||||
}
|
||||
int Top() const override
|
||||
{
|
||||
@@ -142,12 +153,25 @@ public:
|
||||
else
|
||||
return Y;
|
||||
}
|
||||
void SetTop(int absTop) override
|
||||
{
|
||||
if (m_Parent) {
|
||||
Y = absTop - m_Parent->Top();
|
||||
} else {
|
||||
Y = absTop;
|
||||
}
|
||||
}
|
||||
int Bottom() const override
|
||||
{
|
||||
if (m_Parent)
|
||||
return std::min(m_Parent->Bottom(), Top() + Height);
|
||||
else
|
||||
return Top() + Height;
|
||||
return Top() + Height;
|
||||
}
|
||||
void SetBottom(int absBottom) override
|
||||
{
|
||||
if (m_Parent) {
|
||||
Y = absBottom - Height - m_Parent->Top();
|
||||
} else {
|
||||
Y = absBottom - Height;
|
||||
}
|
||||
}
|
||||
|
||||
glm::vec2 Scale()
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
#ifndef GUI_GameFrame_h__
|
||||
#define GUI_GameFrame_h__
|
||||
|
||||
#include "GUI/Frame.h"
|
||||
#include "GUI/MainMenuFrame.h"
|
||||
#include "GUI/WorldFrame.h"
|
||||
#include "GUI/Viewport.h"
|
||||
#include "GUI/TextureFrame.h"
|
||||
#include "GUI/PlayerHUD.h"
|
||||
|
||||
#include "GameWorld.h"
|
||||
#include "Events/GameStart.h"
|
||||
#include "Events/GameOver.h"
|
||||
#include "Events/Dead.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
namespace GUI
|
||||
{
|
||||
|
||||
class GameFrame : public Frame
|
||||
{
|
||||
public:
|
||||
GameFrame(Frame* parent, std::string name)
|
||||
: Frame(parent, name)
|
||||
, m_GameOver(false)
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &GUI::GameFrame::OnGameStart);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &GUI::GameFrame::OnGameOver);
|
||||
|
||||
m_World = std::make_shared<GameWorld>(EventBroker, ResourceManager);
|
||||
m_WorldFrame = new WorldFrame(this, "GameWorldFrame", m_World);
|
||||
{
|
||||
vp1 = new Viewport(m_WorldFrame, "Viewport1", m_World);
|
||||
vp1->X = 0;
|
||||
vp1->Width = this->Width / 2.f;
|
||||
new PlayerHUD(vp1, "PlayerHUD", m_World, 1);
|
||||
|
||||
vp2 = new Viewport(m_WorldFrame, "Viewport2", m_World);
|
||||
vp2->X = vp1->Right();
|
||||
vp2->Width = this->Width / 2.f;
|
||||
new PlayerHUD(vp2, "PlayerHUD", m_World, 2);
|
||||
|
||||
m_FreeCamViewport = new Viewport(m_WorldFrame, "ViewportFreeCam", m_World);
|
||||
m_FreeCamViewport->Hide();
|
||||
}
|
||||
m_WorldFrame->Hide();
|
||||
m_World->Initialize();
|
||||
|
||||
m_MainMenuFrame = new MainMenuFrame(this, "MainMenu");
|
||||
}
|
||||
|
||||
private:
|
||||
EventRelay <Frame, Events::GameStart> m_EGameStart;
|
||||
|
||||
bool OnGameStart(const Events::GameStart& event)
|
||||
{
|
||||
m_WorldFrame->Show();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
EventRelay <Frame, Events::GameOver> m_EGameOver;
|
||||
|
||||
bool OnGameOver(const Events::GameOver& event)
|
||||
{
|
||||
m_GameOver = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<GameWorld> m_World;
|
||||
|
||||
MainMenuFrame* m_MainMenuFrame;
|
||||
WorldFrame* m_WorldFrame;
|
||||
Viewport* vp1;
|
||||
Viewport* vp2;
|
||||
Viewport* m_FreeCamViewport;
|
||||
|
||||
bool m_GameOver;
|
||||
|
||||
bool OnKeyUp(const Events::KeyUp& event) override
|
||||
{
|
||||
if (event.KeyCode == GLFW_KEY_1) {
|
||||
if (m_FreeCamViewport->Hidden())
|
||||
m_FreeCamViewport->Show();
|
||||
else
|
||||
m_FreeCamViewport->Hide();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GUI_GameFrame_h__
|
||||
@@ -0,0 +1,120 @@
|
||||
#ifndef GUI_SLIDER_H__
|
||||
#define GUI_SLIDER_H__
|
||||
|
||||
#include "GUI/TextureFrame.h"
|
||||
#include "GUI/Button.h"
|
||||
#include "GUI/EButtonPress.h"
|
||||
#include "GUI/EButtonRelease.h"
|
||||
#include "GUI/ESliderUpdate.h"
|
||||
#include "Core/EMouseMove.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
namespace GUI
|
||||
{
|
||||
|
||||
class Slider : public TextureFrame
|
||||
{
|
||||
public:
|
||||
Slider(Frame* parent, std::string name)
|
||||
: TextureFrame(parent, name)
|
||||
{
|
||||
m_SliderButton = new GUI::Button(this, "SliderButton");
|
||||
m_SliderButton->DisableScissor();
|
||||
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EButtonPress, &Slider::OnButtonPress);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EButtonRelease, &Slider::OnButtonRelease);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMouseMove, &Slider::OnMouseMove);
|
||||
}
|
||||
|
||||
float Percentage() const { return m_Percentage; }
|
||||
void SetPercentage(const float percentage) { m_Percentage = percentage; }
|
||||
|
||||
void SetTextureHover(std::string resourceName)
|
||||
{
|
||||
m_SliderButton->SetTextureHover(resourceName);
|
||||
}
|
||||
void SetTextureReleased(std::string resourceName)
|
||||
{
|
||||
m_SliderButton->SetTextureReleased(resourceName);
|
||||
}
|
||||
void SetTexturePressed(std::string resourceName)
|
||||
{
|
||||
m_SliderButton->SetTexturePressed(resourceName);
|
||||
}
|
||||
|
||||
void CenterSlider()
|
||||
{
|
||||
m_SliderButton->Y = (Height / 2) - (m_SliderButton->Height / 2);
|
||||
}
|
||||
|
||||
~Slider()
|
||||
{
|
||||
if (m_SliderButton != nullptr) {
|
||||
delete m_SliderButton;
|
||||
m_SliderButton = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Update(double dt) override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
Button* m_SliderButton = nullptr;
|
||||
bool m_IsGrabbed = false;
|
||||
float m_Percentage = 0.f;
|
||||
|
||||
EventRelay<Frame, Events::ButtonPress> m_EButtonPress;
|
||||
EventRelay<Frame, Events::ButtonRelease> m_EButtonRelease;
|
||||
EventRelay<Frame, Events::MouseMove> m_EMouseMove;
|
||||
|
||||
virtual bool OnButtonPress(const Events::ButtonPress& event)
|
||||
{
|
||||
if (event.Button == m_SliderButton) {
|
||||
m_IsGrabbed = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool OnButtonRelease(const Events::ButtonRelease& event)
|
||||
{
|
||||
if (event.Button == m_SliderButton) {
|
||||
m_IsGrabbed = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool OnMouseMove(const Events::MouseMove& event)
|
||||
{
|
||||
if (m_IsGrabbed) {
|
||||
// Set horizontal position
|
||||
m_SliderButton->X += event.DeltaX;
|
||||
if (m_SliderButton->Left() < Left()) {
|
||||
m_SliderButton->SetLeft(Left());
|
||||
} else if (m_SliderButton->Right() > Right()) {
|
||||
m_SliderButton->SetRight(Right());
|
||||
}
|
||||
|
||||
// Update percentage
|
||||
float newPercentage = m_SliderButton->X / (float)(Width - m_SliderButton->Width);
|
||||
Events::SliderUpdate e;
|
||||
e.FrameName = Name();
|
||||
e.Slider = this;
|
||||
e.Percentage = newPercentage;
|
||||
e.DeltaPercentage = newPercentage - m_Percentage;
|
||||
EventBroker->Publish(e);
|
||||
m_Percentage = newPercentage;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,9 @@ public:
|
||||
TextureFrame(Frame* parent, std::string name)
|
||||
: Frame(parent, name) { }
|
||||
|
||||
void EnableScissor() { m_ScissorEnabled = true; }
|
||||
void DisableScissor() { m_ScissorEnabled = false; }
|
||||
|
||||
void Draw(RenderQueueCollection& rq) override
|
||||
{
|
||||
if (m_Texture == nullptr)
|
||||
@@ -23,22 +26,24 @@ public:
|
||||
// Main texture
|
||||
{
|
||||
FrameJob job;
|
||||
job.Scissor = m_Parent->AbsoluteRectangle();
|
||||
job.Scissor = (m_ScissorEnabled) ? m_Parent->AbsoluteRectangle() : Rectangle();
|
||||
job.Viewport = Rectangle(Left(), Top(), Width, Height);
|
||||
job.TextureID = m_Texture->ResourceID;
|
||||
job.DiffuseTexture = *m_Texture;
|
||||
job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a * m_CurrentFade);
|
||||
job.Name = Name();
|
||||
rq.GUI.Add(job);
|
||||
}
|
||||
|
||||
// Texture while fading
|
||||
if (m_FadeTexture && m_CurrentFade < 1) {
|
||||
FrameJob job;
|
||||
job.Scissor = m_Parent->AbsoluteRectangle();
|
||||
job.Scissor = (m_ScissorEnabled) ? m_Parent->AbsoluteRectangle() : Rectangle();
|
||||
job.Viewport = Rectangle(Left(), Top(), Width, Height);
|
||||
job.TextureID = m_FadeTexture->ResourceID;
|
||||
job.DiffuseTexture = *m_FadeTexture;
|
||||
job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a);
|
||||
job.Name = Name();
|
||||
rq.GUI.Add(job);
|
||||
}
|
||||
}
|
||||
@@ -51,6 +56,15 @@ public:
|
||||
if (m_Texture == nullptr) {
|
||||
m_Texture = ResourceManager::Load<dd::Texture>("Textures/Core/ErrorTexture.png");
|
||||
}
|
||||
SizeToTexture();
|
||||
}
|
||||
|
||||
void SizeToTexture()
|
||||
{
|
||||
if (m_Texture != nullptr) {
|
||||
this->Width = m_Texture->Width;
|
||||
this->Height = m_Texture->Height;
|
||||
}
|
||||
}
|
||||
|
||||
void FadeToTexture(std::string resourceName, double duration)
|
||||
@@ -77,6 +91,7 @@ public:
|
||||
void SetColor(glm::vec4 val) { m_Color = val; }
|
||||
|
||||
protected:
|
||||
bool m_ScissorEnabled = true;
|
||||
dd::Texture* m_Texture = nullptr;
|
||||
dd::Texture* m_FadeTexture = nullptr;
|
||||
glm::vec4 m_Color = glm::vec4(1.f, 1.f, 1.f, 1.f);
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
#ifndef GUI_Viewport_h__
|
||||
#define GUI_Viewport_h__
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "GUI/Frame.h"
|
||||
#include "World.h"
|
||||
#include "Systems/TransformSystem.h"
|
||||
#include "Components/Transform.h"
|
||||
#include "Components/Camera.h"
|
||||
#include "RenderQueue.h"
|
||||
#include "Camera.h"
|
||||
|
||||
namespace GUI
|
||||
{
|
||||
|
||||
class Viewport : public Frame
|
||||
{
|
||||
public:
|
||||
Viewport(Frame* parent, std::string name, std::shared_ptr<World> world)
|
||||
: Frame(parent, name)
|
||||
, m_World(world)
|
||||
{ }
|
||||
|
||||
EntityID CameraEntity() const { return m_CameraEntity; }
|
||||
void SetCameraEntity(EntityID cameraEntity)
|
||||
{
|
||||
m_CameraEntity = cameraEntity;
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(cameraEntity);
|
||||
if (!transformComponent)
|
||||
return;
|
||||
auto cameraComponent = m_World->GetComponent<Components::Camera>(cameraEntity);
|
||||
if (!cameraComponent)
|
||||
return;
|
||||
|
||||
m_Camera = std::make_shared<Camera>(cameraComponent->FOV, cameraComponent->NearClip, cameraComponent->FarClip);
|
||||
}
|
||||
|
||||
|
||||
void Update(double dt) override
|
||||
{
|
||||
if (!m_TransformSystem)
|
||||
m_TransformSystem = m_World->GetSystem<Systems::TransformSystem>();
|
||||
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(m_CameraEntity);
|
||||
if (!transformComponent)
|
||||
return;
|
||||
|
||||
auto cameraComponent = m_World->GetComponent<Components::Camera>(m_CameraEntity);
|
||||
if (!cameraComponent)
|
||||
return;
|
||||
|
||||
Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(m_CameraEntity);
|
||||
|
||||
m_Camera->SetFOV(cameraComponent->FOV);
|
||||
m_Camera->SetNearClip(cameraComponent->NearClip);
|
||||
m_Camera->SetFarClip(cameraComponent->FarClip);
|
||||
m_Camera->SetPosition(absoluteTransform.Position);
|
||||
m_Camera->SetOrientation(absoluteTransform.Orientation);
|
||||
}
|
||||
|
||||
void Draw(std::shared_ptr<Renderer> renderer) override
|
||||
{
|
||||
if (!m_Camera)
|
||||
return;
|
||||
|
||||
renderer->SetCamera(m_Camera);
|
||||
renderer->SetViewport(AbsoluteRectangle());
|
||||
renderer->DrawWorld(m_Parent->RenderQueue);
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<World> m_World;
|
||||
std::shared_ptr<Systems::TransformSystem> m_TransformSystem;
|
||||
std::shared_ptr<Camera> m_Camera;
|
||||
EntityID m_CameraEntity;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // GUI_Viewport_h__
|
||||
@@ -1,241 +0,0 @@
|
||||
#ifndef GUI_WorldFrame_h__
|
||||
#define GUI_WorldFrame_h__
|
||||
|
||||
#include "GUI/Frame.h"
|
||||
#include "GUI/Viewport.h"
|
||||
#include "RenderQueue.h"
|
||||
#include "World.h"
|
||||
#include "Systems/TransformSystem.h"
|
||||
#include "Events/SetViewportCamera.h"
|
||||
#include "Components/Transform.h"
|
||||
#include "Components/Model.h"
|
||||
#include "Components/Sprite.h"
|
||||
#include "Components/PointLight.h"
|
||||
#include "Components/BlendMap.h"
|
||||
|
||||
|
||||
namespace GUI
|
||||
{
|
||||
|
||||
class WorldFrame : public Frame
|
||||
{
|
||||
public:
|
||||
WorldFrame(Frame* parent, std::string name, std::shared_ptr<World> world)
|
||||
: Frame(parent, name)
|
||||
, m_World(world)
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ESetViewportCamera, &WorldFrame::OnSetViewportCamera);
|
||||
}
|
||||
|
||||
void Update(double dt) override
|
||||
{
|
||||
if (!m_TransformSystem)
|
||||
m_TransformSystem = m_World->GetSystem<Systems::TransformSystem>();
|
||||
|
||||
m_World->Update(dt);
|
||||
}
|
||||
|
||||
void Draw(std::shared_ptr<Renderer> renderer) override
|
||||
{
|
||||
RenderQueue.Clear();
|
||||
renderer->ClearPointLights();
|
||||
|
||||
for (auto &pair : *m_World->GetEntities())
|
||||
{
|
||||
EntityID entity = pair.first;
|
||||
|
||||
auto templateComponent = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateComponent)
|
||||
continue;
|
||||
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (!transform)
|
||||
continue;
|
||||
|
||||
auto modelComponent = m_World->GetComponent<Components::Model>(entity);
|
||||
if (modelComponent)
|
||||
{
|
||||
Model* modelAsset = nullptr;
|
||||
if (modelComponent->AverageNormals)
|
||||
{
|
||||
modelAsset = ResourceManager->Load<Model>("AveragedModel", modelComponent->ModelFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
modelAsset = ResourceManager->Load<Model>("Model", modelComponent->ModelFile);
|
||||
}
|
||||
|
||||
|
||||
if (modelAsset)
|
||||
{
|
||||
Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(entity);
|
||||
glm::mat4 modelMatrix = glm::translate(glm::mat4(), absoluteTransform.Position)
|
||||
* glm::toMat4(absoluteTransform.Orientation)
|
||||
* glm::scale(absoluteTransform.Scale);
|
||||
auto blendmapComponent = m_World->GetComponent<Components::BlendMap>(entity);
|
||||
if (blendmapComponent)
|
||||
{
|
||||
BlendMapTexture RedTexture;
|
||||
RedTexture.Diffuse = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureRed);
|
||||
RedTexture.Normal = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureRedNormal);
|
||||
RedTexture.Specular = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureRedSpecular);
|
||||
|
||||
BlendMapTexture GreenTexture;
|
||||
GreenTexture.Diffuse = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureGreen);
|
||||
GreenTexture.Normal = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureGreenNormal);
|
||||
GreenTexture.Specular = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureGreenSpecular);
|
||||
|
||||
BlendMapTexture BlueTexture;
|
||||
BlueTexture.Diffuse = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureBlue);
|
||||
BlueTexture.Normal = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureBlueNormal);
|
||||
BlueTexture.Specular = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureBlueSpecular);
|
||||
|
||||
float textureRepeat = blendmapComponent->TextureRepeats;
|
||||
|
||||
EnqueueBlendMapModel(modelAsset, RedTexture, GreenTexture, BlueTexture, textureRepeat, modelMatrix, modelComponent->Color);
|
||||
}
|
||||
else
|
||||
{
|
||||
EnqueueModel(modelAsset, modelMatrix, modelComponent->Transparent, modelComponent->Color);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
auto spriteComponent = m_World->GetComponent<Components::Sprite>(entity);
|
||||
if (spriteComponent)
|
||||
{
|
||||
auto textureAsset = ResourceManager->Load<Texture>("Texture", spriteComponent->SpriteFile);
|
||||
if (textureAsset)
|
||||
{
|
||||
Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(entity);
|
||||
glm::quat orientation2D = glm::angleAxis(glm::eulerAngles(absoluteTransform.Orientation).z, glm::vec3(0, 0, -1));
|
||||
glm::mat4 modelMatrix = glm::translate(absoluteTransform.Position)
|
||||
* glm::toMat4(orientation2D)
|
||||
* glm::scale(absoluteTransform.Scale);
|
||||
EnqueueSprite(textureAsset, modelMatrix, spriteComponent->Color);
|
||||
}
|
||||
}
|
||||
|
||||
auto pointLightComponent = m_World->GetComponent<Components::PointLight>(entity);
|
||||
if (pointLightComponent)
|
||||
{
|
||||
glm::vec3 position = m_TransformSystem->AbsolutePosition(entity);
|
||||
renderer->AddPointLightToDraw(
|
||||
position,
|
||||
pointLightComponent->Specular,
|
||||
pointLightComponent->Diffuse,
|
||||
pointLightComponent->specularExponent,
|
||||
pointLightComponent->ConstantAttenuation,
|
||||
pointLightComponent->LinearAttenuation,
|
||||
pointLightComponent->QuadraticAttenuation,
|
||||
pointLightComponent->Radius
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
RenderQueue.Sort();
|
||||
}
|
||||
|
||||
protected:
|
||||
std::shared_ptr<World> m_World;
|
||||
|
||||
private:
|
||||
struct BlendMapTexture
|
||||
{
|
||||
GLuint Diffuse;
|
||||
GLuint Normal;
|
||||
GLuint Specular;
|
||||
};
|
||||
|
||||
EventRelay<Frame, Events::SetViewportCamera> m_ESetViewportCamera;
|
||||
bool OnSetViewportCamera(const Events::SetViewportCamera &event)
|
||||
{
|
||||
// Search next layer for viewports and update cameras
|
||||
auto itpair = m_Children[m_Layer + 1].equal_range(event.ViewportFrame);
|
||||
for (auto it = itpair.first; it != itpair.second; ++it)
|
||||
{
|
||||
auto viewportFrame = dynamic_cast<GUI::Viewport*>(it->second);
|
||||
if (!viewportFrame)
|
||||
continue;
|
||||
|
||||
viewportFrame->SetCameraEntity(event.CameraEntity);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<Systems::TransformSystem> m_TransformSystem;
|
||||
|
||||
void EnqueueModel(Model* model, glm::mat4 modelMatrix, float transparent, glm::vec4 color)
|
||||
{
|
||||
for (auto texGroup : model->TextureGroups)
|
||||
{
|
||||
ModelJob job;
|
||||
job.TextureID = texGroup.Texture->ResourceID;
|
||||
job.DiffuseTexture = *texGroup.Texture;
|
||||
job.NormalTexture = (texGroup.NormalMap) ? *texGroup.NormalMap : 0;
|
||||
job.SpecularTexture = (texGroup.SpecularMap) ? *texGroup.SpecularMap : 0;
|
||||
job.VAO = model->VAO;
|
||||
job.StartIndex = texGroup.StartIndex;
|
||||
job.EndIndex = texGroup.EndIndex;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Transparent = transparent;
|
||||
job.Color = color;
|
||||
|
||||
if(job.Transparent)
|
||||
{
|
||||
RenderQueue.Forward.Add(job);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderQueue.Deferred.Add(job);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EnqueueBlendMapModel(Model* model, BlendMapTexture textureRed, BlendMapTexture textureGreen, BlendMapTexture textureBlue, float textureRepeat, glm::mat4 modelMatrix, glm::vec4 color)
|
||||
{
|
||||
for (auto texGroup : model->TextureGroups)
|
||||
{
|
||||
BlendMapModelJob job;
|
||||
job.TextureID = texGroup.Texture->ResourceID;
|
||||
job.DiffuseTexture = *texGroup.Texture;
|
||||
job.NormalTexture = (texGroup.NormalMap) ? *texGroup.NormalMap : 0;
|
||||
job.SpecularTexture = (texGroup.SpecularMap) ? *texGroup.SpecularMap : 0;
|
||||
job.BlendMapTextureRed = textureRed.Diffuse;
|
||||
job.BlendMapTextureRedNormal = textureRed.Normal;
|
||||
job.BlendMapTextureRedSpecular = textureRed.Specular;
|
||||
job.BlendMapTextureGreen = textureGreen.Diffuse;
|
||||
job.BlendMapTextureGreenNormal = textureGreen.Normal;
|
||||
job.BlendMapTextureGreenSpecular = textureGreen.Specular;
|
||||
job.BlendMapTextureBlue = textureBlue.Diffuse;
|
||||
job.BlendMapTextureBlueNormal = textureBlue.Normal;
|
||||
job.BlendMapTextureBlueSpecular = textureBlue.Specular;
|
||||
job.TextureRepeat = textureRepeat;
|
||||
job.VAO = model->VAO;
|
||||
job.StartIndex = texGroup.StartIndex;
|
||||
job.EndIndex = texGroup.EndIndex;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Color = color;
|
||||
|
||||
RenderQueue.Deferred.Add(job);
|
||||
}
|
||||
}
|
||||
|
||||
void EnqueueSprite(Texture* texture, glm::mat4 modelMatrix, glm::vec4 color)
|
||||
{
|
||||
SpriteJob job;
|
||||
job.TextureID = texture->ResourceID;
|
||||
job.Texture = *texture;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Color = color;
|
||||
|
||||
RenderQueue.Forward.Add(job);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // GUI_WorldFrame_h__
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef GUI_MAINMENU_H__
|
||||
#define GUI_MAINMENU_H__
|
||||
|
||||
#include "GUI/TextureFrame.h"
|
||||
#include "Game/MainMenuMain.h"
|
||||
#include "Game/MainMenuOptions.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
namespace GUI
|
||||
{
|
||||
|
||||
class MainMenu : public TextureFrame
|
||||
{
|
||||
public:
|
||||
MainMenu(Frame* parent, std::string name)
|
||||
: TextureFrame(parent, name)
|
||||
{
|
||||
SetTexture("Textures/GUI/Menu/Background.png");
|
||||
Width = 675;
|
||||
Height = 1080;
|
||||
|
||||
m_LeftBanner = new GUI::TextureFrame(this, "MainMenuLeftBanner");
|
||||
m_LeftBanner->SetTexture("Textures/GUI/Menu/Left.png");
|
||||
m_LeftBanner->Width = 231;
|
||||
m_LeftBanner->Height = 1080;
|
||||
|
||||
m_MainMenuMain = new GUI::MainMenuMain(this, "MainMenuMain");
|
||||
m_MainMenuMain->SetLeft(m_LeftBanner->Right());
|
||||
m_MainMenuMain->SetTop(60);
|
||||
|
||||
m_MainMenuOptions = new GUI::MainMenuOptions(this, "MainMenuOptions");
|
||||
m_MainMenuOptions->SetLeft(m_LeftBanner->Right());
|
||||
m_MainMenuOptions->SetTop(m_MainMenuMain->Bottom());
|
||||
}
|
||||
|
||||
private:
|
||||
TextureFrame* m_LeftBanner;
|
||||
MainMenuMain* m_MainMenuMain;
|
||||
MainMenuOptions* m_MainMenuOptions;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
#ifndef GUI_MAINMENUMAIN_H__
|
||||
#define GUI_MAINMENUMAIN_H__
|
||||
|
||||
#include "GUI/TextureFrame.h"
|
||||
#include "GUI/Button.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
namespace GUI
|
||||
{
|
||||
|
||||
class MainMenuMain : public TextureFrame
|
||||
{
|
||||
public:
|
||||
MainMenuMain(Frame* parent, std::string name)
|
||||
: TextureFrame(parent, name)
|
||||
{
|
||||
Width = 409;
|
||||
Height = 543;
|
||||
|
||||
m_Title = new GUI::TextureFrame(this, "MainMenuMainTitle");
|
||||
m_Title->SetTexture("Textures/GUI/Menu/MainTitle.png");
|
||||
|
||||
m_SquidoutButton = new GUI::Button(this, "MainMenuMainSquidoutButton");
|
||||
m_SquidoutButton->SetTop(m_Title->Bottom());
|
||||
m_SquidoutButton->SetTextureReleased("Textures/GUI/Menu/MainSquidout.png");
|
||||
m_SquidoutButton->SetTextureHover("Textures/GUI/Menu/MainSquidoutHover.png");
|
||||
m_SquidoutButton->SetTexturePressed("Textures/GUI/Menu/MainSquidoutClick.png");
|
||||
m_SquidoutButton->SizeToTexture();
|
||||
|
||||
m_TimeAttackButton = new GUI::Button(this, "MainMenuMainTimeAttackButton");
|
||||
m_TimeAttackButton->SetTop(m_SquidoutButton->Bottom());
|
||||
m_TimeAttackButton->SetTextureReleased("Textures/GUI/Menu/MainTimeAttack.png");
|
||||
m_TimeAttackButton->SetTextureHover("Textures/GUI/Menu/MainTimeAttackHover.png");
|
||||
m_TimeAttackButton->SetTexturePressed("Textures/GUI/Menu/MainTimeAttackClick.png");
|
||||
m_TimeAttackButton->SizeToTexture();
|
||||
|
||||
m_OptionsButton = new GUI::Button(this, "MainMenuMainOptionsButton");
|
||||
m_OptionsButton->SetTop(m_TimeAttackButton->Bottom());
|
||||
m_OptionsButton->SetTextureReleased("Textures/GUI/Menu/MainOptions.png");
|
||||
m_OptionsButton->SetTextureHover("Textures/GUI/Menu/MainOptionsHover.png");
|
||||
m_OptionsButton->SetTexturePressed("Textures/GUI/Menu/MainOptionsClick.png");
|
||||
m_OptionsButton->SizeToTexture();
|
||||
}
|
||||
|
||||
private:
|
||||
TextureFrame* m_Title;
|
||||
Button* m_SquidoutButton;
|
||||
Button* m_TimeAttackButton;
|
||||
Button* m_OptionsButton;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,49 @@
|
||||
#ifndef GUI_MAINMENUOPTIONS_H__
|
||||
#define GUI_MAINMENUOPTIONS_H__
|
||||
|
||||
#include "GUI/TextureFrame.h"
|
||||
#include "GUI/Button.h"
|
||||
#include "GUI/Slider.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
namespace GUI
|
||||
{
|
||||
|
||||
class MainMenuOptions : public TextureFrame
|
||||
{
|
||||
public:
|
||||
MainMenuOptions(Frame* parent, std::string name)
|
||||
: TextureFrame(parent, name)
|
||||
{
|
||||
Width = 409;
|
||||
Height = 1080;
|
||||
|
||||
m_Title = new GUI::TextureFrame(this, "MainMenuOptionsTitle");
|
||||
m_Title->SetTexture("Textures/GUI/Menu/OptionsTitle.png");
|
||||
|
||||
m_TitleSFX = new GUI::TextureFrame(this, "MainMenuOptionsSFXTitle");
|
||||
m_TitleSFX->SetTop(m_Title->Bottom() + 20);
|
||||
m_TitleSFX->SetTexture("Textures/GUI/Menu/OptionsSFXTitle.png");
|
||||
m_SFXSlider = new GUI::Slider(this, "MainMenuOptionsSFXSlider");
|
||||
m_SFXSlider->X = 66;
|
||||
m_SFXSlider->SetTop(m_TitleSFX->Bottom());
|
||||
m_SFXSlider->SetTexture("Textures/GUI/Menu/SliderBackground.png");
|
||||
m_SFXSlider->SetTextureReleased("Textures/GUI/Menu/SliderHandle.png");
|
||||
m_SFXSlider->CenterSlider();
|
||||
|
||||
m_TitleBGM = new GUI::TextureFrame(this, "MainMenuOptionsBGMTitle");
|
||||
m_TitleBGM->SetTop(m_TitleSFX->Bottom());
|
||||
m_TitleBGM->SetTexture("Textures/GUI/Menu/OptionsBGMTitle.png");
|
||||
}
|
||||
|
||||
private:
|
||||
TextureFrame* m_Title;
|
||||
TextureFrame* m_TitleSFX;
|
||||
Slider* m_SFXSlider;
|
||||
TextureFrame* m_TitleBGM;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user