The Battle for Wesnoth  1.17.0-dev
campaign_difficulty.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2021
3  by Iris Morelle <shadowm2006@gmail.com>
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 "config.hpp"
20 
21 #include <vector>
22 
23 namespace gui2::dialogs
24 {
25 
26 /**
27  * Helper function to convert old difficulty markup. Declared outside class to allow other
28  * classes to make use of it.
29  */
31 
32 /**
33  * @ingroup GUIWindowDefinitionWML
34  *
35  * The campaign mode difficulty menu.
36  * Key |Type |Mandatory|Description
37  * ------------------|--------------|---------|-----------
38  * title | @ref label |yes |Dialog title label.
39  * message | scroll_label |no |Text label displaying a description or instructions.
40  * listbox | @ref listbox |yes |Listbox displaying user choices, defined by WML for each campaign.
41  * icon | control |yes |Widget which shows a listbox item icon, first item markup column.
42  * label | control |yes |Widget which shows a listbox item label, second item markup column.
43  * description | control |yes |Widget which shows a listbox item description, third item markup column.
44  */
46 {
47 public:
48  /**
49  * @param campaign The campaign the difficulty is being chosen for
50  */
51  campaign_difficulty(const config& campaign);
52 
53  /**
54  * Returns the selected difficulty define after displaying.
55  * @return 'CANCEL' if the dialog was canceled.
56  */
57  std::string selected_difficulty() const
58  {
59  return selected_difficulty_;
60  }
61 
62 private:
64  std::string campaign_id_;
65  std::string selected_difficulty_;
66 
67  virtual const std::string& window_id() const override;
68 
69  virtual void pre_show(window& window) override;
70 
71  virtual void post_show(window& window) override;
72 };
73 } // namespace dialogs
virtual const std::string & window_id() const override
The id of the window to build.
Definitions for the interface to Wesnoth Markup Language (WML).
std::string selected_difficulty() const
Returns the selected difficulty define after displaying.
config generate_difficulty_config(const config &source)
Helper function to convert old difficulty markup.
The campaign mode difficulty menu.
Abstract base class for all modal dialogs.
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:61
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:65
campaign_difficulty(const config &campaign)
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.