I'll create a GUI interface using Visual Basic, see if I can track an IP address

This commit is contained in:
2014-05-24 20:37:55 +02:00
parent 2fbcad4dbf
commit 07c74ff9f5
14 changed files with 401 additions and 85 deletions
+48 -14
View File
@@ -2,12 +2,14 @@
#define GUI_Frame_h__
#include <memory>
#include <map>
#include "Util/Rectangle.h"
#include "EventBroker.h"
// HACK: Decouple renderer plz
#include "ResourceManager.h"
#include "Renderer.h"
#include "RenderQueue.h"
#include "Texture.h"
namespace GUI
{
@@ -24,13 +26,16 @@ public:
};
// Set up a base frame with an event broker
Frame(std::shared_ptr<::EventBroker> eventBroker)
Frame(std::shared_ptr<::EventBroker> eventBroker, std::shared_ptr<::ResourceManager> resourceManager)
: EventBroker(eventBroker)
, Rectangle()
, ResourceManager(resourceManager)
, Rectangle()
, m_Name("UIParent")
{ Initialize(); }
// Create a frame as a child
Frame(std::shared_ptr<Frame> parent)
Frame(std::shared_ptr<Frame> parent, std::string name)
: Rectangle(static_cast<Rectangle>(*parent)) // Clone parent rectangle using copy constructor
, m_Name(name)
{ SetParent(parent); Initialize(); }
virtual void Initialize() { }
@@ -40,18 +45,15 @@ public:
parent->AddChild(std::shared_ptr<Frame>(this));
m_Parent = parent;
EventBroker = parent->EventBroker;
ResourceManager = parent->ResourceManager;
}
void AddChild(std::shared_ptr<Frame> child)
{
m_Children.push_back(child);
if (m_Parent != nullptr)
{
m_Parent->AddChild(child);
}
m_Children.push_back(std::make_pair(child->Name(), child));
}
typedef std::list<std::shared_ptr<Frame>>::const_iterator FrameChildrenIterator;
typedef std::map<std::string, std::shared_ptr<Frame>>::const_iterator FrameChildrenIterator;
FrameChildrenIterator begin()
{
return m_Children.begin();
@@ -61,13 +63,45 @@ public:
return m_Children.end();
}
virtual void Update(double dt) { }
virtual void Draw(Renderer* renderer) { }
std::string Name() const { return m_Name; }
void SetName(std::string val) { m_Name = val; }
virtual void Update(double dt)
{
for (auto &pair : m_Children)
{
pair.second->Update(dt);
}
}
void DrawLayered(std::shared_ptr<Renderer> renderer)
{
renderer->SetViewport(GetLeft(), GetTop(), GetRight(), GetBottom());
this->Draw(renderer);
renderer->Draw();
for (auto &pair : m_Children)
{
pair.second->Draw(renderer);
}
}
virtual void Draw(std::shared_ptr<Renderer> renderer)
{
renderer->SetViewport(GetLeft(), GetTop(), GetRight(), GetBottom());
renderer->Draw();
}
protected:
std::shared_ptr<::EventBroker> EventBroker;
std::shared_ptr<::ResourceManager> ResourceManager;
std::string m_Name;
std::shared_ptr<Frame> m_Parent;
std::list<std::shared_ptr<Frame>> m_Children;
std::multimap<std::string, std::shared_ptr<Frame>> m_Children; // name -> frame
};
}