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