Author: mordante
Date: Sat Jul 12 20:44:47 2008
New Revision: 27945

URL: http://svn.gna.org/viewcvs/wesnoth?rev=27945&view=rev
Log:
* Make the code work for images at the right side as well.
* It seemed the dialog was 2 pixels to wide for left and right side, which has
  been fixed.
* Move the right side trigger closer to the left side test area in the test 
  scenario.

Modified:
    trunk/data/gui/default/window/message.cfg
    trunk/data/scenario-test.cfg
    trunk/src/game_events.cpp

Modified: trunk/data/gui/default/window/message.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/gui/default/window/message.cfg?rev=27945&r1=27944&r2=27945&view=diff
==============================================================================
--- trunk/data/gui/default/window/message.cfg (original)
+++ trunk/data/gui/default/window/message.cfg Sat Jul 12 20:44:47 2008
@@ -56,9 +56,9 @@
 
                                [image]
                                        x = "(width - image_width)"
-                                       y = "(250 - image_height)"
-                                       # NOTE this image can be removed once 
we move to the final code.
-                                       name = "arch_fem200.png"
+                                       y = "(height - image_height)"
+                                       name = "(portrait_image)"
+                                       vertical_mirror = "(portrait_mirror)"
                                [/image]
 
                        [/draw]
@@ -227,56 +227,39 @@
 
 #unddef RESOLUTION
 
-[window]
-       id = "message_test_right"
-       description = "Test dialog to test Jetryl's new message style and 
Kitty's portraits."
-
-       [resolution]
+#define RESOLUTION_RIGHT WIDTH HEIGHT IMAGE_WIDTH
+       [resolution]
+               window_width = {WIDTH}
+               window_height = {HEIGHT}
+
                definition = "message_test_right"
 
-               automatic_placement = "true"
-               vertical_placement = "bottom"
-               horizontal_placement = "left"
+               automatic_placement = "false"
+
+               # NOTE the values will be overwritten in the game later on, 
maybe we should allow
+               # variables here as well...
+               x = 0
+               y = 0
+               width = 750
+               height = 400
                
                [grid]
 
                        [row]
 
                                [column]
-
-                                       # This spacer makes sure the dialog has 
a minimum height.
-                                       [spacer]
-                                               width = 0
-                                               height = 250
-                                       [/spacer]
-
-                               [/column]
-
-
-                               [column]
                                        vertical_alignment = "bottom"
+                                       horizontal_grow = "true"
 
                                        [panel]
                                                definition = "message_test"
                                                        
                                                [grid]
+
                                                        [row]
 
                                                                [column]
-
-                                                                       # This 
spacer makes sure the panel has a minimum width.
-                                                                       [spacer]
-                                                                               
width = 658
-                                                                               
height = 0
-                                                                       
[/spacer]
-
-                                                               [/column]
-
-                                                       [/row]
-
-                                                       [row]
-
-                                                               [column]
+                                                                       
horizontal_grow = "true"
 
                                                                        [grid]
 
@@ -284,6 +267,8 @@
 
                                                                                
        [column]
                                                                                
                grow_factor = 1
+                                                                               
                horizontal_grow = "true"
+
                                                                                
                border = "all"
                                                                                
                border_size = 5
                                                                                
                horizontal_alignment = "left"
@@ -296,15 +281,12 @@
                                                                                
        [/column]
 
                                                                                
        [column]
-                                                                               
                border = "all"
-                                                                               
                border_size = 5
-                                                                               
                horizontal_alignment = "left"
 
                                                                                
                [spacer]
                                                                                
                        # reserve place for the image and set a minimum height 
for the text
                                                                                
                        id = "image_place_holder"
 
-                                                                               
                        width = 250
+                                                                               
                        width = {IMAGE_WIDTH}
                                                                                
                        height = 75
                                                                                
                [/spacer]
 
@@ -329,6 +311,14 @@
                [/grid]
 
        [/resolution]
+#enddef
+
+[window]
+       id = "message_test_right"
+       description = "Test dialog to test Jetryl's new message style and 
Kitty's portraits."
+       {RESOLUTION_RIGHT 1000 700 250}
+       {RESOLUTION_RIGHT 0 0 500}
 
 [/window]
 
+#unddef RESOLUTION_RIGHT

Modified: trunk/data/scenario-test.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/scenario-test.cfg?rev=27945&r1=27944&r2=27945&view=diff
==============================================================================
--- trunk/data/scenario-test.cfg (original)
+++ trunk/data/scenario-test.cfg Sat Jul 12 20:44:47 2008
@@ -145,7 +145,7 @@
        [/event]
 
        [label]
-               x,y=13,7
+               x,y=19,11
                text="right"
        [/label]
 
@@ -153,11 +153,11 @@
                name=moveto
         first_time_only=no
         [filter]
-            x,y,side=13,7,1
+            x,y,side=19,11,1
         [/filter]
 
                [message_test_right]
-                       message="Test foo bar bla bla bla bla bla bla bla bla 
bla bla bla"
+                       message="Test message"
                [/message_test_right]
        [/event]
     turns=36

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=27945&r1=27944&r2=27945&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Sat Jul 12 20:44:47 2008
@@ -1905,7 +1905,6 @@
        // be removed without further notice.
        WML_HANDLER_FUNCTION(message_test_left,/*handler*/,event_info, cfg)
        {
-
                const std::string message = cfg["message"];
                gui2::init();
                gui2::twindow window = gui2::build((screen)->video(), 
"message_test_left");
@@ -1934,7 +1933,7 @@
                 */
                window.set_size(::create_rect(0, 
                        gui2::settings::screen_height - window_height, 
-                       gui2::settings::screen_width - 140, window_height));
+                       gui2::settings::screen_width - 142, window_height));
 
                window.canvas(1).set_variable("portrait_image", variant(image));
                window.canvas(1).set_variable("portrait_mirror", 
variant(mirror));
@@ -1947,11 +1946,40 @@
                window.show();
        }
 
-       WML_HANDLER_FUNCTION(message_test_right,/*handler*/,/*event_info*/,cfg)
+       WML_HANDLER_FUNCTION(message_test_right,/*handler*/,event_info,cfg)
        {
                const std::string message = cfg["message"];
                gui2::init();
                gui2::twindow window = gui2::build((screen)->video(), 
"message_test_right");
+
+               // 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;
+               unsigned window_height = 400;
+               if(spacer && spacer->get_best_size().x == 500) {
+                       image_size = 400;
+                       window_height = 600;
+               }
+
+               const unit_map::iterator speaker = units->find(event_info.loc1);
+               assert(speaker != units->end());
+
+               const tportrait* portrait = 
speaker->second.portrait(image_size, tportrait::RIGHT);
+               const std::string image = portrait ? portrait->image : "";
+               const bool mirror = portrait ? portrait->mirror : false;
+
+               /** 
+                * @todo FIXME these fixed sizes should depend on the map size 
and maybe 
+                * let wml determine the height.
+                */
+               window.set_size(::create_rect(0, 
+                       gui2::settings::screen_height - window_height, 
+                       gui2::settings::screen_width - 142, window_height));
+
+               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);


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to