diff options
Diffstat (limited to 'src/tracker_panel.cpp')
| -rw-r--r-- | src/tracker_panel.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
| diff --git a/src/tracker_panel.cpp b/src/tracker_panel.cpp index daaeff7..5f9f8ea 100644 --- a/src/tracker_panel.cpp +++ b/src/tracker_panel.cpp | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | constexpr int AREA_ACTUAL_SIZE = 64; | 10 | constexpr int AREA_ACTUAL_SIZE = 64; |
| 11 | constexpr int AREA_BORDER_SIZE = 5; | 11 | constexpr int AREA_BORDER_SIZE = 5; |
| 12 | constexpr int AREA_EFFECTIVE_SIZE = AREA_ACTUAL_SIZE + AREA_BORDER_SIZE * 2; | 12 | constexpr int AREA_EFFECTIVE_SIZE = AREA_ACTUAL_SIZE + AREA_BORDER_SIZE * 2; |
| 13 | constexpr int PLAYER_SIZE = 96; | ||
| 13 | 14 | ||
| 14 | TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) { | 15 | TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) { |
| 15 | map_image_ = wxImage(GetAbsolutePath("assets/lingo_map.png").c_str(), | 16 | map_image_ = wxImage(GetAbsolutePath("assets/lingo_map.png").c_str(), |
| @@ -18,6 +19,12 @@ TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) { | |||
| 18 | return; | 19 | return; |
| 19 | } | 20 | } |
| 20 | 21 | ||
| 22 | player_image_ = | ||
| 23 | wxImage(GetAbsolutePath("assets/player.png").c_str(), wxBITMAP_TYPE_PNG); | ||
| 24 | if (!player_image_.IsOk()) { | ||
| 25 | return; | ||
| 26 | } | ||
| 27 | |||
| 21 | for (const MapArea &map_area : GD_GetMapAreas()) { | 28 | for (const MapArea &map_area : GD_GetMapAreas()) { |
| 22 | AreaIndicator area; | 29 | AreaIndicator area; |
| 23 | area.area_id = map_area.id; | 30 | area.area_id = map_area.id; |
| @@ -50,6 +57,20 @@ void TrackerPanel::OnPaint(wxPaintEvent &event) { | |||
| 50 | wxPaintDC dc(this); | 57 | wxPaintDC dc(this); |
| 51 | dc.DrawBitmap(rendered_, 0, 0); | 58 | dc.DrawBitmap(rendered_, 0, 0); |
| 52 | 59 | ||
| 60 | if (AP_GetPlayerPosition().has_value()) { | ||
| 61 | // 1588, 1194 | ||
| 62 | // 14x14 -> 154x154 | ||
| 63 | double intended_x = | ||
| 64 | 1588.0 + (std::get<0>(*AP_GetPlayerPosition()) * (154.0 / 14.0)); | ||
| 65 | double intended_y = | ||
| 66 | 1194.0 + (std::get<1>(*AP_GetPlayerPosition()) * (154.0 / 14.0)); | ||
| 67 | |||
| 68 | int real_x = offset_x_ + scale_x_ * intended_x - scaled_player_.GetWidth() / 2; | ||
| 69 | int real_y = offset_y_ + scale_y_ * intended_y - scaled_player_.GetHeight() / 2; | ||
| 70 | |||
| 71 | dc.DrawBitmap(scaled_player_, real_x, real_y); | ||
| 72 | } | ||
| 73 | |||
| 53 | event.Skip(); | 74 | event.Skip(); |
| 54 | } | 75 | } |
| 55 | 76 | ||
| @@ -91,6 +112,17 @@ void TrackerPanel::Redraw() { | |||
| 91 | map_image_.Scale(final_width, final_height, wxIMAGE_QUALITY_NORMAL) | 112 | map_image_.Scale(final_width, final_height, wxIMAGE_QUALITY_NORMAL) |
| 92 | .Size(panel_size, {final_x, final_y}, 0, 0, 0)); | 113 | .Size(panel_size, {final_x, final_y}, 0, 0, 0)); |
| 93 | 114 | ||
| 115 | offset_x_ = final_x; | ||
| 116 | offset_y_ = final_y; | ||
| 117 | scale_x_ = static_cast<double>(final_width) / image_size.GetWidth(); | ||
| 118 | scale_y_ = static_cast<double>(final_height) / image_size.GetHeight(); | ||
| 119 | |||
| 120 | int player_width = PLAYER_SIZE * scale_x_; | ||
| 121 | int player_height = PLAYER_SIZE * scale_y_; | ||
| 122 | scaled_player_ = | ||
| 123 | wxBitmap(player_image_.Scale(player_width > 0 ? player_width : 1, | ||
| 124 | player_height > 0 ? player_height : 1)); | ||
| 125 | |||
| 94 | wxMemoryDC dc; | 126 | wxMemoryDC dc; |
| 95 | dc.SelectObject(rendered_); | 127 | dc.SelectObject(rendered_); |
| 96 | 128 | ||
