diff options
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 | } | ||
