The Battle for Wesnoth  1.19.5+dev
map_generator.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2024
3  by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 class config;
19 
20 #include "exceptions.hpp"
21 #include "map/location.hpp"
22 #include "utils/optional_fwd.hpp"
23 
24 #include <cstdint>
25 
27 {
28  mapgen_exception(const std::string& msg)
29  : game::error(msg)
30  {}
31 };
32 
34 {
35 public:
36  virtual ~map_generator() {}
37 
38  /**
39  * Returns true if the map generator has an interactive screen,
40  * which allows the user to modify how the generator behaves.
41  */
42  virtual bool allow_user_config() const;
43 
44  /**
45  * Display the interactive screen, which allows the user
46  * to modify how the generator behaves.
47  * (This function will not be called if allow_user_config() returns false).
48  */
49  virtual void user_config();
50 
51  /**
52  * Returns a string identifying the generator by name.
53  * The name should not contain spaces.
54  */
55  virtual std::string name() const = 0;
56 
57  /**
58  * Return a friendly name for the generator
59  * used to differentiate between different configs of the same generator
60  */
61  virtual std::string config_name() const = 0;
62 
63  /**
64  * Creates a new map and returns it.
65  * args may contain arguments to the map generator.
66  */
67  virtual std::string create_map(utils::optional<uint32_t> randomseed = {}) = 0;
68 
69  virtual config create_scenario(utils::optional<uint32_t> randomseed = {});
70 };
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:172
virtual ~map_generator()
virtual config create_scenario(utils::optional< uint32_t > randomseed={})
virtual std::string create_map(utils::optional< uint32_t > randomseed={})=0
Creates a new map and returns it.
virtual std::string config_name() const =0
Return a friendly name for the generator used to differentiate between different configs of the same ...
virtual std::string name() const =0
Returns a string identifying the generator by name.
virtual void user_config()
Display the interactive screen, which allows the user to modify how the generator behaves.
virtual bool allow_user_config() const
Returns true if the map generator has an interactive screen, which allows the user to modify how the ...
static void msg(const char *act, debug_info &i, const char *to="", const char *result="")
Definition: debugger.cpp:109
Base class for all the errors encountered by the engine.
Definition: exceptions.hpp:29
mapgen_exception(const std::string &msg)