The Battle for Wesnoth  1.19.5+dev
game_delete.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2024
3  by Jörg Hinrichs <joerg.hinrichs@alice-dsl.de>
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 
17 
19 
20 namespace gui2::dialogs
21 {
22 
23 REGISTER_DIALOG(game_delete)
24 
25 /**
26  * Helper to invert @ref prefs::get().ask_delete_saves.
27  *
28  * The value stored and the way shown is inverted.
29  */
30 static bool get_dont_ask_again()
31 {
32  return !prefs::get().ask_delete();
33 }
34 
35 /**
36  * Helper to invert @ref prefs::get().set_ask_delete_saves.
37  *
38  * The value stored and the way shown is inverted.
39  */
40 static void set_dont_ask_again(const bool ask_again)
41 {
42  prefs::get().set_ask_delete(!ask_again);
43 }
44 
46  : modal_dialog(window_id())
47 {
49  "dont_ask_again", true, &get_dont_ask_again, &set_dont_ask_again);
50 }
51 
52 } // namespace dialogs
Abstract base class for all modal dialogs.
field_bool * register_bool(const std::string &id, const bool mandatory, const std::function< bool()> callback_load_value=nullptr, const std::function< void(bool)> callback_save_value=nullptr, const std::function< void(widget &)> callback_change=nullptr, const bool initial_fire=false)
Creates a new boolean field.
static prefs & get()
REGISTER_DIALOG(editor_edit_unit)
static void set_dont_ask_again(const bool ask_again)
Helper to invert .set_ask_delete_saves.
Definition: game_delete.cpp:40
static bool get_dont_ask_again()
Helper to invert .ask_delete_saves.
Definition: game_delete.cpp:30