Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
map_settings_manager.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
4
5#pragma once
6
7#include <string>
8#include "settings.h"
9
10struct NoiseParams;
11struct MapgenParams;
12
13/*
14 MapSettingsManager is a centralized object for management (creating,
15 loading, storing, saving, etc.) of config settings related to the Map.
16
17 It has two phases: the initial r/w "gather and modify settings" state, and
18 the final r/o "read and save settings" state.
19
20 The typical use case is, in order, as follows:
21 - Create a MapSettingsManager object
22 - Try to load map metadata into it from the metadata file
23 - Manually view and modify the current configuration as desired through a
24 Settings-like interface
25 - When all modifications are finished, create a 'Parameters' object
26 containing the finalized, active parameters. This could be passed along
27 to whichever Map-related objects that may require it.
28 - Save these active settings to the metadata file when requested
29*/
31public:
32 MapSettingsManager(const std::string &map_meta_path);
34
35 // Finalized map generation parameters
37
38 bool getMapSetting(const std::string &name, std::string *value_out) const;
39
40 bool getMapSettingNoiseParams(const std::string &name,
41 NoiseParams *value_out) const;
42
43 // Note: Map config becomes read-only after makeMapgenParams() gets called
44 // (i.e. mapgen_params is non-NULL). Attempts to set map config after
45 // params have been finalized will result in failure.
46 bool setMapSetting(const std::string &name,
47 const std::string &value, bool override_meta = false);
48
49 bool setMapSettingNoiseParams(const std::string &name,
50 const NoiseParams *value, bool override_meta = false);
51
52 bool loadMapMeta();
53 bool saveMapMeta();
55
56private:
57 std::string m_map_meta_path;
58
62};
Definition map_settings_manager.h:30
MapSettingsManager(const std::string &map_meta_path)
Definition map_settings_manager.cpp:13
bool loadMapMeta()
Definition map_settings_manager.cpp:82
Settings * m_defaults
Definition map_settings_manager.h:60
bool setMapSetting(const std::string &name, const std::string &value, bool override_meta=false)
Definition map_settings_manager.cpp:52
bool getMapSettingNoiseParams(const std::string &name, NoiseParams *value_out) const
Definition map_settings_manager.cpp:44
bool setMapSettingNoiseParams(const std::string &name, const NoiseParams *value, bool override_meta=false)
Definition map_settings_manager.cpp:67
~MapSettingsManager()
Definition map_settings_manager.cpp:29
MapgenParams * makeMapgenParams()
Definition map_settings_manager.cpp:126
MapgenParams * mapgen_params
Definition map_settings_manager.h:36
Settings * m_map_settings
Definition map_settings_manager.h:61
std::string m_map_meta_path
Definition map_settings_manager.h:57
bool getMapSetting(const std::string &name, std::string *value_out) const
Definition map_settings_manager.cpp:37
SettingsHierarchy m_hierarchy
Definition map_settings_manager.h:59
bool saveMapMeta()
Definition map_settings_manager.cpp:97
Definition settings.h:58
Definition settings.h:109
Definition mapgen.h:114
Definition noise.h:119