2014-02-11 14:13:35 +01:00
|
|
|
//////////////////////////////////////
|
|
|
|
// 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"
|
2014-02-11 14:13:35 +01:00
|
|
|
|
|
|
|
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-11 14:13:35 +01:00
|
|
|
{}
|
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)
|
2014-02-11 14:13:35 +01:00
|
|
|
{
|
|
|
|
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)
|
2014-02-11 14:13:35 +01:00
|
|
|
{
|
|
|
|
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)
|
2014-02-11 14:13:35 +01:00
|
|
|
{
|
|
|
|
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)
|
2014-02-11 14:13:35 +01:00
|
|
|
{
|
|
|
|
CreateTexture(textureName);
|
|
|
|
}
|
2014-02-12 09:08:38 +01:00
|
|
|
virtual ~EventButtonGUI()
|
|
|
|
{
|
|
|
|
Oyster::Graphics::API::DeleteTexture(texture);
|
|
|
|
texture = NULL;
|
|
|
|
}
|
2014-02-11 14:13:35 +01:00
|
|
|
|
|
|
|
void CreateTexture(std::wstring textureName)
|
|
|
|
{
|
|
|
|
//Create texture
|
2014-02-12 10:02:52 +01:00
|
|
|
texture = Oyster::Graphics::API::CreateTexture(textureName);
|
2014-02-11 14:13:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2014-02-12 10:02:52 +01:00
|
|
|
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)
|
|
|
|
{
|
2014-02-12 10:02:52 +01:00
|
|
|
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
|
|
|
|
{
|
2014-02-12 10:02:52 +01:00
|
|
|
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
|
|
|
}
|
2014-02-11 14:13:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
float xPos, yPos;
|
2014-02-12 09:08:38 +01:00
|
|
|
float width, height;
|
|
|
|
Oyster::Graphics::API::Texture texture;
|
|
|
|
|
2014-02-11 14:13:35 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|