about summary refs log tree commit diff stats
path: root/area_window.cpp
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-05-02 10:07:25 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2023-05-02 10:07:25 -0400
commit9f25878acfe1c7281a96f83742349516510c5b6d (patch)
treed68daca94d65ac97fe9ac0a87fb0a3f95f4b6fea /area_window.cpp
parent531898b0fef9f81e82ad5d5f38d2c627a0c10e56 (diff)
downloadlingo-ap-tracker-9f25878acfe1c7281a96f83742349516510c5b6d.tar.gz
lingo-ap-tracker-9f25878acfe1c7281a96f83742349516510c5b6d.tar.bz2
lingo-ap-tracker-9f25878acfe1c7281a96f83742349516510c5b6d.zip
Added areas to map
Diffstat (limited to 'area_window.cpp')
-rw-r--r--area_window.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/area_window.cpp b/area_window.cpp new file mode 100644 index 0000000..b142525 --- /dev/null +++ b/area_window.cpp
@@ -0,0 +1,39 @@
1#include "area_window.h"
2
3#include <iostream>
4
5#include "game_data.h"
6
7AreaWindow::AreaWindow(wxWindow* parent, int area_id)
8 : wxWindow(parent, wxID_ANY), area_id_(area_id) {
9 SetSize(EFFECTIVE_SIZE, EFFECTIVE_SIZE);
10
11 Redraw();
12
13 Bind(wxEVT_PAINT, &AreaWindow::OnPaint, this);
14 Bind(wxEVT_ENTER_WINDOW, &AreaWindow::OnEnterWindow, this);
15}
16
17void AreaWindow::OnPaint(wxPaintEvent& event) {
18 if (GetSize() != rendered_.GetSize()) {
19 Redraw();
20 }
21
22 wxPaintDC dc(this);
23 dc.DrawBitmap(rendered_, 0, 0);
24}
25
26void AreaWindow::OnEnterWindow(wxMouseEvent& event) {
27 std::cout << GetGameData().GetMapArea(area_id_).name << std::endl;
28}
29
30void AreaWindow::Redraw() {
31 int actual_border_size = GetSize().GetWidth() * BORDER_SIZE / EFFECTIVE_SIZE;
32
33 rendered_ = wxBitmap(GetSize());
34 wxMemoryDC dc;
35 dc.SelectObject(rendered_);
36 dc.SetPen(*wxThePenList->FindOrCreatePen(*wxBLACK, actual_border_size));
37 dc.SetBrush(*wxGREEN_BRUSH);
38 dc.DrawRectangle({0, 0}, GetSize());
39}