The Battle for Wesnoth  1.17.0-dev
controller.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2021
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 /**
17  * @file
18  * Storyscreen controller (interface).
19  */
20 
21 #pragma once
22 
23 #include "storyscreen/parser.hpp"
24 
25 #include <memory>
26 #include <string>
27 #include <vector>
28 
29 namespace storyscreen
30 {
31 class part;
32 class floating_image;
33 
34 class controller : private story_parser
35 {
36 public:
37  typedef std::shared_ptr<part> part_pointer_type;
38 
39  controller(const vconfig& data, const std::string& scenario_name);
40 
41  part_pointer_type get_part(int index) const
42  {
43  return parts_.at(index);
44  }
45 
46  int max_parts() const
47  {
48  return parts_.size();
49  }
50 
51 private:
52  /** Inherited from story_parser. */
53  virtual bool resolve_wml_helper(const std::string& key, const vconfig& node) override;
54 
55  std::string scenario_name_;
56 
57  // The part cache.
58  std::vector<part_pointer_type> parts_;
59 };
60 
61 } // end namespace storyscreen
std::vector< part_pointer_type > parts_
Definition: controller.hpp:58
std::shared_ptr< part > part_pointer_type
Definition: controller.hpp:37
Small helper class to encapsulate the common logic for parsing storyscreen WML.
Definition: parser.hpp:28
controller(const vconfig &data, const std::string &scenario_name)
Definition: controller.cpp:36
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Definition: unicode.cpp:72
part_pointer_type get_part(int index) const
Definition: controller.hpp:41
A variable-expanding proxy for the config class.
Definition: variable.hpp:44
virtual bool resolve_wml_helper(const std::string &key, const vconfig &node) override
Inherited from story_parser.
Definition: controller.cpp:44
std::string scenario_name_
Definition: controller.hpp:55