From 22014b967d0d9651b72bffbe02aba75dc98180a4 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 2 May 2023 12:05:05 -0400 Subject: Show locations popup when hovering over area --- area_window.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'area_window.cpp') diff --git a/area_window.cpp b/area_window.cpp index 482dcb0..2f334e4 100644 --- a/area_window.cpp +++ b/area_window.cpp @@ -4,14 +4,15 @@ #include "game_data.h" -AreaWindow::AreaWindow(wxWindow* parent, int area_id) - : wxWindow(parent, wxID_ANY), area_id_(area_id) { +AreaWindow::AreaWindow(wxWindow* parent, int area_id, AreaPopup* popup) + : wxWindow(parent, wxID_ANY), area_id_(area_id), popup_(popup) { SetSize(EFFECTIVE_SIZE, EFFECTIVE_SIZE); Redraw(); Bind(wxEVT_PAINT, &AreaWindow::OnPaint, this); Bind(wxEVT_ENTER_WINDOW, &AreaWindow::OnEnterWindow, this); + Bind(wxEVT_LEAVE_WINDOW, &AreaWindow::OnLeaveWindow, this); } void AreaWindow::OnPaint(wxPaintEvent& event) { @@ -23,14 +24,9 @@ void AreaWindow::OnPaint(wxPaintEvent& event) { dc.DrawBitmap(rendered_, 0, 0); } -void AreaWindow::OnEnterWindow(wxMouseEvent& event) { - std::cout << GetGameData().GetMapArea(area_id_).name << std::endl; - std::cout << "---" << std::endl; - for (const Location& loc : GetGameData().GetMapArea(area_id_).locations) { - std::cout << loc.name << std::endl; - } - std::cout << "---" << std::endl; -} +void AreaWindow::OnEnterWindow(wxMouseEvent& event) { popup_->Show(); } + +void AreaWindow::OnLeaveWindow(wxMouseEvent& event) { popup_->Hide(); } void AreaWindow::Redraw() { int actual_border_size = GetSize().GetWidth() * BORDER_SIZE / EFFECTIVE_SIZE; -- cgit 1.4.1