The Battle for Wesnoth  1.15.2+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
24 {
25 namespace dialogs
26 {
27 
28 /** Dialog to view the storyscreen. */
29 class story_viewer : public modal_dialog
30 {
31 public:
32  story_viewer(const std::string& scenario_name, const config& cfg_parsed);
33 
34  ~story_viewer();
35 
36  static void display(const std::string& scenario_name, const config& story)
37  {
38  try {
39  story_viewer viewer(scenario_name, story);
40  if(viewer.controller_.max_parts() > 0) {
41  viewer.show();
42  }
43  } catch(const std::out_of_range&) {}
44  }
45 
46 private:
47  /** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
48  virtual const std::string& window_id() const override;
49 
50  /** Inherited from modal_dialog. */
51  virtual void pre_show(window& window) override;
52 
53  void clear_image_timer();
54 
56 
57  void display_part(window& window);
58 
59  using floating_image_list = std::vector<storyscreen::floating_image>;
60  void draw_floating_image(window& window, floating_image_list::const_iterator image_iter, int this_part_index);
61 
65  };
66 
67  void nav_button_callback(window& window, NAV_DIRECTION direction);
68 
69  void key_press_callback(window& window, 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 draw_callback(window& window);
76 
77  void flag_stack_as_dirty(window& window);
78 
80 
82 
84 
85  std::size_t timer_id_;
86  std::size_t next_draw_;
87 
89 
90  enum FADE_STATE {
94  };
95 
97 };
98 
99 } // namespace dialogs
100 } // namespace gui2
storyscreen::controller::part_pointer_type current_part_
void key_press_callback(window &window, const SDL_Keycode key)
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 draw_callback(window &window)
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).
Generic file dialog.
Definition: field-fwd.hpp:22
std::shared_ptr< part > part_pointer_type
Definition: controller.hpp:36
void nav_button_callback(window &window, NAV_DIRECTION direction)
void flag_stack_as_dirty(window &window)
void begin_fade_draw(bool fade_in)
Various uncategorised dialogs.
void draw_floating_image(window &window, floating_image_list::const_iterator image_iter, int this_part_index)
Dialog to view the storyscreen.
storyscreen::controller controller_
void display_part(window &window)
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:68
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:63
virtual const std::string & window_id() const override
Inherited from modal_dialog, implemented by REGISTER_DIALOG.