Author: ilor
Date: Wed Jun 18 17:48:46 2008
New Revision: 27282
URL: http://svn.gna.org/viewcvs/wesnoth?rev=27282&view=rev
Log:
display::draw() refactor followup - remove some debug code, add more doxygen
comments, move halo:: calls down to game_display to reduce link time dependency
(and fix a linker error in editor)
Modified:
trunk/src/display.cpp
trunk/src/display.hpp
trunk/src/game_display.cpp
trunk/src/game_display.hpp
Modified: trunk/src/display.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=27282&r1=27281&r2=27282&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Wed Jun 18 17:48:46 2008
@@ -1416,14 +1416,8 @@
SDL_Rect srcrect = dstrect;
srcrect.x -= dx;
srcrect.y -= dy;
- DBG_DP << "xmove is " << xmove << ", ymove is " << ymove << "\n";
- DBG_DP << "screen is: w" << screen->w << " h" << screen->h << "\n";
- DBG_DP << "map_area() is: x" << map_area().x << " y" << map_area().y <<
" w" << map_area().w << " h" << map_area().h << "\n";
- DBG_DP << "srcrect is: x" << srcrect.x << " y" << srcrect.y << " w" <<
srcrect.w << " h" << srcrect.h << "\n";
- DBG_DP << "dstrect is: x" << dstrect.x << " y" << dstrect.y << " w" <<
dstrect.w << " h" << dstrect.h << "\n";
if (!screen_.update_locked())
SDL_BlitSurface(screen,&srcrect,screen,&dstrect);
- DBG_DP << "blitted\n";
// Invalidate locations in the newly visible rects
@@ -1849,16 +1843,14 @@
pre_draw();
update_time_of_day();
if(!map_.empty()) {
- halo::unrender(invalidated_);
//int simulate_delay = 0;
if(!invalidated_.empty()) {
changed = true;
- INFO_DP << invalidated_.size() << "\n";
draw_invalidated();
invalidated_.clear();
}
drawing_buffer_commit();
- halo::render();
+ post_commit();
draw_sidebar();
//! @todo FIXME: This changed can probably be smarter
changed = true;
@@ -1873,11 +1865,6 @@
surface const disp(screen_.getSurface());
SDL_Rect area = screen_area();
SDL_FillRect(disp, &area, SDL_MapRGB(disp->format, 0, 0, 0));
-}
-
-void display::pre_draw()
-{
- //no action by default
}
const SDL_Rect& display::get_clip_rect()
Modified: trunk/src/display.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.hpp?rev=27282&r1=27281&r2=27282&view=diff
==============================================================================
--- trunk/src/display.hpp (original)
+++ trunk/src/display.hpp Wed Jun 18 17:48:46 2008
@@ -197,12 +197,17 @@
virtual bool rectangle_need_update(const gamemap::location&
first_corner, const gamemap::location& second_corner) const;
virtual bool zone_need_update(const int x1,const int y1, const int x2,
const int y2) const;
virtual void draw_minimap_units() {};
+
+ /**
+ * Function to invalidate animated terrains which may have changed.
+ */
virtual void invalidate_animations();
+
/**
* Per-location invalidation called by invalidate_animations()
* defaults to no action, overriden by derived classes
*/
- virtual void invalidate_animations_location(gamemap::location loc){}
+ virtual void invalidate_animations_location(gamemap::location loc) {}
const gamemap& get_map()const { return map_;}
@@ -377,9 +382,9 @@
/**
* Called near the beginning of each draw() call.
* Derived classes can use this to add extra actions before redrawing
- * invalidated hexes takes place
- */
- virtual void pre_draw();
+ * invalidated hexes takes place. No action here by default.
+ */
+ virtual void pre_draw() {}
/**
* Get the clipping rectangle for drawing.
@@ -396,6 +401,12 @@
virtual void draw_invalidated();
/**
+ * Hook for actions to take right after draw() calls
drawing_buffer_commit
+ * No action here by default.
+ */
+ virtual void post_commit() {}
+
+ /**
* Redraws a single gamemap location.
*/
virtual void draw_hex(const gamemap::location& loc);
@@ -413,7 +424,7 @@
/**
* Called near the end of a draw operation, derived classes can use
this
- * to render a specific sidebar
+ * to render a specific sidebar. Very similar to post_commit.
*/
virtual void draw_sidebar();
Modified: trunk/src/game_display.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_display.cpp?rev=27282&r1=27281&r2=27282&view=diff
==============================================================================
--- trunk/src/game_display.cpp (original)
+++ trunk/src/game_display.cpp Wed Jun 18 17:48:46 2008
@@ -310,9 +310,15 @@
void game_display::draw_invalidated()
{
+ halo::unrender(invalidated_);
display::draw_invalidated();
std::vector<gamemap::location> unit_invals =
get_invalidated_unit_locations();
redraw_units(unit_invals);
+}
+
+void game_display::post_commit()
+{
+ halo::render();
}
void game_display::draw_hex(const gamemap::location& loc)
@@ -394,7 +400,6 @@
{
tod_ = status_.get_time_of_day();
}
-
void game_display::redraw_units(const std::vector<gamemap::location>&
invalidated_unit_locations)
{
Modified: trunk/src/game_display.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_display.hpp?rev=27282&r1=27281&r2=27282&view=diff
==============================================================================
--- trunk/src/game_display.hpp (original)
+++ trunk/src/game_display.hpp Wed Jun 18 17:48:46 2008
@@ -127,6 +127,9 @@
*/
std::vector<gamemap::location> get_invalidated_unit_locations();
+ /**
+ * Hex brightening for game - take units into account
+ */
image::TYPE get_image_type(const gamemap::location& loc);
/**
@@ -136,14 +139,22 @@
void draw_invalidated();
+ void post_commit();
+
void draw_hex(const gamemap::location& loc);
void update_time_of_day();
-
- //! Function to invalidate animated terrains which may have changed.
+ /**
+ * Animated hex invalidation specific to gameplay
+ */
void invalidate_animations();
+
+ /**
+ * Extra game per-location invalidation (village ownership)
+ */
void invalidate_animations_location(gamemap::location loc);
+
virtual void draw_minimap_units();
public:
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits