diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-02 10:07:25 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-05-02 10:07:25 -0400 |
commit | 9f25878acfe1c7281a96f83742349516510c5b6d (patch) | |
tree | d68daca94d65ac97fe9ac0a87fb0a3f95f4b6fea /area_window.cpp | |
parent | 531898b0fef9f81e82ad5d5f38d2c627a0c10e56 (diff) | |
download | lingo-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.cpp | 39 |
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 | |||
7 | AreaWindow::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 | |||
17 | void 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 | |||
26 | void AreaWindow::OnEnterWindow(wxMouseEvent& event) { | ||
27 | std::cout << GetGameData().GetMapArea(area_id_).name << std::endl; | ||
28 | } | ||
29 | |||
30 | void 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 | } | ||