Fixed blendmaps

Merge remote-tracking branch 'origin/gui' into deffered_rendering

Conflicts:
	vs11/Returngeance/Returngeance.vcxproj.filters
This commit is contained in:
Tleety
2014-05-28 22:08:50 +02:00
21 changed files with 932 additions and 1201 deletions
+3 -2
View File
@@ -36,8 +36,7 @@ public:
// Create a frame as a child
Frame(Frame* parent, std::string name)
: Rectangle(static_cast<Rectangle>(*parent)) // Clone parent rectangle using copy constructor
, m_Name(name)
: m_Name(name)
, m_Layer(0)
{ SetParent(std::shared_ptr<Frame>(parent)); }
@@ -52,6 +51,8 @@ public:
return;
}
Width = parent->Width;
Height = parent->Height;
m_Layer = parent->Layer() + 1;
parent->AddChild(std::shared_ptr<Frame>(this));
m_Parent = parent;
+9 -20
View File
@@ -5,8 +5,7 @@
#include "GUI/WorldFrame.h"
#include "GUI/Viewport.h"
#include "GUI/TextureFrame.h"
#include "Events/Damage.h"
#include "GUI/PlayerHUD.h"
#include "GameWorld.h"
@@ -19,42 +18,32 @@ public:
GameFrame(Frame* parent, std::string name)
: Frame(parent, name)
{
EVENT_SUBSCRIBE_MEMBER(m_EDamage, &GameFrame::OnDamage);
m_World = std::make_shared<GameWorld>(EventBroker, ResourceManager);
auto worldFrame = new WorldFrame(this, "GameWorldFrame", m_World);
{
vp1 = new Viewport(worldFrame, "Viewport1", m_World);
vp1->X = 0;
vp1->Width = 640;
vp1->Height = 720 / 2;
new PlayerHUD(vp1, "PlayerHUD", m_World, 1);
vp2 = new Viewport(worldFrame, "Viewport2", m_World);
vp2->X = vp1->Right();
vp2->Width = 640;
vp2->Height = 720 / 2;
new PlayerHUD(vp2, "PlayerHUD", m_World, 2);
tex = new TextureFrame(vp1, "TextureFrameThingy");
tex->SetTexture("Textures/GUI/hurt.png");
auto vpc = new Viewport(worldFrame, "ViewportFreeCam", m_World);
vpc->Y = 720 / 2;
vpc->Height = 720 / 2;
}
m_World->Initialize();
}
void Update(double dt)
{
}
bool OnDamage(const Events::Damage &event)
{
//tex->SetTexture("Textures/GUI/hurt.png");
return false;
}
private:
EventRelay<Frame, Events::Damage> m_EDamage;
std::shared_ptr<GameWorld> m_World;
Viewport* vp1;
Viewport* vp2;
TextureFrame* tex;
};
}
+53
View File
@@ -0,0 +1,53 @@
#ifndef GUI_HealthOverlay_h__
#define GUI_HealthOverlay_h__
#include "GUI/TextureFrame.h"
#include "World.h"
#include "Events/Damage.h"
#include "Components/Player.h"
#include "Components/Health.h"
namespace GUI
{
class HealthOverlay : public TextureFrame
{
public:
HealthOverlay(Frame* parent, std::string name, std::shared_ptr<World> world, int playerID)
: TextureFrame(parent, name)
, m_World(world)
, m_PlayerID(playerID)
{
EVENT_SUBSCRIBE_MEMBER(m_EDamage, &HealthOverlay::OnDamage);
SetTexture("Textures/GUI/hurt.png");
SetColor(glm::vec4(0.f));
}
bool OnDamage(const Events::Damage &event)
{
auto player = m_World->GetComponent<Components::Player>(event.Entity);
if (!player)
return false;
if (player->ID != m_PlayerID)
return false;
auto health = m_World->GetComponent<Components::Health>(event.Entity);
if (!health)
return false;
SetColor(glm::vec4(1.f, 1.f, 1.f, 1 - health->Amount / 100.f));
return true;
}
protected:
std::shared_ptr<World> m_World;
int m_PlayerID;
EventRelay<Frame, Events::Damage> m_EDamage;
};
}
#endif // GUI_TextureFrame_h__
+30
View File
@@ -0,0 +1,30 @@
#include "GUI/Frame.h"
#include "GUI/HealthOverlay.h"
#ifndef GUI_PlayerHUD_h__
#define GUI_PlayerHUD_h__
namespace GUI
{
class PlayerHUD : public Frame
{
public:
PlayerHUD(Frame* parent, std::string name, std::shared_ptr<World> world, int playerID)
: Frame(parent, name)
, m_World(world)
, m_PlayerID(playerID)
{
m_HealthOverlay = new HealthOverlay(this, "HealthOverlay", m_World, m_PlayerID);
}
protected:
std::shared_ptr<World> m_World;
int m_PlayerID;
HealthOverlay* m_HealthOverlay;
};
}
#endif // GUI_TextureFrame_h__
+13 -4
View File
@@ -11,7 +11,10 @@ class TextureFrame : public Frame
{
public:
TextureFrame(Frame* parent, std::string name)
: Frame(parent, name) { }
: Frame(parent, name)
, m_Texture(nullptr)
, m_Color(glm::vec4(1.f, 1.f, 1.f, 1.f))
{ }
void Draw(std::shared_ptr<Renderer> renderer) override
{
@@ -22,20 +25,26 @@ public:
SpriteJob job;
job.TextureID = m_Texture->ResourceID;
job.Texture = *m_Texture;
job.Color = m_Color;
RenderQueue.Add(job);
renderer->SetCamera(nullptr);
renderer->DrawFrame(RenderQueue);
}
std::shared_ptr<::Texture> Texture() const { return m_Texture; }
::Texture* Texture() const { return m_Texture; }
void SetTexture(std::string resourceName)
{
m_Texture = std::shared_ptr<::Texture>(ResourceManager->Load<::Texture>("Texture", resourceName));
m_Texture = ResourceManager->Load<::Texture>("Texture", resourceName);
}
glm::vec4 Color() const { return m_Color; }
void SetColor(glm::vec4 val) { m_Color = val; }
protected:
std::shared_ptr<::Texture> m_Texture;
::Texture* m_Texture;
glm::vec4 m_Color;
};
}