diff options
| author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-05-14 11:40:58 -0400 |
|---|---|---|
| committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-05-14 11:40:58 -0400 |
| commit | 34133b1e330a7d3c2a3e6a6bcd36deb5f95e8f13 (patch) | |
| tree | 159acd53a925cb8d3e3d44f189b6827f4b27385d | |
| parent | 2bab4f7ae28d0d0b836f00e073816bc920e62d55 (diff) | |
| download | lingo-ap-tracker-34133b1e330a7d3c2a3e6a6bcd36deb5f95e8f13.tar.gz lingo-ap-tracker-34133b1e330a7d3c2a3e6a6bcd36deb5f95e8f13.tar.bz2 lingo-ap-tracker-34133b1e330a7d3c2a3e6a6bcd36deb5f95e8f13.zip | |
Double buffered painting looks better
| -rw-r--r-- | src/area_popup.cpp | 6 | ||||
| -rw-r--r-- | src/subway_map.cpp | 6 | ||||
| -rw-r--r-- | src/tracker_panel.cpp | 6 |
3 files changed, 15 insertions, 3 deletions
| 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 @@ | |||
| 1 | #include "area_popup.h" | 1 | #include "area_popup.h" |
| 2 | 2 | ||
| 3 | #include <wx/dcbuffer.h> | ||
| 4 | |||
| 3 | #include "ap_state.h" | 5 | #include "ap_state.h" |
| 4 | #include "game_data.h" | 6 | #include "game_data.h" |
| 5 | #include "global.h" | 7 | #include "global.h" |
| @@ -8,6 +10,8 @@ | |||
| 8 | 10 | ||
| 9 | AreaPopup::AreaPopup(wxWindow* parent, int area_id) | 11 | AreaPopup::AreaPopup(wxWindow* parent, int area_id) |
| 10 | : wxScrolledCanvas(parent, wxID_ANY), area_id_(area_id) { | 12 | : wxScrolledCanvas(parent, wxID_ANY), area_id_(area_id) { |
| 13 | SetBackgroundStyle(wxBG_STYLE_PAINT); | ||
| 14 | |||
| 11 | unchecked_eye_ = | 15 | unchecked_eye_ = |
| 12 | wxBitmap(wxImage(GetAbsolutePath("assets/unchecked.png").c_str(), | 16 | wxBitmap(wxImage(GetAbsolutePath("assets/unchecked.png").c_str(), |
| 13 | wxBITMAP_TYPE_PNG) | 17 | wxBITMAP_TYPE_PNG) |
| @@ -108,7 +112,7 @@ void AreaPopup::UpdateIndicators() { | |||
| 108 | } | 112 | } |
| 109 | 113 | ||
| 110 | void AreaPopup::OnPaint(wxPaintEvent& event) { | 114 | void AreaPopup::OnPaint(wxPaintEvent& event) { |
| 111 | wxPaintDC dc(this); | 115 | wxBufferedPaintDC dc(this); |
| 112 | PrepareDC(dc); | 116 | PrepareDC(dc); |
| 113 | dc.DrawBitmap(rendered_, 0, 0); | 117 | dc.DrawBitmap(rendered_, 0, 0); |
| 114 | 118 | ||
| 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 @@ | |||
| 1 | #include "subway_map.h" | 1 | #include "subway_map.h" |
| 2 | 2 | ||
| 3 | #include <wx/dcbuffer.h> | ||
| 4 | |||
| 3 | #include "game_data.h" | 5 | #include "game_data.h" |
| 4 | #include "global.h" | 6 | #include "global.h" |
| 5 | #include "tracker_state.h" | 7 | #include "tracker_state.h" |
| @@ -13,6 +15,8 @@ enum class ItemDrawType { | |||
| 13 | }; | 15 | }; |
| 14 | 16 | ||
| 15 | SubwayMap::SubwayMap(wxWindow *parent) : wxPanel(parent, wxID_ANY) { | 17 | SubwayMap::SubwayMap(wxWindow *parent) : wxPanel(parent, wxID_ANY) { |
| 18 | SetBackgroundStyle(wxBG_STYLE_PAINT); | ||
| 19 | |||
| 16 | map_image_ = | 20 | map_image_ = |
| 17 | wxImage(GetAbsolutePath("assets/subway.png").c_str(), wxBITMAP_TYPE_PNG); | 21 | wxImage(GetAbsolutePath("assets/subway.png").c_str(), wxBITMAP_TYPE_PNG); |
| 18 | if (!map_image_.IsOk()) { | 22 | if (!map_image_.IsOk()) { |
| @@ -47,7 +51,7 @@ void SubwayMap::OnPaint(wxPaintEvent &event) { | |||
| 47 | Redraw(); | 51 | Redraw(); |
| 48 | } | 52 | } |
| 49 | 53 | ||
| 50 | wxPaintDC dc(this); | 54 | wxBufferedPaintDC dc(this); |
| 51 | dc.DrawBitmap(rendered_, 0, 0); | 55 | dc.DrawBitmap(rendered_, 0, 0); |
| 52 | 56 | ||
| 53 | event.Skip(); | 57 | 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 @@ | |||
| 1 | #include "tracker_panel.h" | 1 | #include "tracker_panel.h" |
| 2 | 2 | ||
| 3 | #include <wx/dcbuffer.h> | ||
| 4 | |||
| 3 | #include "ap_state.h" | 5 | #include "ap_state.h" |
| 4 | #include "area_popup.h" | 6 | #include "area_popup.h" |
| 5 | #include "game_data.h" | 7 | #include "game_data.h" |
| @@ -13,6 +15,8 @@ constexpr int AREA_EFFECTIVE_SIZE = AREA_ACTUAL_SIZE + AREA_BORDER_SIZE * 2; | |||
| 13 | constexpr int PLAYER_SIZE = 96; | 15 | constexpr int PLAYER_SIZE = 96; |
| 14 | 16 | ||
| 15 | TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) { | 17 | TrackerPanel::TrackerPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY) { |
| 18 | SetBackgroundStyle(wxBG_STYLE_PAINT); | ||
| 19 | |||
| 16 | map_image_ = wxImage(GetAbsolutePath("assets/lingo_map.png").c_str(), | 20 | map_image_ = wxImage(GetAbsolutePath("assets/lingo_map.png").c_str(), |
| 17 | wxBITMAP_TYPE_PNG); | 21 | wxBITMAP_TYPE_PNG); |
| 18 | if (!map_image_.IsOk()) { | 22 | if (!map_image_.IsOk()) { |
| @@ -54,7 +58,7 @@ void TrackerPanel::OnPaint(wxPaintEvent &event) { | |||
| 54 | Redraw(); | 58 | Redraw(); |
| 55 | } | 59 | } |
| 56 | 60 | ||
| 57 | wxPaintDC dc(this); | 61 | wxBufferedPaintDC dc(this); |
| 58 | dc.DrawBitmap(rendered_, 0, 0); | 62 | dc.DrawBitmap(rendered_, 0, 0); |
| 59 | 63 | ||
| 60 | if (AP_GetPlayerPosition().has_value()) { | 64 | if (AP_GetPlayerPosition().has_value()) { |
