Polyphase Game Engine
Loading...
Searching...
No Matches
CssThemeManager.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include "CssThemeParser.h"
6#include <string>
7#include <vector>
8
9struct CustomThemeEntry
10{
11 std::string Name;
12 std::string FileName; // filename within Preferences/Themes/ directory
13 CssThemeData ParsedData;
14 bool IsValid = false;
15 bool IsBundled = false; // true for themes loaded from Engine/Assets/Themes/
16};
17
18class CssThemeManager
19{
20public:
21 static CssThemeManager& Get();
22
23 // Import a CSS file as a new custom theme
24 bool ImportTheme(const std::string& filePath, const std::string& name);
25
26 // Remove a custom theme by index
27 void RemoveTheme(int index);
28
29 // Re-parse a theme from its saved CSS file
30 bool ReimportTheme(int index);
31
32 // Re-import a theme from a new external CSS file (replaces the stored copy)
33 bool ReimportThemeFromFile(int index, const std::string& filePath);
34
35 // Apply a custom theme by index
36 void ApplyTheme(int index);
37
38 // Load bundled themes from Engine/Assets/Themes/
39 void LoadBundledThemes();
40
41 // Persistence
42 void LoadThemeList();
43 void SaveThemeList();
44
45 // Accessors
46 int GetThemeCount() const { return static_cast<int>(mThemes.size()); }
47 const std::vector<CustomThemeEntry>& GetThemes() const { return mThemes; }
48 const std::string& GetThemeName(int index) const;
49
50private:
51 CssThemeManager() = default;
52
53 std::string GetThemesDirectory() const;
54 std::string GetThemeListPath() const;
55
56 std::vector<CustomThemeEntry> mThemes;
57};
58
59#endif