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