Story Viewer: implemented correct display of panel borders based on story text position
This commit is contained in:
parent
f07261325e
commit
a5b795c57a
3 changed files with 83 additions and 18 deletions
76
data/gui/widget/panel_story_viewer.cfg
Normal file
76
data/gui/widget/panel_story_viewer.cfg
Normal file
|
@ -0,0 +1,76 @@
|
|||
#textdomain wesnoth-lib
|
||||
###
|
||||
### The panel used in the story viewer.
|
||||
###
|
||||
|
||||
#define _GUI_BASE_NAME
|
||||
"translucent65" #enddef
|
||||
|
||||
#define _GUI_RESOLUTION RESOLUTION BORDER_SIDE_1 BORDER_SIDE_2 OFFSET_SIDE_1 OFFSET_SIDE_2 OFFSET_TOTAL
|
||||
[resolution]
|
||||
|
||||
{RESOLUTION}
|
||||
|
||||
left_border = 0
|
||||
right_border = 0
|
||||
top_border = {BORDER_SIDE_1}
|
||||
bottom_border = {BORDER_SIDE_2}
|
||||
|
||||
[background]
|
||||
|
||||
[draw]
|
||||
|
||||
# This works fine for normal messges. However, messages with options behave
|
||||
# strangely, and messages with scrollbars perform badly.
|
||||
# Uncomment once this has been fixed.
|
||||
#{DEFAULT_BLUR}
|
||||
|
||||
[image]
|
||||
x = 0
|
||||
y = {OFFSET_SIDE_1}
|
||||
w = "(width)"
|
||||
h = "(if(height < {OFFSET_TOTAL}, 0, height - if(panel_mode != 'bottom', {OFFSET_SIDE_2}, 0)))"
|
||||
name = "dialogs/" + {_GUI_BASE_NAME} + "-background.png"
|
||||
[/image]
|
||||
|
||||
[image]
|
||||
x = 0
|
||||
y = 0
|
||||
w = "(width)"
|
||||
resize_mode = "stretch"
|
||||
name = "(if(panel_mode = 'middle' or panel_mode = 'bottom', 'dialogs/" + {_GUI_BASE_NAME} + "-border-top.png', ''))"
|
||||
[/image]
|
||||
|
||||
[image]
|
||||
x = 0
|
||||
y = "(height - image_height)"
|
||||
w = "(width)"
|
||||
resize_mode = "stretch"
|
||||
name = "(if(panel_mode = 'middle' or panel_mode = 'top', 'dialogs/" + {_GUI_BASE_NAME} + "-border-bottom.png', ''))"
|
||||
[/image]
|
||||
|
||||
[/draw]
|
||||
|
||||
[/background]
|
||||
|
||||
[foreground]
|
||||
|
||||
[draw]
|
||||
|
||||
[/draw]
|
||||
|
||||
[/foreground]
|
||||
|
||||
[/resolution]
|
||||
#enddef
|
||||
|
||||
[panel_definition]
|
||||
id = "story_viewer_panel"
|
||||
description = "The panel for the story viewer, with variable borders."
|
||||
|
||||
{_GUI_RESOLUTION () 10 13 0 8 14}
|
||||
|
||||
[/panel_definition]
|
||||
|
||||
#undef _GUI_BASE_NAME
|
||||
#undef _GUI_RESOLUTION
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
[panel]
|
||||
id = "text_panel"
|
||||
definition = "wml_message"
|
||||
definition = "story_viewer_panel"
|
||||
|
||||
# This panel isn't meant to have any contents.
|
||||
# It simply serves as the background.
|
||||
|
|
|
@ -67,17 +67,6 @@ static config get_title_area_decor_config()
|
|||
return cfg;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static panel* get_new_panel(const std::string& definition)
|
||||
{
|
||||
panel* panel_ptr = new panel();
|
||||
panel_ptr->set_definition(definition);
|
||||
panel_ptr->set_id("text_panel");
|
||||
|
||||
return panel_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
REGISTER_DIALOG(story_viewer)
|
||||
|
||||
story_viewer::story_viewer(storyscreen::controller& controller)
|
||||
|
@ -234,20 +223,20 @@ void story_viewer::display_part(window& window)
|
|||
//
|
||||
stacked_widget& text_stack = find_widget<stacked_widget>(&window, "text_and_control_stack", false);
|
||||
|
||||
//std::string new_definition;
|
||||
std::string new_panel_mode;
|
||||
gui2::point new_origin;
|
||||
|
||||
switch(current_part_->story_text_location()) {
|
||||
case storyscreen::part::BLOCK_TOP:
|
||||
//new_definition = "wml_message_top";
|
||||
new_panel_mode = "top";
|
||||
// Default 0,0 origin value is correct.
|
||||
break;
|
||||
case storyscreen::part::BLOCK_MIDDLE:
|
||||
//new_definition = "wml_message_center";
|
||||
new_panel_mode = "middle";
|
||||
new_origin.y = (window.get_size().y / 2) - (text_stack.get_size().y / 2);
|
||||
break;
|
||||
case storyscreen::part::BLOCK_BOTTOM:
|
||||
//new_definition = "wml_message";
|
||||
new_panel_mode = "bottom";
|
||||
new_origin.y = window.get_size().y - text_stack.get_size().y;
|
||||
break;
|
||||
}
|
||||
|
@ -255,8 +244,8 @@ void story_viewer::display_part(window& window)
|
|||
// FIXME: sometimes the text won't appear after a move...
|
||||
text_stack.set_origin(new_origin);
|
||||
|
||||
// TODO
|
||||
//delete text_stack.get_layer_grid(0)->swap_child("text_panel", get_new_panel(new_definition), true);
|
||||
// Set the panel mode control variable for the panel's borders.
|
||||
find_widget<panel>(&window, "text_panel", false).get_canvas(0).set_variable("panel_mode", wfl::variant(new_panel_mode));
|
||||
|
||||
const std::string& part_text = current_part_->text();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue