Author: boucman
Date: Wed Nov 26 23:18:07 2008
New Revision: 31107

URL: http://svn.gna.org/viewcvs/wesnoth?rev=31107&view=rev
Log:
fix problems with haloes being sometime displayed twice and/or incorrectly 
flipped

Modified:
    trunk/src/unit.cpp
    trunk/src/unit.hpp
    trunk/src/unit_animation.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=31107&r1=31106&r2=31107&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Wed Nov 26 23:18:07 2008
@@ -140,7 +140,6 @@
 
            frame_begin_time_(o.frame_begin_time_),
            unit_halo_(halo::NO_HALO),
-           unit_anim_halo_(halo::NO_HALO),
            getsHit_(o.getsHit_),
            refreshing_(o.refreshing_),
            hidden_(o.hidden_),
@@ -214,7 +213,6 @@
        next_idling_(0),
        frame_begin_time_(0),
        unit_halo_(halo::NO_HALO),
-       unit_anim_halo_(halo::NO_HALO),
        getsHit_(0),
        refreshing_(false),
        hidden_(false),
@@ -292,7 +290,6 @@
        next_idling_(0),
        frame_begin_time_(0),
        unit_halo_(halo::NO_HALO),
-       unit_anim_halo_(halo::NO_HALO),
        getsHit_(0),
        refreshing_(false),
        hidden_(false),
@@ -398,7 +395,6 @@
        next_idling_(0),
        frame_begin_time_(0),
        unit_halo_(halo::NO_HALO),
-       unit_anim_halo_(halo::NO_HALO),
        getsHit_(0),
        refreshing_(false),
        hidden_(false),
@@ -435,7 +431,6 @@
        next_idling_ = 0;
        frame_begin_time_ = 0;
        unit_halo_ = halo::NO_HALO;
-       unit_anim_halo_ = halo::NO_HALO;
 }
 
 unit::unit(const unit_type* t, int side, bool use_traits, bool dummy_unit,
@@ -497,7 +492,6 @@
        next_idling_(0),
        frame_begin_time_(0),
        unit_halo_(halo::NO_HALO),
-       unit_anim_halo_(halo::NO_HALO),
        getsHit_(0),
        refreshing_(false),
        hidden_(false),
@@ -1843,6 +1837,7 @@
        if(utils::string_bool(get_state("stoned"))) params.image_mod +="~GS()";
        if(facing_ == map_location::SOUTH_WEST || facing_ == 
map_location::SOUTH_EAST || facing_ == map_location::SOUTH ) {
                params.image_mod +="~FL(vertical)";
+               params.halo_mod +="~FL(vertical)";
        }
 
        const frame_parameters adjusted_params = 
anim_->get_current_params(params,true);
@@ -1872,20 +1867,6 @@
        } else if(unit_halo_ != halo::NO_HALO) {
                halo::set_location(unit_halo_, x, y);
        }
-
-       if(unit_anim_halo_ != halo::NO_HALO) {
-               halo::remove(unit_anim_halo_);
-               unit_anim_halo_ = halo::NO_HALO;
-       }
-       if(!adjusted_params.halo.empty()) {
-               int dx = static_cast<int>(adjusted_params.halo_x * 
disp.get_zoom_factor());
-               int dy = static_cast<int>(adjusted_params.halo_y * 
disp.get_zoom_factor());
-               if (facing_west) dx = -dx;
-               unit_anim_halo_ = halo::add(x + dx, y+ dy,
-                       adjusted_params.halo, map_location(-1, -1),
-                       facing_west ? halo::HREVERSE : halo::NORMAL);
-       }
-
 
 
 
@@ -2024,10 +2005,6 @@
                halo::remove(unit_halo_);
                unit_halo_ = halo::NO_HALO;
        }
-       if(unit_anim_halo_ != halo::NO_HALO) {
-               halo::remove(unit_anim_halo_);
-               unit_anim_halo_ = halo::NO_HALO;
-       }
 }
 bool unit::invalidate(const map_location &loc)
 {
@@ -2064,6 +2041,7 @@
                                facing_ == map_location::SOUTH_EAST ||
                                facing_ == map_location::SOUTH ) {
                        params.image_mod +="~FL(vertical)";
+                       params.halo_mod +="~FL(vertical)";
                }
 
                 //get_animation()->update_last_draw_time();

Modified: trunk/src/unit.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.hpp?rev=31107&r1=31106&r2=31107&view=diff
==============================================================================
--- trunk/src/unit.hpp (original)
+++ trunk/src/unit.hpp Wed Nov 26 23:18:07 2008
@@ -201,7 +201,7 @@
         * skip functions assuming that)
         */
        void redraw_unit(game_display& disp, const map_location& loc, const 
bool fake = false);
-       /** Clear unit_halo_ and unit_anim_halo_ */
+       /** Clear unit_halo_  */
        void clear_haloes();
 
 
@@ -422,7 +422,6 @@
 
 
        int unit_halo_;
-       int unit_anim_halo_;
        bool getsHit_;
        bool refreshing_; // avoid infinite recursion
        bool hidden_;

Modified: trunk/src/unit_animation.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_animation.cpp?rev=31107&r1=31106&r2=31107&view=diff
==============================================================================
--- trunk/src/unit_animation.cpp (original)
+++ trunk/src/unit_animation.cpp Wed Nov 26 23:18:07 2008
@@ -13,7 +13,6 @@
    */
 
 #include "global.hpp"
