16 #define GETTEXT_DOMAIN "wesnoth-lib"
44 cfg[
"w"] =
"(screen_width)";
45 cfg[
"h"] =
"(image_original_height * 2)";
46 cfg[
"name"] =
"dialogs/story_title_decor.png~O(75%)";
59 , controller_(
vconfig(cfg_parsed, true), scenario_name)
61 , current_part_(
nullptr)
65 , fade_state_(NOT_FADING)
67 update_current_part_ptr();
116 static const int VOICE_SOUND_SOURCE_ID = 255;
126 music_config[
"ms_after"] = 2000;
127 music_config[
"immediate"] =
true;
146 bool has_background =
false;
147 config* base_layer =
nullptr;
149 for(
const auto& layer :
current_part_->get_background_layers()) {
150 has_background |= !layer.file().
empty();
152 const bool preserve_ratio = layer.keep_aspect_ratio();
153 const bool tile_h = layer.tile_horizontally();
154 const bool tile_v = layer.tile_vertically();
157 std::string width_formula =
"(image_original_width)";
158 std::string height_formula =
"(image_original_height)";
163 std::string x_formula;
164 std::string y_formula;
169 x_formula =
"(max(pos, 0) where pos = (width / 2 - image_width / 2))";
175 y_formula =
"(max(pos, 0) where pos = (height / 2 - image_height / 2))";
178 if(layer.scale_horizontally() && preserve_ratio) {
179 height_formula =
"(min((image_original_height * width / image_original_width), height))";
180 }
else if(layer.scale_vertically() || tile_v) {
181 height_formula =
"(height)";
184 if(layer.scale_vertically() && preserve_ratio) {
185 width_formula =
"(min((image_original_width * height / image_original_height), width))";
186 }
else if(layer.scale_horizontally() || tile_h) {
187 width_formula =
"(width)";
190 image[
"x"] = x_formula;
191 image[
"y"] = y_formula;
192 image[
"w"] = width_formula;
193 image[
"h"] = height_formula;
194 image[
"name"] = layer.file();
195 image[
"resize_mode"] = (tile_h || tile_v) ?
"tile_center" :
"scale";
199 if(base_layer ==
nullptr || layer.is_base_layer()) {
200 base_layer = &layer_image;
214 if(base_layer !=
nullptr) {
215 (*base_layer)[
"actions"] = R
"((
217 set_var('base_scale_x', as_decimal(image_width) / as_decimal(image_original_width)),
218 set_var('base_scale_y', as_decimal(image_height) / as_decimal(image_original_height)),
219 set_var('base_origin_x', clip_x),
220 set_var('base_origin_y', clip_y)
247 showing_title =
true;
255 showing_title =
false;
265 std::string new_panel_mode;
269 new_panel_mode =
"top";
272 new_panel_mode =
"center";
275 new_panel_mode =
"bottom";
293 if(part_text.empty() || !has_background) {
319 const auto& floating_images =
current_part_->get_floating_images();
326 if(!floating_images.empty()) {
337 while((this_part_index ==
part_index_) && (image_iter != images.end())) {
338 const auto& floating_image = *image_iter;
341 std::ostringstream x_ss;
342 std::ostringstream y_ss;
345 x_ss <<
"(trunc(" << floating_image.ref_x() <<
" * base_scale_x) + base_origin_x";
346 y_ss <<
"(trunc(" << floating_image.ref_y() <<
" * base_scale_y) + base_origin_y";
348 if(floating_image.centered()) {
349 x_ss <<
" - (image_width / 2)";
350 y_ss <<
" - (image_height / 2)";
357 image[
"x"] = x_ss.str();
358 image[
"y"] = y_ss.str();
361 if(floating_image.resize_with_background()) {
362 image[
"w"] =
"(image_original_width * base_scale_x)";
363 image[
"h"] =
"(image_original_height * base_scale_y)";
366 image[
"name"] = floating_image.file();
377 const unsigned int draw_delay = floating_image.display_delay();
429 const bool next_keydown =
431 || key == SDLK_RETURN
432 || key == SDLK_KP_ENTER
433 || key == SDLK_RIGHT;
435 const bool back_keydown =
436 key == SDLK_BACKSPACE
441 }
else if(back_keydown) {
493 find_widget<scroll_label>(
get_window(),
"part_text",
false).set_text_alpha(new_alpha);
509 find_widget<stacked_widget>(
get_window(),
"text_and_control_stack",
false).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.
window * get_window()
Returns a pointer to the dialog's window.
Dialog to view the storyscreen.
void flag_stack_as_dirty()
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.
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)
void nav_button_callback(NAV_DIRECTION direction)
void update_current_part_ptr()
void key_press_callback(const SDL_Keycode key)
A label displays text that can be wrapped but no scrollbars are provided.
virtual void update()
Update state and any parameters that may effect layout, or any of the later stages.
base class of top level items, the only item which needs to store the final canvases to draw on.
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
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
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 uint32_t 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.