-
-
Notifications
You must be signed in to change notification settings - Fork 991
/
story_viewer.hpp
102 lines (72 loc) · 2.28 KB
/
story_viewer.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
Copyright (C) 2017-2018 by Charles Dang <exodia339@gmail.com>
Part of the Battle for Wesnoth Project https://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#pragma once
#include "gui/dialogs/modal_dialog.hpp"
#include "config.hpp"
#include "storyscreen/controller.hpp"
#include "storyscreen/part.hpp"
class CVideo;
namespace gui2
{
namespace dialogs
{
/** Dialog to view the storyscreen. */
class story_viewer : public modal_dialog
{
public:
story_viewer(const std::string& scenario_name, const config& cfg_parsed);
~story_viewer();
static void display(const std::string& scenario_name, const config& story)
{
try {
story_viewer viewer(scenario_name, story);
if(viewer.controller_.max_parts() > 0) {
viewer.show();
}
} catch(const std::out_of_range&) {}
}
private:
/** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const override;
/** Inherited from modal_dialog. */
virtual void pre_show(window& window) override;
void clear_image_timer();
void update_current_part_ptr();
void display_part(window& window);
using floating_image_list = std::vector<storyscreen::floating_image>;
void draw_floating_image(window& window, floating_image_list::const_iterator image_iter, int this_part_index);
enum NAV_DIRECTION {
DIR_FORWARD,
DIR_BACKWARDS
};
void nav_button_callback(window& window, NAV_DIRECTION direction);
void key_press_callback(window& window, const SDL_Keycode key);
void set_next_draw();
void begin_fade_draw(bool fade_in);
void halt_fade_draw();
void draw_callback(window& window);
void flag_stack_as_dirty(window& window);
storyscreen::controller controller_;
int part_index_;
storyscreen::controller::part_pointer_type current_part_;
size_t timer_id_;
size_t next_draw_;
int fade_step_;
enum FADE_STATE {
FADING_IN,
FADING_OUT,
NOT_FADING
};
FADE_STATE fade_state_;
};
} // namespace dialogs
} // namespace gui2