-
 #include "map.hpp"
 #include "halo.hpp"
 #include "unit.hpp"

Modified: trunk/src/unit_frame.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_frame.cpp?rev=31107&r1=31106&r2=31107&view=diff
==============================================================================
--- trunk/src/unit_frame.cpp (original)
+++ trunk/src/unit_frame.cpp Wed Nov 26 23:18:07 2008
@@ -162,6 +162,7 @@
        halo_(""),
        halo_x_(""),
        halo_y_(""),
+       halo_mod_(""),
        sound_(""),
        text_(""),
        text_color_(0),
@@ -191,7 +192,7 @@
        } else {
                duration(atoi(cfg[frame_string+"end"].c_str()) - 
atoi(cfg[frame_string+"begin"].c_str()));
        }
-       
halo(cfg[frame_string+"halo"],cfg[frame_string+"halo_x"],cfg[frame_string+"halo_y"]);
+       
halo(cfg[frame_string+"halo"],cfg[frame_string+"halo_x"],cfg[frame_string+"halo_y"],cfg[frame_string+"halo_mod"]);
         tmp_string_vect=utils::split(cfg[frame_string+"blend_color"]);
        if(tmp_string_vect.size() ==3) {
                
blend(cfg[frame_string+"blend_ratio"],display::rgb(atoi(tmp_string_vect[0].c_str()),atoi(tmp_string_vect[1].c_str()),atoi(tmp_string_vect[2].c_str())));
@@ -217,6 +218,7 @@
        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.halo_mod = halo_mod_;
        result.sound = sound_;
        result.text = text_;
        result.text_color = text_color_;
@@ -253,11 +255,12 @@
        text_color_=text_color;
        return *this;
 }
-frame_builder & frame_builder::halo(const std::string &halo, const std::string 
&halo_x, const std::string& halo_y)
+frame_builder & frame_builder::halo(const std::string &halo, const std::string 
&halo_x, const std::string& halo_y,const std::string & halo_mod)
 {
        halo_ = progressive_string(halo,duration_);
        halo_x_ = progressive_int(halo_x,duration_);
        halo_y_ = progressive_int(halo_y,duration_);
+       halo_mod_= halo_mod;
        return *this;
 }
 frame_builder & frame_builder::duration(const int duration)
@@ -422,13 +425,13 @@
                if(direction != map_location::SOUTH_WEST && direction != 
map_location::NORTH_WEST) {
                        *halo_id = 
halo::add(static_cast<int>(x+current_data.halo_x* 
game_display::get_singleton()->get_zoom_factor()),
                                        static_cast<int>(y+current_data.halo_y* 
game_display::get_singleton()->get_zoom_factor()),
-                                       current_data.halo,
+                                       current_data.halo + 
current_data.halo_mod,
                                        map_location(-1, -1),
                                        orientation);
                } else {
                        *halo_id = 
halo::add(static_cast<int>(x-current_data.halo_x* 
game_display::get_singleton()->get_zoom_factor()),
                                        static_cast<int>(y+current_data.halo_y* 
game_display::get_singleton()->get_zoom_factor()),
-                                       current_data.halo,
+                                       current_data.halo + 
current_data.halo_mod,
                                        map_location(-1, -1),
                                        orientation);
                }
@@ -523,6 +526,10 @@
        result.halo_y = 
current_val.halo_y?current_val.halo_y:animation_val.halo_y;
        result.halo_y += engine_val.halo_y;
 
+       /** engine provides hflip modifications */
+               result.halo_mod = current_val.halo_mod +animation_val.halo_mod;
+       if(primary)     result.halo_mod += engine_val.halo_mod;
+
        assert(engine_val.duration == 0);
        result.duration = current_val.duration;
 

Modified: trunk/src/unit_frame.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_frame.hpp?rev=31107&r1=31106&r2=31107&view=diff
==============================================================================
--- trunk/src/unit_frame.hpp (original)
+++ trunk/src/unit_frame.hpp Wed Nov 26 23:18:07 2008
@@ -73,6 +73,7 @@
        halo(""),
        halo_x(0),
        halo_y(0),
+       halo_mod(""),
        sound(""),
        text(""),
        text_color(0),
@@ -93,6 +94,7 @@
        std::string halo;
        int halo_x;
        int halo_y;
+       std::string halo_mod;
        std::string sound;
        std::string text;
        Uint32 text_color;
@@ -120,6 +122,7 @@
                halo_(""),
                halo_x_(""),
                halo_y_(""),
+               halo_mod_(""),
                sound_(""),
                text_(""),
                text_color_(0),
@@ -139,7 +142,7 @@
                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);
+               frame_builder & halo(const std::string &halo, const std::string 
&halo_x, const std::string& halo_y,const std::string& halo_mod);
                frame_builder & duration(const int duration);
                frame_builder & blend(const std::string& blend_ratio,const 
Uint32 blend_color);
                frame_builder & highlight(const std::string& highlight);
@@ -162,6 +165,7 @@
                progressive_string halo_;
                progressive_int halo_x_;
                progressive_int halo_y_;
+               std::string halo_mod_;
                std::string sound_;
                std::string text_;
                Uint32 text_color_;


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

Reply via email to