The Battle for Wesnoth  1.15.12+dev
story_viewer.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017-2018 by Charles Dang <exodia339@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 #pragma once
16 
18 
19 #include "config.hpp"
21 #include "storyscreen/part.hpp"
22 
23 namespace gui2::dialogs
24 {
25 
26 /** Dialog to view the storyscreen. */
27 class story_viewer : public modal_dialog
28 {
29 public:
30  story_viewer(const std::string& scenario_name, const config& cfg_parsed);
31 
32  ~story_viewer();
33 
34  static void display(const std::string& scenario_name, const config& story)
35  {
36  try {
37  story_viewer viewer(scenario_name, story);
38  if(viewer.controller_.max_parts() > 0) {
39  viewer.show();
40  }
41  } catch(const std::out_of_range&) {}
42  }
43 
44 private:
45  virtual const std::string& window_id() const override;
46 
47  virtual void pre_show(window& window) override;
48 
49  void clear_image_timer();
50 
52 
53  void display_part();
54 
55  using floating_image_list = std::vector<storyscreen::floating_image>;
56  void draw_floating_image(floating_image_list::const_iterator image_iter, int this_part_index);
57 
61  };
62 
63  void nav_button_callback( NAV_DIRECTION direction);
64 
65  void key_press_callback(const SDL_Keycode key);
66 
67  void set_next_draw();
68  void begin_fade_draw(bool fade_in);
69  void halt_fade_draw();
70 
71  void draw_callback();
72 
73  void flag_stack_as_dirty();
74 
76 
78 
80 
81  std::size_t timer_id_;
82  std::size_t next_draw_;
83 
85 
86  enum FADE_STATE {
90  };
91 
93 };
94 
95 } // namespace dialogs
storyscreen::controller::part_pointer_type current_part_
std::vector< storyscreen::floating_image > floating_image_list
static void display(const std::string &scenario_name, const config &story)
Storyscreen parts and floating images representation.
void key_press_callback(const SDL_Keycode key)
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
bool show(const unsigned auto_close_time=0)
Shows the window.
Definitions for the interface to Wesnoth Markup Language (WML).
std::shared_ptr< part > part_pointer_type
Definition: controller.hpp:36
void begin_fade_draw(bool fade_in)
Dialog to view the storyscreen.
storyscreen::controller controller_
Abstract base class for all modal dialogs.
story_viewer(const std::string &scenario_name, const config &cfg_parsed)
Storyscreen controller (interface).
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:59
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:64
void draw_floating_image(floating_image_list::const_iterator image_iter, int this_part_index)
virtual const std::string & window_id() const override
The id of the window to build.
void nav_button_callback(NAV_DIRECTION direction)