commit c4baf4ba
Moved the TextManager out
Changed files
| M | source/code/ReplayPlayer.cpp before |
| A | source/code/TextManager.hpp |
| M | source/code/global.hpp before |
| M | source/code/main.cpp before |
diff --git a/source/code/ReplayPlayer.cpp b/source/code/ReplayPlayer.cpp
index a01c583..94dc131 100644
--- a/source/code/ReplayPlayer.cpp
+++ b/source/code/ReplayPlayer.cpp
@@ -25,6 +25,15 @@ http://www.blockattack.net
#include "global.hpp"
#include "common.h"
#include "MenuSystem.h"
+//#include "BlockGameSdl.inc"
+
+
+
+/*static void MoveBlockGameSdls( BlockGameSdl& game1, BlockGameSdl& game2 ) {
+ game1.SetTopXY(50, globalData.ysize/2-284);
+ game2.SetTopXY(globalData.xsize-500, globalData.ysize/2-284);
+}*/
+
ReplayPlayer::ReplayPlayer() {
}
@@ -38,6 +47,8 @@ bool ReplayPlayer::IsActive() {
void ReplayPlayer::Draw(SDL_Renderer* target) {
DrawBackground(target);
+ //MoveBlockGameSdls(theGame, theGame2);
+ //DrawEverything(globalData.xsize, globalData.ysize, &theGame, &theGame2);
}
void ReplayPlayer::ProcessInput(const SDL_Event& event, bool& processed) {
diff --git a/source/code/TextManager.hpp b/source/code/TextManager.hpp
new file mode 100644
index 0000000..1e61afa
--- /dev/null
+++ b/source/code/TextManager.hpp
@@ -0,0 +1,109 @@
+/*
+===========================================================================
+blockattack - Block Attack - Rise of the Blocks
+Copyright (C) 2005-2017 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
+http://www.blockattack.net
+===========================================================================
+*/
+
+#ifndef TEXTMANAGER_HPP
+#define TEXTMANAGER_HPP
+
+
+class TextMessage {
+private:
+ int x = 0;
+ int y = 0;
+ string textt;
+ unsigned long int time = 0;
+ unsigned long int placeTime = 0; //Then the text was placed
+public:
+
+ TextMessage() {
+ }
+
+ //constructor:
+ TextMessage(int X, int Y,const char* Text,unsigned int Time) {
+ placeTime = currentTime;
+ x = X;
+ y = Y;
+ textt = Text;
+ time = Time;
+ } //constructor
+
+ //true if the text has expired
+ bool removeMe() {
+ return currentTime-placeTime>time;
+ }
+
+ int getX() {
+ return x;
+ }
+
+ int getY() {
+ return y;
+ }
+
+ const char* getText() {
+ return textt.c_str();
+ }
+}; //text popup
+
+class TextManager {
+ static const int maxNumberOfTexts = 6*12*2*2;
+public:
+ TextMessage textArray[maxNumberOfTexts];
+ bool textUsed[maxNumberOfTexts];
+
+ TextManager() {
+ for (int i=0; i<maxNumberOfTexts; i++) {
+ textUsed[i] = false;
+ }
+ }
+
+ int addText(int x, int y,string Text,unsigned int Time) {
+ int textNumber = 0;
+ while (textNumber<maxNumberOfTexts && textUsed[textNumber]) {
+ textNumber++;
+ }
+ if (textNumber==maxNumberOfTexts) {
+ return -1;
+ }
+ currentTime = SDL_GetTicks();
+ textArray[textNumber] = TextMessage(x,y,Text.c_str(),Time);
+ textUsed[textNumber] = true;
+ return 1;
+ } //addText
+
+ void update() {
+ currentTime = SDL_GetTicks();
+ for (int i = 0; i<maxNumberOfTexts; i++) {
+
+ if (textUsed[i]) {
+ if (textArray[i].removeMe()) {
+ textUsed[i] = false;
+ }
+ }
+ }
+ } //update
+
+
+}; //textManager
+
+#endif /* TEXTMANAGER_HPP */
+
diff --git a/source/code/global.hpp b/source/code/global.hpp
index 997dfb0..50d54c1 100644
--- a/source/code/global.hpp
+++ b/source/code/global.hpp
@@ -1,7 +1,7 @@
/*
===========================================================================
blockattack - Block Attack - Rise of the Blocks
-Copyright (C) 2005-2012 Poul Sander
+Copyright (C) 2005-2017 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
@@ -40,6 +40,8 @@ int runGame(Gametype gametype,int level);
bool OpenDialogbox(int x, int y, std::string& name, const std::string& header);
void DrawBackground(SDL_Renderer* target);
void UpdateMouseCoordinates(const SDL_Event& event, int& mousex, int& mousey);
+void DrawIMG(const sago::SagoSprite& sprite, SDL_Renderer* target, int x, int y);
+void DrawIMG_Bounded(const sago::SagoSprite& sprite, SDL_Renderer* target, int x, int y, int minx, int miny, int maxx, int maxy);
struct GlobalData {
sago::SagoSprite bHighScore;
diff --git a/source/code/main.cpp b/source/code/main.cpp
index 3a6ebb1..6700dd5 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -493,85 +493,7 @@ public:
static ExplosionManager theExplosionManager;
-//text pop-up
-class TextMessage {
-private:
- int x = 0;
- int y = 0;
- string textt;
- unsigned long int time = 0;
- unsigned long int placeTime = 0; //Then the text was placed
-public:
-
- TextMessage() {
- }
-
- //constructor:
- TextMessage(int X, int Y,const char* Text,unsigned int Time) {
- placeTime = currentTime;
- x = X;
- y = Y;
- textt = Text;
- time = Time;
- } //constructor
-
- //true if the text has expired
- bool removeMe() {
- return currentTime-placeTime>time;
- }
-
- int getX() {
- return x;
- }
-
- int getY() {
- return y;
- }
-
- const char* getText() {
- return textt.c_str();
- }
-}; //text popup
-
-class TextManager {
-public:
- TextMessage textArray[maxNumberOfBalls];
- bool textUsed[maxNumberOfBalls];
-
- TextManager() {
- for (int i=0; i<maxNumberOfBalls; i++) {
- textUsed[i] = false;
- }
- }
-
- int addText(int x, int y,string Text,unsigned int Time) {
- int textNumber = 0;
- while (textNumber<maxNumberOfBalls && textUsed[textNumber]) {
- textNumber++;
- }
- if (textNumber==maxNumberOfBalls) {
- return -1;
- }
- currentTime = SDL_GetTicks();
- textArray[textNumber] = TextMessage(x,y,Text.c_str(),Time);
- textUsed[textNumber] = true;
- return 1;
- } //addText
-
- void update() {
- currentTime = SDL_GetTicks();
- for (int i = 0; i<maxNumberOfBalls; i++) {
-
- if (textUsed[i]) {
- if (textArray[i].removeMe()) {
- textUsed[i] = false;
- }
- }
- }
- } //update
-
-
-}; //textManager
+#include "TextManager.hpp"
static TextManager theTextManager;