The Battle for Wesnoth  1.17.0-dev
story_viewer.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017 - 2021
3  by Charles Dang <exodia339@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 #pragma once
17 
19 
20 #include "config.hpp"
22 #include "storyscreen/part.hpp"
23 
24 namespace gui2::dialogs
25 {
26 
27 /** Dialog to view the storyscreen. */
28 class story_viewer : public modal_dialog
29 {
30 public:
31  story_viewer(const std::string& scenario_name, const config& cfg_parsed);
32 
33  ~story_viewer();
34 
35  static void display(const std::string& scenario_name, const config& story)
36  {
37  try {
38  story_viewer viewer(scenario_name, story);
39  if(viewer.controller_.max_parts() > 0) {
40  viewer.show();
41  }
42  } catch(const std::out_of_range&) {}
43  }
44 
45 private:
46  virtual const std::string& window_id() const override;
47 
48  virtual void pre_show(window& window) override;
49 
50  void clear_image_timer();
51 
53 
54  void display_part();
55 
56  using floating_image_list = std::vector<storyscreen::floating_image>;
57  void draw_floating_image(floating_image_list::const_iterator image_iter, int this_part_index);
58 
62  };
63 
64  void nav_button_callback( NAV_DIRECTION direction);
65 
66  void key_press_callback(const SDL_Keycode key);
67 
68  void set_next_draw();
69  void begin_fade_draw(bool fade_in);
70  void halt_fade_draw();
71 
72  void draw_callback();
73 
74  void flag_stack_as_dirty();
75 
77 
79 
81 
82  std::size_t timer_id_;
83  std::size_t next_draw_;
84 
86 
87  enum FADE_STATE {
91  };
92 
94 };
95 
96 } // 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:37
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:60
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:65
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)