The Battle for Wesnoth  1.15.12+dev
game_version_dialog.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013 - 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 
18 
19 #include "build_info.hpp"
20 
21 #include <map>
22 
23 #include <array>
24 
25 namespace gui2
26 {
27 class listbox;
28 
29 namespace dialogs
30 {
31 
32 /**
33  * @ingroup GUIWindowDefinitionWML
34  *
35  * Dialog displaying the various paths used by the game to locate resource and configuration files.
36  *
37  * There are several item types used to build widget ids in this dialog.
38  * All references to TYPE below refer to the following suffixes: datadir, config, userdata, saves, addons, cache.
39  * Key |Type |Mandatory|Description
40  * ------------------|--------------|---------|-----------
41  * path_TYPE | text_box |yes |Textbox containing the filesystem path for the given item.
42  * copy_TYPE | @ref button |yes |Copies the given item's path to clipboard.
43  * browse_TYPE | @ref button |yes |Launches the default file browser on the given item's path.
44  */
45 class game_version : public modal_dialog
46 {
47 public:
48  /**
49  * Constructor.
50  */
51  game_version();
52 
53  /**
54  * The display function.
55  *
56  * See @ref modal_dialog for more information.
57  */
59 
60 private:
61  const std::string path_wid_stem_;
62  const std::string copy_wid_stem_;
63  const std::string browse_wid_stem_;
64 
65  std::map<std::string, std::string> path_map_;
66 
67 #ifdef _WIN32
68  const std::string log_path_;
69 #endif
70 
71  typedef std::array<std::string, 4> deplist_entry;
72  std::vector<deplist_entry> deps_;
73 
74  std::vector<game_config::optional_feature> opts_;
75 
76  std::string report_;
77 
79 
80  virtual const std::string& window_id() const override;
81 
82  virtual void pre_show(window& window) override;
83 
84  //
85  // Widget event callbacks.
86  //
87 
88  /**
89  * Callback function called when switching tabs.
90  */
91  void tab_switch_callback();
92 
93  /**
94  * Callback function for the dialog-wide copy-to-clipboard button.
95  */
96  void report_copy_callback();
97 
98  /**
99  * Callback function for copy-to-clipboard action buttons.
100  *
101  * @param path Filesystem path associated with the widget.
102  */
103  void copy_to_clipboard_callback(const std::string& path);
104 
105  /**
106  * Callback function for browse-directory action buttons.
107  *
108  * @param path Filesystem path associated with the widget.
109  */
110  void browse_directory_callback(const std::string& path);
111 };
112 } // namespace dialogs
113 } // namespace gui2
void report_copy_callback()
Callback function for the dialog-wide copy-to-clipboard button.
const std::string path_wid_stem_
The display function.
std::map< std::string, std::string > path_map_
void tab_switch_callback()
Callback function called when switching tabs.
std::array< std::string, 4 > deplist_entry
Dialog displaying the various paths used by the game to locate resource and configuration files...
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
Generic file dialog.
Definition: field-fwd.hpp:22
void copy_to_clipboard_callback(const std::string &path)
Callback function for copy-to-clipboard action buttons.
std::vector< deplist_entry > deps_
void browse_directory_callback(const std::string &path)
Callback function for browse-directory action buttons.
virtual const std::string & window_id() const override
The id of the window to build.
std::string path
Definition: game_config.cpp:38
Various uncategorised dialogs.
std::vector< game_config::optional_feature > opts_
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:64