commit 5d5a5e92
Add support for different border
Changed files
diff --git a/Game/data/sprites/sample_alt_gfx.sprite b/Game/data/sprites/sample_alt_gfx.sprite
index 4d9aaef..05ade22 100644
--- a/Game/data/sprites/sample_alt_gfx.sprite
+++ b/Game/data/sprites/sample_alt_gfx.sprite
@@ -19,5 +19,14 @@
"number_of_frames" : 1,
"frame_time" : 1
}
+,"board_back_back_mirror" : {
+ "texture" : "alt_gfx/board_back_back_mirror",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 699,
+ "width" : 476,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+}
}
diff --git a/Game/data/textures/alt_gfx/board_back_back_mirror.png b/Game/data/textures/alt_gfx/board_back_back_mirror.png
new file mode 100644
index 0000000..1754dac
Binary files /dev/null and b/Game/data/textures/alt_gfx/board_back_back_mirror.png differ
diff --git a/source/AUTH b/source/AUTH
index a9889db..e36a2a1 100644
--- a/source/AUTH
+++ b/source/AUTH
@@ -16,6 +16,8 @@ penguinattack.ttf Dustin Norlander - GPLv2
/textures/
alt_gfx/back_board_sample_snow.jpg Poul Sander
+alt_gfx/background.png Poul Sander
+alt_gfx/board_back_back_mirror.png qubodup (mirror of board_back_back.pn)
back_board.png qubodup
background.png qubodup
background_sixteen_nine.png Poul Sander (based of qubodup's background.png)
diff --git a/source/code/BlockGameSdl.hpp b/source/code/BlockGameSdl.hpp
index 5457945..936e675 100644
--- a/source/code/BlockGameSdl.hpp
+++ b/source/code/BlockGameSdl.hpp
@@ -426,12 +426,14 @@ private:
public:
//Draws everything
void DoPaintJob() {
- DrawIMG(globalData.boardBackBack,globalData.screen,this->GetTopX()-60,this->GetTopY()-68);
-
- this->scoreLabel.Draw(globalData.screen, this->GetTopX()+310,this->GetTopY()-68+148);
- 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);
+ const ThemeBorderData& border = globalData.theme.border;
+ sago::SagoSprite backback = globalData.spriteHolder->GetSprite(border.border_sprite);
+ DrawIMG(backback, globalData.screen, this->GetTopX()+border.border_sprite_offset.first, this->GetTopY()+border.border_sprite_offset.second);
+
+ this->scoreLabel.Draw(globalData.screen, this->GetTopX()+border.score_label_offset.first,this->GetTopY()+border.score_label_offset.second);
+ this->timeLabel.Draw(globalData.screen, this->GetTopX()+border.time_label_offset.first,this->GetTopY()+border.time_label_offset.second);
+ this->chainLabel.Draw(globalData.screen, this->GetTopX()+border.chain_label_offset.first,this->GetTopY()+border.chain_label_offset.second);
+ this->speedLabel.Draw(globalData.screen, this->GetTopX()+border.speed_label_offset.first,this->GetTopY()+border.speed_label_offset.second);
globalData.spriteHolder->GetSprite(globalData.theme.back_board).DrawScaled(globalData.screen, SDL_GetTicks(), this->GetTopX(),this->GetTopY(), BOARD_WIDTH, BOARD_HEIGHT);
PaintBricks();
@@ -569,7 +571,7 @@ public:
std::string strHolder;
strHolder = std::to_string(this->GetScore()+this->GetHandicap());
player_score.SetText(strHolder);
- player_score.Draw(globalData.screen, this->GetTopX()+310,this->GetTopY()+100);
+ player_score.Draw(globalData.screen, this->GetTopX()+border.score_label_offset.first,this->GetTopY()+border.score_label_offset.second+22);
if (this->GetAIenabled()) {
player_name.SetText(_("AI"));
}
@@ -620,14 +622,14 @@ public:
}
player_time.SetText(strHolder);
}
- player_time.Draw(globalData.screen, this->GetTopX()+310,this->GetTopY()+150);
+ player_time.Draw(globalData.screen, this->GetTopX()+border.time_label_offset.first,this->GetTopY()+border.time_label_offset.second+22);
strHolder = std::to_string(this->GetChains());
player_chain.SetText(strHolder);
- player_chain.Draw(globalData.screen, this->GetTopX()+310,this->GetTopY()+200);
+ player_chain.Draw(globalData.screen, this->GetTopX()+border.chain_label_offset.first,this->GetTopY()+border.chain_label_offset.second+22);
//drawspeedLevel:
strHolder = std::to_string(this->GetSpeedLevel());
player_speed.SetText(strHolder);
- player_speed.Draw(globalData.screen, this->GetTopX()+310,this->GetTopY()+250);
+ player_speed.Draw(globalData.screen, this->GetTopX()+border.speed_label_offset.first,this->GetTopY()+border.speed_label_offset.second+22);
if ((this->isStageClear()) &&(this->GetTopY()+700+50*(this->GetStageClearLimit()-this->GetLinesCleared())-this->GetPixels()-1<600+this->GetTopY())) {
oldBubleX = this->GetTopX()+280;
oldBubleY = this->GetTopY()+650+50*(this->GetStageClearLimit()-this->GetLinesCleared())-this->GetPixels()-1;
diff --git a/source/code/menudef_themes.cpp b/source/code/menudef_themes.cpp
index bd82a25..50c05e4 100644
--- a/source/code/menudef_themes.cpp
+++ b/source/code/menudef_themes.cpp
@@ -90,6 +90,11 @@ static void themesEditSwitchBoardBackground() {
globalData.theme = themeToEdit;
}
+static void themesEditSwitchBorder() {
+ themeToEdit.border = ThemesGetNextBorder(themeToEdit.border.name);
+ globalData.theme = themeToEdit;
+}
+
static void themesEditSlot(int slot) {
ThemesMenu tem(globalData.screen, fmt::format(_("Edit custom theme {}"), slot), true);
size_t theme_index = ThemeGetNumber(fmt::format("custom_slot_{}", slot));
@@ -105,6 +110,10 @@ static void themesEditSlot(int slot) {
bSwitchBoardBackground.setLabel(_("Switch board background"));
bSwitchBoardBackground.setAction(&themesEditSwitchBoardBackground);
tem.addButton(&bSwitchBoardBackground);
+ Button bSwitchBorder;
+ bSwitchBorder.setLabel(_("Switch border"));
+ bSwitchBorder.setAction(&themesEditSwitchBorder);
+ tem.addButton(&bSwitchBorder);
themeBackup = globalData.theme;
themeToEdit = ThemesGet(theme_index);
globalData.theme = themeToEdit;
diff --git a/source/code/themes.cpp b/source/code/themes.cpp
index 1053502..7358bdc 100644
--- a/source/code/themes.cpp
+++ b/source/code/themes.cpp
@@ -132,6 +132,7 @@ void from_json(const json& j, ThemeFileData& p) {
static std::vector<Theme> themes(1);
static std::map<std::string, BackGroundData> background_data;
static std::map<std::string, DecorationData> decoration_data;
+static std::map<std::string, ThemeBorderData> border_data;
static bool initialized = false;
static size_t current_theme = 0;
@@ -182,6 +183,23 @@ static void ThemesInitBackGroundData() {
decoration_data[smileys.name] = smileys;
}
+static void ThemesInitBorderData() {
+ ThemeBorderData standard;
+ standard.name = "standard";
+ standard.border_sprite = "board_back_back";
+ standard.border_sprite_offset = {-60, -68};
+ border_data[standard.name] = standard;
+ ThemeBorderData mirror = standard;
+ mirror.name = "mirror";
+ mirror.border_sprite = "board_back_back_mirror";
+ mirror.border_sprite_offset = {-116, -68};
+ mirror.score_label_offset = {-100, 80};
+ mirror.time_label_offset = {-100,129};
+ mirror.chain_label_offset = {-100, 178};
+ mirror.speed_label_offset = {-100, 227};
+ border_data[mirror.name] = mirror;
+}
+
static bool str_startswith(const std::string& s, const char* prefix) {
return (s.rfind(prefix, 0) == 0);
}
@@ -233,6 +251,7 @@ void ThemesInit() {
initialized = true;
ThemesInitBackGroundData();
ThemesInitCustomBackgrounds();
+ ThemesInitBorderData();
themes.resize(1); //Add the default theme
ThemesFillMissingFields(themes[0]);
const std::vector<std::string>& theme_files = sago::GetFileList("themes");
@@ -312,6 +331,33 @@ std::string ThemesGetNextBoardBackground(const std::string& current) {
return ret;
}
+ThemeBorderData ThemesGetBorder(const std::string& name) {
+ ThemesInit();
+ auto it = border_data.find(name);
+ if (it == border_data.end()) {
+ return border_data["standard"];
+ }
+ return it->second;
+}
+
+ThemeBorderData ThemesGetNextBorder(const std::string& current) {
+ ThemesInit();
+ ThemeBorderData ret = border_data["standard"];
+ for (auto& pair : border_data) {
+ if (pair.first == current) {
+ auto it = border_data.find(current);
+ ++it;
+ if (it == border_data.end()) {
+ it = border_data.begin();
+ }
+ ret = it->second;
+ break;
+ }
+ }
+ return ret;
+}
+
+
void ThemesInitCustomBackgrounds() {
std::vector<std::string> custom_backgrounds = sago::GetFileList("textures/backgrounds");
std::stringstream sprite_stream;
diff --git a/source/code/themes.hpp b/source/code/themes.hpp
index f74f837..144ece4 100644
--- a/source/code/themes.hpp
+++ b/source/code/themes.hpp
@@ -43,6 +43,17 @@ struct BackGroundData {
};
+struct ThemeBorderData {
+ std::string name = "standard";
+ std::string border_sprite = "board_back_back";
+ std::pair<int, int> border_sprite_offset = {-60, -68};
+ std::pair<int, int> score_label_offset = {310, 80};
+ std::pair<int, int> time_label_offset = {310,129};
+ std::pair<int, int> chain_label_offset = {310, 178};
+ std::pair<int, int> speed_label_offset = {310, 227};
+};
+
+
struct DecorationData {
std::string name = "smilies";
std::vector<std::string> decoration_sprites = {"smileys0", "smileys1", "smileys2", "smileys3"};
@@ -53,6 +64,7 @@ struct Theme {
std::string back_board = "back_board"; // Can also be "back_board_sample_snow" or "trans_cover"
BackGroundData background; //Serialized as background.background_name
DecorationData decoration;
+ ThemeBorderData border;
};
struct ThemeFileData {
@@ -95,4 +107,8 @@ BackGroundData ThemesGetNextBackground(const std::string& current);
std::string ThemesGetNextBoardBackground(const std::string& current);
+ThemeBorderData ThemesGetBorder(const std::string& name);
+
+ThemeBorderData ThemesGetNextBorder(const std::string& current);
+
void ThemesInitCustomBackgrounds();
\ No newline at end of file