63 lines
1.9 KiB
C
63 lines
1.9 KiB
C
|
//////////////////////////////////////
|
||
|
// 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)
|
||
|
{}
|
||
|
ButtonEllipse(std::wstring textureName, Owner owner, float xPos, float yPos, float textureWidth, float textureHeight)
|
||
|
: EventButtonGUI(textureName, owner, xPos, yPos, textureWidth, textureHeight)
|
||
|
{}
|
||
|
ButtonEllipse(std::wstring textureName, EventFunc func, float xPos, float yPos, float textureWidth, float textureHeight)
|
||
|
: EventButtonGUI(textureName, func, xPos, yPos, textureWidth, textureHeight)
|
||
|
{}
|
||
|
ButtonEllipse(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float textureWidth, float textureHeight)
|
||
|
: EventButtonGUI(textureName, func, owner, xPos, yPos, textureWidth, textureHeight)
|
||
|
{}
|
||
|
ButtonEllipse(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float textureWidth, float textureHeight)
|
||
|
: EventButtonGUI(textureName, func, owner, userData, xPos, yPos, textureWidth, textureHeight)
|
||
|
{}
|
||
|
virtual ~ButtonEllipse()
|
||
|
{}
|
||
|
|
||
|
//Circle vs point collision
|
||
|
bool Collision(InputClass* inputObject)
|
||
|
{
|
||
|
POINT p;
|
||
|
GetCursorPos(&p);
|
||
|
ScreenToClient(WindowShell::GetHWND(), &p);
|
||
|
RECT r;
|
||
|
GetClientRect(WindowShell::GetHWND(), &r);
|
||
|
|
||
|
//Should come from the InputClass
|
||
|
float xMouse = (float)p.x / (float)r.right, yMouse = (float)p.y / (float)r.bottom;
|
||
|
|
||
|
double normx = (xMouse - xPos) / width;
|
||
|
double normy = (yMouse - yPos) / height;
|
||
|
|
||
|
return (normx * normx + normy * normy) < 0.25;
|
||
|
}
|
||
|
|
||
|
protected:
|
||
|
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endif
|