openMSX
GlobalSettings.cc
Go to the documentation of this file.
1#include "GlobalSettings.hh"
2#include "SettingsConfig.hh"
4#include "strCat.hh"
5#include "view.hh"
6#include "xrange.hh"
7#include "build-info.hh"
8#include <memory>
9#include <SDL.h>
10
11namespace openmsx {
12
14 : commandController(commandController_)
15 , pauseSetting(commandController, "pause",
16 "pauses the emulation", false, Setting::Save::NO)
17 , powerSetting(commandController, "power",
18 "turn power on/off", false, Setting::Save::NO)
19 , autoSaveSetting(commandController, "save_settings_on_exit",
20 "automatically save settings when openMSX exits", true)
21 , umrCallBackSetting(commandController, "umr_callback",
22 "Tcl proc to call when an UMR is detected", {})
23 , invalidPsgDirectionsSetting(commandController,
24 "invalid_psg_directions_callback",
25 "Tcl proc called when the MSX program has set invalid PSG port directions",
26 "default_invalid_psg_directions_callback")
27 , invalidPpiModeSetting(commandController,
28 "invalid_ppi_mode_callback",
29 "Tcl proc called when the MSX program has set an invalid PPI mode",
30 "default_invalid_ppi_mode_callback")
31 , resampleSetting(commandController, "resampler", "Resample algorithm",
36 , speedManager(commandController)
37 , throttleManager(commandController)
38{
39 getPowerSetting().attach(*this);
40}
41
43{
44 getPowerSetting().detach(*this);
45 commandController.getSettingsConfig().setSaveSettings(
46 autoSaveSetting.getBoolean());
47}
48
49// Observer<Setting>
50void GlobalSettings::update(const Setting& setting) noexcept
51{
52 if (&setting == &getPowerSetting()) { // either on or off
53 // automatically unpause after a power off/on cycle
54 // this solved a bug, but apart from that this behaviour also
55 // makes more sense
56 try {
57 getPauseSetting().setBoolean(false);
58 } catch(...) {
59 // Ignore. E.g. can trigger when a Tcl trace on the
60 // pause setting triggers errors in the Tcl script.
61 }
62 }
63}
64
65} // namespace openmsx
BaseSetting * setting
bool getBoolean() const noexcept
EnumSettingBase::Map Map
GlobalSettings(GlobalCommandController &commandController)
BooleanSetting & getPowerSetting()
void setSaveSettings(bool save)
void detach(Observer< T > &observer)
Definition Subject.hh:60
This file implemented 3 utility functions:
Definition Autofire.cc:11