git repos / blockattack-game

commit 465d2e3f

sago007 · 2020-06-28 08:40
465d2e3f951fc149f0e8dc37a605d3808e593a36 patch · browse files
parent faf9296b6c1ebc17057fc213ece2ba401718b68b

Started moving font definitions to a common file for all help screens

Changed files

M source/code/HelpAboutState.cpp before
A source/code/HelpCommon.cpp
A source/code/HelpCommon.hpp
M source/code/HelpGamepadState.cpp before
diff --git a/source/code/HelpAboutState.cpp b/source/code/HelpAboutState.cpp index 6049a48..c00ab6d 100644 --- a/source/code/HelpAboutState.cpp +++ b/source/code/HelpAboutState.cpp
@@ -136,4 +136,4 @@ void HelpAboutState::Update() {
}
}
-}
\ No newline at end of file
+}
diff --git a/source/code/HelpCommon.cpp b/source/code/HelpCommon.cpp new file mode 100644 index 0000000..cede2d9 --- /dev/null +++ b/source/code/HelpCommon.cpp
@@ -0,0 +1,43 @@
+/*
+===========================================================================
+blockattack - Block Attack - Rise of the Blocks
+Copyright (C) 2005-2020 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 "HelpCommon.hpp"
+
+
+
+template<typename T> void setHelp30FontTemplate(const sago::SagoDataHolder* holder, T& field, const char* text) {
+ field.SetHolder(holder);
+ field.SetFont("freeserif");
+ field.SetColor({255,255,255,255});
+ field.SetFontSize(30);
+ field.SetOutline(2, {0,0,0,255});
+ field.SetText(text);
+}
+
+void setHelp30Font(const sago::SagoDataHolder* holder, sago::SagoTextField& field, const char* text) {
+ setHelp30FontTemplate(holder, field, text);
+}
+
+void setHelp30Font(const sago::SagoDataHolder* holder, sago::SagoTextBox& field, const char* text) {
+ setHelp30FontTemplate(holder, field, text);
+}
diff --git a/source/code/HelpCommon.hpp b/source/code/HelpCommon.hpp new file mode 100644 index 0000000..5af3a75 --- /dev/null +++ b/source/code/HelpCommon.hpp
@@ -0,0 +1,29 @@
+/*
+===========================================================================
+blockattack - Block Attack - Rise of the Blocks
+Copyright (C) 2005-2020 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 "sago/SagoTextBox.hpp"
+#include "sago/SagoTextField.hpp"
+
+
+void setHelp30Font(const sago::SagoDataHolder* holder, sago::SagoTextField& field, const char* text);
+void setHelp30Font(const sago::SagoDataHolder* holder, sago::SagoTextBox& field, const char* text);
diff --git a/source/code/HelpGamepadState.cpp b/source/code/HelpGamepadState.cpp index 5de5c25..5024cee 100644 --- a/source/code/HelpGamepadState.cpp +++ b/source/code/HelpGamepadState.cpp
@@ -21,6 +21,7 @@ https://blockattack.net
===========================================================================
*/
+#include "HelpCommon.hpp"
#include "HelpGamepadState.hpp"
#include "global.hpp"
#include "common.h"
@@ -29,23 +30,6 @@ https://blockattack.net
const int buttonOffset = 160;
-template<typename T> void setHelpGamepadFontTemplate(const sago::SagoDataHolder* holder, T& field, const char* text) {
- field.SetHolder(holder);
- field.SetFont("freeserif");
- field.SetColor({255,255,255,255});
- field.SetFontSize(30);
- field.SetOutline(2, {0,0,0,255});
- field.SetText(text);
-}
-
-static void setHelpGamepadFont(const sago::SagoDataHolder* holder, sago::SagoTextField& field, const char* text) {
- setHelpGamepadFontTemplate(holder, field, text);
-}
-
-static void setHelpGamepadFont(const sago::SagoDataHolder* holder, sago::SagoTextBox& field, const char* text) {
- setHelpGamepadFontTemplate(holder, field, text);
-}
-
static std::string getLabelForSupportedControllerNames() {
std::string s = _("Only SDL2 compatible controllers are supported!\nSupported controllers: ");
@@ -60,13 +44,13 @@ static std::string getLabelForSupportedControllerNames() {
HelpGamepadState::HelpGamepadState() {
- setHelpGamepadFont(&globalData.spriteHolder->GetDataHolder(), moveLabel, _("Move cursor"));
- setHelpGamepadFont(&globalData.spriteHolder->GetDataHolder(), pushLabel, _("Push line"));
- setHelpGamepadFont(&globalData.spriteHolder->GetDataHolder(), backLabel, _("Back (Menu)"));
- setHelpGamepadFont(&globalData.spriteHolder->GetDataHolder(), switchLabel, _("Switch"));
- setHelpGamepadFont(&globalData.spriteHolder->GetDataHolder(), confirmLabel, _("Confirm"));
+ setHelp30Font(&globalData.spriteHolder->GetDataHolder(), moveLabel, _("Move cursor"));
+ setHelp30Font(&globalData.spriteHolder->GetDataHolder(), pushLabel, _("Push line"));
+ setHelp30Font(&globalData.spriteHolder->GetDataHolder(), backLabel, _("Back (Menu)"));
+ setHelp30Font(&globalData.spriteHolder->GetDataHolder(), switchLabel, _("Switch"));
+ setHelp30Font(&globalData.spriteHolder->GetDataHolder(), confirmLabel, _("Confirm"));
std::string s = getLabelForSupportedControllerNames();
- setHelpGamepadFont(&globalData.spriteHolder->GetDataHolder(), supportedControllers, s.c_str());
+ setHelp30Font(&globalData.spriteHolder->GetDataHolder(), supportedControllers, s.c_str());
supportedControllers.SetMaxWidth(740);
}
@@ -84,7 +68,7 @@ void HelpGamepadState::ProcessInput(const SDL_Event& event, bool& processed) {
UnInitGameControllers();
InitGameControllers();
std::string s = getLabelForSupportedControllerNames();
- setHelpGamepadFont(&globalData.spriteHolder->GetDataHolder(), supportedControllers, s.c_str());
+ setHelp30Font(&globalData.spriteHolder->GetDataHolder(), supportedControllers, s.c_str());
processed = true;
}