diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/tracker_panel.cpp | 116 | ||||
| -rw-r--r-- | src/tracker_panel.h | 3 |
2 files changed, 70 insertions, 49 deletions
| diff --git a/src/tracker_panel.cpp b/src/tracker_panel.cpp index 64e6ab3..37e3265 100644 --- a/src/tracker_panel.cpp +++ b/src/tracker_panel.cpp | |||
| @@ -44,6 +44,7 @@ TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) { | |||
| 44 | areas_.push_back(area); | 44 | areas_.push_back(area); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | Resize(); | ||
| 47 | Redraw(); | 48 | Redraw(); |
| 48 | 49 | ||
| 49 | Bind(wxEVT_PAINT, &TrackerPanel::OnPaint, this); | 50 | Bind(wxEVT_PAINT, &TrackerPanel::OnPaint, this); |
| @@ -57,8 +58,24 @@ void TrackerPanel::UpdateIndicators(bool reset) { | |||
| 57 | 58 | ||
| 58 | if (reset) { | 59 | if (reset) { |
| 59 | for (AreaIndicator &area : areas_) { | 60 | for (AreaIndicator &area : areas_) { |
| 61 | const MapArea &map_area = GD_GetMapArea(area.area_id); | ||
| 62 | |||
| 63 | if (IsAreaPostgame(area.area_id)) { | ||
| 64 | area.active = false; | ||
| 65 | } else if (panels_mode_) { | ||
| 66 | area.active = map_area.has_single_panel; | ||
| 67 | } else if (!AP_IsLocationVisible(map_area.classification) && | ||
| 68 | !(map_area.hunt && GetTrackerConfig().show_hunt_panels) && | ||
| 69 | !(AP_IsPaintingShuffle() && !map_area.paintings.empty())) { | ||
| 70 | area.active = false; | ||
| 71 | } else { | ||
| 72 | area.active = true; | ||
| 73 | } | ||
| 74 | |||
| 60 | area.popup->ResetIndicators(); | 75 | area.popup->ResetIndicators(); |
| 61 | } | 76 | } |
| 77 | |||
| 78 | Resize(); | ||
| 62 | } else { | 79 | } else { |
| 63 | for (AreaIndicator &area : areas_) { | 80 | for (AreaIndicator &area : areas_) { |
| 64 | area.popup->UpdateIndicators(); | 81 | area.popup->UpdateIndicators(); |
| @@ -103,6 +120,7 @@ void TrackerPanel::RefreshSavedata() { | |||
| 103 | 120 | ||
| 104 | void TrackerPanel::OnPaint(wxPaintEvent &event) { | 121 | void TrackerPanel::OnPaint(wxPaintEvent &event) { |
| 105 | if (GetSize() != rendered_.GetSize()) { | 122 | if (GetSize() != rendered_.GetSize()) { |
| 123 | Resize(); | ||
| 106 | Redraw(); | 124 | Redraw(); |
| 107 | 125 | ||
| 108 | if (refresh_button_ != nullptr) { | 126 | if (refresh_button_ != nullptr) { |
| @@ -160,7 +178,7 @@ void TrackerPanel::OnRefreshSavedata(wxCommandEvent &event) { | |||
| 160 | RefreshSavedata(); | 178 | RefreshSavedata(); |
| 161 | } | 179 | } |
| 162 | 180 | ||
| 163 | void TrackerPanel::Redraw() { | 181 | void TrackerPanel::Resize() { |
| 164 | wxSize panel_size = GetSize(); | 182 | wxSize panel_size = GetSize(); |
| 165 | wxSize image_size = map_image_.GetSize(); | 183 | wxSize image_size = map_image_.GetSize(); |
| 166 | 184 | ||
| @@ -180,7 +198,7 @@ void TrackerPanel::Redraw() { | |||
| 180 | final_x = (panel_size.GetWidth() - final_width) / 2; | 198 | final_x = (panel_size.GetWidth() - final_width) / 2; |
| 181 | } | 199 | } |
| 182 | 200 | ||
| 183 | rendered_ = wxBitmap( | 201 | scaled_map_ = wxBitmap( |
| 184 | map_image_.Scale(final_width, final_height, wxIMAGE_QUALITY_NORMAL) | 202 | map_image_.Scale(final_width, final_height, wxIMAGE_QUALITY_NORMAL) |
| 185 | .Size(panel_size, {final_x, final_y}, 0, 0, 0)); | 203 | .Size(panel_size, {final_x, final_y}, 0, 0, 0)); |
| 186 | 204 | ||
| @@ -195,32 +213,57 @@ void TrackerPanel::Redraw() { | |||
| 195 | wxBitmap(player_image_.Scale(player_width > 0 ? player_width : 1, | 213 | wxBitmap(player_image_.Scale(player_width > 0 ? player_width : 1, |
| 196 | player_height > 0 ? player_height : 1)); | 214 | player_height > 0 ? player_height : 1)); |
| 197 | 215 | ||
| 216 | real_area_size_ = final_width * AREA_EFFECTIVE_SIZE / image_size.GetWidth(); | ||
| 217 | |||
| 218 | for (AreaIndicator &area : areas_) { | ||
| 219 | const MapArea &map_area = GD_GetMapArea(area.area_id); | ||
| 220 | |||
| 221 | int real_area_x = final_x + (map_area.map_x - (AREA_EFFECTIVE_SIZE / 2)) * | ||
| 222 | final_width / image_size.GetWidth(); | ||
| 223 | int real_area_y = final_y + (map_area.map_y - (AREA_EFFECTIVE_SIZE / 2)) * | ||
| 224 | final_width / image_size.GetWidth(); | ||
| 225 | |||
| 226 | area.real_x1 = real_area_x; | ||
| 227 | area.real_x2 = real_area_x + real_area_size_; | ||
| 228 | area.real_y1 = real_area_y; | ||
| 229 | area.real_y2 = real_area_y + real_area_size_; | ||
| 230 | |||
| 231 | int popup_x = | ||
| 232 | final_x + map_area.map_x * final_width / image_size.GetWidth(); | ||
| 233 | int popup_y = | ||
| 234 | final_y + map_area.map_y * final_width / image_size.GetWidth(); | ||
| 235 | |||
| 236 | area.popup->SetClientSize( | ||
| 237 | area.popup->GetVirtualSize().GetWidth(), | ||
| 238 | std::min(panel_size.GetHeight(), | ||
| 239 | area.popup->GetVirtualSize().GetHeight())); | ||
| 240 | |||
| 241 | if (popup_x + area.popup->GetSize().GetWidth() > panel_size.GetWidth()) { | ||
| 242 | popup_x = panel_size.GetWidth() - area.popup->GetSize().GetWidth(); | ||
| 243 | } | ||
| 244 | if (popup_y + area.popup->GetSize().GetHeight() > panel_size.GetHeight()) { | ||
| 245 | popup_y = panel_size.GetHeight() - area.popup->GetSize().GetHeight(); | ||
| 246 | } | ||
| 247 | area.popup->SetPosition({popup_x, popup_y}); | ||
| 248 | } | ||
| 249 | } | ||
| 250 | |||
| 251 | void TrackerPanel::Redraw() { | ||
| 252 | rendered_ = scaled_map_; | ||
| 253 | |||
| 198 | wxMemoryDC dc; | 254 | wxMemoryDC dc; |
| 199 | dc.SelectObject(rendered_); | 255 | dc.SelectObject(rendered_); |
| 200 | 256 | ||
| 201 | int real_area_size = | ||
| 202 | final_width * AREA_EFFECTIVE_SIZE / image_size.GetWidth(); | ||
| 203 | int actual_border_size = | 257 | int actual_border_size = |
| 204 | real_area_size * AREA_BORDER_SIZE / AREA_EFFECTIVE_SIZE; | 258 | real_area_size_ * AREA_BORDER_SIZE / AREA_EFFECTIVE_SIZE; |
| 205 | const wxPoint upper_left_triangle[] = { | 259 | const wxPoint upper_left_triangle[] = { |
| 206 | {0, 0}, {0, real_area_size}, {real_area_size, 0}}; | 260 | {0, 0}, {0, real_area_size_}, {real_area_size_, 0}}; |
| 207 | const wxPoint lower_right_triangle[] = {{0, real_area_size - 1}, | 261 | const wxPoint lower_right_triangle[] = {{0, real_area_size_ - 1}, |
| 208 | {real_area_size - 1, 0}, | 262 | {real_area_size_ - 1, 0}, |
| 209 | {real_area_size, real_area_size}}; | 263 | {real_area_size_, real_area_size_}}; |
| 210 | 264 | ||
| 211 | for (AreaIndicator &area : areas_) { | 265 | for (AreaIndicator &area : areas_) { |
| 212 | const MapArea &map_area = GD_GetMapArea(area.area_id); | 266 | const MapArea &map_area = GD_GetMapArea(area.area_id); |
| 213 | if (IsAreaPostgame(area.area_id)) { | ||
| 214 | area.active = false; | ||
| 215 | } else if (panels_mode_) { | ||
| 216 | area.active = map_area.has_single_panel; | ||
| 217 | } else if (!AP_IsLocationVisible(map_area.classification) && | ||
| 218 | !(map_area.hunt && GetTrackerConfig().show_hunt_panels) && | ||
| 219 | !(AP_IsPaintingShuffle() && !map_area.paintings.empty())) { | ||
| 220 | area.active = false; | ||
| 221 | } else { | ||
| 222 | area.active = true; | ||
| 223 | } | ||
| 224 | 267 | ||
| 225 | if (!area.active) { | 268 | if (!area.active) { |
| 226 | continue; | 269 | continue; |
| @@ -276,10 +319,8 @@ void TrackerPanel::Redraw() { | |||
| 276 | } | 319 | } |
| 277 | } | 320 | } |
| 278 | 321 | ||
| 279 | int real_area_x = final_x + (map_area.map_x - (AREA_EFFECTIVE_SIZE / 2)) * | 322 | int real_area_x = area.real_x1; |
| 280 | final_width / image_size.GetWidth(); | 323 | int real_area_y = area.real_y1; |
| 281 | int real_area_y = final_y + (map_area.map_y - (AREA_EFFECTIVE_SIZE / 2)) * | ||
| 282 | final_width / image_size.GetWidth(); | ||
| 283 | 324 | ||
| 284 | if (has_reachable_unchecked && has_unreachable_unchecked && | 325 | if (has_reachable_unchecked && has_unreachable_unchecked && |
| 285 | GetTrackerConfig().hybrid_areas) { | 326 | GetTrackerConfig().hybrid_areas) { |
| @@ -293,7 +334,7 @@ void TrackerPanel::Redraw() { | |||
| 293 | dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, actual_border_size)); | 334 | dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, actual_border_size)); |
| 294 | dc.SetBrush(*wxTRANSPARENT_BRUSH); | 335 | dc.SetBrush(*wxTRANSPARENT_BRUSH); |
| 295 | dc.DrawRectangle({real_area_x, real_area_y}, | 336 | dc.DrawRectangle({real_area_x, real_area_y}, |
| 296 | {real_area_size, real_area_size}); | 337 | {real_area_size_, real_area_size_}); |
| 297 | 338 | ||
| 298 | } else { | 339 | } else { |
| 299 | const wxBrush *brush_color = wxGREY_BRUSH; | 340 | const wxBrush *brush_color = wxGREY_BRUSH; |
| @@ -308,31 +349,8 @@ void TrackerPanel::Redraw() { | |||
| 308 | dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, actual_border_size)); | 349 | dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, actual_border_size)); |
| 309 | dc.SetBrush(*brush_color); | 350 | dc.SetBrush(*brush_color); |
| 310 | dc.DrawRectangle({real_area_x, real_area_y}, | 351 | dc.DrawRectangle({real_area_x, real_area_y}, |
| 311 | {real_area_size, real_area_size}); | 352 | {real_area_size_, real_area_size_}); |
| 312 | } | 353 | } |
| 313 | |||
| 314 | area.real_x1 = real_area_x; | ||
| 315 | area.real_x2 = real_area_x + real_area_size; | ||
| 316 | area.real_y1 = real_area_y; | ||
| 317 | area.real_y2 = real_area_y + real_area_size; | ||
| 318 | |||
| 319 | int popup_x = | ||
| 320 | final_x + map_area.map_x * final_width / image_size.GetWidth(); | ||
| 321 | int popup_y = | ||
| 322 | final_y + map_area.map_y * final_width / image_size.GetWidth(); | ||
| 323 | |||
| 324 | area.popup->SetClientSize( | ||
| 325 | area.popup->GetVirtualSize().GetWidth(), | ||
| 326 | std::min(panel_size.GetHeight(), | ||
| 327 | area.popup->GetVirtualSize().GetHeight())); | ||
| 328 | |||
| 329 | if (popup_x + area.popup->GetSize().GetWidth() > panel_size.GetWidth()) { | ||
| 330 | popup_x = panel_size.GetWidth() - area.popup->GetSize().GetWidth(); | ||
| 331 | } | ||
| 332 | if (popup_y + area.popup->GetSize().GetHeight() > panel_size.GetHeight()) { | ||
| 333 | popup_y = panel_size.GetHeight() - area.popup->GetSize().GetHeight(); | ||
| 334 | } | ||
| 335 | area.popup->SetPosition({popup_x, popup_y}); | ||
| 336 | } | 354 | } |
| 337 | } | 355 | } |
| 338 | 356 | ||
| diff --git a/src/tracker_panel.h b/src/tracker_panel.h index ae89a35..abab1bf 100644 --- a/src/tracker_panel.h +++ b/src/tracker_panel.h | |||
| @@ -44,6 +44,7 @@ class TrackerPanel : public wxPanel { | |||
| 44 | void OnMouseMove(wxMouseEvent &event); | 44 | void OnMouseMove(wxMouseEvent &event); |
| 45 | void OnRefreshSavedata(wxCommandEvent &event); | 45 | void OnRefreshSavedata(wxCommandEvent &event); |
| 46 | 46 | ||
| 47 | void Resize(); | ||
| 47 | void Redraw(); | 48 | void Redraw(); |
| 48 | 49 | ||
| 49 | void RefreshSavedata(); | 50 | void RefreshSavedata(); |
| @@ -52,6 +53,7 @@ class TrackerPanel : public wxPanel { | |||
| 52 | 53 | ||
| 53 | wxImage map_image_; | 54 | wxImage map_image_; |
| 54 | wxImage player_image_; | 55 | wxImage player_image_; |
| 56 | wxBitmap scaled_map_; | ||
| 55 | wxBitmap rendered_; | 57 | wxBitmap rendered_; |
| 56 | wxBitmap scaled_player_; | 58 | wxBitmap scaled_player_; |
| 57 | 59 | ||
| @@ -61,6 +63,7 @@ class TrackerPanel : public wxPanel { | |||
| 61 | int offset_y_ = 0; | 63 | int offset_y_ = 0; |
| 62 | double scale_x_ = 0; | 64 | double scale_x_ = 0; |
| 63 | double scale_y_ = 0; | 65 | double scale_y_ = 0; |
| 66 | int real_area_size_ = 0; | ||
| 64 | 67 | ||
| 65 | std::vector<AreaIndicator> areas_; | 68 | std::vector<AreaIndicator> areas_; |
| 66 | 69 | ||
