Author: mordante
Date: Sat Nov 1 00:02:23 2008
New Revision: 30482
URL: http://svn.gna.org/viewcvs/wesnoth?rev=30482&view=rev
Log:
Initial commit to support the new dialogs.
Modified:
trunk/data/scenario-test.cfg
trunk/src/game_events.cpp
Modified: trunk/data/scenario-test.cfg
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/scenario-test.cfg?rev=30482&r1=30481&r2=30482&view=diff
==============================================================================
--- trunk/data/scenario-test.cfg (original)
+++ trunk/data/scenario-test.cfg Sat Nov 1 00:02:23 2008
@@ -261,6 +261,24 @@
[message_test_right]
message="Test message"
[/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}
Modified: trunk/src/game_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=30482&r1=30481&r2=30482&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Sat Nov 1 00:02:23 2008
@@ -2999,6 +2999,42 @@
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);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits