The Battle for Wesnoth  1.15.10+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  /** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
46  virtual const std::string& window_id() const override;
47 
48  /** Inherited from modal_dialog. */
49  virtual void pre_show(window& window) override;
50 
51  void clear_image_timer();
52 
54 
55  void display_part();
56 
57  using floating_image_list = std::vector<storyscreen::floating_image>;
58  void draw_floating_image(floating_image_list::const_iterator image_iter, int this_part_index);
59 
63  };
64 
65  void nav_button_callback( NAV_DIRECTION direction);
66 
67  void key_press_callback(const SDL_Keycode key);
68 
69  void set_next_draw();
70  void begin_fade_draw(bool fade_in);
71  void halt_fade_draw();
72 
73  void draw_callback();
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 };
96 
97 } // 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
Inherited from modal_dialog.
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
Inherited from modal_dialog, implemented by REGISTER_DIALOG.
void nav_button_callback(NAV_DIRECTION direction)