WIP Frame
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "EventBroker.h"
|
#include "EventBroker.h"
|
||||||
|
#include "GUI/Frame.h"
|
||||||
#include "Renderer.h"
|
#include "Renderer.h"
|
||||||
#include "GameWorld.h"
|
#include "GameWorld.h"
|
||||||
|
|
||||||
@@ -15,6 +16,8 @@ public:
|
|||||||
m_Renderer = std::make_shared<Renderer>();
|
m_Renderer = std::make_shared<Renderer>();
|
||||||
m_Renderer->Initialize();
|
m_Renderer->Initialize();
|
||||||
|
|
||||||
|
m_UIParent = std::make_shared<GUI::Frame>(0, 0, m_Renderer->Width(), m_Renderer->Height());
|
||||||
|
|
||||||
m_World = std::make_shared<GameWorld>(m_EventBroker, m_Renderer);
|
m_World = std::make_shared<GameWorld>(m_EventBroker, m_Renderer);
|
||||||
m_World->Initialize();
|
m_World->Initialize();
|
||||||
|
|
||||||
@@ -38,6 +41,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
std::shared_ptr<EventBroker> m_EventBroker;
|
std::shared_ptr<EventBroker> m_EventBroker;
|
||||||
std::shared_ptr<Renderer> m_Renderer;
|
std::shared_ptr<Renderer> m_Renderer;
|
||||||
|
std::shared_ptr<GUI::Frame> m_UIParent;
|
||||||
// TODO: This should ultimately live in GameFrame
|
// TODO: This should ultimately live in GameFrame
|
||||||
std::shared_ptr<GameWorld> m_World;
|
std::shared_ptr<GameWorld> m_World;
|
||||||
|
|
||||||
|
|||||||
+22
-6
@@ -4,6 +4,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "Util/Rectangle.h"
|
#include "Util/Rectangle.h"
|
||||||
|
#include "EventBroker.h"
|
||||||
|
|
||||||
namespace GUI
|
namespace GUI
|
||||||
{
|
{
|
||||||
@@ -19,13 +20,28 @@ public:
|
|||||||
Bottom
|
Bottom
|
||||||
};
|
};
|
||||||
|
|
||||||
Frame() { }
|
// Set up a base frame with an event broker
|
||||||
|
Frame(std::shared_ptr<::EventBroker> eventBroker)
|
||||||
Frame(const Frame &parent)
|
: EventBroker(eventBroker)
|
||||||
: Rectangle(static_cast<Rectangle>(parent))
|
, Rectangle()
|
||||||
, Parent(std::shared_ptr<Frame>(&parent)) { }
|
{ Initialize(); }
|
||||||
|
// Create a frame as a child
|
||||||
|
Frame(std::shared_ptr<Frame> parent)
|
||||||
|
: Rectangle(static_cast<Rectangle>(*parent)) // Clone parent rectangle using copy constructor
|
||||||
|
{ SetParent(parent); Initialize(); }
|
||||||
|
|
||||||
std::shared_ptr<Frame> Parent;
|
virtual void Initialize() { }
|
||||||
|
std::shared_ptr<Frame> Parent() const { return m_Parent; }
|
||||||
|
void SetParent(std::shared_ptr<Frame> parent)
|
||||||
|
{
|
||||||
|
m_Parent = parent;
|
||||||
|
EventBroker = parent->EventBroker;
|
||||||
|
}
|
||||||
|
virtual void Update(double dt) { }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::shared_ptr<::EventBroker> EventBroker;
|
||||||
|
std::shared_ptr<Frame> m_Parent;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user