Fixed some of Kacperks's code.
This commit is contained in:
26
GUI.cpp
26
GUI.cpp
@@ -1,6 +1,9 @@
|
||||
#include "GUI.h"
|
||||
|
||||
Button::Button(sf::Image* normal,sf::Image* clicked,std::string words,sf::Vector2f location) {
|
||||
// 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;
|
||||
@@ -11,14 +14,17 @@ Button::Button(sf::Image* normal,sf::Image* clicked,std::string words,sf::Vector
|
||||
String.SetPosition(location.x+3,location.y+3);
|
||||
String.SetSize(14);
|
||||
}
|
||||
void Button::checkClick (sf::Vector2f mousePos) {
|
||||
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) {
|
||||
|
||||
void Button::setState(bool which)
|
||||
{
|
||||
current = which;
|
||||
if (current) {
|
||||
currentSpr=&clicked;
|
||||
@@ -26,16 +32,20 @@ void Button::setState(bool which) {
|
||||
}
|
||||
currentSpr=&normal;
|
||||
}
|
||||
void Button::setText(std::string words) {
|
||||
void Button::setText(std::string words)
|
||||
{
|
||||
String.SetText(words);
|
||||
}
|
||||
bool Button::getVar() {
|
||||
bool Button::getVar()
|
||||
{
|
||||
return current;
|
||||
}
|
||||
sf::Sprite* Button::getSprite() {
|
||||
sf::Sprite* Button::getSprite()
|
||||
{
|
||||
return currentSpr;
|
||||
}
|
||||
|
||||
sf::String * Button::getText() {
|
||||
sf::String * Button::getText()
|
||||
{
|
||||
return &String;
|
||||
}
|
||||
}*/
|
||||
|
||||
Reference in New Issue
Block a user