From 34133b1e330a7d3c2a3e6a6bcd36deb5f95e8f13 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Tue, 14 May 2024 11:40:58 -0400 Subject: Double buffered painting looks better --- src/area_popup.cpp | 6 +++++- src/subway_map.cpp | 6 +++++- src/tracker_panel.cpp | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/area_popup.cpp b/src/area_popup.cpp index 3b5d8d4..6e70315 100644 --- a/src/area_popup.cpp +++ b/src/area_popup.cpp @@ -1,5 +1,7 @@ #include "area_popup.h" +#include + #include "ap_state.h" #include "game_data.h" #include "global.h" @@ -8,6 +10,8 @@ AreaPopup::AreaPopup(wxWindow* parent, int area_id) : wxScrolledCanvas(parent, wxID_ANY), area_id_(area_id) { + SetBackgroundStyle(wxBG_STYLE_PAINT); + unchecked_eye_ = wxBitmap(wxImage(GetAbsolutePath("assets/unchecked.png").c_str(), wxBITMAP_TYPE_PNG) @@ -108,7 +112,7 @@ void AreaPopup::UpdateIndicators() { } void AreaPopup::OnPaint(wxPaintEvent& event) { - wxPaintDC dc(this); + wxBufferedPaintDC dc(this); PrepareDC(dc); dc.DrawBitmap(rendered_, 0, 0); diff --git a/src/subway_map.cpp b/src/subway_map.cpp index 7d9786d..f857270 100644 --- a/src/subway_map.cpp +++ b/src/subway_map.cpp @@ -1,5 +1,7 @@ #include "subway_map.h" +#include + #include "game_data.h" #include "global.h" #include "tracker_state.h" @@ -13,6 +15,8 @@ enum class ItemDrawType { }; SubwayMap::SubwayMap(wxWindow *parent) : wxPanel(parent, wxID_ANY) { + SetBackgroundStyle(wxBG_STYLE_PAINT); + map_image_ = wxImage(GetAbsolutePath("assets/subway.png").c_str(), wxBITMAP_TYPE_PNG); if (!map_image_.IsOk()) { @@ -47,7 +51,7 @@ void SubwayMap::OnPaint(wxPaintEvent &event) { Redraw(); } - wxPaintDC dc(this); + wxBufferedPaintDC dc(this); dc.DrawBitmap(rendered_, 0, 0); event.Skip(); diff --git a/src/tracker_panel.cpp b/src/tracker_panel.cpp index 5f9f8ea..66bce81 100644 --- a/src/tracker_panel.cpp +++ b/src/tracker_panel.cpp @@ -1,5 +1,7 @@ #include "tracker_panel.h" +#include + #include "ap_state.h" #include "area_popup.h" #include "game_data.h" @@ -13,6 +15,8 @@ constexpr int AREA_EFFECTIVE_SIZE = AREA_ACTUAL_SIZE + AREA_BORDER_SIZE * 2; constexpr int PLAYER_SIZE = 96; TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) { + SetBackgroundStyle(wxBG_STYLE_PAINT); + map_image_ = wxImage(GetAbsolutePath("assets/lingo_map.png").c_str(), wxBITMAP_TYPE_PNG); if (!map_image_.IsOk()) { @@ -54,7 +58,7 @@ void TrackerPanel::OnPaint(wxPaintEvent &event) { Redraw(); } - wxPaintDC dc(this); + wxBufferedPaintDC dc(this); dc.DrawBitmap(rendered_, 0, 0); if (AP_GetPlayerPosition().has_value()) { -- cgit 1.4.1