The Battle for Wesnoth  1.17.21+dev
about.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2023
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 #include "tstring.hpp"
19 
20 #include <optional>
21 #include <string>
22 #include <utility>
23 #include <vector>
24 
25 class config;
26 class game_config_view;
27 
28 namespace about
29 {
31 {
32  struct about_group
33  {
34  explicit about_group(const config& cfg);
35 
36  /** Contributor names. */
37  std::vector<std::pair<std::string, std::string>> names;
38 
39  /** The section title. */
41 
42  bool operator<(const about_group& o) const;
43  };
44 
45  credits_group(const config& cfg, bool is_campaign_credits);
46 
47  /** The group's sub-groups. Corresponds to each [about] tag .*/
48  std::vector<about_group> sections;
49 
50  /** Optional group ID. Currently only used for identifying campaigns. */
51  std::string id;
52 
53  /** Optional group title. Currently only used for identifying campaigns. */
55 };
56 
57 using credits_data = std::vector<credits_group>;
58 
59 /** Gets all credits data. */
61 
62 /** Gets credits for a given campaign. Returns a null optional if that campaign has no credits. */
63 std::optional<credits_data::const_iterator> get_campaign_credits(const std::string& campaign);
64 
65 /** Gets credit background images for a given campaign. */
66 std::vector<std::string> get_background_images(const std::string& campaign);
67 
68 /** Regenerates the credits data. */
69 void set_about(const game_config_view& cfg);
70 
71 } // namespace about
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:161
A class grating read only view to a vector of config objects, viewed as one config with all children ...
Display credits about all contributors.
std::vector< credits_group > credits_data
Definition: about.hpp:57
void set_about(const game_config_view &cfg)
Regenerates the credits data.
Definition: about.cpp:119
std::vector< std::string > get_background_images(const std::string &campaign)
Gets credit background images for a given campaign.
Definition: about.cpp:106
std::optional< credits_data::const_iterator > get_campaign_credits(const std::string &campaign)
Gets credits for a given campaign.
Definition: about.cpp:99
const credits_data & get_credits_data()
Gets all credits data.
Definition: about.cpp:94
about_group(const config &cfg)
Definition: about.cpp:78
bool operator<(const about_group &o) const
Definition: about.cpp:89
std::vector< std::pair< std::string, std::string > > names
Contributor names.
Definition: about.hpp:37
t_string title
The section title.
Definition: about.hpp:40
t_string header
Optional group title.
Definition: about.hpp:54
std::string id
Optional group ID.
Definition: about.hpp:51
credits_group(const config &cfg, bool is_campaign_credits)
Definition: about.cpp:47
std::vector< about_group > sections
The group's sub-groups.
Definition: about.hpp:48