Fixed some of Kacperks's code.

This commit is contained in:
Functioning Member of Society 2022-11-01 17:07:58 -04:00
parent 70830e5014
commit fbe3bbd55e
4 changed files with 68 additions and 65 deletions

26
GUI.cpp
View File

@ -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;
}
}*/

View File

@ -1,5 +1,5 @@
# depslib dependency file v1.0
1667180176 source:c:\development\xtreemminer\main.cpp
1667335610 source:c:\development\xtreemminer\main.cpp
<stdlib.h>
<GL/glut.h>
"Utilities.h"

View File

@ -2,64 +2,54 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="include/stb_image.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="8925" topLine="160" />
</Cursor>
</File>
<File name="include/Logger.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="include\Logger.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="97" topLine="0" />
</Cursor>
</File>
<File name="include/MapBlock.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="438" topLine="0" />
</Cursor>
</File>
<File name="main.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="238" topLine="9" />
</Cursor>
</File>
<File name="include/Base.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="include\Base.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="28" topLine="0" />
</Cursor>
</File>
<File name="include/Nodes.h" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="264" topLine="0" />
</Cursor>
</File>
<File name="include/TextureHandler.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2192" topLine="17" />
</Cursor>
</File>
<File name="include/GUI.h" open="1" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="455" topLine="0" />
</Cursor>
</File>
<File name="include/NodeRenderer.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
<File name="include\NodeRenderer.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
<Cursor>
<Cursor1 position="2409" topLine="75" />
</Cursor>
</File>
<File name="GUI.cpp" open="1" top="1" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="MapBlock.cpp" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1155" topLine="0" />
<Cursor1 position="1001" topLine="34" />
</Cursor>
</File>
<File name="include/FastNoiseLite.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2573" topLine="100" />
</Cursor>
</File>
<File name="include\MapBlock.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="438" topLine="0" />
</Cursor>
</File>
<File name="include\stb_image.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="8925" topLine="160" />
</Cursor>
</File>
<File name="include\Nodes.h" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="264" topLine="0" />
</Cursor>
</File>
<File name="include\FastNoiseLite.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="100664" topLine="2262" />
</Cursor>
</File>
<File name="MapBlock.cpp" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="include\TextureHandler.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1001" topLine="27" />
<Cursor1 position="2192" topLine="17" />
</Cursor>
</File>
</CodeBlocks_layout_file>

View File

@ -1,23 +1,26 @@
#ifndef GUI
#defome GUI
#define GUI
#include "Base.h"
#include <SFML/Main.hpp>
#include <SFML/Graphics.hpp>
class Button {
public:
Button (sf::Image* normal,sf::Image* clicked,std::string,sf::Vector2f location);
void checkClick (sf::Vector2f);
void setState(bool);
void setText(std::string);
bool getVar();
sf::Sprite* getSprite();
sf::String * getText();
private:
sf::Sprite normal;
sf::Sprite clicked;
sf::Sprite* currentSpr;
sf::String String;
bool current;
class Button
{
public:
Button(sf::Image* normal, sf::Image* clicked, std::string text, Position2D location);
void checkClick(Position2D);
void setState(bool state);
void setText(std::string);
bool getVar();
sf::Sprite* getSprite();
sf::String* getText();
private:
sf::Sprite normal;
sf::Sprite clicked;
sf::Sprite* currentSpr;
sf::String String;
bool current;
};
#endif // GUI
#endif