16 #define GETTEXT_DOMAIN "wesnoth-lib"
42 cfg[
"w"] =
"(screen_width)";
43 cfg[
"h"] =
"(image_original_height * 2)";
44 cfg[
"name"] =
"dialogs/story_title_decor.png~O(75%)";
57 , controller_(
vconfig(cfg_parsed, true), scenario_name)
59 , current_part_(
nullptr)
63 , fade_state_(NOT_FADING)
65 update_current_part_ptr();
114 static const int VOICE_SOUND_SOURCE_ID = 255;
124 music_config[
"ms_after"] = 2000;
125 music_config[
"immediate"] =
true;
144 bool has_background =
false;
145 config* base_layer =
nullptr;
147 for(
const auto& layer :
current_part_->get_background_layers()) {
148 has_background |= !layer.file().
empty();
150 const bool preserve_ratio = layer.keep_aspect_ratio();
151 const bool tile_h = layer.tile_horizontally();
152 const bool tile_v = layer.tile_vertically();
155 std::string width_formula =
"(image_original_width)";
156 std::string height_formula =
"(image_original_height)";
161 std::string x_formula;
162 std::string y_formula;
167 x_formula =
"(max(pos, 0) where pos = (width / 2 - image_width / 2))";
173 y_formula =
"(max(pos, 0) where pos = (height / 2 - image_height / 2))";
176 if(layer.scale_horizontally() && preserve_ratio) {
177 height_formula =
"(min((image_original_height * width / image_original_width), height))";
178 }
else if(layer.scale_vertically() || tile_v) {
179 height_formula =
"(height)";
182 if(layer.scale_vertically() && preserve_ratio) {
183 width_formula =
"(min((image_original_width * height / image_original_height), width))";
184 }
else if(layer.scale_horizontally() || tile_h) {
185 width_formula =
"(width)";
188 image[
"x"] = x_formula;
189 image[
"y"] = y_formula;
190 image[
"w"] = width_formula;
191 image[
"h"] = height_formula;
192 image[
"name"] = layer.file();
193 image[
"resize_mode"] = (tile_h || tile_v) ?
"tile_center" :
"scale";
197 if(base_layer ==
nullptr || layer.is_base_layer()) {
198 base_layer = &layer_image;
212 if(base_layer !=
nullptr) {
213 (*base_layer)[
"actions"] = R
"((
215 set_var('base_scale_x', as_decimal(image_width) / as_decimal(image_original_width)),
216 set_var('base_scale_y', as_decimal(image_height) / as_decimal(image_original_height)),
217 set_var('base_origin_x', clip_x),
218 set_var('base_origin_y', clip_y)
245 showing_title =
true;
253 showing_title =
false;
263 std::string new_panel_mode;
267 new_panel_mode =
"top";
270 new_panel_mode =
"center";
273 new_panel_mode =
"bottom";
291 if(part_text.empty() || !has_background) {
317 const auto& floating_images =
current_part_->get_floating_images();
324 if(!floating_images.empty()) {
335 while((this_part_index ==
part_index_) && (image_iter != images.end())) {
336 const auto& floating_image = *image_iter;
339 std::ostringstream x_ss;
340 std::ostringstream y_ss;
343 x_ss <<
"(trunc(" << floating_image.ref_x() <<
" * base_scale_x) + base_origin_x";
344 y_ss <<
"(trunc(" << floating_image.ref_y() <<
" * base_scale_y) + base_origin_y";
346 if(floating_image.centered()) {
347 x_ss <<
" - (image_width / 2)";
348 y_ss <<
" - (image_height / 2)";
355 image[
"x"] = x_ss.str();
356 image[
"y"] = y_ss.str();
359 if(floating_image.resize_with_background()) {
360 image[
"w"] =
"(image_original_width * base_scale_x)";
361 image[
"h"] =
"(image_original_height * base_scale_y)";
364 image[
"name"] = floating_image.file();
375 const unsigned int draw_delay = floating_image.display_delay();
427 const bool next_keydown =
429 || key == SDLK_RETURN
430 || key == SDLK_KP_ENTER
431 || key == SDLK_RIGHT;
433 const bool back_keydown =
434 key == SDLK_BACKSPACE
439 }
else if(back_keydown) {
491 find_widget<scroll_label>(
get_window(),
"part_text",
false).set_text_alpha(new_alpha);
507 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
REGISTER_DIALOG(tod_new_schedule)
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)
Contains the gui2 timer routines.