Author: mordante
Date: Sun May 27 01:39:22 2007
New Revision: 17881
URL: http://svn.gna.org/viewcvs/wesnoth?rev=17881&view=rev
Log:
converted scroll_to_tile() to use gamemap::location
Modified:
trunk/src/display.cpp
trunk/src/display.hpp
trunk/src/editor/editor.cpp
trunk/src/game_events.cpp
trunk/src/menu_events.cpp
trunk/src/mouse_events.cpp
trunk/src/playsingle_controller.cpp
trunk/src/unit_display.cpp
Modified: trunk/src/display.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=17881&r1=17880&r2=17881&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Sun May 27 01:39:22 2007
@@ -532,10 +532,8 @@
SDL_SaveBMP(screen_.getSurface().get(), name.c_str());
}
-void display::scroll_to_tile(int x, int y, SCROLL_TYPE scroll_type, bool
check_fogged)
-{
- const gamemap::location loc(x,y);
-
+void display::scroll_to_tile(const gamemap::location& loc, SCROLL_TYPE
scroll_type, bool check_fogged)
+{
if(screen_.update_locked() || (check_fogged && fogged(loc))) {
return;
}
@@ -654,7 +652,7 @@
// if rectangle formed by corners (x1,y1) and (x2,y2) is larger
// than map area then just scroll to (x1,y1)
if(diffx > map_area().w || diffy > map_area().h) {
- scroll_to_tile(x1,y1,scroll_type,check_fogged);
+
scroll_to_tile(gamemap::location(x1,y1),scroll_type,check_fogged);
} else {
// only scroll if rectangle is not completely inside map area
// assume most paths are within rectangle, sometimes
@@ -663,7 +661,7 @@
if (outside_area(map_area(),minx,miny) ||
outside_area(map_area(),maxx,maxy)) {
// scroll to middle point of rectangle
-
scroll_to_tile((x1+x2)/2,(y1+y2)/2,scroll_type,check_fogged);
+
scroll_to_tile(gamemap::location((x1+x2)/2,(y1+y2)/2),scroll_type,check_fogged);
} // else don't scroll, rectangle is already on screen
}
}
@@ -677,7 +675,7 @@
i will comment it out
const hotkey::basic_handler key_events_handler(gui_);
*/
- scroll_to_tile(leader->first.x,leader->first.y,ONSCREEN);
+ scroll_to_tile(leader->first, ONSCREEN);
}
}
Modified: trunk/src/display.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.hpp?rev=17881&r1=17880&r2=17881&view=diff
==============================================================================
--- trunk/src/display.hpp (original)
+++ trunk/src/display.hpp Sun May 27 01:39:22 2007
@@ -101,7 +101,7 @@
//function which will scroll such that location x,y is on-screen.
// WARP jumps to x,y; SCROLL uses scroll speed;
// ONSCREEN only scrolls if x,y is offscreen
- void scroll_to_tile(int x, int y, SCROLL_TYPE scroll_type=ONSCREEN,
bool check_fogged=true);
+ void scroll_to_tile(const gamemap::location& loc, SCROLL_TYPE
scroll_type=ONSCREEN, bool check_fogged=true);
//function which will scroll such that location x1,y1 is on-screen.
//it will also try to make it such that x2,y2 is on-screen but this
Modified: trunk/src/editor/editor.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor/editor.cpp?rev=17881&r1=17880&r2=17881&view=diff
==============================================================================
--- trunk/src/editor/editor.cpp (original)
+++ trunk/src/editor/editor.cpp Sun May 27 01:39:22 2007
@@ -1033,7 +1033,7 @@
const gamemap::location& minimap_loc =
gui_.minimap_location_on(mousex,mousey);
const gamemap::location hex = gui_.hex_clicked_on(mousex, mousey);
if (minimap_loc.valid()) {
-
gui_.scroll_to_tile(minimap_loc.x,minimap_loc.y,display::WARP,false);
+ gui_.scroll_to_tile(minimap_loc,display::WARP,false);
}
else if (key_[SDLK_RSHIFT] || key_[SDLK_LSHIFT]) {
if (key_[SDLK_RALT] || key_[SDLK_LALT]) {
@@ -1244,7 +1244,7 @@
const gamemap::location& minimap_loc =
gui_.minimap_location_on(mousex,mousey);
const gamemap::location hex = gui_.hex_clicked_on(mousex, mousey);
if (minimap_loc.valid()) {
-
gui_.scroll_to_tile(minimap_loc.x,minimap_loc.y,display::WARP,false);
+ gui_.scroll_to_tile(minimap_loc,display::WARP,false);
}
}
Modified: trunk/src/game_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=17881&r1=17880&r2=17881&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Sun May 27 01:39:22 2007
@@ -637,9 +637,8 @@
std::string y = cfg["y"];
std::string check_fogged = cfg["check_fogged"];
wassert(state_of_game != NULL);
- const int xpos = atoi(x.c_str());
- const int ypos = atoi(y.c_str());
-
screen->scroll_to_tile(xpos,ypos,display::SCROLL,utils::string_bool(check_fogged,false));
+ const gamemap::location loc(atoi(x.c_str()), atoi(y.c_str()));
+
screen->scroll_to_tile(loc,display::SCROLL,utils::string_bool(check_fogged,false));
}
else if(cmd == "scroll_to_unit") {
@@ -650,7 +649,7 @@
}
std::string check_fogged = cfg["check_fogged"];
if(u != units->end()) {
-
screen->scroll_to_tile(u->first.x,u->first.y,display::SCROLL,utils::string_bool(check_fogged,false));
+
screen->scroll_to_tile(u->first,display::SCROLL,utils::string_bool(check_fogged,false));
}
}
@@ -1556,7 +1555,8 @@
if(speaker != units->end()) {
LOG_DP << "scrolling to speaker..\n";
screen->highlight_hex(speaker->first);
-
screen->scroll_to_tile(speaker->first.x,speaker->first.y-1);
+ // FIXME: Why is this y-1???
+
screen->scroll_to_tile(gamemap::location(speaker->first.x,speaker->first.y-1));
if(image.empty()) {
image = speaker->second.profile();
@@ -1671,7 +1671,7 @@
while(un != units->end()) {
if(game_events::unit_matches_filter(un,cfg)) {
if(utils::string_bool(cfg["animate"])) {
-
screen->scroll_to_tile(un->first.x,un->first.y);
+ screen->scroll_to_tile(un->first);
unit_display::unit_die(un->first,un->second);
}
@@ -2046,7 +2046,7 @@
//we have found a unit that matches the filter
if(u != units->end() && ! screen->fogged(u->first)) {
screen->highlight_hex(u->first);
- screen->scroll_to_tile(u->first.x,u->first.y);
+ screen->scroll_to_tile(u->first);
u->second.set_extra_anim(*screen,u->first,cfg["flag"]);
while(!u->second.get_animation()->animation_finished())
{
Modified: trunk/src/menu_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=17881&r1=17880&r2=17881&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Sun May 27 01:39:22 2007
@@ -351,7 +351,7 @@
if(selected > 0 && selected < int(locations_list.size())) {
const gamemap::location& loc = locations_list[selected];
- gui_->scroll_to_tile(loc.x,loc.y,display::WARP);
+ gui_->scroll_to_tile(loc,display::WARP);
}
}
@@ -1246,7 +1246,7 @@
const unit_map::const_iterator i = team_leader(team_num,units_);
if(i != units_.end()) {
clear_shroud(team_num);
-
gui_->scroll_to_tile(i->first.x,i->first.y,display::WARP);
+ gui_->scroll_to_tile(i->first,display::WARP);
}
}
@@ -1737,7 +1737,7 @@
}
if(found) {
last_search_hit_ = loc;
-
gui_->scroll_to_tile(loc.x,loc.y,display::ONSCREEN,false);
+ gui_->scroll_to_tile(loc,display::ONSCREEN,false);
gui_->highlight_hex(loc);
} else {
last_search_hit_ = gamemap::location();
Modified: trunk/src/mouse_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_events.cpp?rev=17881&r1=17880&r2=17881&view=diff
==============================================================================
--- trunk/src/mouse_events.cpp (original)
+++ trunk/src/mouse_events.cpp Sun May 27 01:39:22 2007
@@ -718,7 +718,7 @@
if(loc.valid()) {
if(loc != last_hex_) {
last_hex_ = loc;
-
(*gui_).scroll_to_tile(loc.x,loc.y,display::WARP,false);
+
(*gui_).scroll_to_tile(loc,display::WARP,false);
}
} else {
// clicking outside of the minimap will end
minimap scrolling
@@ -996,7 +996,7 @@
if(loc.valid()) {
minimap_scrolling_ = true;
last_hex_ = loc;
- gui_->scroll_to_tile(loc.x,loc.y,display::WARP,false);
+ gui_->scroll_to_tile(loc,display::WARP,false);
} else {
const SDL_Rect& rect = gui_->map_area();
const int centerx = (rect.x + rect.w)/2;
@@ -1064,7 +1064,7 @@
if(loc.valid()) {
minimap_scrolling_ = true;
last_hex_ = loc;
- gui_->scroll_to_tile(loc.x,loc.y,display::WARP,false);
+ gui_->scroll_to_tile(loc,display::WARP,false);
return;
}
@@ -1475,7 +1475,7 @@
current_paths_ =
paths(map_,status_,gameinfo_,units_,it->first,teams_,false,teleport,viewing_team(),path_turns_);
gui_->highlight_reach(current_paths_);
- gui_->scroll_to_tile(it->first.x,it->first.y,display::WARP);
+ gui_->scroll_to_tile(it->first,display::WARP);
}
if (it == itx) {
Modified: trunk/src/playsingle_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playsingle_controller.cpp?rev=17881&r1=17880&r2=17881&view=diff
==============================================================================
--- trunk/src/playsingle_controller.cpp (original)
+++ trunk/src/playsingle_controller.cpp Sun May 27 01:39:22 2007
@@ -50,10 +50,9 @@
play_controller::init_gui();
if(first_human_team_ != -1) {
- gui_->scroll_to_tile(map_.starting_position(first_human_team_ +
1).x,
- map_.starting_position(first_human_team_
+ 1).y, display::WARP);
- }
-
gui_->scroll_to_tile(map_.starting_position(1).x,map_.starting_position(1).y,display::WARP);
+ gui_->scroll_to_tile(map_.starting_position(first_human_team_ +
1), display::WARP);
+ }
+ gui_->scroll_to_tile(map_.starting_position(1), display::WARP);
update_locker lock_display(gui_->video(),recorder.is_skipping());
events::raise_draw_event();
Modified: trunk/src/unit_display.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_display.cpp?rev=17881&r1=17880&r2=17881&view=diff
==============================================================================
--- trunk/src/unit_display.cpp (original)
+++ trunk/src/unit_display.cpp Sun May 27 01:39:22 2007
@@ -39,7 +39,7 @@
temp_unit.set_teleporting(*disp,a);
if (!disp->fogged(a)) { // teleport
- disp->scroll_to_tile(a.x,a.y,display::ONSCREEN);
+ disp->scroll_to_tile(a,display::ONSCREEN);
while(!temp_unit.get_animation()->animation_finished() &&
temp_unit.get_animation()->get_animation_time() < 0) {
disp->invalidate(a);
disp->place_temporary_unit(temp_unit, a);
@@ -50,7 +50,7 @@
}
if (!disp->fogged(b)) { // teleport
temp_unit.restart_animation(*disp,0);
- disp->scroll_to_tile(b.x,b.y,display::ONSCREEN);
+ disp->scroll_to_tile(b,display::ONSCREEN);
while(!temp_unit.get_animation()->animation_finished()) {
disp->invalidate(b);
disp->place_temporary_unit(temp_unit, b);
@@ -531,7 +531,7 @@
if(u == disp->get_units().end()) return;
u->second.set_hidden(true);
- disp->scroll_to_tile(loc.x,loc.y,display::ONSCREEN);
+ disp->scroll_to_tile(loc,display::ONSCREEN);
disp->draw();
u->second.set_recruited(*disp,loc);
u->second.set_hidden(false);
@@ -552,7 +552,7 @@
if(healing==0) return;
// This is all the pretty stuff.
int start_time = INT_MAX;
- disp->scroll_to_tile(healed_loc.x, healed_loc.y, display::ONSCREEN);
+ disp->scroll_to_tile(healed_loc, display::ONSCREEN);
disp->select_hex(healed_loc);
unit healed = healed_p;
bool was_hidden = healed.get_hidden();
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits