Merge remote-tracking branch 'origin/master' into particles
Conflicts: src/GUI/GameFrame.h src/GUI/TextureFrame.h vs11/Returngeance/Returngeance.vcxproj.filters
This commit is contained in:
+42
-7
@@ -25,6 +25,9 @@ public:
|
||||
Bottom
|
||||
};
|
||||
|
||||
static const int BaseWidth = 1280;
|
||||
static const int BaseHeight = 720;
|
||||
|
||||
// Set up a base frame with an event broker
|
||||
Frame(std::shared_ptr<::EventBroker> eventBroker, std::shared_ptr<::ResourceManager> resourceManager)
|
||||
: EventBroker(eventBroker)
|
||||
@@ -33,14 +36,14 @@ public:
|
||||
, m_Name("UIParent")
|
||||
, m_Layer(0)
|
||||
, m_Hidden(false)
|
||||
{ }
|
||||
{ Initialize(); }
|
||||
|
||||
// Create a frame as a child
|
||||
Frame(Frame* parent, std::string name)
|
||||
: m_Name(name)
|
||||
, m_Layer(0)
|
||||
, m_Hidden(false)
|
||||
{ SetParent(std::shared_ptr<Frame>(parent)); }
|
||||
{ SetParent(std::shared_ptr<Frame>(parent)); Initialize(); }
|
||||
|
||||
::RenderQueuePair RenderQueue;
|
||||
|
||||
@@ -89,7 +92,10 @@ public:
|
||||
}
|
||||
int Right() const override
|
||||
{
|
||||
return Left() + Width;
|
||||
if (m_Parent)
|
||||
return std::min(m_Parent->Right(), Left() + Width);
|
||||
else
|
||||
return Left() + Width;
|
||||
}
|
||||
int Top() const override
|
||||
{
|
||||
@@ -100,14 +106,34 @@ public:
|
||||
}
|
||||
int Bottom() const override
|
||||
{
|
||||
return Top() + Height;
|
||||
if (m_Parent)
|
||||
return std::min(m_Parent->Bottom(), Top() + Height);
|
||||
else
|
||||
return Top() + Height;
|
||||
}
|
||||
|
||||
glm::vec2 Scale()
|
||||
{
|
||||
if (m_Parent)
|
||||
return m_Parent->Scale();
|
||||
else
|
||||
return glm::vec2(Width, Height) / glm::vec2(BaseWidth, BaseHeight);
|
||||
}
|
||||
|
||||
Rectangle AbsoluteRectangle()
|
||||
{
|
||||
return Rectangle(Left(), Top(), Width, Height);
|
||||
int left = Left();
|
||||
int top = Top();
|
||||
int width = Right() - left;
|
||||
int height = Bottom() - top;
|
||||
return Rectangle(left, top, width, height);
|
||||
}
|
||||
|
||||
virtual bool OnKeyDown(const Events::KeyDown &event) { return false; }
|
||||
virtual bool OnKeyUp(const Events::KeyUp &event) { return false; }
|
||||
//virtual bool OnMouseDown(const Events::KeyDown &event) { }
|
||||
//virtual bool OnMouseUp(const Events::KeyDown &event) { }
|
||||
|
||||
void UpdateLayered(double dt)
|
||||
{
|
||||
if (this->Hidden())
|
||||
@@ -137,7 +163,7 @@ public:
|
||||
return;
|
||||
|
||||
// Draw ourselves
|
||||
renderer->SetViewport(AbsoluteRectangle());
|
||||
renderer->SetScissor(AbsoluteRectangle());
|
||||
this->Draw(renderer);
|
||||
|
||||
// Draw children
|
||||
@@ -150,7 +176,7 @@ public:
|
||||
if (child->Hidden())
|
||||
continue;
|
||||
Rectangle rect = child->AbsoluteRectangle();
|
||||
renderer->SetViewport(rect);
|
||||
renderer->SetScissor(rect);
|
||||
child->Draw(renderer);
|
||||
}
|
||||
}
|
||||
@@ -170,6 +196,15 @@ protected:
|
||||
typedef std::multimap<std::string, std::shared_ptr<Frame>> Children_t; // name -> frame
|
||||
std::map<int, Children_t> m_Children; // layer -> Children_t
|
||||
|
||||
private:
|
||||
EventRelay<Frame, Events::KeyDown> m_EKeyDown;
|
||||
EventRelay<Frame, Events::KeyUp> m_EKeyUp;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, &Frame::OnKeyDown);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKeyUp, &Frame::OnKeyUp);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user