Initial commit to support the new dialogs.

This commit is contained in:
Mark de Wever 2008-10-31 23:02:23 +00:00
parent 5ee43b4ae1
commit c53526e0c7
2 changed files with 54 additions and 0 deletions

View file

@ -263,6 +263,24 @@ Xu , Xu , Qxu , Qxu , Ql , Ql
[/message_test_right]
[/event]
[label]
x,y=20,12
text="dialog"
[/label]
[event]
name=moveto
first_time_only=no
[filter]
x,y,side=20,12,1
[/filter]
[message]
speaker=unit
message="Test message"
[/message]
[/event]
{PLACE_IMAGE items/book1.png 2 2}
{PLACE_IMAGE items/book2.png 3 2}
{PLACE_IMAGE items/book3.png 4 2}

View file

@ -2999,6 +2999,42 @@ namespace {
if (side_for_show && !get_replay_source().is_skipping())
{
// We whether we can show the new dialog.
if(gui2::new_widgets && options.empty() && speaker != units->end()) {
// Get the portrait and if found proceed to use the new dialog.
gui2::twindow window = gui2::build((screen)->video(), "message_test_left");
// Use an ugly hack, if the spacer has the wanted best_size we use the
// bigger image otherwise the smaller one.
gui2::tspacer* spacer =
dynamic_cast<gui2::tspacer*>(window.find_widget("image_place_holder", false));
unsigned image_size = 200;
if(spacer && spacer->get_best_size().x == 500) {
image_size = 400;
}
const tportrait* portrait =
speaker->second.portrait(image_size, tportrait::LEFT);
if(portrait) {
const t_string message = cfg["message"];
const std::string image = portrait ? portrait->image : "";
const bool mirror = portrait ? portrait->mirror : false;
window.canvas(1).set_variable("portrait_image", variant(image));
window.canvas(1).set_variable("portrait_mirror", variant(mirror));
gui2::tcontrol* label = dynamic_cast<gui2::tcontrol*>(window.find_widget("message", false));
assert(label);
label->set_label(message);
window.show();
return;
}
}
const t_string msg = cfg["message"];
const std::string duration_str = cfg["duration"];
const unsigned int lifetime = average_frame_time * lexical_cast_default<unsigned int>(duration_str, prevent_misclick_duration);