2014-02-11 14:13:35 +01:00
|
|
|
//////////////////////////////////////
|
|
|
|
// Created by Pontus Fransson 2014 //
|
|
|
|
//////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef DANBIAS_CLIENT_BUTTON_RECTANGLE_H
|
|
|
|
#define DANBIAS_CLIENT_BUTTON_RECTANGLE_H
|
|
|
|
|
|
|
|
#include "EventButtonGUI.h"
|
|
|
|
|
|
|
|
namespace DanBias
|
|
|
|
{
|
|
|
|
namespace Client
|
|
|
|
{
|
|
|
|
template <typename Owner>
|
|
|
|
class ButtonRectangle : public EventButtonGUI<Owner>
|
|
|
|
{
|
|
|
|
public:
|
2014-02-18 09:32:10 +01:00
|
|
|
ButtonRectangle(std::wstring textureName, std::wstring buttonText,
|
|
|
|
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
|
2014-02-19 15:40:09 +01:00
|
|
|
Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
|
|
|
|
: EventButtonGUI(textureName, buttonText
|
|
|
|
, textColor, backColor, hoverColor, pressedColor
|
|
|
|
, owner, pos, size, resize)
|
2014-02-11 14:13:35 +01:00
|
|
|
{}
|
2014-02-18 09:32:10 +01:00
|
|
|
ButtonRectangle(std::wstring textureName, std::wstring buttonText,
|
|
|
|
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
|
2014-02-19 15:40:09 +01:00
|
|
|
EventFunc func, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
|
|
|
|
: EventButtonGUI(textureName, buttonText
|
|
|
|
, textColor, backColor, hoverColor, pressedColor
|
|
|
|
, func, pos, size, resize)
|
2014-02-11 14:13:35 +01:00
|
|
|
{}
|
2014-02-18 09:32:10 +01:00
|
|
|
ButtonRectangle(std::wstring textureName, std::wstring buttonText,
|
|
|
|
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
|
2014-02-19 15:40:09 +01:00
|
|
|
EventFunc func, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
|
|
|
|
: EventButtonGUI(textureName, buttonText
|
|
|
|
, textColor, backColor, hoverColor, pressedColor
|
|
|
|
, func, owner, pos, size, resize)
|
2014-02-11 14:13:35 +01:00
|
|
|
{}
|
2014-02-18 09:32:10 +01:00
|
|
|
ButtonRectangle(std::wstring textureName, std::wstring buttonText,
|
|
|
|
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
|
2014-02-19 15:40:09 +01:00
|
|
|
EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
|
|
|
|
: EventButtonGUI(textureName, buttonText
|
|
|
|
, textColor, backColor, hoverColor, pressedColor
|
|
|
|
, func, owner, userData, pos, size, resize)
|
2014-02-11 14:13:35 +01:00
|
|
|
{}
|
2014-02-12 09:08:38 +01:00
|
|
|
virtual ~ButtonRectangle()
|
2014-02-11 14:13:35 +01:00
|
|
|
{}
|
|
|
|
|
2014-02-19 15:40:09 +01:00
|
|
|
//Rectangle vs point collision
|
2014-02-12 15:44:27 +01:00
|
|
|
bool Collision(Oyster::Event::MouseInput& input)
|
2014-02-11 14:13:35 +01:00
|
|
|
{
|
2014-02-12 15:44:27 +01:00
|
|
|
float xMouse = input.x, yMouse = input.y;
|
2014-02-12 09:08:38 +01:00
|
|
|
|
2014-02-13 15:21:05 +01:00
|
|
|
float widthTemp = pos.x - size.x * 0.5f;
|
|
|
|
float widthTemp2 = pos.x + size.x * 0.5f;
|
|
|
|
float heightTemp = pos.y - size.y * 0.5f;
|
|
|
|
float heightTemp2 = pos.y + size.y * 0.5f;
|
2014-02-11 14:13:35 +01:00
|
|
|
|
2014-02-12 09:08:38 +01:00
|
|
|
if(xMouse >= widthTemp && xMouse <= widthTemp2 &&
|
|
|
|
yMouse >= heightTemp && yMouse <= heightTemp2)
|
2014-02-11 14:13:35 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|