Polyphase Game Engine
Loading...
Searching...
No Matches
PreferencesModule.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include <string>
6#include <vector>
7#include "document.h"
8
9class PreferencesModule
10{
11public:
12 virtual ~PreferencesModule();
13
14 // Required overrides
15 virtual const char* GetName() const = 0;
16 virtual void Render() = 0;
17
18 // Optional overrides
19 virtual const char* GetParentPath() const { return ""; }
20 virtual void LoadSettings(const rapidjson::Document& doc);
21 virtual void SaveSettings(rapidjson::Document& doc);
22
23 // Hierarchy management
24 void AddSubModule(PreferencesModule* sub);
25 const std::vector<PreferencesModule*>& GetSubModules() const;
26
27 // Path utilities
28 std::string GetFullPath() const;
29 std::string GetSettingsFilePath() const;
30
31 // Dirty flag for unsaved changes
32 bool IsDirty() const { return mDirty; }
33 void SetDirty(bool dirty) { mDirty = dirty; }
34
35protected:
36 std::vector<PreferencesModule*> mSubModules;
37 bool mDirty = false;
38};
39
40// Registration macros (following Factory.h pattern)
41#define DECLARE_PREFERENCES_MODULE(Class) \
42 static const char* GetStaticName(); \
43 static const char* GetStaticParentPath();
44
45#define DEFINE_PREFERENCES_MODULE(Class, Name, ParentPath) \
46 const char* Class::GetStaticName() { return Name; } \
47 const char* Class::GetStaticParentPath() { return ParentPath; }
48
49#endif
Definition JsonHelpers.h:15