commit d4f28be2
Add exit button to HowTo screen
Changed files
| M | source/code/HelpGamepadState.cpp before |
| M | source/code/HelpHowtoState.cpp before |
| M | source/code/HelpHowtoState.hpp before |
diff --git a/source/code/HelpGamepadState.cpp b/source/code/HelpGamepadState.cpp
index a164199..7810613 100644
--- a/source/code/HelpGamepadState.cpp
+++ b/source/code/HelpGamepadState.cpp
@@ -120,7 +120,7 @@ void HelpGamepadState::Draw(SDL_Renderer* target) {
}
void HelpGamepadState::Update() {
- // If the mouse button is released, make bMouseUp equal true
+ // If the mouse button is released, make bMouseUp equal true
if ( !(SDL_GetMouseState(nullptr, nullptr)&SDL_BUTTON(1)) ) {
bMouseUp=true;
}
diff --git a/source/code/HelpHowtoState.cpp b/source/code/HelpHowtoState.cpp
index e2f13d6..d455b52 100644
--- a/source/code/HelpHowtoState.cpp
+++ b/source/code/HelpHowtoState.cpp
@@ -26,6 +26,11 @@ https://blockattack.net
#include "common.h"
#include "MenuSystem.h"
+const int xsize = 1024;
+const int ysize = 768;
+const int buttonOffset = 160;
+extern sago::SagoSprite bExit;
+
HelpHowtoState::HelpHowtoState() {
box.SetHolder(&globalData.spriteHolder->GetDataHolder());
box.SetFontSize(30);
@@ -57,8 +62,23 @@ void HelpHowtoState::Draw(SDL_Renderer* target) {
DrawBackground(target);
box.SetMaxWidth(1000);
box.Draw(target, 10,10);
+ bExit.Draw(globalData.screen, SDL_GetTicks(), xsize-buttonOffset, ysize-buttonOffset);
}
void HelpHowtoState::Update() {
-
+ // If the mouse button is released, make bMouseUp equal true
+ if ( !(SDL_GetMouseState(nullptr, nullptr)&SDL_BUTTON(1)) ) {
+ bMouseUp=true;
+ }
+
+ if (SDL_GetMouseState(nullptr,nullptr)&SDL_BUTTON(1) && bMouseUp) {
+ bMouseUp = false;
+
+ //The Score button:
+ if ((globalData.mousex>xsize-buttonOffset) && (globalData.mousex<xsize-buttonOffset+bExit.GetWidth())
+ && (globalData.mousey>ysize-buttonOffset) && (globalData.mousey<ysize-buttonOffset+bExit.GetHeight())) {
+ isActive = false;
+ }
+
+ }
}
\ No newline at end of file
diff --git a/source/code/HelpHowtoState.hpp b/source/code/HelpHowtoState.hpp
index e0954d6..6f09546 100644
--- a/source/code/HelpHowtoState.hpp
+++ b/source/code/HelpHowtoState.hpp
@@ -41,6 +41,7 @@ public:
private:
bool isActive = true;
+ bool bMouseUp = true;
sago::SagoTextBox box;
};