The Battle for Wesnoth 1.21.0-dev
 
Loading...
Searching...
No Matches
sp_options_configure.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2008 - 2025
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#define GETTEXT_DOMAIN "wesnoth-lib"
16
18
20#include "saved_game.hpp"
21
22namespace gui2::dialogs
23{
24
25REGISTER_DIALOG(sp_options_configure)
26
27sp_options_configure::sp_options_configure(ng::create_engine& create_engine)
28 : modal_dialog(window_id())
29 , create_engine_(create_engine)
30 , options_manager_()
31{
32 set_show_even_without_video(true);
33 set_allow_plugin_skip(false);
34}
35
37{
39 options_manager_->update_all_options();
40
41 plugins_context_.reset(new plugins_context("Campaign Configure"));
42 plugins_context_->set_callback("launch", [this](const config&) { set_retval(retval::OK); }, false);
43}
44
46{
47 if(get_retval() == retval::OK) {
49 prefs::get().set_options(options_manager_->get_options_config());
50 }
51}
52
53} // namespace dialogs
A config object defines a single node in a WML file, with access to child nodes.
Definition config.hpp:157
Abstract base class for all modal dialogs.
std::unique_ptr< plugins_context > plugins_context_
virtual void pre_show() override
Actions to be taken before showing the window.
virtual void post_show() override
Actions to be taken after the window has been shown.
std::unique_ptr< mp_options_helper > options_manager_
void set_retval(const int retval, const bool close_window=true)
Sets there return value of the window.
Definition window.hpp:387
int get_retval()
Definition window.hpp:394
saved_game & get_state()
static prefs & get()
void set_options(const config &values)
mp_game_settings & mp_settings()
Multiplayer parameters for this game.
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
@ OK
Dialog was closed with the OK button.
Definition retval.hpp:35