Author: boucman
Date: Mon May 19 20:03:25 2008
New Revision: 26721

URL: http://svn.gna.org/viewcvs/wesnoth?rev=26721&view=rev
Log:
generalize the way TC is handled, as a side effect, we have an image_mod= 
parameter that can be put both at [frame] and [animation] level and will be 
applied to the image(s) of the block

Modified:
    trunk/src/unit.cpp
    trunk/src/unit_frame.cpp
    trunk/src/unit_frame.hpp

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=26721&r1=26720&r2=26721&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Mon May 19 20:03:25 2008
@@ -1655,6 +1655,7 @@
                params.blend_with = disp.rgb(0,255,0);
                params.blend_ratio = 0.25;
        }
+       params.image_mod = image_mods();
 
        const frame_parameters adjusted_params = 
anim_->get_current_params(params,true);
 
@@ -1723,10 +1724,7 @@
        if(image_loc.is_void()|| image_loc.get_filename() == "") {
                image_loc = absolute_image();
        }
-       std::string mod=image_mods();
-       if(mod.size()){
-               image_loc = image::locator(image_loc,mod);
-       }
+       image_loc = image::locator(image_loc,adjusted_params.image_mod);
 #else
        image_loc = absolute_image();
 #endif

Modified: trunk/src/unit_frame.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_frame.cpp?rev=26721&r1=26720&r2=26721&view=diff
==============================================================================
--- trunk/src/unit_frame.cpp (original)
+++ trunk/src/unit_frame.cpp Mon May 19 20:03:25 2008
@@ -158,8 +158,8 @@
 
 frame_builder::frame_builder(const config& cfg,const std::string& frame_string)
 {
-       image(image::locator(cfg[frame_string+"image"]));
-       image_diagonal(image::locator(cfg[frame_string+"image_diagonal"]));
+       
image(image::locator(cfg[frame_string+"image"]),cfg[frame_string+"image_mod"]);
+       
image_diagonal(image::locator(cfg[frame_string+"image_diagonal"]),cfg[frame_string+"image_mod"]);
        sound(cfg[frame_string+"sound"]);
        std::vector<std::string> 
tmp_string_vect=utils::split(cfg[frame_string+"text_color"]);
        if(tmp_string_vect.size() ==3) {
@@ -195,12 +195,13 @@
        result.duration = duration_;
        result.image = image_;
        result.image_diagonal = image_diagonal_;
+       result.image_mod = image_mod_;
        result.halo = halo_.get_current_element(current_time);
+       result.halo_x = halo_x_.get_current_element(current_time);
+       result.halo_y = halo_y_.get_current_element(current_time);
        result.sound = sound_;
        result.text = text_;
        result.text_color = text_color_;
-       result.halo_x = halo_x_.get_current_element(current_time);
-       result.halo_y = halo_y_.get_current_element(current_time);
        result.blend_with = blend_with_;
        result.blend_ratio = blend_ratio_.get_current_element(current_time);
        result.highlight_ratio = 
highlight_ratio_.get_current_element(current_time,1.0);
@@ -210,14 +211,16 @@
        result.y = y_.get_current_element(current_time);
        return result;
 }
-frame_builder & frame_builder::image(const image::locator image )
+frame_builder & frame_builder::image(const image::locator image ,const 
std::string & image_mod)
 {
        image_ = image;
-       return *this;
-}
-frame_builder & frame_builder::image_diagonal(const image::locator 
image_diagonal)
+       image_mod_ = image_mod;
+       return *this;
+}
+frame_builder & frame_builder::image_diagonal(const image::locator 
image_diagonal,const std::string& image_mod)
 {
        image_diagonal_ = image_diagonal;
+       image_mod_ = image_mod;
        return *this;
 }
 frame_builder & frame_builder::sound(const std::string& sound)
