about summary refs log tree commit diff stats
path: root/src/tracker_panel.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-12-17 15:40:19 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2024-12-17 15:40:19 -0500
commitad7c3e616fdc6f13812ec52675d226a19351494a (patch)
tree4cdd8b27c6df4e5f3475fe1b3f1815689b387fd7 /src/tracker_panel.cpp
parent5ea44a418ec5db446dd28daf5ed95f46fea504f8 (diff)
downloadlingo-ap-tracker-ad7c3e616fdc6f13812ec52675d226a19351494a.tar.gz
lingo-ap-tracker-ad7c3e616fdc6f13812ec52675d226a19351494a.tar.bz2
lingo-ap-tracker-ad7c3e616fdc6f13812ec52675d226a19351494a.zip
Added getting player position from IPC
Diffstat (limited to 'src/tracker_panel.cpp')
-rw-r--r--src/tracker_panel.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/tracker_panel.cpp b/src/tracker_panel.cpp index 27e825a..2f2d596 100644 --- a/src/tracker_panel.cpp +++ b/src/tracker_panel.cpp
@@ -10,6 +10,7 @@
10#include "game_data.h" 10#include "game_data.h"
11#include "global.h" 11#include "global.h"
12#include "godot_variant.h" 12#include "godot_variant.h"
13#include "ipc_state.h"
13#include "tracker_config.h" 14#include "tracker_config.h"
14#include "tracker_state.h" 15#include "tracker_state.h"
15 16
@@ -59,7 +60,8 @@ void TrackerPanel::UpdateIndicators() {
59 60
60void TrackerPanel::SetSavedataPath(std::string savedata_path) { 61void TrackerPanel::SetSavedataPath(std::string savedata_path) {
61 if (!panels_mode_) { 62 if (!panels_mode_) {
62 wxButton *refresh_button = new wxButton(this, wxID_ANY, "Refresh", {15, 15}); 63 wxButton *refresh_button =
64 new wxButton(this, wxID_ANY, "Refresh", {15, 15});
63 refresh_button->Bind(wxEVT_BUTTON, &TrackerPanel::OnRefreshSavedata, this); 65 refresh_button->Bind(wxEVT_BUTTON, &TrackerPanel::OnRefreshSavedata, this);
64 } 66 }
65 67
@@ -94,16 +96,25 @@ void TrackerPanel::OnPaint(wxPaintEvent &event) {
94 wxBufferedPaintDC dc(this); 96 wxBufferedPaintDC dc(this);
95 dc.DrawBitmap(rendered_, 0, 0); 97 dc.DrawBitmap(rendered_, 0, 0);
96 98
97 if (AP_GetPlayerPosition().has_value()) { 99 std::optional<std::tuple<int, int>> player_position;
100 if (IPC_IsConnected()) {
101 player_position = IPC_GetPlayerPosition();
102 } else {
103 player_position = AP_GetPlayerPosition();
104 }
105
106 if (player_position.has_value()) {
98 // 1588, 1194 107 // 1588, 1194
99 // 14x14 -> 154x154 108 // 14x14 -> 154x154
100 double intended_x = 109 double intended_x =
101 1588.0 + (std::get<0>(*AP_GetPlayerPosition()) * (154.0 / 14.0)); 110 1588.0 + (std::get<0>(*player_position) * (154.0 / 14.0));
102 double intended_y = 111 double intended_y =
103 1194.0 + (std::get<1>(*AP_GetPlayerPosition()) * (154.0 / 14.0)); 112 1194.0 + (std::get<1>(*player_position) * (154.0 / 14.0));
104 113
105 int real_x = offset_x_ + scale_x_ * intended_x - scaled_player_.GetWidth() / 2; 114 int real_x =
106 int real_y = offset_y_ + scale_y_ * intended_y - scaled_player_.GetHeight() / 2; 115 offset_x_ + scale_x_ * intended_x - scaled_player_.GetWidth() / 2;
116 int real_y =
117 offset_y_ + scale_y_ * intended_y - scaled_player_.GetHeight() / 2;
107 118
108 dc.DrawBitmap(scaled_player_, real_x, real_y); 119 dc.DrawBitmap(scaled_player_, real_x, real_y);
109 } 120 }
@@ -182,8 +193,8 @@ void TrackerPanel::Redraw() {
182 if (panels_mode_) { 193 if (panels_mode_) {
183 area.active = map_area.has_single_panel; 194 area.active = map_area.has_single_panel;
184 } else if (!AP_IsLocationVisible(map_area.classification) && 195 } else if (!AP_IsLocationVisible(map_area.classification) &&
185 !(map_area.hunt && GetTrackerConfig().show_hunt_panels) && 196 !(map_area.hunt && GetTrackerConfig().show_hunt_panels) &&
186 !(AP_IsPaintingShuffle() && !map_area.paintings.empty())) { 197 !(AP_IsPaintingShuffle() && !map_area.paintings.empty())) {
187 area.active = false; 198 area.active = false;
188 } else { 199 } else {
189 area.active = true; 200 area.active = true;