| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
1 |
/* |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
2 |
=========================================================================== |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
3 |
blockattack - Block Attack - Rise of the Blocks |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
4 |
Copyright (C) 2005-2013 Poul Sander |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
5 |
|
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
6 |
This program is free software: you can redistribute it and/or modify |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
7 |
it under the terms of the GNU General Public License as published by |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
8 |
the Free Software Foundation, either version 2 of the License, or |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
9 |
(at your option) any later version. |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
10 |
|
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
11 |
This program is distributed in the hope that it will be useful, |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
14 |
GNU General Public License for more details. |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
15 |
|
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
16 |
You should have received a copy of the GNU General Public License |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
17 |
along with this program. If not, see http://www.gnu.org/licenses/ |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
18 |
|
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
19 |
Source information and contacts persons can be found at |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
20 |
http://blockattack.net |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
21 |
=========================================================================== |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
22 |
*/ |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
23 |
#include "global.hpp" |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
24 |
#include "menudef_themes.hpp" |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
25 |
#include "MenuSystem.h" |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
26 |
#include "BlockGameSdl.hpp" |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
27 |
#include <fmt/core.h> |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
28 |
|
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
29 |
static void switchTheme() { |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
30 |
globalData.theme = ThemesGetNext(); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
31 |
} |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
32 |
|
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
33 |
|
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
34 |
static void testMusic() { |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
35 |
static bool highbeatNext = false; |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
36 |
int musicVolume = Config::getInstance()->getInt("volume_music"); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
37 |
std::string music_name = "bgmusic"; |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
38 |
if (highbeatNext) { |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
39 |
music_name = "highbeat"; |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
40 |
} |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
41 |
Mix_PlayMusic(globalData.spriteHolder->GetDataHolder().getMusicHandler(music_name.c_str()).get(), 1); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
42 |
Mix_VolumeMusic(musicVolume); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
43 |
highbeatNext = !highbeatNext; //Toggle between standard and highbeat |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
44 |
} |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
45 |
|
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
46 |
|
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
47 |
|
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
48 |
class ThemesMenu : public Menu { |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
49 |
public: |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
50 |
std::shared_ptr<BlockGameSdl> game; |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
51 |
sago::SagoTextField themeTitle; |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
52 |
|
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
53 |
ThemesMenu(SDL_Renderer* screen, const std::string& title, bool submenu) : Menu(screen, title, submenu) { |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
54 |
game = std::make_shared<BlockGameSdl>(globalData.xsize-450,100,&globalData.spriteHolder->GetDataHolder()); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
55 |
game->putSampleBlocks(); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
56 |
sagoTextSetBlueFont(themeTitle); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
57 |
} |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
58 |
|
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
59 |
void placeButtons() override { |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
60 |
int nextY = 100; |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
61 |
int X = 10; |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
62 |
for (Button* it : buttons) { |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
63 |
it->x = X; |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
64 |
it->y = nextY; |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
65 |
nextY += it->standardButton.ysize+10; |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
66 |
} |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
67 |
exit.x = X; |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
68 |
exit.y = nextY; |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
69 |
} |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
70 |
|
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
71 |
void Draw(SDL_Renderer* target) override { |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
72 |
Menu::Draw(target); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
73 |
game->DoPaintJob(); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
74 |
themeTitle.SetText(fmt::format(_("Theme: {}"), globalData.theme.theme_name)); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
75 |
themeTitle.Draw(target, 10, globalData.ysize-50,sago::SagoTextField::Alignment::left); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
76 |
} |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
77 |
}; |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
78 |
|
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
79 |
static int theme2edit = 0; |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
80 |
|
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
81 |
static void themesEditSlot1() { |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
82 |
ThemesMenu tem(globalData.screen, _("Edit custom theme 1"), true); |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
83 |
size_t theme_index = ThemeGetNumber("custom_slot_1"); |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
84 |
if (theme_index == 0) { |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
85 |
// Theme not found |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
86 |
return; |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
87 |
} |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
88 |
theme2edit = theme_index; |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
89 |
globalData.theme = ThemesGet(theme2edit); |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
90 |
RunGameState(tem); |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
91 |
} |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
92 |
|
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
93 |
|
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
94 |
void OpenThemesMenu() { |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
95 |
ThemesMenu tm(globalData.screen, _("Themes"), true); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
96 |
Button bSwitchTheme; |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
97 |
bSwitchTheme.setLabel(_("Switch theme")); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
98 |
bSwitchTheme.setAction(&switchTheme); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
99 |
tm.addButton(&bSwitchTheme); |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
100 |
Button bEditTheme1; |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
101 |
bEditTheme1.setLabel(_("Edit custom theme 1")); |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
102 |
bEditTheme1.setAction(&themesEditSlot1); |
| 7602f86d |
Poul Sander |
2024-01-10 21:39 |
103 |
tm.addButton(&bEditTheme1); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
104 |
if (!globalData.NoSound) { |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
105 |
Button bTestMusic; |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
106 |
bTestMusic.setLabel(_("Test music")); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
107 |
bTestMusic.setAction(&testMusic); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
108 |
tm.addButton(&bTestMusic); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
109 |
} |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
110 |
RunGameState(tm); |
| e35cd386 |
Poul Sander |
2023-11-29 20:33 |
111 |
} |
|
|
1970-01-01 00:00 |
112 |
|