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

66 lines
2.5 KiB
C
Raw Normal View History

//////////////////////////////////////
// Created by Pontus Fransson 2014 //
//////////////////////////////////////
#ifndef DANBIAS_CLIENT_BUTTON_RECTANGLE_H
#define DANBIAS_CLIENT_BUTTON_RECTANGLE_H
#include "EventButtonGUI.h"
2014-02-12 09:08:38 +01:00
#include <iostream>
//Only for testing because we don't have any other input
#include "../WindowManager/WindowShell.h"
namespace DanBias
{
namespace Client
{
template <typename Owner>
class ButtonRectangle : public EventButtonGUI<Owner>
{
public:
ButtonRectangle()
2014-02-12 09:08:38 +01:00
: EventButtonGUI(), width(0), height(0)
{}
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButtonGUI(textureName, buttonText, textColor, owner, pos, size, resize)
{}
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButtonGUI(textureName, buttonText, textColor, func, pos, size, resize)
{}
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButtonGUI(textureName, buttonText, textColor, func, owner, pos, size, resize)
{}
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
: EventButtonGUI(textureName, buttonText, textColor, func, owner, userData, pos, size, resize)
{}
2014-02-12 09:08:38 +01:00
virtual ~ButtonRectangle()
{}
//Circle vs point collision
bool Collision(Oyster::Event::MouseInput& input)
{
//Should come from the InputClass
float xMouse = input.x, yMouse = input.y;
2014-02-12 09:08:38 +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-12 09:08:38 +01:00
//std::cout << p.x << ' ' << p.y << ' ' << widthTemp << ' ' << heightTemp << std::endl;
2014-02-12 09:08:38 +01:00
if(xMouse >= widthTemp && xMouse <= widthTemp2 &&
yMouse >= heightTemp && yMouse <= heightTemp2)
{
return true;
}
return false;
}
protected:
};
}
}
#endif