From ad7c3e616fdc6f13812ec52675d226a19351494a Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 17 Dec 2024 15:40:19 -0500 Subject: Added getting player position from IPC --- src/tracker_panel.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/tracker_panel.cpp') 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 @@ #include "game_data.h" #include "global.h" #include "godot_variant.h" +#include "ipc_state.h" #include "tracker_config.h" #include "tracker_state.h" @@ -59,7 +60,8 @@ void TrackerPanel::UpdateIndicators() { void TrackerPanel::SetSavedataPath(std::string savedata_path) { if (!panels_mode_) { - wxButton *refresh_button = new wxButton(this, wxID_ANY, "Refresh", {15, 15}); + wxButton *refresh_button = + new wxButton(this, wxID_ANY, "Refresh", {15, 15}); refresh_button->Bind(wxEVT_BUTTON, &TrackerPanel::OnRefreshSavedata, this); } @@ -94,16 +96,25 @@ void TrackerPanel::OnPaint(wxPaintEvent &event) { wxBufferedPaintDC dc(this); dc.DrawBitmap(rendered_, 0, 0); - if (AP_GetPlayerPosition().has_value()) { + std::optional> player_position; + if (IPC_IsConnected()) { + player_position = IPC_GetPlayerPosition(); + } else { + player_position = AP_GetPlayerPosition(); + } + + if (player_position.has_value()) { // 1588, 1194 // 14x14 -> 154x154 double intended_x = - 1588.0 + (std::get<0>(*AP_GetPlayerPosition()) * (154.0 / 14.0)); + 1588.0 + (std::get<0>(*player_position) * (154.0 / 14.0)); double intended_y = - 1194.0 + (std::get<1>(*AP_GetPlayerPosition()) * (154.0 / 14.0)); + 1194.0 + (std::get<1>(*player_position) * (154.0 / 14.0)); - int real_x = offset_x_ + scale_x_ * intended_x - scaled_player_.GetWidth() / 2; - int real_y = offset_y_ + scale_y_ * intended_y - scaled_player_.GetHeight() / 2; + int real_x = + offset_x_ + scale_x_ * intended_x - scaled_player_.GetWidth() / 2; + int real_y = + offset_y_ + scale_y_ * intended_y - scaled_player_.GetHeight() / 2; dc.DrawBitmap(scaled_player_, real_x, real_y); } @@ -182,8 +193,8 @@ void TrackerPanel::Redraw() { if (panels_mode_) { area.active = map_area.has_single_panel; } else if (!AP_IsLocationVisible(map_area.classification) && - !(map_area.hunt && GetTrackerConfig().show_hunt_panels) && - !(AP_IsPaintingShuffle() && !map_area.paintings.empty())) { + !(map_area.hunt && GetTrackerConfig().show_hunt_panels) && + !(AP_IsPaintingShuffle() && !map_area.paintings.empty())) { area.active = false; } else { area.active = true; -- cgit 1.4.1