16 #define GETTEXT_DOMAIN "wesnoth-lib"
46 cfg[
"w"] =
"(screen_width)";
47 cfg[
"h"] =
"(image_original_height * 2)";
48 cfg[
"name"] =
"dialogs/story_title_decor.png~O(75%)";
61 , controller_(
vconfig(cfg_parsed, true), scenario_name)
63 , current_part_(
nullptr)
67 , fade_state_(NOT_FADING)
69 update_current_part_ptr();
97 find_widget<scroll_label>(
get_window(),
"part_text",
false)
121 static const int VOICE_SOUND_SOURCE_ID = 255;
131 music_config[
"ms_after"] = 2000;
132 music_config[
"immediate"] =
true;
151 bool has_background =
false;
152 config* base_layer =
nullptr;
154 for(
const auto& layer :
current_part_->get_background_layers()) {
155 has_background |= !layer.file().
empty();
157 const bool preserve_ratio = layer.keep_aspect_ratio();
158 const bool tile_h = layer.tile_horizontally();
159 const bool tile_v = layer.tile_vertically();
162 std::string width_formula =
"(image_original_width)";
163 std::string height_formula =
"(image_original_height)";
168 std::string x_formula;
169 std::string y_formula;
174 x_formula =
"(max(pos, 0) where pos = (width / 2 - image_width / 2))";
180 y_formula =
"(max(pos, 0) where pos = (height / 2 - image_height / 2))";
183 if(layer.scale_horizontally() && preserve_ratio) {
184 height_formula =
"(min((image_original_height * width / image_original_width), height))";
185 }
else if(layer.scale_vertically() || tile_v) {
186 height_formula =
"(height)";
189 if(layer.scale_vertically() && preserve_ratio) {
190 width_formula =
"(min((image_original_width * height / image_original_height), width))";
191 }
else if(layer.scale_horizontally() || tile_h) {
192 width_formula =
"(width)";
195 image[
"x"] = x_formula;
196 image[
"y"] = y_formula;
197 image[
"w"] = width_formula;
198 image[
"h"] = height_formula;
199 image[
"name"] = layer.file();
200 image[
"resize_mode"] = (tile_h || tile_v) ?
"tile_center" :
"scale";
204 if(base_layer ==
nullptr || layer.is_base_layer()) {
205 base_layer = &layer_image;
219 if(base_layer !=
nullptr) {
220 (*base_layer)[
"actions"] = R
"((
222 set_var('base_scale_x', as_decimal(image_width) / as_decimal(image_original_width)),
223 set_var('base_scale_y', as_decimal(image_height) / as_decimal(image_original_height)),
224 set_var('base_origin_x', clip_x),
225 set_var('base_origin_y', clip_y)
252 showing_title =
true;
260 showing_title =
false;
270 std::string new_panel_mode;
275 new_panel_mode =
"top";
278 new_panel_mode =
"center";
281 new_panel_mode =
"bottom";
299 if(part_text.empty() || !has_background) {
324 const auto& floating_images =
current_part_->get_floating_images();
331 if(!floating_images.empty()) {
342 while((this_part_index ==
part_index_) && (image_iter != images.end())) {
343 const auto& floating_image = *image_iter;
346 std::ostringstream x_ss;
347 std::ostringstream y_ss;
350 x_ss <<
"(trunc(" << floating_image.ref_x() <<
" * base_scale_x) + base_origin_x";
351 y_ss <<
"(trunc(" << floating_image.ref_y() <<
" * base_scale_y) + base_origin_y";
353 if(floating_image.centered()) {
354 x_ss <<
" - (image_width / 2)";
355 y_ss <<
" - (image_height / 2)";
362 image[
"x"] = x_ss.str();
363 image[
"y"] = y_ss.str();
366 if(floating_image.resize_with_background()) {
367 image[
"w"] =
"(image_original_width * base_scale_x)";
368 image[
"h"] =
"(image_original_height * base_scale_y)";
371 image[
"name"] = floating_image.file();
382 const unsigned int draw_delay = floating_image.display_delay();
383 if(draw_delay != 0) {
434 const bool next_keydown =
436 || key == SDLK_RETURN
437 || key == SDLK_KP_ENTER
438 || key == SDLK_RIGHT;
440 const bool back_keydown =
441 key == SDLK_BACKSPACE
446 }
else if(back_keydown) {
498 find_widget<scroll_label>(
get_window(),
"part_text",
false).set_text_alpha(new_alpha);
514 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)
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
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 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.