The Battle for Wesnoth  1.19.0-dev
campaign_difficulty.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2024
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 
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
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
The campaign mode difficulty menu.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
campaign_difficulty(const config &campaign)
virtual const std::string & window_id() const override
The ID of the window to build.
std::string selected_difficulty() const
Returns the selected difficulty define after displaying.
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
Abstract base class for all modal dialogs.
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition: window.hpp:63
config generate_difficulty_config(const config &source)
Helper function to convert old difficulty markup.