16 #define GETTEXT_DOMAIN "wesnoth-lib"
45 cfg[
"w"] =
"(screen_width)";
46 cfg[
"h"] =
"(image_original_height * 2)";
47 cfg[
"name"] =
"dialogs/story_title_decor.png~O(75%)";
60 , controller_(
vconfig(cfg_parsed, true), scenario_name)
62 , current_part_(
nullptr)
66 , fade_state_(NOT_FADING)
68 update_current_part_ptr();
96 find_widget<scroll_label>(
"part_text")
120 static const int VOICE_SOUND_SOURCE_ID = 255;
122 find_widget<button>(
"prev").set_active(
part_index_ != 0);
130 music_config[
"ms_after"] = 2000;
131 music_config[
"immediate"] =
true;
150 bool has_background =
false;
151 config* base_layer =
nullptr;
153 for(
const auto& layer :
current_part_->get_background_layers()) {
154 has_background |= !layer.file().
empty();
156 const bool preserve_ratio = layer.keep_aspect_ratio();
157 const bool tile_h = layer.tile_horizontally();
158 const bool tile_v = layer.tile_vertically();
161 std::string width_formula =
"(image_original_width)";
162 std::string height_formula =
"(image_original_height)";
167 std::string x_formula;
168 std::string y_formula;
173 x_formula =
"(max(pos, 0) where pos = (width / 2 - image_width / 2))";
179 y_formula =
"(max(pos, 0) where pos = (height / 2 - image_height / 2))";
182 if(layer.scale_horizontally() && preserve_ratio) {
183 height_formula =
"(min((image_original_height * width / image_original_width), height))";
184 }
else if(layer.scale_vertically() || tile_v) {
185 height_formula =
"(height)";
188 if(layer.scale_vertically() && preserve_ratio) {
189 width_formula =
"(min((image_original_width * height / image_original_height), width))";
190 }
else if(layer.scale_horizontally() || tile_h) {
191 width_formula =
"(width)";
194 image[
"x"] = x_formula;
195 image[
"y"] = y_formula;
196 image[
"w"] = width_formula;
197 image[
"h"] = height_formula;
198 image[
"name"] = layer.file();
199 image[
"resize_mode"] = (tile_h || tile_v) ?
"tile_center" :
"scale";
203 if(base_layer ==
nullptr || layer.is_base_layer()) {
204 base_layer = &layer_image;
218 if(base_layer !=
nullptr) {
219 (*base_layer)[
"actions"] = R
"((
221 set_var('base_scale_x', as_decimal(image_width) / as_decimal(image_original_width)),
222 set_var('base_scale_y', as_decimal(image_height) / as_decimal(image_original_height)),
223 set_var('base_origin_x', clip_x),
224 set_var('base_origin_y', clip_y)
245 label& title_label = find_widget<label>(
"title");
251 showing_title =
true;
259 showing_title =
false;
267 stacked_widget& text_stack = find_widget<stacked_widget>(
"text_and_control_stack");
269 std::string new_panel_mode;
274 new_panel_mode =
"top";
277 new_panel_mode =
"center";
280 new_panel_mode =
"bottom";
298 if(part_text.empty() || !has_background) {
309 scroll_label& text_label = find_widget<scroll_label>(
"part_text");
323 const auto& floating_images =
current_part_->get_floating_images();
330 if(!floating_images.empty()) {
341 while((this_part_index ==
part_index_) && (image_iter != images.end())) {
342 const auto& floating_image = *image_iter;
345 std::ostringstream x_ss;
346 std::ostringstream y_ss;
349 x_ss <<
"(trunc(" << floating_image.ref_x() <<
" * base_scale_x) + base_origin_x";
350 y_ss <<
"(trunc(" << floating_image.ref_y() <<
" * base_scale_y) + base_origin_y";
352 if(floating_image.centered()) {
353 x_ss <<
" - (image_width / 2)";
354 y_ss <<
" - (image_height / 2)";
361 image[
"x"] = x_ss.str();
362 image[
"y"] = y_ss.str();
365 if(floating_image.resize_with_background()) {
366 image[
"w"] =
"(image_original_width * base_scale_x)";
367 image[
"h"] =
"(image_original_height * base_scale_y)";
370 image[
"name"] = floating_image.file();
381 const auto& draw_delay = floating_image.display_delay();
382 if(draw_delay != std::chrono::milliseconds{0}) {
400 find_widget<scroll_label>(
"part_text").set_text_alpha(
ALPHA_OPAQUE);
433 const bool next_keydown =
435 || key == SDLK_RETURN
436 || key == SDLK_KP_ENTER
437 || key == SDLK_RIGHT;
439 const bool back_keydown =
440 key == SDLK_BACKSPACE
445 }
else if(back_keydown) {
497 find_widget<scroll_label>(
"part_text").set_text_alpha(new_alpha);
513 find_widget<stacked_widget>(
"text_and_control_stack").queue_redraw();
A config object defines a single node in a WML file, with access to child nodes.
config & add_child(config_key_type key)
void set_prevent_draw(bool pd=true)
Prevent the game display from drawing.
static display * get_singleton()
Returns the display object if a display object exists.
A simple canvas which can be drawn upon.
void set_variable(const std::string &key, wfl::variant &&value)
void queue_reblur()
Clear the cached blur texture, forcing it to regenerate.
void append_cfg(const config &cfg)
Appends data to the config.
void update_size_variables()
Update WFL size variables.
void set_cfg(const config &cfg, const bool force=false)
Sets the config.
Abstract base class for all modal dialogs.
Dialog to view the storyscreen.
void flag_stack_as_dirty()
storyscreen::controller controller_
void begin_fade_draw(bool fade_in)
bool game_was_already_hidden_
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)
virtual void pre_show() override
Actions to be taken before showing the window.
void nav_button_callback(NAV_DIRECTION direction)
virtual void post_show() override
Actions to be taken after the window has been shown.
void update_current_part_ptr()
void key_press_callback(const SDL_Keycode key)
virtual void update()
Update state and any parameters that may effect layout, or any of the later stages.
void set_enter_disabled(const bool enter_disabled)
Disable the enter key.
void close()
Requests to close the window.
part_pointer_type get_part(int index) const
@ BLOCK_BOTTOM
Bottom of the screen.
@ BLOCK_MIDDLE
Center of the screen.
@ BLOCK_TOP
Top of the screen.
A variable-expanding proxy for the config class.
constexpr uint8_t ALPHA_OPAQUE
map_display and display: classes which take care of displaying the map and game-data on the screen.
REGISTER_DIALOG(editor_edit_unit)
static config get_title_area_decor_config()
static const unsigned int LAYER_TEXT
static const unsigned int LAYER_BACKGROUND
void connect_signal_pre_key_press(dispatcher &dispatcher, const signal_keyboard &signal)
Connects the signal for 'snooping' on the keypress.
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
std::size_t add_timer(const std::chrono::milliseconds &interval, const std::function< void(std::size_t id)> &callback, const bool repeat)
Adds a new timer.
PangoAlignment decode_text_alignment(const std::string &alignment)
Converts a text alignment string to a text alignment.
bool remove_timer(const std::size_t id)
Removes a timer.
Functions to load and save images from/to disk.
void play_sound(const std::string &files, channel_group group, unsigned int repeats)
void play_music_config(const config &music_node, bool allow_interrupt_current_track, int i)
void play_sound_positioned(const std::string &files, int id, int repeats, unsigned int distance)
This file contains the settings handling of the widget library.
Contains the gui2 timer routines.