@@ -341,10 +344,10 @@
        }
        image::locator image_loc;
        if(direction != gamemap::location::NORTH && direction != 
gamemap::location::SOUTH) {
-               image_loc = current_data.image_diagonal;
+               image_loc = 
image::locator(current_data.image_diagonal,current_data.image_mod);
        } 
        if(image_loc.is_void() || image_loc.get_filename() == "") { // invalid 
diag image, or not diagonal
-               image_loc = current_data.image;
+               image_loc = 
image::locator(current_data.image,current_data.image_mod);
        }
 
        surface image;
@@ -453,53 +456,55 @@
         *  
         *  */
        frame_parameters result;
-       const frame_parameters & current_value = 
builder_.parameters(current_time);
+       const frame_parameters & current_val = 
builder_.parameters(current_time);
        assert(engine_val.image.is_void() || engine_val.image.get_filename() == 
"");
-       result.image = current_value.image.is_void() || 
current_value.image.get_filename() == 
""?animation_val.image:current_value.image;
+       result.image = current_val.image.is_void() || 
current_val.image.get_filename() == ""?animation_val.image:current_val.image;
 
        assert(engine_val.image_diagonal.is_void() || 
engine_val.image_diagonal.get_filename() == "");
-       result.image_diagonal = current_value.image_diagonal.is_void()|| 
current_value.image_diagonal.get_filename() == 
""?animation_val.image_diagonal:current_value.image_diagonal;
+       result.image_diagonal = current_val.image_diagonal.is_void()|| 
current_val.image_diagonal.get_filename() == 
""?animation_val.image_diagonal:current_val.image_diagonal;
+
+       result.image_mod = engine_val.image_mod + current_val.image_mod 
+animation_val.image_mod;
 
        assert(engine_val.halo.empty());
-       result.halo = 
current_value.halo.empty()?animation_val.halo:current_value.halo;
+       result.halo = 
current_val.halo.empty()?animation_val.halo:current_val.halo;
+
+       assert(engine_val.halo_x == 0);
+       result.halo_x =  
current_val.halo_x?current_val.halo_x:animation_val.halo_x;
+
+       result.halo_y = 
current_val.halo_y?current_val.halo_y:animation_val.halo_y;
+       result.halo_y += engine_val.halo_y;
+
+       assert(engine_val.duration == 0);
+       result.duration = current_val.duration;
 
        assert(engine_val.sound.empty());
-       result.sound = 
current_value.sound.empty()?animation_val.sound:current_value.sound;
+       result.sound = 
current_val.sound.empty()?animation_val.sound:current_val.sound;
 
        assert(engine_val.text.empty());
-       result.text = 
current_value.text.empty()?animation_val.text:current_value.text;
+       result.text = 
current_val.text.empty()?animation_val.text:current_val.text;
 
        assert(engine_val.text_color == 0);
-       result.text_color = 
current_value.text_color?current_value.text_color:animation_val.text_color;
-
-       assert(engine_val.halo_x == 0);
-       result.halo_x =  
current_value.halo_x?current_value.halo_x:animation_val.halo_x;
-
-       result.halo_y = 
current_value.halo_y?current_value.halo_y:animation_val.halo_y;
-       result.halo_y += engine_val.halo_y;
-
-       assert(engine_val.duration == 0);
-       result.duration = current_value.duration;
-
-       result.blend_with = 
current_value.blend_with?current_value.blend_with:animation_val.blend_with;
+       result.text_color = 
current_val.text_color?current_val.text_color:animation_val.text_color;
+
+       result.blend_with = 
current_val.blend_with?current_val.blend_with:animation_val.blend_with;
        if(primary&& engine_val.blend_with) result.blend_with = 
engine_val.blend_with;
 
-       result.blend_ratio = 
current_value.blend_ratio?current_value.blend_ratio:animation_val.blend_ratio;
+       result.blend_ratio = 
current_val.blend_ratio?current_val.blend_ratio:animation_val.blend_ratio;
        if(primary && engine_val.blend_ratio) result.blend_ratio += 
engine_val.blend_ratio;
 
