From 49d36e6eb44306fff8d1709c34843932adb76eaf Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Sat, 24 Mar 2018 14:36:40 +1100 Subject: [PATCH] Display: always draw the map in the full window This is a temporary measure that removes reliance on the theme map rect. I need to ponder the best design to handle displaying the full map. --- src/display.cpp | 12 +++++++++++- src/display.hpp | 12 +++--------- src/editor/editor_display.cpp | 2 +- src/editor/editor_display.hpp | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index 1fbd045deba1..cebe31e31fea 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -497,6 +497,11 @@ const SDL_Rect& display::map_area() const return res; } +const SDL_Rect display::map_outside_area() const +{ + return map_screenshot_ ? max_map_area() : video_.screen_area(); +} + bool display::outside_area(const SDL_Rect& area, const int x, const int y) { const int x_thresh = hex_size(); @@ -616,6 +621,11 @@ const rect_of_hexes display::hexes_under_rect(const SDL_Rect& r) const return res; } +const rect_of_hexes display::get_visible_hexes() const +{ + return hexes_under_rect(map_area()); +} + bool display::team_valid() const { return currentTeam_ < dc_->teams().size(); @@ -1551,7 +1561,7 @@ const map_labels& display::labels() const return *map_labels_; } -const SDL_Rect& display::get_clip_rect() +const SDL_Rect display::get_clip_rect() { return map_area(); } diff --git a/src/display.hpp b/src/display.hpp index b1333e0c78c5..3c35be571e49 100644 --- a/src/display.hpp +++ b/src/display.hpp @@ -298,10 +298,7 @@ class display : public events::sdl_handler * Returns the available area for a map, this may differ from the above. * This area will get the background area applied to it. */ - const SDL_Rect& map_outside_area() const - { - return map_screenshot_ ? max_map_area() : theme_.main_map_location(video_.screen_area()); - } + const SDL_Rect map_outside_area() const; /** Check if the bbox of the hex at x,y has pixels outside the area rectangle. */ static bool outside_area(const SDL_Rect& area, const int x, const int y); @@ -383,10 +380,7 @@ class display : public events::sdl_handler const rect_of_hexes hexes_under_rect(const SDL_Rect& r) const; /** Returns the rectangular area of visible hexes */ - const rect_of_hexes get_visible_hexes() const - { - return hexes_under_rect(map_area()); - } + const rect_of_hexes get_visible_hexes() const; /** Returns true if location (x,y) is covered in shroud. */ bool shrouded(const map_location& loc) const; @@ -864,7 +858,7 @@ class display : public events::sdl_handler * Get the clipping rectangle for drawing. * Virtual since the editor might use a slightly different approach. */ - virtual const SDL_Rect& get_clip_rect(); + virtual const SDL_Rect get_clip_rect(); /** Draw the appropriate fog or shroud transition images for a specific hex. */ void draw_fog_shroud_transition_images(const map_location& loc, image::TYPE image_type); diff --git a/src/editor/editor_display.cpp b/src/editor/editor_display.cpp index 711e09390190..16a3bda25acb 100644 --- a/src/editor/editor_display.cpp +++ b/src/editor/editor_display.cpp @@ -99,7 +99,7 @@ void editor_display::draw_hex_overlays() } } -const SDL_Rect& editor_display::get_clip_rect() +const SDL_Rect editor_display::get_clip_rect() { return map_outside_area(); } diff --git a/src/editor/editor_display.hpp b/src/editor/editor_display.hpp index a38f88569e9c..462b8d07dc06 100644 --- a/src/editor/editor_display.hpp +++ b/src/editor/editor_display.hpp @@ -51,7 +51,7 @@ class editor_display : public display virtual void draw_hex_cursor(const map_location& loc) override; virtual void draw_hex_overlays() override; - const SDL_Rect& get_clip_rect() override; + const SDL_Rect get_clip_rect() override; std::set brush_locations_;