summary refs log tree commit diff stats
path: root/tools/mapedit/src
diff options
context:
space:
mode:
Diffstat (limited to 'tools/mapedit/src')
-rw-r--r--tools/mapedit/src/widget.cpp26
-rw-r--r--tools/mapedit/src/widget.h3
2 files changed, 29 insertions, 0 deletions
diff --git a/tools/mapedit/src/widget.cpp b/tools/mapedit/src/widget.cpp index 47efa18..53249c7 100644 --- a/tools/mapedit/src/widget.cpp +++ b/tools/mapedit/src/widget.cpp
@@ -7,6 +7,7 @@ BEGIN_EVENT_TABLE(MapeditWidget, wxScrolledWindow)
7 EVT_LEFT_DOWN(MapeditWidget::OnClick) 7 EVT_LEFT_DOWN(MapeditWidget::OnClick)
8 EVT_LEFT_UP(MapeditWidget::OnMouseUp) 8 EVT_LEFT_UP(MapeditWidget::OnMouseUp)
9 EVT_MOTION(MapeditWidget::OnMouseMove) 9 EVT_MOTION(MapeditWidget::OnMouseMove)
10 EVT_LEAVE_WINDOW(MapeditWidget::OnMouseOut)
10END_EVENT_TABLE() 11END_EVENT_TABLE()
11 12
12MapeditWidget::MapeditWidget() 13MapeditWidget::MapeditWidget()
@@ -51,6 +52,20 @@ void MapeditWidget::OnPaint(wxPaintEvent& event)
51 dc.StretchBlit(x*TILE_WIDTH*scale-vX, y*TILE_HEIGHT*scale-vY, TILE_WIDTH*scale, TILE_HEIGHT*scale, &tiles_dc, tile%8*TILE_WIDTH, tile/8*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT); 52 dc.StretchBlit(x*TILE_WIDTH*scale-vX, y*TILE_HEIGHT*scale-vY, TILE_WIDTH*scale, TILE_HEIGHT*scale, &tiles_dc, tile%8*TILE_WIDTH, tile/8*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT);
52 } 53 }
53 } 54 }
55
56 if (mouseIsIn)
57 {
58 int tile = tileWidget->getSelected();
59 int x = (mousePos.x + vX) / (TILE_WIDTH * scale);
60 int y = (mousePos.y + vY) / (TILE_HEIGHT * scale);
61
62 dc.StretchBlit(x*TILE_WIDTH*scale-vX, y*TILE_HEIGHT*scale-vY, TILE_WIDTH*scale, TILE_HEIGHT*scale, &tiles_dc, tile%8*TILE_WIDTH, tile/8*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT);
63
64 wxPen pen(*wxGREEN, 2);
65 dc.SetPen(pen);
66 dc.SetBrush(*wxTRANSPARENT_BRUSH);
67 dc.DrawRectangle(x*TILE_WIDTH*scale-vX, y*TILE_HEIGHT*scale-vY, TILE_WIDTH*scale, TILE_HEIGHT*scale);
68 }
54} 69}
55 70
56void MapeditWidget::SetTile(wxPoint pos) 71void MapeditWidget::SetTile(wxPoint pos)
@@ -80,6 +95,10 @@ void MapeditWidget::OnMouseMove(wxMouseEvent& event)
80 { 95 {
81 SetTile(event.GetPosition()); 96 SetTile(event.GetPosition());
82 } 97 }
98
99 mouseIsIn = true;
100 mousePos = event.GetPosition();
101 Refresh();
83} 102}
84 103
85void MapeditWidget::OnMouseUp(wxMouseEvent& event) 104void MapeditWidget::OnMouseUp(wxMouseEvent& event)
@@ -87,6 +106,13 @@ void MapeditWidget::OnMouseUp(wxMouseEvent& event)
87 mouseIsDown = false; 106 mouseIsDown = false;
88} 107}
89 108
109void MapeditWidget::OnMouseOut(wxMouseEvent& event)
110{
111 mouseIsIn = false;
112
113 Refresh();
114}
115
90void MapeditWidget::ZoomIn() 116void MapeditWidget::ZoomIn()
91{ 117{
92 SetZoomSize(scale+1); 118 SetZoomSize(scale+1);
diff --git a/tools/mapedit/src/widget.h b/tools/mapedit/src/widget.h index f66b0b2..c8bfb57 100644 --- a/tools/mapedit/src/widget.h +++ b/tools/mapedit/src/widget.h
@@ -25,6 +25,7 @@ class MapeditWidget : public wxScrolledWindow {
25 void OnClick(wxMouseEvent& event); 25 void OnClick(wxMouseEvent& event);
26 void OnMouseMove(wxMouseEvent& event); 26 void OnMouseMove(wxMouseEvent& event);
27 void OnMouseUp(wxMouseEvent& event); 27 void OnMouseUp(wxMouseEvent& event);
28 void OnMouseOut(wxMouseEvent& event);
28 29
29 private: 30 private:
30 void SetTile(wxPoint pos); 31 void SetTile(wxPoint pos);
@@ -35,6 +36,8 @@ class MapeditWidget : public wxScrolledWindow {
35 TileWidget* tileWidget; 36 TileWidget* tileWidget;
36 bool mouseIsDown = false; 37 bool mouseIsDown = false;
37 int scale; 38 int scale;
39 wxPoint mousePos;
40 bool mouseIsIn = false;
38 41
39 DECLARE_DYNAMIC_CLASS(MapeditWidget); 42 DECLARE_DYNAMIC_CLASS(MapeditWidget);
40 DECLARE_EVENT_TABLE(); 43 DECLARE_EVENT_TABLE();