The Battle for Wesnoth  1.19.0-dev
game_version_dialog.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2013 - 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 
19 
20 #include "build_info.hpp"
21 
22 #include <map>
23 
24 #include <array>
25 
26 namespace gui2
27 {
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  /** path to current log file */
68  const std::string log_path_;
69 
70  typedef std::array<std::string, 4> deplist_entry;
71  std::vector<deplist_entry> deps_;
72 
73  std::vector<game_config::optional_feature> opts_;
74 
75  std::string report_;
76 
78 
79  virtual const std::string& window_id() const override;
80 
81  virtual void pre_show(window& window) override;
82 
83  //
84  // Widget event callbacks.
85  //
86 
87  /**
88  * Callback function called when switching tabs.
89  */
90  void tab_switch_callback();
91 
92  /**
93  * Callback function for the dialog-wide copy-to-clipboard button.
94  */
95  void report_copy_callback();
96 
97  /**
98  * Callback function for copy-to-clipboard action buttons.
99  *
100  * @param path Filesystem path associated with the widget.
101  */
102  void copy_to_clipboard_callback(const std::string& path);
103 
104  /**
105  * Callback function for browse-directory action buttons.
106  *
107  * @param path Filesystem path associated with the widget.
108  */
109  void browse_directory_callback(const std::string& path);
110 };
111 } // namespace dialogs
112 } // namespace gui2
Dialog displaying the various paths used by the game to locate resource and configuration files.
const std::string path_wid_stem_
The display function.
void tab_switch_callback()
Callback function called when switching tabs.
std::array< std::string, 4 > deplist_entry
virtual const std::string & window_id() const override
The ID of the window to build.
void report_copy_callback()
Callback function for the dialog-wide copy-to-clipboard button.
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
void copy_to_clipboard_callback(const std::string &path)
Callback function for copy-to-clipboard action buttons.
std::map< std::string, std::string > path_map_
const std::string log_path_
path to current log file
std::vector< deplist_entry > deps_
void browse_directory_callback(const std::string &path)
Callback function for browse-directory action buttons.
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:63
#define DEFINE_SIMPLE_DISPLAY_WRAPPER(dialog)
Adds a bare-bones static display function to a dialog class that immediately invokes the dialogs's mo...
Various uncategorised dialogs.
std::string path
Definition: filesystem.cpp:83
Generic file dialog.