The Battle for Wesnoth  1.19.0-dev
game_end_exceptions.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 - 2024
3  by Joerg Hinrichs <joerg.hinrichs@alice-dsl.de>
4  Copyright (C) 2003 by David White <dave@whitevine.net>
5  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY.
13 
14  See the COPYING file for more details.
15 */
16 
17 #include "config.hpp"
18 #include "game_end_exceptions.hpp"
19 
21  : carryover_report(true)
22  , linger_mode(true)
23  , reveal_map(true)
24 {}
25 
27  : prescenario_save(true)
28  , replay_save(true)
29  , proceed_to_next_level(false)
30  , is_victory(true)
31  , test_result("")
32  , transient()
33 {
34 }
35 
36 void end_level_data::write(config& cfg) const
37 {
38  cfg["prescenario_save"] = prescenario_save;
39  cfg["replay_save"] = replay_save;
40  cfg["proceed_to_next_level"] = proceed_to_next_level;
41  cfg["is_victory"] = is_victory;
42  cfg["test_result"] = test_result;
43 }
44 
45 void end_level_data::read(const config& cfg)
46 {
47  prescenario_save = cfg["prescenario_save"].to_bool(true);
48  replay_save = cfg["replay_save"].to_bool(true);
49  proceed_to_next_level = cfg["proceed_to_next_level"].to_bool(true);
50  is_victory = cfg["is_victory"].to_bool(true);
51  test_result = cfg["test_result"].str();
52 }
53 
55 {
56  config r;
57  write(r);
58  return r;
59 }
60 
62 {
63  config r;
64  write(r);
65  transient.write(r);
66  return r;
67 }
68 
70 {
71  cfg["carryover_report"] = carryover_report;
72  cfg["linger_mode"] = linger_mode;
73  cfg["reveal_map"] = reveal_map;
74 }
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
Contains the exception interfaces used to signal completion of a scenario, campaign or turn.
void read(const config &cfg)
bool prescenario_save
Should a prescenario be created the next game?
void write(config &cfg) const
bool replay_save
Should a replay save be made?
bool proceed_to_next_level
whether to proceed to the next scenario, equals is_victory in sp.
config to_config() const
std::string test_result
result to use if this is a unit test
config to_config_full() const
Includes the transient data.
bool carryover_report
Should a summary of the scenario outcome be displayed?
bool linger_mode
Should linger mode be invoked?
bool reveal_map
Should we reveal map when game is ended? (Multiplayer only)
void write(config &cfg) const