2014-02-12 09:08:38 +01:00
|
|
|
//////////////////////////////////////
|
|
|
|
// Created by Pontus Fransson 2014 //
|
|
|
|
//////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef DANBIAS_CLIENT_BUTTON_CIRCLE_H
|
|
|
|
#define DANBIAS_CLIENT_BUTTON_CIRCLE_H
|
|
|
|
|
|
|
|
#include "EventButtonGUI.h"
|
|
|
|
|
|
|
|
//Only for testing because we don't have any other input
|
|
|
|
#include "../WindowManager/WindowShell.h"
|
|
|
|
|
|
|
|
namespace DanBias
|
|
|
|
{
|
|
|
|
namespace Client
|
|
|
|
{
|
|
|
|
template <typename Owner>
|
|
|
|
class ButtonEllipse : public EventButtonGUI<Owner>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ButtonEllipse()
|
|
|
|
: EventButtonGUI(), radius(0)
|
|
|
|
{}
|
2014-02-17 13:05:35 +01:00
|
|
|
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, Owner owner, Oyster::Math::Float3 pos,
|
2014-02-14 09:44:21 +01:00
|
|
|
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
2014-02-13 15:21:05 +01:00
|
|
|
: EventButtonGUI(textureName, buttonText, textColor, owner, pos, size, resize)
|
2014-02-12 09:08:38 +01:00
|
|
|
{}
|
2014-02-17 13:05:35 +01:00
|
|
|
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Oyster::Math::Float3 pos,
|
2014-02-14 09:44:21 +01:00
|
|
|
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
2014-02-13 15:21:05 +01:00
|
|
|
: EventButtonGUI(textureName, buttonText, textColor, func, pos, size, resize)
|
2014-02-12 09:08:38 +01:00
|
|
|
{}
|
2014-02-17 13:05:35 +01:00
|
|
|
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos,
|
2014-02-14 09:44:21 +01:00
|
|
|
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
2014-02-13 15:21:05 +01:00
|
|
|
: EventButtonGUI(textureName, buttonText, textColor, func, owner, pos, size, resize)
|
2014-02-12 09:08:38 +01:00
|
|
|
{}
|
2014-02-17 13:05:35 +01:00
|
|
|
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos,
|
2014-02-14 09:44:21 +01:00
|
|
|
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
2014-02-13 15:21:05 +01:00
|
|
|
: EventButtonGUI(textureName, buttonText, textColor, func, owner, userData, pos, size, resize)
|
2014-02-12 09:08:38 +01:00
|
|
|
{}
|
|
|
|
virtual ~ButtonEllipse()
|
|
|
|
{}
|
|
|
|
|
|
|
|
//Circle vs point collision
|
2014-02-12 15:44:27 +01:00
|
|
|
bool Collision(Oyster::Event::MouseInput& input)
|
2014-02-12 09:08:38 +01:00
|
|
|
{
|
|
|
|
//Should come from the InputClass
|
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
|
|
|
double normx = (xMouse - pos.x) / size.x;
|
|
|
|
double normy = (yMouse - pos.y) / size.y;
|
2014-02-12 09:08:38 +01:00
|
|
|
|
|
|
|
return (normx * normx + normy * normy) < 0.25;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|