-       result.highlight_ratio = 
current_value.highlight_ratio!=1.0?current_value.highlight_ratio:animation_val.highlight_ratio;
+       result.highlight_ratio = 
current_val.highlight_ratio!=1.0?current_val.highlight_ratio:animation_val.highlight_ratio;
        if(primary && engine_val.highlight_ratio != 1.0) result.highlight_ratio 
= result.highlight_ratio +engine_val.highlight_ratio - 1.0; // selected unit
 
        assert(engine_val.offset == 0);
-       result.offset = 
current_value.offset?current_value.offset:animation_val.offset;
-
-       result.submerge = 
current_value.submerge?current_value.submerge:animation_val.submerge;
+       result.offset = 
current_val.offset?current_val.offset:animation_val.offset;
+
+       result.submerge = 
current_val.submerge?current_val.submerge:animation_val.submerge;
        if(primary && engine_val.submerge) result.submerge = 
engine_val.submerge;
 
        assert(engine_val.x == 0);
-       result.x = current_value.x?current_value.x:animation_val.x;
-
-       result.y = current_value.y?current_value.y:animation_val.y; 
+       result.x = current_val.x?current_val.x:animation_val.x;
+
+       result.y = current_val.y?current_val.y:animation_val.y; 
        result.y += engine_val.y;
 
        return result;

Modified: trunk/src/unit_frame.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_frame.hpp?rev=26721&r1=26720&r2=26721&view=diff
==============================================================================
--- trunk/src/unit_frame.hpp (original)
+++ trunk/src/unit_frame.hpp Mon May 19 20:03:25 2008
@@ -68,12 +68,13 @@
        frame_parameters():
        image(""),
        image_diagonal(""),
+       image_mod(""),
        halo(""),
+       halo_x(0),
+       halo_y(0),
        sound(""),
        text(""),
        text_color(0),
-       halo_x(0),
-       halo_y(0),
        duration(0),
        blend_with(0),
        blend_ratio(0.0),
@@ -86,12 +87,13 @@
 
        image::locator image;
        image::locator image_diagonal;
+       std::string image_mod;
        std::string halo;
+       int halo_x;
+       int halo_y;
        std::string sound;
        std::string text;
        Uint32 text_color;
-       int halo_x;
-       int halo_y;
        int duration;
        Uint32 blend_with;
        double blend_ratio;
@@ -108,12 +110,13 @@
                frame_builder():
                image_(image::locator()),
                image_diagonal_(image::locator()),
+               image_mod_(""),
                halo_(""),
+               halo_x_(""),
+               halo_y_(""),
                sound_(""),
                text_(""),
                text_color_(0),
-               halo_x_(""),
-               halo_y_(""),
                duration_(1),
                blend_with_(0),
                blend_ratio_(""),
@@ -125,8 +128,8 @@
        {};
                frame_builder(const config& cfg,const std::string &frame_string 
= "");
                //! allow easy chained modifications will raised assert if used 
after initialization
-               frame_builder & image(const image::locator image );
-               frame_builder & image_diagonal(const image::locator 
image_diagonal);
+               frame_builder & image(const image::locator image ,const 
std::string & image_mod="");
+               frame_builder & image_diagonal(const image::locator 
image_diagonal,const std::string & image_mod="");
                frame_builder & sound(const std::string& sound);
                frame_builder & text(const std::string& text,const  Uint32 
text_color);
                frame_builder & halo(const std::string &halo, const std::string 
&halo_x, const std::string& halo_y);
@@ -147,12 +150,13 @@
        private:
                image::locator image_;
                image::locator image_diagonal_;
+               std::string image_mod_;
                progressive_string halo_;
+               progressive_int halo_x_;
+               progressive_int halo_y_;
                std::string sound_;
                std::string text_;
                Uint32 text_color_;
-               progressive_int halo_x_;
-               progressive_int halo_y_;
                int duration_;
                Uint32 blend_with_;
                progressive_double blend_ratio_;


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

Reply via email to