Author: boucman
Date: Thu Mar 20 22:43:50 2008
New Revision: 24913
URL: http://svn.gna.org/viewcvs/wesnoth?rev=24913&view=rev
Log:
add two new progressive parameters for animations : x and y. notice that
refresh rules still apply, unit shall not leave their redraw zone. This can be
applied to all types of frames in the usual ways
Modified:
trunk/src/unit.cpp
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=24913&r1=24912&r2=24913&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Thu Mar 20 22:43:50 2008
@@ -1720,7 +1720,7 @@
int dx = static_cast<int>(params.halo_x *
disp.get_zoom_factor());
int dy = static_cast<int>(params.halo_y *
disp.get_zoom_factor());
if (facing_west) dx = -dx;
- unit_anim_halo_ = halo::add(x + dx, y + dy,
+ unit_anim_halo_ = halo::add(x + dx, y+ dy,
params.halo, gamemap::location(-1, -1),
facing_west ? halo::HREVERSE : halo::NORMAL);
}
@@ -1808,8 +1808,8 @@
}
if (image != NULL) {
- int tmp_x = x - image->w/2;
- int tmp_y = y - image->h/2;
+ const int tmp_x = params.x +x - image->w/2;
+ const int tmp_y = params.y +y - image->h/2;
disp.render_unit_image(tmp_x, tmp_y, fake, drawing_order,
image, facing_west, stoned,
highlight_ratio, blend_with, blend_ratio,
submerge);
}
Modified: trunk/src/unit_animation.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_animation.cpp?rev=24913&r1=24912&r2=24913&view=diff
==============================================================================
--- trunk/src/unit_animation.cpp (original)
+++ trunk/src/unit_animation.cpp Thu Mar 20 22:43:50 2008
@@ -291,7 +291,7 @@
std::vector<unit_animation>::const_iterator itor;
add_anims(animations,cfg);
for(itor = animations.begin(); itor != animations.end() ; itor++) {
- if
(std::find(itor->event_.begin(),itor->event_.end(),"_default_")!=
itor->event_.end()) {
+ if
(std::find(itor->event_.begin(),itor->event_.end(),"default")!=
itor->event_.end()) {
animation_base.push_back(*itor);
animation_base.back().base_score_ =
unit_animation::DEFAULT_ANIM;
animation_base.back().event_.clear();
@@ -434,7 +434,7 @@
expanded_cfg = unit_animation::prepare_animation(cfg,"standing_anim");
const config::child_list& standing_anims =
expanded_cfg.get_children("standing_anim");
for(anim_itor = standing_anims.begin(); anim_itor !=
standing_anims.end(); ++anim_itor) {
- (**anim_itor)["apply_to"] ="standing,_default_";
+ (**anim_itor)["apply_to"] ="standing,default";
animations.push_back(unit_animation(**anim_itor));
}
expanded_cfg = unit_animation::prepare_animation(cfg,"idle_anim");
Modified: trunk/src/unit_frame.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_frame.cpp?rev=24913&r1=24912&r2=24913&view=diff
==============================================================================
--- trunk/src/unit_frame.cpp (original)
+++ trunk/src/unit_frame.cpp Thu Mar 20 22:43:50 2008
@@ -184,6 +184,8 @@
highlight(cfg[frame_string+"alpha"]);
offset(cfg[frame_string+"offset"]);
submerge(cfg[frame_string+"submerge"]);
+ x(cfg[frame_string+"x"]);
+ y(cfg[frame_string+"y"]);
}
@@ -204,6 +206,8 @@
result.highlight_ratio =
highlight_ratio_.get_current_element(current_time,default_val.highlight_ratio);
result.offset =
offset_.get_current_element(current_time,default_val.offset);
result.submerge =
submerge_.get_current_element(current_time,default_val.submerge);
+ result.x = x_.get_current_element(current_time,default_val.x);
+ result.y = y_.get_current_element(current_time,default_val.y);
return result;
}
frame_builder & frame_builder::image(const image::locator image )
@@ -249,6 +253,8 @@
highlight_ratio_=progressive_double(highlight_ratio_.get_original(),duration_);
offset_=progressive_double(offset_.get_original(),duration_);
submerge_=progressive_double(submerge_.get_original(),duration_);
+ x_=progressive_int(x_.get_original(),duration_);
+ y_=progressive_int(y_.get_original(),duration_);
}
frame_builder & frame_builder::blend(const std::string& blend_ratio,const
Uint32 blend_color)
{
@@ -269,6 +275,16 @@
frame_builder & frame_builder::submerge(const std::string& submerge)
{
submerge_=progressive_double(submerge,duration_);
+ return *this;
+}
+frame_builder & frame_builder::x(const std::string& x)
+{
+ x_=progressive_int(x,duration_);
+ return *this;
+}
+frame_builder & frame_builder::y(const std::string& y)
+{
+ y_=progressive_int(y,duration_);
return *this;
}
bool frame_builder::does_not_change() const
@@ -279,7 +295,9 @@
blend_ratio_.does_not_change() &&
highlight_ratio_.does_not_change() &&
offset_.does_not_change() &&
- submerge_.does_not_change();
+ submerge_.does_not_change() &&
+ x_.does_not_change() &&
+ y_.does_not_change();
}
bool frame_builder::need_update() const
{
@@ -289,7 +307,9 @@
!blend_ratio_.does_not_change() ||
!highlight_ratio_.does_not_change() ||
!offset_.does_not_change() ||
- !submerge_.does_not_change() ) {
+ !submerge_.does_not_change() ||
+ !x_.does_not_change() ||
+ !y_.does_not_change() ) {
return true;
}
return false;
@@ -334,13 +354,16 @@
false
);
}
- const int x = static_cast<int>(tmp_offset * xdst + (1.0-tmp_offset) *
xsrc) + d2 ;
+ const int x = static_cast<int>(tmp_offset * xdst + (1.0-tmp_offset) *
xsrc) + d2;
const int y = static_cast<int>(tmp_offset * ydst + (1.0-tmp_offset) *
ysrc) + d2;
if (image != NULL) {
bool facing_west = direction == gamemap::location::NORTH_WEST
|| direction == gamemap::location::SOUTH_WEST;
bool facing_north = direction == gamemap::location::NORTH_WEST
|| direction == gamemap::location::NORTH || direction ==
gamemap::location::NORTH_EAST;
- game_display::get_singleton()->render_unit_image(x- image->w/2,
y - image->h/2, false, gamemap::get_drawing_order(src), image, facing_west,
false,
- ftofxp(current_data.highlight_ratio),
current_data.blend_with,
current_data.blend_ratio,current_data.submerge,!facing_north);
+ game_display::get_singleton()->render_unit_image(x +
current_data.x- image->w/2,
+ y + current_data.y- image->h/2, false,
+ gamemap::get_drawing_order(src), image,
facing_west, false,
+ ftofxp(current_data.highlight_ratio),
current_data.blend_with,
+
current_data.blend_ratio,current_data.submerge,!facing_north);
}
halo::remove(*halo_id);
*halo_id = halo::NO_HALO;
Modified: trunk/src/unit_frame.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_frame.hpp?rev=24913&r1=24912&r2=24913&view=diff
==============================================================================
--- trunk/src/unit_frame.hpp (original)
+++ trunk/src/unit_frame.hpp Thu Mar 20 22:43:50 2008
@@ -79,7 +79,9 @@
blend_ratio(0.0),
highlight_ratio(1.0),
offset(0),
- submerge(0.0)
+ submerge(0.0),
+ x(0),
+ y(0)
{};
image::locator image;
@@ -96,6 +98,8 @@
double highlight_ratio;
double offset;
double submerge;
+ int x;
+ int y;
} ;
//! keep most parameters in a separate class to simplify handling of large
number of parameters
class frame_builder {
@@ -115,7 +119,9 @@
blend_ratio_(""),
highlight_ratio_(""),
offset_(""),
- submerge_("")
+ submerge_(""),
+ x_(""),
+ y_("")
{};
frame_builder(const config& cfg,const std::string &frame_string
= "");
//! allow easy chained modifications will raised assert if used
after initialization
@@ -129,6 +135,8 @@
frame_builder & highlight(const std::string& highlight);
frame_builder & offset(const std::string& offset);
frame_builder & submerge(const std::string& submerge);
+ frame_builder & x(const std::string& x);
+ frame_builder & y(const std::string& y);
//! getters for the different parameters
const frame_parameters parameters(int current_time, const
frame_parameters & default_val = frame_parameters()) const;
@@ -151,6 +159,8 @@
progressive_double highlight_ratio_;
progressive_double offset_;
progressive_double submerge_;
+ progressive_int x_;
+ progressive_int y_;
};
//! Describe a unit's animation sequence.
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits