The Battle for Wesnoth  1.17.0-dev
core_selection.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2021
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 
18 
19 class config;
20 
21 namespace gui2::dialogs
22 {
23 
24 /**
25  * @ingroup GUIWindowDefinitionWML
26  *
27  * This shows the dialog which allows the user to choose which core to play.
28  * Key |Type |Mandatory|Description
29  * ------------------|--------------|---------|-----------
30  * core_list | @ref listbox |yes |A listbox that contains all available cores.
31  * icon | @ref image |no |The icon for the core.
32  * name | control |no |The name of the core.
33  * core_details | multi_page |yes |A multi page widget that shows more details for the selected core.
34  * image | @ref image |no |The image for the core.
35  * description | control |no |The description of the core.
36  */
38 {
39 public:
40  explicit core_selection(const std::vector<config>& cores, int choice)
41  : cores_(cores), choice_(choice)
42  {
43  }
44 
45  /***** ***** ***** setters / getters for members ***** ****** *****/
46 
47  int get_choice() const
48  {
49  return choice_;
50  }
51 
52 private:
53  /** Called when another core is selected. */
54  void core_selected() const;
55 
56  virtual const std::string& window_id() const override;
57 
58  virtual void pre_show(window& window) override;
59 
60  virtual void post_show(window& window) override;
61 
62  /** Contains the config objects for all cores. */
63  const std::vector<config>& cores_;
64 
65  /** The chosen core. */
66  int choice_;
67 };
68 
69 } // namespace dialogs
int choice_
The chosen core.
core_selection(const std::vector< config > &cores, int choice)
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
const std::vector< config > & cores_
Contains the config objects for all cores.
void core_selected() const
Called when another core is selected.
Abstract base class for all modal dialogs.
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
This shows the dialog which allows the user to choose which core to play.
virtual const std::string & window_id() const override
The id of the window to build.
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