| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
1 |
/* |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
2 |
=========================================================================== |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
3 |
blockattack - Block Attack - Rise of the Blocks |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
4 |
Copyright (C) 2005-2018 Poul Sander |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
5 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
6 |
This program is free software: you can redistribute it and/or modify |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
7 |
it under the terms of the GNU General Public License as published by |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
8 |
the Free Software Foundation, either version 2 of the License, or |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
9 |
(at your option) any later version. |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
10 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
11 |
This program is distributed in the hope that it will be useful, |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
14 |
GNU General Public License for more details. |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
15 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
16 |
You should have received a copy of the GNU General Public License |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
17 |
along with this program. If not, see http://www.gnu.org/licenses/ |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
18 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
19 |
Source information and contacts persons can be found at |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
20 |
https://blockattack.net |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
21 |
=========================================================================== |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
22 |
*/ |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
23 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
24 |
#include "HelpAboutState.hpp" |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
25 |
#include "global.hpp" |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
26 |
#include "common.h" |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
27 |
#include "MenuSystem.h" |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
28 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
29 |
const int xsize = 1024; |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
30 |
const int ysize = 768; |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
31 |
const int buttonOffset = 160; |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
32 |
extern sago::SagoSprite bExit; |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
33 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
34 |
HelpAboutState::HelpAboutState() { |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
35 |
} |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
36 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
37 |
HelpAboutState::~HelpAboutState() { |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
38 |
} |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
39 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
40 |
bool HelpAboutState::IsActive() { |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
41 |
return isActive; |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
42 |
} |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
43 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
44 |
void HelpAboutState::ProcessInput(const SDL_Event& event, bool& processed) { |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
45 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
46 |
UpdateMouseCoordinates(event, globalData.mousex, globalData.mousey); |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
47 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
48 |
if (isConfirmEvent(event) || isEscapeEvent(event)) { |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
49 |
isActive = false; |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
50 |
processed = true; |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
51 |
} |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
52 |
} |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
53 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
54 |
void HelpAboutState::Draw(SDL_Renderer* target) { |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
55 |
DrawBackground(target); |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
56 |
bExit.Draw(globalData.screen, SDL_GetTicks(), xsize-buttonOffset, ysize-buttonOffset); |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
57 |
#if DEBUG |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
58 |
static sago::SagoTextField mousePos; |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
59 |
mousePos.SetHolder(&globalData.spriteHolder->GetDataHolder()); |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
60 |
mousePos.SetFontSize(16); |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
61 |
mousePos.SetOutline(1, {128,128,128,255}); |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
62 |
mousePos.SetText(std::string("Mouse position: ")+std::to_string(globalData.mousex)+std::string(", ")+std::to_string(globalData.mousey)); |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
63 |
mousePos.Draw(target, 0,0); |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
64 |
#endif |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
65 |
} |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
66 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
67 |
void HelpAboutState::Update() { |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
68 |
// If the mouse button is released, make bMouseUp equal true |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
69 |
if ( !(SDL_GetMouseState(nullptr, nullptr)&SDL_BUTTON(1)) ) { |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
70 |
bMouseUp=true; |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
71 |
} |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
72 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
73 |
if (SDL_GetMouseState(nullptr,nullptr)&SDL_BUTTON(1) && bMouseUp) { |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
74 |
bMouseUp = false; |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
75 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
76 |
//The Score button: |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
77 |
if ((globalData.mousex>xsize-buttonOffset) && (globalData.mousex<xsize-buttonOffset+bExit.GetWidth()) |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
78 |
&& (globalData.mousey>ysize-buttonOffset) && (globalData.mousey<ysize-buttonOffset+bExit.GetHeight())) { |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
79 |
isActive = false; |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
80 |
} |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
81 |
|
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
82 |
} |
| 5147de4e |
Poul Sander |
2018-05-06 12:59 |
83 |
} |