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) {
307 text_label.set_text_alpha(0);
308 text_label.set_label(part_text);
316 const auto& floating_images =
current_part_->get_floating_images();
323 if(!floating_images.empty()) {
334 while((this_part_index ==
part_index_) && (image_iter != images.end())) {
335 const auto& floating_image = *image_iter;
338 std::ostringstream x_ss;
339 std::ostringstream y_ss;
342 x_ss <<
"(trunc(" << floating_image.ref_x() <<
" * base_scale_x) + base_origin_x";
343 y_ss <<
"(trunc(" << floating_image.ref_y() <<
" * base_scale_y) + base_origin_y";
345 if(floating_image.centered()) {
346 x_ss <<
" - (image_width / 2)";
347 y_ss <<
" - (image_height / 2)";
354 image[
"x"] = x_ss.str();
355 image[
"y"] = y_ss.str();
358 if(floating_image.resize_with_background()) {
359 image[
"w"] =
"(image_original_width * base_scale_x)";
360 image[
"h"] =
"(image_original_height * base_scale_y)";
363 image[
"name"] = floating_image.file();
364 config cfg{
"image", std::move(image)};
366 cfg.
add_child(
"image", std::move(image));
374 const unsigned int draw_delay = floating_image.display_delay();
375 if(draw_delay != 0) {
426 const bool next_keydown =
428 || key == SDLK_RETURN
429 || key == SDLK_KP_ENTER
430 || key == SDLK_RIGHT;
432 const bool back_keydown =
433 key == SDLK_BACKSPACE
438 }
else if(back_keydown) {
490 find_widget<scroll_label>(
get_window(),
"part_text",
false).set_text_alpha(new_alpha);
storyscreen::controller::part_pointer_type current_part_
void close()
Requests to close the window.
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
static const unsigned int LAYER_TEXT
static display * get_singleton()
Returns the display object if a display object exists.
void play_sound_positioned(const std::string &files, int id, int repeats, unsigned int distance)
static const unsigned int LAYER_BACKGROUND
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
void key_press_callback(const SDL_Keycode key)
void set_variable(const std::string &key, wfl::variant &&value)
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
void update_size_variables()
Update WFL size variables.
A label displays a text, the text can be wrapped but no scrollbars are provided.
PangoAlignment decode_text_alignment(const std::string &alignment)
Converts a text alignment string to a text alignment.
void set_cfg(const config &cfg, const bool force=false)
Sets the config.
void play_sound(const std::string &files, channel_group group, unsigned int repeats)
constexpr uint8_t ALPHA_OPAQUE
void begin_fade_draw(bool fade_in)
This file contains the settings handling of the widget library.
void append_cfg(const config &cfg)
Appends data to the config.
bool game_was_already_hidden_
void set_prevent_draw(bool pd)
Prevent the game display from drawing.
map_display and display: classes which take care of displaying the map and game-data on the screen...
window * get_window()
Returns a pointer to the dialog's window.
A simple canvas which can be drawn upon.
static config get_title_area_decor_config()
void flag_stack_as_dirty()
virtual void update()
Update state and any parameters that may effect layout, or any of the later stages.
Contains the gui2 timer routines.
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.
Dialog to view the storyscreen.
virtual void set_active(const bool active) override
See styled_widget::set_active.
config & add_child(config_key_type key)
part_pointer_type get_part(int index) const
void update_current_part_ptr()
storyscreen::controller controller_
void play_music_config(const config &music_node, bool allow_interrupt_current_track, int i)
A variable-expanding proxy for the config class.
Abstract base class for all modal dialogs.
Functions to load and save images from/to disk.
void connect_signal_pre_key_press(dispatcher &dispatcher, const signal_keyboard &signal)
Connects the signal for 'snooping' on the keypress.
virtual void update() override
top_level_drawable hook to animate the view
A config object defines a single node in a WML file, with access to child nodes.
base class of top level items, the only item which needs to store the final canvases to draw on...
void draw_floating_image(floating_image_list::const_iterator image_iter, int this_part_index)
void nav_button_callback(NAV_DIRECTION direction)
bool remove_timer(const std::size_t id)
Removes a timer.
void set_enter_disabled(const bool enter_disabled)
Disable the enter key.