2022-11-01 11:36:12 +01:00
|
|
|
#include "GUI.h"
|
|
|
|
|
2022-11-01 22:07:58 +01:00
|
|
|
// Code contributed by Kacperks
|
|
|
|
// COMMENTED OUT BECAUSE IT DOESN'T WORK!
|
|
|
|
/*
|
|
|
|
Button::Button(sf::Image* normal, sf::Image* clicked, std::string words, Position2D location) {
|
2022-11-01 11:36:12 +01:00
|
|
|
this->normal.SetImage(*normal);
|
|
|
|
this->clicked.SetImage(*clicked);
|
|
|
|
this->currentSpr=&this->normal;
|
|
|
|
current =false;
|
|
|
|
this->normal.SetPosition(location);
|
|
|
|
this->clicked.SetPosition(location);
|
|
|
|
String.SetText(words);
|
|
|
|
String.SetPosition(location.x+3,location.y+3);
|
|
|
|
String.SetSize(14);
|
|
|
|
}
|
2022-11-01 22:07:58 +01:00
|
|
|
void Button::checkClick (sf::Vector2f mousePos)
|
|
|
|
{
|
2022-11-01 11:36:12 +01:00
|
|
|
if (mousePos.x>currentSpr->GetPosition().x && mousePos.x<(currentSpr->GetPosition().x + currentSpr->GetSize().x)) {
|
|
|
|
if(mousePos.y>currentSpr->GetPosition().y && mousePos.y<(currentSpr->GetPosition().y + currentSpr->GetSize().y)) {
|
|
|
|
setState(!current);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-11-01 22:07:58 +01:00
|
|
|
|
|
|
|
void Button::setState(bool which)
|
|
|
|
{
|
2022-11-01 11:36:12 +01:00
|
|
|
current = which;
|
|
|
|
if (current) {
|
|
|
|
currentSpr=&clicked;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
currentSpr=&normal;
|
|
|
|
}
|
2022-11-01 22:07:58 +01:00
|
|
|
void Button::setText(std::string words)
|
|
|
|
{
|
2022-11-01 11:36:12 +01:00
|
|
|
String.SetText(words);
|
|
|
|
}
|
2022-11-01 22:07:58 +01:00
|
|
|
bool Button::getVar()
|
|
|
|
{
|
2022-11-01 11:36:12 +01:00
|
|
|
return current;
|
|
|
|
}
|
2022-11-01 22:07:58 +01:00
|
|
|
sf::Sprite* Button::getSprite()
|
|
|
|
{
|
2022-11-01 11:36:12 +01:00
|
|
|
return currentSpr;
|
|
|
|
}
|
|
|
|
|
2022-11-01 22:07:58 +01:00
|
|
|
sf::String * Button::getText()
|
|
|
|
{
|
2022-11-01 11:36:12 +01:00
|
|
|
return &String;
|
2022-11-01 22:07:58 +01:00
|
|
|
}*/
|