refactor look-mode screen shifting into function
This commit is contained in:
@@ -1154,6 +1154,13 @@ static void handle_party_death() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void screen_shift(int dx, int dy, bool& need_redraw) {
|
||||||
|
center.x += dx;
|
||||||
|
center.y += dy;
|
||||||
|
|
||||||
|
need_redraw = true;
|
||||||
|
}
|
||||||
|
|
||||||
bool handle_action(const sf::Event& event, cFramerateLimiter& fps_limiter) {
|
bool handle_action(const sf::Event& event, cFramerateLimiter& fps_limiter) {
|
||||||
long item_hit;
|
long item_hit;
|
||||||
bool are_done = false;
|
bool are_done = false;
|
||||||
@@ -1342,20 +1349,16 @@ bool handle_action(const sf::Event& event, cFramerateLimiter& fps_limiter) {
|
|||||||
// MARK: Begin: Screen shift
|
// MARK: Begin: Screen shift
|
||||||
if(scrollableModes.count(overall_mode) && the_point.in(terrain_viewport) && !the_point.in(world_screen)) {
|
if(scrollableModes.count(overall_mode) && the_point.in(terrain_viewport) && !the_point.in(world_screen)) {
|
||||||
if(the_point.y < world_screen.top && center.y > univ.town->in_town_rect.top && center.y > 4) {
|
if(the_point.y < world_screen.top && center.y > univ.town->in_town_rect.top && center.y > 4) {
|
||||||
center.y--;
|
screen_shift(0, -1, need_redraw);
|
||||||
need_redraw = true;
|
|
||||||
}
|
}
|
||||||
if(the_point.x < world_screen.left && center.x > univ.town->in_town_rect.left && center.x > 4) {
|
if(the_point.x < world_screen.left && center.x > univ.town->in_town_rect.left && center.x > 4) {
|
||||||
center.x--;
|
screen_shift(-1, 0, need_redraw);
|
||||||
need_redraw = true;
|
|
||||||
}
|
}
|
||||||
if(the_point.y > world_screen.bottom && center.y < univ.town->in_town_rect.bottom && center.y < univ.town->max_dim - 5) {
|
if(the_point.y > world_screen.bottom && center.y < univ.town->in_town_rect.bottom && center.y < univ.town->max_dim - 5) {
|
||||||
center.y++;
|
screen_shift(0, 1, need_redraw);
|
||||||
need_redraw = true;
|
|
||||||
}
|
}
|
||||||
if(the_point.x > world_screen.right && center.x < univ.town->in_town_rect.right && center.x < univ.town->max_dim - 5) {
|
if(the_point.x > world_screen.right && center.x < univ.town->in_town_rect.right && center.x < univ.town->max_dim - 5) {
|
||||||
center.x++;
|
screen_shift(1, 0, need_redraw);
|
||||||
need_redraw = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// MARK: End: Screen shift
|
// MARK: End: Screen shift
|
||||||
|
|||||||
@@ -60,5 +60,6 @@ void handle_new_pc_graphic();
|
|||||||
void handle_rename_pc();
|
void handle_rename_pc();
|
||||||
void handle_begin_look(bool right_button, bool& need_redraw);
|
void handle_begin_look(bool right_button, bool& need_redraw);
|
||||||
void handle_look(location destination, bool right_button, eKeyMod mods, bool& need_redraw, bool& need_reprint);
|
void handle_look(location destination, bool right_button, eKeyMod mods, bool& need_redraw, bool& need_reprint);
|
||||||
|
void screen_shift(int dx, int dy, bool& need_redraw);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user