3 Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef MAP_SETTINGS_MANAGER_HEADER
21 #define MAP_SETTINGS_MANAGER_HEADER
30 MapSettingsManager is a centralized object for management (creating,
31 loading, storing, saving, etc.) of config settings related to the Map.
33 It has two phases: the initial r/w "gather and modify settings" state, and
34 the final r/o "read and save settings" state.
36 The typical use case is, in order, as follows:
37 - Create a MapSettingsManager object
38 - Try to load map metadata into it from the metadata file
39 - Manually view and modify the current configuration as desired through a
40 Settings-like interface
41 - When all modifications are finished, create a 'Parameters' object
42 containing the finalized, active parameters. This could be passed along
43 to whichever Map-related objects that may require it.
44 - Save these active settings to the metadata file when requested
46 class MapSettingsManager {
48 MapSettingsManager(Settings *user_settings,
49 const std::string &map_meta_path);
50 ~MapSettingsManager();
52 // Finalized map generation parameters
53 MapgenParams *mapgen_params = nullptr;
55 bool getMapSetting(const std::string &name, std::string *value_out);
57 bool getMapSettingNoiseParams(
58 const std::string &name, NoiseParams *value_out);
60 // Note: Map config becomes read-only after makeMapgenParams() gets called
61 // (i.e. mapgen_params is non-NULL). Attempts to set map config after
62 // params have been finalized will result in failure.
63 bool setMapSetting(const std::string &name,
64 const std::string &value, bool override_meta = false);
66 bool setMapSettingNoiseParams(const std::string &name,
67 const NoiseParams *value, bool override_meta = false);
71 MapgenParams *makeMapgenParams();
74 std::string m_map_meta_path;
75 Settings *m_map_settings;
76 Settings *m_user_settings;