blob: 77b840e235be6d11766b9115a87e1db69be1ba5b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#ifndef WIDGET_H
#define WIDGET_H
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include "map.h"
#include "tile_widget.h"
#include <list>
#include <memory>
#include <utility>
#include <set>
class MapeditFrame;
enum EditMode {
EditTiles,
EditEntities
};
class MapeditWidget : public wxScrolledCanvas {
public:
MapeditWidget();
MapeditWidget(wxWindow* parent, wxWindowID winid, Map* map, TileWidget* tileWidget, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
void ZoomIn();
void ZoomOut();
void SetEditMode(EditMode editMode);
void StartAddingEntity(MapObject* object);
void CancelAddingEntity();
void SetMap(Map* map);
void SetIsSettingStart(bool isSetting);
MapeditFrame* frame;
protected:
void Init();
virtual wxSize DoGetBestSize() const;
void OnPaint(wxPaintEvent& event);
void OnClick(wxMouseEvent& event);
void OnRightClick(wxMouseEvent& event);
void OnMouseMove(wxMouseEvent& event);
void OnMouseUp(wxMouseEvent& event);
void OnMouseOut(wxMouseEvent& event);
private:
void SetTile(wxPoint pos);
void SetZoomSize(int zoom);
Map* map = nullptr;
wxBitmap tiles;
TileWidget* tileWidget;
bool mouseIsDown = false;
int scale = 1;
wxPoint mousePos {GAME_WIDTH/2, GAME_HEIGHT/2};
bool mouseIsIn = false;
EditMode editMode = EditTiles;
int currentPlayer = 0;
bool isSettingPos = false;
std::set<std::pair<int,int>> changeBuffer;
MapObject* addingEntity = nullptr;
MapObjectEntry* movingEntity = nullptr;
std::shared_ptr<MapObjectEntry> selectedEntity;
DECLARE_DYNAMIC_CLASS(MapeditWidget)
DECLARE_EVENT_TABLE()
};
#endif
|