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 
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  /** top_level_drawable hook to animate the view */
46  virtual void update() override;
47 
48 private:
49  virtual const std::string& window_id() const override;
50 
51  virtual void pre_show(window& window) override;
52  virtual void post_show(window& window) override;
53 
54  void clear_image_timer();
55 
57 
58  void display_part();
59 
60  using floating_image_list = std::vector<storyscreen::floating_image>;
61  void draw_floating_image(floating_image_list::const_iterator image_iter, int this_part_index);
62 
66  };
67 
68  void nav_button_callback( NAV_DIRECTION direction);
69 
70  void key_press_callback(const SDL_Keycode key);
71 
72  void set_next_draw();
73  void begin_fade_draw(bool fade_in);
74  void halt_fade_draw();
75 
76  void flag_stack_as_dirty();
77 
79 
81 
83 
84  std::size_t timer_id_;
85  std::size_t next_draw_;
86 
88 
89  enum FADE_STATE {
93  };
94 
96 
98 };
99 
100 } // 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:61
std::shared_ptr< part > part_pointer_type
Definition: controller.hpp:36
Storyscreen controller (interface).
Storyscreen parts and floating images representation.