Danbias/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h

87 lines
2.7 KiB
C
Raw Normal View History

//////////////////////////////////////
// Created by Pontus Fransson 2014 //
//////////////////////////////////////
#ifndef DANBIAS_CLIENT_EVENT_BUTTON_GUI_H
#define DANBIAS_CLIENT_EVENT_BUTTON_GUI_H
#include "../Misc/EventHandler/EventButton.h"
2014-02-12 09:08:38 +01:00
#include "../OysterGraphics/DllInterfaces/GFXAPI.h"
namespace DanBias
{
namespace Client
{
template <typename Owner>
class EventButtonGUI : public Oyster::Event::EventButton<Owner>
{
public:
EventButtonGUI()
2014-02-12 09:08:38 +01:00
: EventButton(), xPos(0), yPos(0), width(0), height(0), texture(NULL)
{}
2014-02-12 09:08:38 +01:00
EventButtonGUI(std::wstring textureName, Owner owner, float xPos, float yPos, float width, float height)
: EventButton(owner), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL)
{
CreateTexture(textureName);
}
2014-02-12 09:08:38 +01:00
EventButtonGUI(std::wstring textureName, EventFunc func, float xPos, float yPos, float width, float height)
: EventButton(func), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL)
{
CreateTexture(textureName);
}
2014-02-12 09:08:38 +01:00
EventButtonGUI(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float width, float height)
: EventButton(func, owner), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL)
{
CreateTexture(textureName);
}
2014-02-12 09:08:38 +01:00
EventButtonGUI(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float width, float height)
: EventButton(func, owner, userData), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL)
{
CreateTexture(textureName);
}
2014-02-12 09:08:38 +01:00
virtual ~EventButtonGUI()
{
Oyster::Graphics::API::DeleteTexture(texture);
texture = NULL;
}
void CreateTexture(std::wstring textureName)
{
//Create texture
texture = Oyster::Graphics::API::CreateTexture(textureName);
}
virtual void Render()
{
2014-02-11 15:06:46 +01:00
if(EventButton<Owner>::Enabled())
{
//Render att xPos and yPos
2014-02-12 09:08:38 +01:00
//With width and height
if(EventButton<Owner>::GetState() == ButtonState_None)
{
Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(1, 1, 1));
2014-02-12 09:08:38 +01:00
}
else if(EventButton<Owner>::GetState() == ButtonState_Hover)
{
Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(0, 1, 0));
2014-02-12 09:08:38 +01:00
}
else
{
Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(1, 0, 0));
2014-02-12 09:08:38 +01:00
}
2014-02-11 15:06:46 +01:00
}
}
protected:
float xPos, yPos;
2014-02-12 09:08:38 +01:00
float width, height;
Oyster::Graphics::API::Texture texture;
};
}
}
#endif