The Battle for Wesnoth  1.19.0-dev
story_viewer.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2017 - 2024
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 
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  /** top_level_drawable hook to animate the view */
45  virtual void update() override;
46 
47 private:
48  virtual const std::string& window_id() const override;
49 
50  virtual void pre_show(window& window) override;
51  virtual void post_show(window& window) override;
52 
53  void clear_image_timer();
54 
56 
57  void display_part();
58 
59  using floating_image_list = std::vector<storyscreen::floating_image>;
60  void draw_floating_image(floating_image_list::const_iterator image_iter, int this_part_index);
61 
65  };
66 
67  void nav_button_callback( NAV_DIRECTION direction);
68 
69  void key_press_callback(const SDL_Keycode key);
70 
71  void set_next_draw();
72  void begin_fade_draw(bool fade_in);
73  void halt_fade_draw();
74 
75  void flag_stack_as_dirty();
76 
78 
80 
82 
83  std::size_t timer_id_;
84  std::size_t next_draw_;
85 
87 
88  enum FADE_STATE {
92  };
93 
95 
97 };
98 
99 } // namespace dialogs
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:159
Abstract base class for all modal dialogs.
bool show(const unsigned auto_close_time=0)
Shows the window.
Dialog to view the storyscreen.
story_viewer(const std::string &scenario_name, const config &cfg_parsed)
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
static void display(const std::string &scenario_name, const config &story)
virtual const std::string & window_id() const override
The ID of the window to build.
storyscreen::controller controller_
void begin_fade_draw(bool fade_in)
storyscreen::controller::part_pointer_type current_part_
virtual void update() override
top_level_drawable hook to animate the view
void draw_floating_image(floating_image_list::const_iterator image_iter, int this_part_index)
void nav_button_callback(NAV_DIRECTION direction)
std::vector< storyscreen::floating_image > floating_image_list
void key_press_callback(const SDL_Keycode key)
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition: window.hpp:63
std::shared_ptr< part > part_pointer_type
Definition: controller.hpp:36
Storyscreen controller (interface).
Storyscreen parts and floating images representation.