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