git repos / blockattack-game

commit 8f0c9d80

Poul Sander · 2023-07-24 21:33
8f0c9d809f4326fb79e6adfcf826951c458e8ed3 patch · browse files
parent c51072978753cb92d95f436481a6189bd6327fcd

Started implementing themes. Themes need to be moved to there own source files

Changed files

M Game/data/textures/board_back_back.png before
M source/code/BlockGameSdl.inc before
M source/code/global.hpp before
M source/code/main.cpp before
M source/code/mainVars.inc before
diff --git a/Game/data/textures/board_back_back.png b/Game/data/textures/board_back_back.png index df77014..b9e04be 100644
Binary files a/Game/data/textures/board_back_back.png and b/Game/data/textures/board_back_back.png differ
diff --git a/source/code/BlockGameSdl.inc b/source/code/BlockGameSdl.inc index c1d2880..7a8bb10 100644 --- a/source/code/BlockGameSdl.inc +++ b/source/code/BlockGameSdl.inc
@@ -410,7 +410,7 @@ public:
this->timeLabel.Draw(globalData.screen, this->GetTopX()+310,this->GetTopY()-68+197);
this->chainLabel.Draw(globalData.screen, this->GetTopX()+310,this->GetTopY()-68+246);
this->speedLabel.Draw(globalData.screen, this->GetTopX()+310,this->GetTopY()-68+295);
- backBoard.DrawScaled(globalData.screen, SDL_GetTicks(), this->GetTopX(),this->GetTopY(), BOARD_WIDTH, BOARD_HEIGHT);
+ globalData.spriteHolder->GetSprite(globalData.theme.back_board).DrawScaled(globalData.screen, SDL_GetTicks(), this->GetTopX(),this->GetTopY(), BOARD_WIDTH, BOARD_HEIGHT);
PaintBricks();
if (stageClear) {
diff --git a/source/code/global.hpp b/source/code/global.hpp index 4d74aee..d0874cd 100644 --- a/source/code/global.hpp +++ b/source/code/global.hpp
@@ -72,6 +72,10 @@ const int SCREEN_HIGHT = 768;
const int BOARD_WIDTH = 300;
const int BOARD_HEIGHT = 600;
+struct Theme {
+ std::string back_board = "back_board"; // Can also be "back_board_sample_snow" or "trans_cover"
+};
+
struct GlobalData {
sago::SagoSprite bHighScore;
sago::SagoSprite bBack;
@@ -96,6 +100,7 @@ struct GlobalData {
std::unique_ptr<sago::SagoSpriteHolder> spriteHolder;
std::vector<std::string> modList;
ModInfo modinfo;
+ Theme theme;
TextManager theTextManager;
diff --git a/source/code/main.cpp b/source/code/main.cpp index 37c1c33..d97d760 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp
@@ -181,7 +181,6 @@ static int InitImages(sago::SagoSpriteHolder& holder) {
globalData.bNext = holder.GetSprite("b_blank");
bRetry = holder.GetSprite("b_blank");
globalData.mouse = holder.GetSprite("mouse");
- backBoard = holder.GetSprite("back_board"); // Can also be "back_board_sample_snow"
sagoTextSetBlueFont(player1name);
sagoTextSetBlueFont(player2name);
@@ -546,7 +545,7 @@ void DrawEverything(int xsize, int ysize,BlockGameSdl* theGame, BlockGameSdl* th
*/
if (!twoPlayers && !theGame->isGameOver()) {
//Blank player2's board:
- backBoard.DrawScaled(globalData.screen, SDL_GetTicks(), theGame2->GetTopX(),theGame2->GetTopY(), BOARD_WIDTH, BOARD_HEIGHT);
+ globalData.spriteHolder->GetSprite(globalData.theme.back_board).DrawScaled(globalData.screen, SDL_GetTicks(), theGame2->GetTopX(),theGame2->GetTopY(), BOARD_WIDTH, BOARD_HEIGHT);
//Write a description:
std::string gametypeName;
std::string infostring;
diff --git a/source/code/mainVars.inc b/source/code/mainVars.inc index e97a4d0..c68bac7 100644 --- a/source/code/mainVars.inc +++ b/source/code/mainVars.inc
@@ -45,7 +45,6 @@ const char sharedir[] = SHAREDIR;
sago::SagoSprite backgroundImage; //Stores the background image
sago::SagoSprite backgroundSixteenNineImage; // For 16:9 format
sago::SagoSprite bExit;
-static sago::SagoSprite backBoard; //Stores the background to the board
static sago::SagoSprite bForward; //The "forward" button
#if NETWORK
//static sago::SagoSprite bNetwork;