about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--area_popup.cpp37
-rw-r--r--area_popup.h18
-rw-r--r--area_window.cpp16
-rw-r--r--area_window.h8
-rw-r--r--tracker_frame.cpp2
-rw-r--r--tracker_panel.cpp22
7 files changed, 92 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9000583..6f089d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -20,6 +20,7 @@ add_executable(lingo_ap_tracker
20 tracker_panel.cpp 20 tracker_panel.cpp
21 game_data.cpp 21 game_data.cpp
22 area_window.cpp 22 area_window.cpp
23 area_popup.cpp
23) 24)
24set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD 17) 25set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD 17)
25set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD_REQUIRED ON) 26set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD_REQUIRED ON)
diff --git a/area_popup.cpp b/area_popup.cpp new file mode 100644 index 0000000..62cbe4d --- /dev/null +++ b/area_popup.cpp
@@ -0,0 +1,37 @@
1#include "area_popup.h"
2
3#include "game_data.h"
4
5AreaPopup::AreaPopup(wxWindow* parent, int area_id)
6 : wxPanel(parent, wxID_ANY), area_id_(area_id) {
7 const MapArea& map_area = GetGameData().GetMapArea(area_id);
8
9 wxBoxSizer* list_sizer = new wxBoxSizer(wxVERTICAL);
10
11 wxStaticText* top_label = new wxStaticText(this, -1, map_area.name);
12 top_label->SetForegroundColour(*wxBLACK);
13 top_label->SetFont(top_label->GetFont().Bold());
14 list_sizer->Add(top_label, wxSizerFlags().Center().DoubleBorder(wxDOWN));
15
16 bool is_first = true;
17 for (const Location& location : map_area.locations) {
18 wxSizerFlags sizer_flags = wxSizerFlags().Left();
19 if (!is_first) {
20 sizer_flags = sizer_flags.Border(wxUP);
21 }
22
23 wxStaticText* section_label = new wxStaticText(this, -1, location.name);
24 section_label->SetForegroundColour(*wxBLACK);
25 list_sizer->Add(section_label, sizer_flags);
26
27 is_first = false;
28 }
29
30 wxBoxSizer* top_sizer = new wxBoxSizer(wxVERTICAL);
31 top_sizer->Add(list_sizer, wxSizerFlags().DoubleBorder(wxALL));
32
33 SetSizerAndFit(top_sizer);
34
35 SetBackgroundColour(*wxLIGHT_GREY);
36 Hide();
37}
diff --git a/area_popup.h b/area_popup.h new file mode 100644 index 0000000..c3de4bb --- /dev/null +++ b/area_popup.h
@@ -0,0 +1,18 @@
1#ifndef AREA_POPUP_H_03FAC988
2#define AREA_POPUP_H_03FAC988
3
4#include <wx/wxprec.h>
5
6#ifndef WX_PRECOMP
7#include <wx/wx.h>
8#endif
9
10class AreaPopup : public wxPanel {
11 public:
12 AreaPopup(wxWindow* parent, int area_id);
13
14 private:
15 int area_id_;
16};
17
18#endif /* end of include guard: AREA_POPUP_H_03FAC988 */
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 @@
4 4
5#include "game_data.h" 5#include "game_data.h"
6 6
7AreaWindow::AreaWindow(wxWindow* parent, int area_id) 7AreaWindow::AreaWindow(wxWindow* parent, int area_id, AreaPopup* popup)
8 : wxWindow(parent, wxID_ANY), area_id_(area_id) { 8 : wxWindow(parent, wxID_ANY), area_id_(area_id), popup_(popup) {
9 SetSize(EFFECTIVE_SIZE, EFFECTIVE_SIZE); 9 SetSize(EFFECTIVE_SIZE, EFFECTIVE_SIZE);
10 10
11 Redraw(); 11 Redraw();
12 12
13 Bind(wxEVT_PAINT, &AreaWindow::OnPaint, this); 13 Bind(wxEVT_PAINT, &AreaWindow::OnPaint, this);
14 Bind(wxEVT_ENTER_WINDOW, &AreaWindow::OnEnterWindow, this); 14 Bind(wxEVT_ENTER_WINDOW, &AreaWindow::OnEnterWindow, this);
15 Bind(wxEVT_LEAVE_WINDOW, &AreaWindow::OnLeaveWindow, this);
15} 16}
16 17
17void AreaWindow::OnPaint(wxPaintEvent& event) { 18void AreaWindow::OnPaint(wxPaintEvent& event) {
@@ -23,14 +24,9 @@ void AreaWindow::OnPaint(wxPaintEvent& event) {
23 dc.DrawBitmap(rendered_, 0, 0); 24 dc.DrawBitmap(rendered_, 0, 0);
24} 25}
25 26
26void AreaWindow::OnEnterWindow(wxMouseEvent& event) { 27void AreaWindow::OnEnterWindow(wxMouseEvent& event) { popup_->Show(); }
27 std::cout << GetGameData().GetMapArea(area_id_).name << std::endl; 28
28 std::cout << "---" << std::endl; 29void AreaWindow::OnLeaveWindow(wxMouseEvent& event) { popup_->Hide(); }
29 for (const Location& loc : GetGameData().GetMapArea(area_id_).locations) {
30 std::cout << loc.name << std::endl;
31 }
32 std::cout << "---" << std::endl;
33}
34 30
35void AreaWindow::Redraw() { 31void AreaWindow::Redraw() {
36 int actual_border_size = GetSize().GetWidth() * BORDER_SIZE / EFFECTIVE_SIZE; 32 int actual_border_size = GetSize().GetWidth() * BORDER_SIZE / EFFECTIVE_SIZE;
diff --git a/area_window.h b/area_window.h index 0806da4..c9abc4c 100644 --- a/area_window.h +++ b/area_window.h
@@ -7,24 +7,30 @@
7#include <wx/wx.h> 7#include <wx/wx.h>
8#endif 8#endif
9 9
10#include "area_popup.h"
11
10class AreaWindow : public wxWindow { 12class AreaWindow : public wxWindow {
11 public: 13 public:
12 static constexpr int ACTUAL_SIZE = 64; 14 static constexpr int ACTUAL_SIZE = 64;
13 static constexpr int BORDER_SIZE = 5; 15 static constexpr int BORDER_SIZE = 5;
14 static constexpr int EFFECTIVE_SIZE = ACTUAL_SIZE + BORDER_SIZE * 2; 16 static constexpr int EFFECTIVE_SIZE = ACTUAL_SIZE + BORDER_SIZE * 2;
15 17
16 AreaWindow(wxWindow* parent, int area_id); 18 AreaWindow(wxWindow* parent, int area_id, AreaPopup* popup);
17 19
18 int GetAreaId() const { return area_id_; } 20 int GetAreaId() const { return area_id_; }
19 21
22 AreaPopup* GetPopup() { return popup_; }
23
20 private: 24 private:
21 void OnPaint(wxPaintEvent& event); 25 void OnPaint(wxPaintEvent& event);
22 void OnEnterWindow(wxMouseEvent& event); 26 void OnEnterWindow(wxMouseEvent& event);
27 void OnLeaveWindow(wxMouseEvent& event);
23 28
24 void Redraw(); 29 void Redraw();
25 30
26 int area_id_; 31 int area_id_;
27 wxBitmap rendered_; 32 wxBitmap rendered_;
33 AreaPopup* popup_;
28}; 34};
29 35
30#endif /* end of include guard: AREA_WINDOW_H_C2653ACF */ 36#endif /* end of include guard: AREA_WINDOW_H_C2653ACF */
diff --git a/tracker_frame.cpp b/tracker_frame.cpp index 0c3827e..b33cce9 100644 --- a/tracker_frame.cpp +++ b/tracker_frame.cpp
@@ -6,6 +6,8 @@ TrackerFrame::TrackerFrame()
6 : wxFrame(nullptr, wxID_ANY, "Lingo Archipelago Tracker") { 6 : wxFrame(nullptr, wxID_ANY, "Lingo Archipelago Tracker") {
7 ::wxInitAllImageHandlers(); 7 ::wxInitAllImageHandlers();
8 8
9 SetSize(1280, 728);
10
9 wxMenu *menuFile = new wxMenu(); 11 wxMenu *menuFile = new wxMenu();
10 menuFile->Append(wxID_EXIT); 12 menuFile->Append(wxID_EXIT);
11 13
diff --git a/tracker_panel.cpp b/tracker_panel.cpp index 0cd65cc..0e78cc5 100644 --- a/tracker_panel.cpp +++ b/tracker_panel.cpp
@@ -1,5 +1,6 @@
1#include "tracker_panel.h" 1#include "tracker_panel.h"
2 2
3#include "area_popup.h"
3#include "game_data.h" 4#include "game_data.h"
4 5
5TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) { 6TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) {
@@ -9,7 +10,13 @@ TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) {
9 } 10 }
10 11
11 for (const MapArea &map_area : GetGameData().GetMapAreas()) { 12 for (const MapArea &map_area : GetGameData().GetMapAreas()) {
12 area_windows_.push_back(new AreaWindow(this, map_area.id)); 13 AreaPopup *area_popup = new AreaPopup(this, map_area.id);
14 area_popup->SetPosition({0, 0});
15 area_popup->Raise();
16
17 AreaWindow *area_window = new AreaWindow(this, map_area.id, area_popup);
18 area_window->Lower();
19 area_windows_.push_back(area_window);
13 } 20 }
14 21
15 Redraw(); 22 Redraw();
@@ -62,5 +69,18 @@ void TrackerPanel::Redraw() {
62 final_y + (map_area.map_y - (AreaWindow::EFFECTIVE_SIZE / 2)) * 69 final_y + (map_area.map_y - (AreaWindow::EFFECTIVE_SIZE / 2)) *
63 final_width / image_size.GetWidth(), 70 final_width / image_size.GetWidth(),
64 }); 71 });
72
73 AreaPopup *area_popup = area_window->GetPopup();
74 int popup_x =
75 final_x + map_area.map_x * final_width / image_size.GetWidth();
76 int popup_y =
77 final_y + map_area.map_y * final_width / image_size.GetWidth();
78 if (popup_x + area_popup->GetSize().GetWidth() > panel_size.GetWidth()) {
79 popup_x = panel_size.GetWidth() - area_popup->GetSize().GetWidth();
80 }
81 if (popup_y + area_popup->GetSize().GetHeight() > panel_size.GetHeight()) {
82 popup_y = panel_size.GetHeight() - area_popup->GetSize().GetHeight();
83 }
84 area_popup->SetPosition({popup_x, popup_y});
65 } 85 }
66} 86}