openMSX
SettingsConfig.hh
Go to the documentation of this file.
1 #ifndef SETTINGSCONFIG_HH
2 #define SETTINGSCONFIG_HH
3 
4 #include "SettingsManager.hh"
5 #include "Command.hh"
6 #include "XMLElement.hh"
7 #include <string>
8 #include <string_view>
9 
10 namespace openmsx {
11 
12 class FileContext;
13 class HotKey;
14 class GlobalCommandController;
15 class CommandController;
16 
18 {
19 public:
20  SettingsConfig(GlobalCommandController& globalCommandController,
21  HotKey& hotKey);
23 
24  void loadSetting(const FileContext& context, std::string_view filename);
25  void saveSetting(std::string_view filename = {});
26  void setSaveSettings(bool save) { mustSaveSettings = save; }
27  void setSaveFilename(const FileContext& context, std::string_view filename);
28 
29  SettingsManager& getSettingsManager() { return settingsManager; }
30  XMLElement& getXMLElement() { return xmlElement; }
31 
32 private:
33  CommandController& commandController;
34 
35  struct SaveSettingsCommand final : Command {
36  explicit SaveSettingsCommand(CommandController& commandController);
37  void execute(span<const TclObject> tokens, TclObject& result) override;
38  std::string help(const std::vector<std::string>& tokens) const override;
39  void tabCompletion(std::vector<std::string>& tokens) const override;
40  } saveSettingsCommand;
41 
42  struct LoadSettingsCommand final : Command {
43  explicit LoadSettingsCommand(CommandController& commandController);
44  void execute(span<const TclObject> tokens, TclObject& result) override;
45  std::string help(const std::vector<std::string>& tokens) const override;
46  void tabCompletion(std::vector<std::string>& tokens) const override;
47  } loadSettingsCommand;
48 
49  SettingsManager settingsManager;
50  XMLElement xmlElement;
51  HotKey& hotKey;
52  std::string saveName;
53  bool mustSaveSettings;
54 };
55 
56 } // namespace openmsx
57 
58 #endif
Definition: span.hh:34
void saveSetting(std::string_view filename={})
void setSaveSettings(bool save)
void loadSetting(const FileContext &context, std::string_view filename)
Manages all settings.
SettingsManager & getSettingsManager()
std::unique_ptr< Context > context
Definition: GLContext.cc:9
constexpr const char *const filename
void setSaveFilename(const FileContext &context, std::string_view filename)
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
SettingsConfig(GlobalCommandController &globalCommandController, HotKey &hotKey)
XMLElement & getXMLElement()