From 9798316b43773e4c7d15851202977a3069f28577 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Mon, 1 May 2023 17:54:50 -0400 Subject: Added map background --- CMakeLists.txt | 1 + assets/lingo_map.png | Bin 0 -> 396452 bytes tracker_frame.cpp | 6 ++++++ tracker_panel.cpp | 27 +++++++++++++++++++++++++++ tracker_panel.h | 23 +++++++++++++++++++++++ 5 files changed, 57 insertions(+) create mode 100755 assets/lingo_map.png create mode 100644 tracker_panel.cpp create mode 100644 tracker_panel.h diff --git a/CMakeLists.txt b/CMakeLists.txt index dffa7ab..cb5cf25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ include(${wxWidgets_USE_FILE}) add_executable(lingo_ap_tracker main.cpp tracker_frame.cpp + tracker_panel.cpp ) set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD 17) set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD_REQUIRED ON) diff --git a/assets/lingo_map.png b/assets/lingo_map.png new file mode 100755 index 0000000..73486af Binary files /dev/null and b/assets/lingo_map.png differ diff --git a/tracker_frame.cpp b/tracker_frame.cpp index 83f42a6..0c3827e 100644 --- a/tracker_frame.cpp +++ b/tracker_frame.cpp @@ -1,7 +1,11 @@ #include "tracker_frame.h" +#include "tracker_panel.h" + TrackerFrame::TrackerFrame() : wxFrame(nullptr, wxID_ANY, "Lingo Archipelago Tracker") { + ::wxInitAllImageHandlers(); + wxMenu *menuFile = new wxMenu(); menuFile->Append(wxID_EXIT); @@ -19,6 +23,8 @@ TrackerFrame::TrackerFrame() Bind(wxEVT_MENU, &TrackerFrame::OnAbout, this, wxID_ABOUT); Bind(wxEVT_MENU, &TrackerFrame::OnExit, this, wxID_EXIT); + + new TrackerPanel(this); } void TrackerFrame::OnAbout(wxCommandEvent &event) { diff --git a/tracker_panel.cpp b/tracker_panel.cpp new file mode 100644 index 0000000..74bf605 --- /dev/null +++ b/tracker_panel.cpp @@ -0,0 +1,27 @@ +#include "tracker_panel.h" + +TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) { + map_image_ = wxImage("assets/lingo_map.png", wxBITMAP_TYPE_PNG); + if (!map_image_.IsOk()) { + return; + } + + Redraw(); + + Bind(wxEVT_PAINT, &TrackerPanel::OnPaint, this); +} + +void TrackerPanel::OnPaint(wxPaintEvent &event) { + if (GetSize() != rendered_.GetSize()) { + Redraw(); + } + + wxPaintDC dc(this); + dc.DrawBitmap(rendered_, 0, 0); +} + +void TrackerPanel::Redraw() { + wxSize sz = GetSize(); + rendered_ = wxBitmap( + map_image_.Scale(sz.GetWidth(), sz.GetHeight(), wxIMAGE_QUALITY_NORMAL)); +} diff --git a/tracker_panel.h b/tracker_panel.h new file mode 100644 index 0000000..49b4d23 --- /dev/null +++ b/tracker_panel.h @@ -0,0 +1,23 @@ +#ifndef TRACKER_PANEL_H_D675A54D +#define TRACKER_PANEL_H_D675A54D + +#include + +#ifndef WX_PRECOMP +#include +#endif + +class TrackerPanel : public wxPanel { +public: + TrackerPanel(wxWindow *parent); + +private: + void OnPaint(wxPaintEvent &event); + + void Redraw(); + + wxImage map_image_; + wxBitmap rendered_; +}; + +#endif /* end of include guard: TRACKER_PANEL_H_D675A54D */ -- cgit 1.4.1