The Battle for Wesnoth  1.19.1+dev
controller.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2003 - 2024
3  by David White <dave@whitevine.net>, 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 /**
17  * @file
18  * Storyscreen controller (implementation).
19  */
20 
22 #include "storyscreen/part.hpp"
23 
24 #include "log.hpp"
25 #include "resources.hpp"
26 #include "variable.hpp"
27 
28 #include <cassert>
29 
30 static lg::log_domain log_engine("engine");
31 #define ERR_NG LOG_STREAM(err, log_engine)
32 #define LOG_NG LOG_STREAM(info, log_engine)
33 
34 namespace storyscreen
35 {
36 controller::controller(const vconfig& data, const std::string& scenario_name)
37  : scenario_name_(scenario_name)
38  , parts_()
39 {
40  assert(resources::gamedata != nullptr && "Ouch: gamedata is nullptr when initializing storyscreen controller");
42 }
43 
44 bool controller::resolve_wml_helper(const std::string& key, const vconfig& node)
45 {
46  bool found = false;
47 
48  if(key == "part" && !node.empty()) {
49  part_pointer_type const story_part(new part(node));
50  // Use scenario name as part title if the WML doesn't supply a custom one.
51  if((*story_part).show_title() && (*story_part).title().empty()) {
52  (*story_part).set_title(scenario_name_);
53  }
54 
55  parts_.push_back(story_part);
56  found = true;
57  }
58 
59  return found;
60 }
61 
62 } // end namespace storyscreen
controller(const vconfig &data, const std::string &scenario_name)
Definition: controller.cpp:36
std::shared_ptr< part > part_pointer_type
Definition: controller.hpp:36
virtual bool resolve_wml_helper(const std::string &key, const vconfig &node) override
Inherited from story_parser.
Definition: controller.cpp:44
std::vector< part_pointer_type > parts_
Definition: controller.hpp:57
std::string scenario_name_
Definition: controller.hpp:54
Represents and contains information about a single storyscreen part.
Definition: part.hpp:227
virtual void resolve_wml(const vconfig &cfg)
Takes care of initializing and branching properties.
Definition: parser.cpp:29
A variable-expanding proxy for the config class.
Definition: variable.hpp:45
bool empty() const
Definition: variable.hpp:100
static lg::log_domain log_engine("engine")
Storyscreen controller (interface).
Standard logging facilities (interface).
game_data * gamedata
Definition: resources.cpp:22
Storyscreen parts and floating images representation.
std::string_view data
Definition: picture.cpp:194