Button Class & MIT License Added.
This commit is contained in:
parent
39a256cb49
commit
cc7dfbc03d
41
GUI.cpp
Normal file
41
GUI.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include "GUI.h"
|
||||
|
||||
Button::Button(sf::Image* normal,sf::Image* clicked,std::string words,sf::Vector2f 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;
|
||||
}
|
21
LICENSE.txt
Normal file
21
LICENSE.txt
Normal file
@ -0,0 +1,21 @@
|
||||
---------------------------------
|
||||
Copyright (c) 2021-2022 MCL
|
||||
Copyright (c) 2022 Cube-Software
|
||||
---------------------------------
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -41,9 +41,11 @@
|
||||
<Add option="-lopengl32" />
|
||||
<Add option="-lsfml-window" />
|
||||
</Linker>
|
||||
<Unit filename="GUI.cpp" />
|
||||
<Unit filename="MapBlock.cpp" />
|
||||
<Unit filename="include/Base.h" />
|
||||
<Unit filename="include/FastNoiseLite.h" />
|
||||
<Unit filename="include/GUI.h" />
|
||||
<Unit filename="include/Logger.h" />
|
||||
<Unit filename="include/MapBlock.h" />
|
||||
<Unit filename="include/NodeRenderer.h" />
|
||||
|
@ -58,3 +58,58 @@
|
||||
1667167831 source:c:\development\xtreemminer\mapblock.cpp
|
||||
"MapBlock.h"
|
||||
|
||||
1667294728 source:/home/kacperks/projects/XtreemNodes/MapBlock.cpp
|
||||
"MapBlock.h"
|
||||
|
||||
1667294728 /home/kacperks/projects/XtreemNodes/include/MapBlock.h
|
||||
"Base.h"
|
||||
<math.h>
|
||||
<cstdio>
|
||||
|
||||
1667294728 /home/kacperks/projects/XtreemNodes/include/Base.h
|
||||
|
||||
1667294728 source:/home/kacperks/projects/XtreemNodes/main.cpp
|
||||
<stdlib.h>
|
||||
<GL/glut.h>
|
||||
"Utilities.h"
|
||||
"MapBlock.h"
|
||||
"Base.h"
|
||||
"NodeRenderer.h"
|
||||
"TextureHandler.h"
|
||||
<math.h>
|
||||
<cstdio>
|
||||
"FastNoiseLite.h"
|
||||
<random>
|
||||
<SFML/Window.hpp>
|
||||
|
||||
1667294728 /home/kacperks/projects/XtreemNodes/include/Utilities.h
|
||||
|
||||
1667294728 /home/kacperks/projects/XtreemNodes/include/NodeRenderer.h
|
||||
"Base.h"
|
||||
"MapBlock.h"
|
||||
<GL/glut.h>
|
||||
|
||||
1667294728 /home/kacperks/projects/XtreemNodes/include/TextureHandler.h
|
||||
"stb_image.h"
|
||||
"Base.h"
|
||||
|
||||
1667088826 /home/kacperks/projects/XtreemNodes/include/stb_image.h
|
||||
"stb_image.h"
|
||||
<stdio.h>
|
||||
<stdlib.h>
|
||||
<stdarg.h>
|
||||
<stddef.h>
|
||||
<stdlib.h>
|
||||
<string.h>
|
||||
<limits.h>
|
||||
<math.h>
|
||||
<stdio.h>
|
||||
<assert.h>
|
||||
<stdint.h>
|
||||
<emmintrin.h>
|
||||
<intrin.h>
|
||||
<arm_neon.h>
|
||||
|
||||
1667294728 /home/kacperks/projects/XtreemNodes/include/FastNoiseLite.h
|
||||
<cmath>
|
||||
|
||||
|
@ -2,54 +2,64 @@
|
||||
<CodeBlocks_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveTarget name="Debug" />
|
||||
<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="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="3452" topLine="136" />
|
||||
</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">
|
||||
<Cursor>
|
||||
<Cursor1 position="28" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<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="1001" topLine="34" />
|
||||
</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\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\stb_image.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<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\NodeRenderer.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="-1" 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="2409" topLine="75" />
|
||||
<Cursor1 position="97" 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">
|
||||
<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">
|
||||
<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\FastNoiseLite.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<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">
|
||||
<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">
|
||||
<Cursor>
|
||||
<Cursor1 position="1155" 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">
|
||||
<Cursor>
|
||||
<Cursor1 position="1001" topLine="27" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
23
include/GUI.h
Normal file
23
include/GUI.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef GUI
|
||||
#defome GUI
|
||||
|
||||
#include <SFML/Main.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;
|
||||
};
|
||||
|
||||
#endif // GUI
|
Loading…
Reference in New Issue
Block a user