| 1 | /* |
| 2 | =========================================================================== |
| 3 | blockattack - Block Attack - Rise of the Blocks |
| 4 | Copyright (C) 2005-2017 Poul Sander |
| 5 | |
| 6 | This program is free software: you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation, either version 2 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program. If not, see http://www.gnu.org/licenses/ |
| 18 | |
| 19 | Source information and contacts persons can be found at |
| 20 | http://www.blockattack.net |
| 21 | =========================================================================== |
| 22 | */ |
| 23 | |
| 24 | #ifndef _GLOBAL_HPP |
| 25 | #define _GLOBAL_HPP |
| 26 | |
| 27 | #include <memory> |
| 28 | #include "sago/SagoSpriteHolder.hpp" |
| 29 | #include "sago/SagoLogicalResize.hpp" |
| 30 | #include "highscore.h" |
| 31 | #include "sago/GameStateInterface.hpp" |
| 32 | #include "TextManager.hpp" |
| 33 | #include "sago/SagoTextField.hpp" |
| 34 | #include "sago/SagoTextBox.hpp" |
| 35 | #include "ModInfo.hpp" |
| 36 | #include "themes.hpp" |
| 37 | |
| 38 | //if SHAREDIR is not used we look in current directory |
| 39 | #ifndef SHAREDIR |
| 40 | #define SHAREDIR "." |
| 41 | #endif |
| 42 | |
| 43 | #ifndef LOCALEDIR |
| 44 | #define LOCALEDIR SHAREDIR"/locale" |
| 45 | #endif |
| 46 | |
| 47 | #ifndef PACKAGE |
| 48 | #define PACKAGE "blockattack_roftb" |
| 49 | #endif |
| 50 | |
| 51 | #define MODLIST_TXT "mod_list.txt" |
| 52 | |
| 53 | void MainMenu(); |
| 54 | void SafeModeMenu(); |
| 55 | void ResetFullscreen(); |
| 56 | void RunGameState(sago::GameStateInterface& state ); |
| 57 | |
| 58 | enum class Gametype { SinglePlayerEndless=0, SinglePlayerTimeTrial=1, StageClear=2, Puzzle=3, SinglePlayerVs=4, TwoPlayerTimeTrial=10, TwoPlayerVs=11, Replay=100 }; |
| 59 | |
| 60 | int runGame(Gametype gametype,int level); |
| 61 | bool OpenDialogbox(int x, int y, std::string& name, const std::string& header); |
| 62 | void DrawBackground(SDL_Renderer* target); |
| 63 | void UpdateMouseCoordinates(const SDL_Event& event, int& mousex, int& mousey); |
| 64 | void DrawIMG(const sago::SagoSprite& sprite, SDL_Renderer* target, int x, int y); |
| 65 | void DrawIMG_Bounded(const sago::SagoSprite& sprite, SDL_Renderer* target, int x, int y, int minx, int miny, int maxx, int maxy); |
| 66 | |
| 67 | //void sagoTextSetHelpFont(sago::SagoTextField& field); |
| 68 | void sagoTextSetBlueFont(sago::SagoTextField& field); |
| 69 | |
| 70 | const int SIXTEEN_NINE_WIDTH = 1364; |
| 71 | const int FOUR_THREE_WIDTH = 1024; |
| 72 | const int SCREEN_HIGHT = 768; |
| 73 | |
| 74 | const int BOARD_WIDTH = 300; |
| 75 | const int BOARD_HEIGHT = 600; |
| 76 | |
| 77 | struct ButtonCords { |
| 78 | int x; |
| 79 | int y; |
| 80 | int xsize; |
| 81 | int ysize; |
| 82 | }; |
| 83 | |
| 84 | |
| 85 | |
| 86 | struct GlobalData { |
| 87 | sago::SagoSprite bHighScore; |
| 88 | sago::SagoSprite bBack; |
| 89 | sago::SagoSprite bNext; |
| 90 | sago::SagoSprite iLevelCheck; //To the level select screen |
| 91 | sago::SagoSprite iLevelCheckBox; |
| 92 | sago::SagoSprite iLevelCheckBoxMarked; |
| 93 | sago::SagoSprite iCheckBoxArea; |
| 94 | bool MusicEnabled; //true if background music is enabled |
| 95 | bool SoundEnabled; //true if sound effects is enabled |
| 96 | bool bFullscreen; //true if game is running fullscreen |
| 97 | std::string replayArgument; //Name of the replay to play (if given as a commandline argument) |
| 98 | std::string player1name; |
| 99 | std::string player2name; |
| 100 | SDL_Renderer* screen = nullptr; //The whole screen; |
| 101 | sago::SoundHandler typingChunk; |
| 102 | sago::SagoSprite mouse; |
| 103 | bool highPriority = false; |
| 104 | bool NoSound = false; |
| 105 | bool alwaysSixteenNine = false; |
| 106 | int verboseLevel = 0; |
| 107 | sago::SagoDataHolder* dataHolder = nullptr; |
| 108 | std::unique_ptr<sago::SagoSpriteHolder> spriteHolder; |
| 109 | std::vector<std::string> modList; |
| 110 | ModInfo modinfo; |
| 111 | Theme theme; |
| 112 | sago::SagoLogicalResize logicalResize; |
| 113 | |
| 114 | TextManager theTextManager; |
| 115 | |
| 116 | int xsize = FOUR_THREE_WIDTH; |
| 117 | int ysize = SCREEN_HIGHT; |
| 118 | int mousex = 0; |
| 119 | int mousey = 0; |
| 120 | |
| 121 | sago::SoundHandler applause; //Applause, then the player is good |
| 122 | sago::SoundHandler boing; //boing sound when clearing |
| 123 | sago::SoundHandler photoClick; //clickSound |
| 124 | sago::SoundHandler counterChunk; //When counting down |
| 125 | sago::SoundHandler counterFinalChunk; |
| 126 | |
| 127 | sago::SagoSprite garbageTL; //the Garbage Blocks |
| 128 | sago::SagoSprite garbageT; |
| 129 | sago::SagoSprite garbageTR; |
| 130 | sago::SagoSprite garbageR; |
| 131 | sago::SagoSprite garbageBR; |
| 132 | sago::SagoSprite garbageB; |
| 133 | sago::SagoSprite garbageBL; |
| 134 | sago::SagoSprite garbageL; |
| 135 | sago::SagoSprite garbageFill; |
| 136 | sago::SagoSprite garbageM; |
| 137 | sago::SagoSprite garbageML; |
| 138 | sago::SagoSprite garbageMR; |
| 139 | sago::SagoSprite garbageGM; |
| 140 | sago::SagoSprite garbageGML; |
| 141 | sago::SagoSprite garbageGMR; |
| 142 | sago::SagoSprite transCover; //The transperant block, covers the upcomming |
| 143 | sago::SagoSprite bSkip; |
| 144 | sago::SagoSprite bRetry; |
| 145 | |
| 146 | sago::SagoSprite blackLine; //The seperator in stage clear |
| 147 | sago::SagoSprite stageBobble; //The bobble instage clear |
| 148 | sago::SagoTextBox tbGameOver; |
| 149 | sago::SagoTextBox tbWinner; |
| 150 | sago::SagoTextBox tbDraw; |
| 151 | sago::SagoSprite iChainFrame; |
| 152 | //Animations: |
| 153 | sago::SagoSprite cursor; //The animated cursor |
| 154 | sago::SagoSprite bomb; |
| 155 | sago::SagoSprite ready; //Before the blocks fall |
| 156 | sago::SagoSprite explosion[4]; //Then a block explodes |
| 157 | //Animations end |
| 158 | sago::SagoSprite counter[3]; //Counts down from 3 |
| 159 | sago::SagoSprite bricks[7]; //The bricks, saved in an array of pointers |
| 160 | sago::SagoSprite crossover; //Cross the bricks that will be cleared soon |
| 161 | sago::SagoSprite balls[7]; //The balls (the small ones that jump around) |
| 162 | |
| 163 | sago::SagoSprite boardBackBack; |
| 164 | |
| 165 | ButtonCords cordNextButton; |
| 166 | ButtonCords cordRetryButton; |
| 167 | |
| 168 | sago::SagoSprite yellow_star; |
| 169 | }; |
| 170 | |
| 171 | #include "BallManager.hpp" |
| 172 | |
| 173 | extern GlobalData globalData; |
| 174 | |
| 175 | #endif /* _GLOBAL_HPP */ |
| 176 |