XtreemNodes/GUI.cpp

52 lines
1.2 KiB
C++

#include "GUI.h"
// Code contributed by Kacperks
// COMMENTED OUT BECAUSE IT DOESN'T WORK!
/*
Button::Button(sf::Image* normal, sf::Image* clicked, std::string words, Position2D location) {
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);
}
void Button::checkClick (sf::Vector2f mousePos)
{
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);
}
}
}
void Button::setState(bool which)
{
current = which;
if (current) {
currentSpr=&clicked;
return;
}
currentSpr=&normal;
}
void Button::setText(std::string words)
{
String.SetText(words);
}
bool Button::getVar()
{
return current;
}
sf::Sprite* Button::getSprite()
{
return currentSpr;
}
sf::String * Button::getText()
{
return &String;
}*/