Debian Codegraph @

source/code/themes.hpp

raw symbols SCIP
1 /*
2 ===========================================================================
3 blockattack - Block Attack - Rise of the Blocks
4 Copyright (C) 2005-2023 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 https://www.blockattack.net
21 ===========================================================================
22 */
23
24 #pragma once
25
26 #include <string>
27 #include <vector>
28
29 enum class ImgScale {
30 Stretch,
31 Tile,
32 Resize,
33 Cut
34 };
35
36 struct BackGroundData {
37 std::string name = "standard";
38 std::string background_sprite = "";
39 std::string background_sprite_16x9 = "";
40 int tileMoveSpeedX = 0; //Move the tiled background every X milliseconds. 0 disables it.
41 int tileMoveSpeedY = 0; //Move the tiled background every X milliseconds. 0 disables it.
42 ImgScale background_scale = ImgScale::Stretch;
43 };
44
45
46 struct ThemeBorderData {
47 std::string name = "standard";
48 std::string border_sprite = "board_back_back";
49 std::pair<int, int> border_sprite_offset = {-60, -68};
50 std::pair<int, int> score_label_offset = {310, 80};
51 std::pair<int, int> time_label_offset = {310,129};
52 std::pair<int, int> chain_label_offset = {310, 178};
53 std::pair<int, int> speed_label_offset = {310, 227};
54 };
55
56
57 struct DecorationData {
58 std::string name = "smilies";
59 std::vector<std::string> decoration_sprites = {"smileys0", "smileys1", "smileys2", "smileys3"};
60 };
61
62 struct Theme {
63 std::string theme_name = "standard";
64 std::string back_board = "back_board"; // Can also be "back_board_sample_snow" or "trans_cover"
65 BackGroundData background; //Serialized as background.background_name
66 DecorationData decoration;
67 ThemeBorderData border;
68 };
69
70 struct ThemeFileData {
71 std::vector<BackGroundData> background_data;
72 std::vector<DecorationData> decoration_data;
73 std::vector<Theme> themes;
74 };
75
76 void ThemesFillMissingFields(Theme& theme);
77
78 void ThemesAddOrReplace(const Theme& theme);
79
80
81 /**
82 * @brief returns a theme from a list
83 * @return A copy of a theme
84 */
85 Theme ThemesGetNext();
86
87 /**
88 * @brief getTheme returns a specific theme
89 * @param theme_number
90 * @return A reference to the theme. The referance is valid until the next call to a "Themes*" function
91 */
92 Theme& ThemesGet(size_t theme_number);
93
94 /**
95 * @brief Saves the themes starting with "custom_slot_" to "custom_themes.json"
96 *
97 */
98 void ThemesSaveCustomSlots();
99
100 /**
101 * Returns the index of a given file.
102 * Returns 0 if it does not exist or is the standard theme.
103 */
104 size_t ThemesGetNumber(const std::string& name);
105
106 bool ThemesBackgroundExists(const std::string& name);
107
108 BackGroundData ThemesGetNextBackground(const std::string& current);
109
110 std::string ThemesGetNextBoardBackground(const std::string& current);
111
112 ThemeBorderData ThemesGetBorder(const std::string& name);
113
114 ThemeBorderData ThemesGetNextBorder(const std::string& current);
115
116 void ThemesInitCustomBackgrounds();