FlightGear next
GraphicsPresets.hxx
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <string>
5#include <vector>
6
7#include <simgear/misc/strutils.hxx>
8#include <simgear/props/propsfwd.hxx>
9#include <simgear/structure/subsystem_mgr.hxx>
10
11// forward decls
12class SGPath;
13
14namespace flightgear {
15
16class GraphicsPresets : public SGSubsystem
17{
18public:
21
22 static const char* staticSubsystemClassId() { return "graphics-presets"; }
23
25 std::string id;
26 std::string name; // localized
27 std::string description; // localized
30
31 SGPropertyNode_ptr properties;
32 };
33
34 using GraphicsPresetVec = std::vector<GraphicsPresetInfo>;
35
36 // implement SGSubsystem intergace
37 void init() override;
38 void shutdown() override;
39
40 void update(double delta_time_sec) override;
41
46 void applyInitialPreset();
47
53 bool applyCurrentPreset();
54
55 bool applyCustomPreset(const SGPath& path);
56
62 bool applyPresetByName(const std::string& name);
63
68
69 bool saveToXML(const SGPath& path, const std::string& name, const std::string& desc);
70
71private:
72 void clearPreset();
73
74 bool loadStandardPreset(const std::string& id, GraphicsPresetInfo& info);
75
76 bool innerApplyPreset(const GraphicsPresetInfo& info, bool overwriteAutosaved);
77
78 bool loadPresetXML(const SGPath& p, GraphicsPresetInfo& info);
79
80
83
84 std::unique_ptr<GraphicsConfigChangeListener> _listener;
85 std::unique_ptr<RequiredPropertyListener> _restartListener;
86 std::unique_ptr<RequiredPropertyListener> _sceneryReloadListener;
87 std::unique_ptr<RequiredPropertyListener> _compositorReloadListener;
88
89 string_list _propertiesToSave;
90};
91
92} // namespace flightgear
#define p(x)
monitor a collection of properties, and set a flag property to true when any of them are modified.
bool applyCustomPreset(const SGPath &path)
void applyInitialPreset()
init() is called too late (after fgOSInit), so we call this method early, to load the initial preset ...
bool applyPresetByName(const std::string &name)
apply a preset identified by its (localized) name.
bool saveToXML(const SGPath &path, const std::string &name, const std::string &desc)
GraphicsPresetVec listPresets()
retrieve all standard presets which are defined
static const char * staticSubsystemClassId()
bool applyCurrentPreset()
Apply the settings defined in the current graphics preset, to the property tree.
void update(double delta_time_sec) override
std::vector< GraphicsPresetInfo > GraphicsPresetVec
std::vector< std::string > string_list
Definition globals.hxx:36
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
Definition Addon.cxx:53
const char * name