git repos / blockattack-game

blame: source/code/theme_editor/ThemeEditorState.hpp

normal view · raw

727f4a09 Poul Sander 2026-05-24 21:47 1
/*
727f4a09 Poul Sander 2026-05-24 21:47 2
===========================================================================
727f4a09 Poul Sander 2026-05-24 21:47 3
blockattack - Block Attack - Rise of the Blocks
727f4a09 Poul Sander 2026-05-24 21:47 4
Copyright (C) 2005-2026 Poul Sander
727f4a09 Poul Sander 2026-05-24 21:47 5
727f4a09 Poul Sander 2026-05-24 21:47 6
This program is free software: you can redistribute it and/or modify
727f4a09 Poul Sander 2026-05-24 21:47 7
it under the terms of the GNU General Public License as published by
727f4a09 Poul Sander 2026-05-24 21:47 8
the Free Software Foundation, either version 2 of the License, or
727f4a09 Poul Sander 2026-05-24 21:47 9
(at your option) any later version.
727f4a09 Poul Sander 2026-05-24 21:47 10
727f4a09 Poul Sander 2026-05-24 21:47 11
This program is distributed in the hope that it will be useful,
727f4a09 Poul Sander 2026-05-24 21:47 12
but WITHOUT ANY WARRANTY; without even the implied warranty of
727f4a09 Poul Sander 2026-05-24 21:47 13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
727f4a09 Poul Sander 2026-05-24 21:47 14
GNU General Public License for more details.
727f4a09 Poul Sander 2026-05-24 21:47 15
727f4a09 Poul Sander 2026-05-24 21:47 16
You should have received a copy of the GNU General Public License
727f4a09 Poul Sander 2026-05-24 21:47 17
along with this program.  If not, see http://www.gnu.org/licenses/
727f4a09 Poul Sander 2026-05-24 21:47 18
727f4a09 Poul Sander 2026-05-24 21:47 19
Source information and contacts persons can be found at
727f4a09 Poul Sander 2026-05-24 21:47 20
https://blockattack.net
727f4a09 Poul Sander 2026-05-24 21:47 21
===========================================================================
727f4a09 Poul Sander 2026-05-24 21:47 22
*/
727f4a09 Poul Sander 2026-05-24 21:47 23
727f4a09 Poul Sander 2026-05-24 21:47 24
#pragma once
727f4a09 Poul Sander 2026-05-24 21:47 25
727f4a09 Poul Sander 2026-05-24 21:47 26
#include "../global.hpp"
727f4a09 Poul Sander 2026-05-24 21:47 27
#include "../sago/GameStateInterface.hpp"
727f4a09 Poul Sander 2026-05-24 21:47 28
#include "../themes.hpp"
727f4a09 Poul Sander 2026-05-24 21:47 29
#include <string>
727f4a09 Poul Sander 2026-05-24 21:47 30
#include <vector>
727f4a09 Poul Sander 2026-05-24 21:47 31
#include <memory>
727f4a09 Poul Sander 2026-05-24 21:47 32
727f4a09 Poul Sander 2026-05-24 21:47 33
class BlockGameSdl;
727f4a09 Poul Sander 2026-05-24 21:47 34
727f4a09 Poul Sander 2026-05-24 21:47 35
class ThemeEditorState : public sago::GameStateInterface {
727f4a09 Poul Sander 2026-05-24 21:47 36
public:
727f4a09 Poul Sander 2026-05-24 21:47 37
	ThemeEditorState();
727f4a09 Poul Sander 2026-05-24 21:47 38
	ThemeEditorState(const ThemeEditorState& orig) = delete;
727f4a09 Poul Sander 2026-05-24 21:47 39
	virtual ~ThemeEditorState();
727f4a09 Poul Sander 2026-05-24 21:47 40
727f4a09 Poul Sander 2026-05-24 21:47 41
	void Init();
727f4a09 Poul Sander 2026-05-24 21:47 42
727f4a09 Poul Sander 2026-05-24 21:47 43
	bool IsActive() override;
727f4a09 Poul Sander 2026-05-24 21:47 44
	void ProcessInput(const SDL_Event& event, bool& processed) override;
727f4a09 Poul Sander 2026-05-24 21:47 45
	void Draw(SDL_Renderer* target) override;
727f4a09 Poul Sander 2026-05-24 21:47 46
	void Update() override;
727f4a09 Poul Sander 2026-05-24 21:47 47
727f4a09 Poul Sander 2026-05-24 21:47 48
private:
727f4a09 Poul Sander 2026-05-24 21:47 49
	void DrawBorderEditor();
727f4a09 Poul Sander 2026-05-24 21:47 50
	void DrawBackgroundEditor();
727f4a09 Poul Sander 2026-05-24 21:47 51
	void DrawThemeComposer();
727f4a09 Poul Sander 2026-05-24 21:47 52
	void DrawPreview(SDL_Renderer* target);
727f4a09 Poul Sander 2026-05-24 21:47 53
727f4a09 Poul Sander 2026-05-24 21:47 54
	void SaveCurrentBorder();
727f4a09 Poul Sander 2026-05-24 21:47 55
	void SaveCurrentBackground();
727f4a09 Poul Sander 2026-05-24 21:47 56
	void SaveCurrentTheme();
727f4a09 Poul Sander 2026-05-24 21:47 57
727f4a09 Poul Sander 2026-05-24 21:47 58
	void LoadBorder(const std::string& name);
727f4a09 Poul Sander 2026-05-24 21:47 59
	void LoadBackground(const std::string& name);
727f4a09 Poul Sander 2026-05-24 21:47 60
727f4a09 Poul Sander 2026-05-24 21:47 61
	bool ValidateSprite(const std::string& sprite_name);
727f4a09 Poul Sander 2026-05-24 21:47 62
	std::vector<std::string> GetAvailableSprites();
727f4a09 Poul Sander 2026-05-24 21:47 63
727f4a09 Poul Sander 2026-05-24 21:47 64
	bool isActive = true;
727f4a09 Poul Sander 2026-05-24 21:47 65
	int current_tab = 0; // 0=Border, 1=Background, 2=Theme
727f4a09 Poul Sander 2026-05-24 21:47 66
727f4a09 Poul Sander 2026-05-24 21:47 67
	// Border editor state
727f4a09 Poul Sander 2026-05-24 21:47 68
	ThemeBorderData current_border;
727f4a09 Poul Sander 2026-05-24 21:47 69
	char border_name_buffer[256] = "";
727f4a09 Poul Sander 2026-05-24 21:47 70
	char border_sprite_buffer[256] = "board_back_back";
727f4a09 Poul Sander 2026-05-24 21:47 71
	int border_offset_x = -60;
727f4a09 Poul Sander 2026-05-24 21:47 72
	int border_offset_y = -68;
727f4a09 Poul Sander 2026-05-24 21:47 73
	int score_offset_x = 310;
727f4a09 Poul Sander 2026-05-24 21:47 74
	int score_offset_y = 80;
727f4a09 Poul Sander 2026-05-24 21:47 75
	int time_offset_x = 310;
727f4a09 Poul Sander 2026-05-24 21:47 76
	int time_offset_y = 129;
727f4a09 Poul Sander 2026-05-24 21:47 77
	int chain_offset_x = 310;
727f4a09 Poul Sander 2026-05-24 21:47 78
	int chain_offset_y = 178;
727f4a09 Poul Sander 2026-05-24 21:47 79
	int speed_offset_x = 310;
727f4a09 Poul Sander 2026-05-24 21:47 80
	int speed_offset_y = 227;
727f4a09 Poul Sander 2026-05-24 21:47 81
	int score_field_x = 310;
727f4a09 Poul Sander 2026-05-24 21:47 82
	int score_field_y = 102;
727f4a09 Poul Sander 2026-05-24 21:47 83
	int time_field_x = 310;
727f4a09 Poul Sander 2026-05-24 21:47 84
	int time_field_y = 151;
727f4a09 Poul Sander 2026-05-24 21:47 85
	int chain_field_x = 310;
727f4a09 Poul Sander 2026-05-24 21:47 86
	int chain_field_y = 200;
727f4a09 Poul Sander 2026-05-24 21:47 87
	int speed_field_x = 310;
727f4a09 Poul Sander 2026-05-24 21:47 88
	int speed_field_y = 249;
727f4a09 Poul Sander 2026-05-24 21:47 89
727f4a09 Poul Sander 2026-05-24 21:47 90
	// Background editor state
727f4a09 Poul Sander 2026-05-24 21:47 91
	BackGroundData current_background;
727f4a09 Poul Sander 2026-05-24 21:47 92
	char background_name_buffer[256] = "";
727f4a09 Poul Sander 2026-05-24 21:47 93
	char background_sprite_buffer[256] = "background";
727f4a09 Poul Sander 2026-05-24 21:47 94
	char background_sprite_16x9_buffer[256] = "background_sixteen_nine";
727f4a09 Poul Sander 2026-05-24 21:47 95
	int background_scale_mode = 0; // 0=Stretch, 1=Tile, 2=Resize, 3=Cut
727f4a09 Poul Sander 2026-05-24 21:47 96
	int tile_move_speed_x = 0;
727f4a09 Poul Sander 2026-05-24 21:47 97
	int tile_move_speed_y = 0;
727f4a09 Poul Sander 2026-05-24 21:47 98
727f4a09 Poul Sander 2026-05-24 21:47 99
	// Theme composer state
727f4a09 Poul Sander 2026-05-24 21:47 100
	char theme_name_buffer[256] = "custom_theme";
727f4a09 Poul Sander 2026-05-24 21:47 101
	int selected_border_index = 0;
727f4a09 Poul Sander 2026-05-24 21:47 102
	int selected_background_index = 0;
727f4a09 Poul Sander 2026-05-24 21:47 103
	int selected_decoration_index = 0;
727f4a09 Poul Sander 2026-05-24 21:47 104
	int selected_board_background = 0; // 0=back_board, 1=back_board_sample_snow, 2=trans_cover
727f4a09 Poul Sander 2026-05-24 21:47 105
	std::vector<std::string> border_names;
727f4a09 Poul Sander 2026-05-24 21:47 106
	std::vector<std::string> background_names;
727f4a09 Poul Sander 2026-05-24 21:47 107
	std::vector<std::string> decoration_names;
727f4a09 Poul Sander 2026-05-24 21:47 108
	const std::vector<std::string> board_backgrounds = {"back_board", "back_board_sample_snow", "trans_cover"};
727f4a09 Poul Sander 2026-05-24 21:47 109
727f4a09 Poul Sander 2026-05-24 21:47 110
	// Preview
727f4a09 Poul Sander 2026-05-24 21:47 111
	std::shared_ptr<BlockGameSdl> preview_game;
727f4a09 Poul Sander 2026-05-24 21:47 112
	Theme preview_theme;
727f4a09 Poul Sander 2026-05-24 21:47 113
	Theme saved_theme;  // Backup of the global theme
727f4a09 Poul Sander 2026-05-24 21:47 114
	bool preview_needs_update = true;
727f4a09 Poul Sander 2026-05-24 21:47 115
	void UpdatePreview();
727f4a09 Poul Sander 2026-05-24 21:47 116
};
1970-01-01 00:00 117