converted scroll_to_tile() to use gamemap::location
This commit is contained in:
parent
2ff87a5542
commit
b5686b7911
8 changed files with 27 additions and 30 deletions
|
@ -532,10 +532,8 @@ void display::screenshot()
|
|||
SDL_SaveBMP(screen_.getSurface().get(), name.c_str());
|
||||
}
|
||||
|
||||
void display::scroll_to_tile(int x, int y, SCROLL_TYPE scroll_type, bool check_fogged)
|
||||
void display::scroll_to_tile(const gamemap::location& loc, SCROLL_TYPE scroll_type, bool check_fogged)
|
||||
{
|
||||
const gamemap::location loc(x,y);
|
||||
|
||||
if(screen_.update_locked() || (check_fogged && fogged(loc))) {
|
||||
return;
|
||||
}
|
||||
|
@ -654,7 +652,7 @@ void display::scroll_to_tiles(int x1, int y1, int x2, int y2,
|
|||
// 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 @@ void display::scroll_to_tiles(int x1, int y1, int x2, int y2,
|
|||
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 @@ void display::scroll_to_leader(unit_map& units, int side)
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ public:
|
|||
//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
|
||||
|
|
|
@ -1033,7 +1033,7 @@ void map_editor::left_button_down(const int mousex, const int mousey) {
|
|||
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 @@ void map_editor::middle_button_down(const int mousex, const int mousey) {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -637,9 +637,8 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
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 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
}
|
||||
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 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
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 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
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 @@ bool event_handler::handle_event_command(const queued_event& event_info,
|
|||
//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()) {
|
||||
|
|
|
@ -351,7 +351,7 @@ namespace events{
|
|||
|
||||
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 @@ namespace events{
|
|||
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 @@ namespace events{
|
|||
}
|
||||
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();
|
||||
|
|
|
@ -718,7 +718,7 @@ void mouse_handler::mouse_motion(int x, int y, const bool browse)
|
|||
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 @@ void mouse_handler::mouse_press(const SDL_MouseButtonEvent& event, const bool br
|
|||
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 @@ void mouse_handler::left_click(const SDL_MouseButtonEvent& event, const bool bro
|
|||
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 @@ inline void mouse_handler::select_unit(const unit_map::const_iterator &it,
|
|||
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) {
|
||||
|
|
|
@ -50,10 +50,9 @@ void playsingle_controller::init_gui(){
|
|||
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(first_human_team_ + 1), 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(1), display::WARP);
|
||||
|
||||
update_locker lock_display(gui_->video(),recorder.is_skipping());
|
||||
events::raise_draw_event();
|
||||
|
|
|
@ -39,7 +39,7 @@ static void teleport_unit_between( const gamemap::location& a, const gamemap::lo
|
|||
|
||||
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 @@ static void teleport_unit_between( const gamemap::location& a, const gamemap::lo
|
|||
}
|
||||
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 @@ void unit_recruited(gamemap::location& loc)
|
|||
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 @@ void unit_healing(unit& healed_p,gamemap::location& healed_loc, std::vector<unit
|
|||
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();
|
||||
|
|
Loading…
Add table
Reference in a new issue