git repos / blockattack-game

commit 54d2d583

sago007 · 2018-04-05 17:52
54d2d583a8c09efe0f05d7571f040b0b5026134b patch · browse files
parent f6e8c70410c3ce3c224cba6cd97d90af04e59e7e

Started adding a gamepad screen to show the keys

Changed files

A source/code/HelpGamepadState.cpp
A source/code/HelpGamepadState.hpp
M source/code/menudef.cpp before
diff --git a/source/code/HelpGamepadState.cpp b/source/code/HelpGamepadState.cpp new file mode 100644 index 0000000..541561c --- /dev/null +++ b/source/code/HelpGamepadState.cpp
@@ -0,0 +1,55 @@
+/*
+===========================================================================
+blockattack - Block Attack - Rise of the Blocks
+Copyright (C) 2005-2018 Poul Sander
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see http://www.gnu.org/licenses/
+
+Source information and contacts persons can be found at
+https://blockattack.net
+===========================================================================
+*/
+
+#include "HelpGamepadState.hpp"
+#include "global.hpp"
+#include "common.h"
+#include "MenuSystem.h"
+
+HelpGamepadState::HelpGamepadState() {
+}
+
+
+HelpGamepadState::~HelpGamepadState() {
+}
+
+bool HelpGamepadState::IsActive() {
+ return isActive;
+}
+
+void HelpGamepadState::ProcessInput(const SDL_Event& event, bool& processed) {
+ UpdateMouseCoordinates(event, globalData.mousex, globalData.mousey);
+
+ if (isConfirmEvent(event) || isEscapeEvent(event)) {
+ isActive = false;
+ processed = true;
+ }
+}
+
+void HelpGamepadState::Draw(SDL_Renderer* target) {
+ DrawBackground(target);
+}
+
+void HelpGamepadState::Update() {
+
+}
\ No newline at end of file
diff --git a/source/code/HelpGamepadState.hpp b/source/code/HelpGamepadState.hpp new file mode 100644 index 0000000..9545f7b --- /dev/null +++ b/source/code/HelpGamepadState.hpp
@@ -0,0 +1,49 @@
+/*
+===========================================================================
+blockattack - Block Attack - Rise of the Blocks
+Copyright (C) 2005-2018 Poul Sander
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see http://www.gnu.org/licenses/
+
+Source information and contacts persons can be found at
+https://blockattack.net
+===========================================================================
+*/
+
+#ifndef HELPGAMEPADSTATE_HPP
+#define HELPGAMEPADSTATE_HPP
+
+#include "sago/GameStateInterface.hpp"
+#include "sago/SagoTextField.hpp"
+#include "sago/SagoTextBox.hpp"
+
+class HelpGamepadState : public sago::GameStateInterface {
+public:
+ HelpGamepadState();
+ HelpGamepadState(const HelpGamepadState& orig) = delete;
+ virtual ~HelpGamepadState();
+
+ bool IsActive() override;
+ void Draw(SDL_Renderer* target) override;
+ void ProcessInput(const SDL_Event& event, bool &processed) override;
+ void Update() override;
+
+private:
+ bool isActive = true;
+private:
+
+};
+
+#endif /* HELPGAMEPADSTATE_HPP */
+
diff --git a/source/code/menudef.cpp b/source/code/menudef.cpp index 33ac0ec..95d239e 100644 --- a/source/code/menudef.cpp +++ b/source/code/menudef.cpp
@@ -26,6 +26,7 @@ http://blockattack.net
#include "MenuSystem.h"
#include "common.h"
#include "HelpHowtoState.hpp"
+#include "HelpGamepadState.hpp"
using std::string;
using std::cerr;
@@ -272,12 +273,21 @@ static void runHowto() {
RunGameState(howto);
}
+static void runHelpGamepad() {
+ HelpGamepadState helpGamepad;
+ RunGameState(helpGamepad);
+}
+
static void HelpMenu() {
Menu m(globalData.screen, _("Help"), true);
Button bHowto;
bHowto.setLabel(_("How to"));
bHowto.setAction(runHowto);
m.addButton(&bHowto);
+ Button bGamepad;
+ bGamepad.setLabel(_("Gamepad"));
+ bGamepad.setAction(runHelpGamepad);
+ m.addButton(&bGamepad);
RunGameState(m);
}