summary refs log tree commit diff stats
path: root/tools/mapedit
diff options
context:
space:
mode:
Diffstat (limited to 'tools/mapedit')
-rw-r--r--tools/mapedit/src/frame.cpp49
-rw-r--r--tools/mapedit/src/frame.h2
-rw-r--r--tools/mapedit/src/map.cpp14
-rw-r--r--tools/mapedit/src/map.h2
-rw-r--r--tools/mapedit/src/tile_widget.cpp6
-rw-r--r--tools/mapedit/src/tile_widget.h2
6 files changed, 50 insertions, 25 deletions
diff --git a/tools/mapedit/src/frame.cpp b/tools/mapedit/src/frame.cpp index 3cd1c15..b3808e2 100644 --- a/tools/mapedit/src/frame.cpp +++ b/tools/mapedit/src/frame.cpp
@@ -43,28 +43,36 @@ MapeditFrame::MapeditFrame(Map map, std::string filename) : wxFrame(NULL, wxID_A
43 43
44 SetMenuBar(menuBar); 44 SetMenuBar(menuBar);
45 45
46 wxBoxSizer* sizermain = new wxBoxSizer(wxVERTICAL); 46 // Layout 1: Splitter between map tree and layout 2
47 wxSplitterWindow* splitter = new wxSplitterWindow(this, wxID_ANY); 47 // Layout 2: Non-splitter between layout 3 and tile chooser
48 splitter->SetSashGravity(0.0); 48 // Layout 3: Splitter between map editor and properties editor
49 splitter->SetMinimumPaneSize(50);
50 sizermain->Add(splitter, 1, wxEXPAND, 0);
51 49
52 wxPanel* tileEditorPanel = new wxPanel(splitter, wxID_ANY); 50 wxSplitterWindow* layout3 = new wxSplitterWindow(this, wxID_ANY);
53 tileEditor = new TileWidget(tileEditorPanel, wxID_ANY, 6, 6, wxPoint(0,0)); 51 layout3->SetSashGravity(1.0);
54 wxBoxSizer* tileSizer = new wxBoxSizer(wxVERTICAL); 52 layout3->SetMinimumPaneSize(20);
55 tileSizer->Add(tileEditor, 1, wxEXPAND, 0);
56 tileEditorPanel->SetSizer(tileSizer);
57 53
58 wxPanel* mapEditorPanel = new wxPanel(splitter, wxID_ANY); 54 tileEditor = new TileWidget(this, wxID_ANY, 6, 6, wxPoint(0,0), wxSize(TILE_WIDTH*6*7,TILE_HEIGHT*10*6));
59 mapEditor = new MapeditWidget(mapEditorPanel, wxID_ANY, &this->map, tileEditor, wxPoint(0,0)); 55 mapEditor = new MapeditWidget(layout3, wxID_ANY, &this->map, tileEditor, wxPoint(0,0), wxSize(GAME_WIDTH*2, GAME_HEIGHT*2));
60 wxBoxSizer* mapSizer = new wxBoxSizer(wxVERTICAL);
61 mapSizer->Add(mapEditor, 1, wxEXPAND, 0);
62 mapEditorPanel->SetSizer(mapSizer);
63 56
64 splitter->SplitVertically(tileEditorPanel, mapEditorPanel); 57 wxPanel* propertyEditor = new wxPanel(layout3, wxID_ANY);
58 titleBox = new wxTextCtrl(propertyEditor, wxID_ANY, map.getTitle());
59 titleBox->Bind(wxEVT_TEXT, &MapeditFrame::OnTitleChange, this);
65 60
66 this->SetSizer(sizermain); 61 wxStaticText* titleLabel = new wxStaticText(propertyEditor, wxID_ANY, "Title:");
67 sizermain->SetSizeHints(this); 62
63 wxFlexGridSizer* propertySizer = new wxFlexGridSizer(1, 2, 9, 25);
64 propertySizer->Add(titleLabel);
65 propertySizer->Add(titleBox, 1, wxEXPAND);
66 propertyEditor->SetSizer(propertySizer);
67 propertySizer->SetSizeHints(propertyEditor);
68
69 layout3->SplitHorizontally(mapEditor, propertyEditor);
70
71 wxBoxSizer* sizer2 = new wxBoxSizer(wxHORIZONTAL);
72 sizer2->Add(layout3, 1, wxEXPAND, 0);
73 sizer2->Add(tileEditor, 0, wxALIGN_TOP | wxALIGN_CENTER_HORIZONTAL | wxLEFT, 2);
74 this->SetSizer(sizer2);
75 sizer2->SetSizeHints(this);
68} 76}
69 77
70void MapeditFrame::OnExit(wxCloseEvent& event) 78void MapeditFrame::OnExit(wxCloseEvent& event)
@@ -156,3 +164,8 @@ void MapeditFrame::OnQuit(wxCommandEvent& event)
156{ 164{
157 // TODO 165 // TODO
158} 166}
167
168void MapeditFrame::OnTitleChange(wxCommandEvent& event)
169{
170 map.setTitle(titleBox->GetLineText(0).ToStdString());
171}
diff --git a/tools/mapedit/src/frame.h b/tools/mapedit/src/frame.h index 53d8998..11990b1 100644 --- a/tools/mapedit/src/frame.h +++ b/tools/mapedit/src/frame.h
@@ -27,10 +27,12 @@ class MapeditFrame : public wxFrame {
27 void OnClose(wxCommandEvent& event); 27 void OnClose(wxCommandEvent& event);
28 void OnExit(wxCloseEvent& event); 28 void OnExit(wxCloseEvent& event);
29 void OnQuit(wxCommandEvent& event); 29 void OnQuit(wxCommandEvent& event);
30 void OnTitleChange(wxCommandEvent& event);
30 31
31 Map map; 32 Map map;
32 MapeditWidget* mapEditor; 33 MapeditWidget* mapEditor;
33 TileWidget* tileEditor; 34 TileWidget* tileEditor;
35 wxTextCtrl* titleBox;
34 std::string filename; 36 std::string filename;
35 37
36 wxDECLARE_EVENT_TABLE(); 38 wxDECLARE_EVENT_TABLE();
diff --git a/tools/mapedit/src/map.cpp b/tools/mapedit/src/map.cpp index 7976419..3a24ace 100644 --- a/tools/mapedit/src/map.cpp +++ b/tools/mapedit/src/map.cpp
@@ -6,7 +6,6 @@
6Map::Map() 6Map::Map()
7{ 7{
8 mapdata = (int*) calloc(MAP_WIDTH * MAP_HEIGHT, sizeof(int)); 8 mapdata = (int*) calloc(MAP_WIDTH * MAP_HEIGHT, sizeof(int));
9 dirty = true;
10} 9}
11 10
12Map::Map(std::string filename) 11Map::Map(std::string filename)
@@ -59,8 +58,6 @@ Map::Map(std::string filename)
59 } 58 }
60 59
61 xmlFreeDoc(doc); 60 xmlFreeDoc(doc);
62
63 dirty = false;
64} 61}
65 62
66Map::Map(const Map& map) 63Map::Map(const Map& map)
@@ -172,3 +169,14 @@ int Map::getTileAt(int x, int y) const
172{ 169{
173 return mapdata[x+y*MAP_WIDTH]; 170 return mapdata[x+y*MAP_WIDTH];
174} 171}
172
173std::string Map::getTitle() const
174{
175 return title;
176}
177
178void Map::setTitle(std::string title)
179{
180 dirty = true;
181 this->title = title;
182}
diff --git a/tools/mapedit/src/map.h b/tools/mapedit/src/map.h index 66e4596..45ec7e1 100644 --- a/tools/mapedit/src/map.h +++ b/tools/mapedit/src/map.h
@@ -49,6 +49,8 @@ class Map {
49 Map& operator= (Map other); 49 Map& operator= (Map other);
50 friend void swap(Map& first, Map& second); 50 friend void swap(Map& first, Map& second);
51 51
52 std::string getTitle() const;
53 void setTitle(std::string title);
52 void save(std::string name); 54 void save(std::string name);
53 bool hasUnsavedChanges() const; 55 bool hasUnsavedChanges() const;
54 void setTileAt(int x, int y, int tile); 56 void setTileAt(int x, int y, int tile);
diff --git a/tools/mapedit/src/tile_widget.cpp b/tools/mapedit/src/tile_widget.cpp index 3dccecb..3b00e59 100644 --- a/tools/mapedit/src/tile_widget.cpp +++ b/tools/mapedit/src/tile_widget.cpp
@@ -1,9 +1,9 @@
1#include "tile_widget.h" 1#include "tile_widget.h"
2#include "map.h" 2#include "map.h"
3 3
4IMPLEMENT_DYNAMIC_CLASS(TileWidget,wxScrolledWindow) 4IMPLEMENT_DYNAMIC_CLASS(TileWidget,wxScrolledCanvas)
5 5
6BEGIN_EVENT_TABLE(TileWidget, wxScrolledWindow) 6BEGIN_EVENT_TABLE(TileWidget, wxScrolledCanvas)
7 EVT_PAINT(TileWidget::OnPaint) 7 EVT_PAINT(TileWidget::OnPaint)
8 EVT_LEFT_DOWN(TileWidget::OnClick) 8 EVT_LEFT_DOWN(TileWidget::OnClick)
9END_EVENT_TABLE() 9END_EVENT_TABLE()
@@ -14,7 +14,7 @@ TileWidget::TileWidget()
14} 14}
15 15
16TileWidget::TileWidget(wxWindow* parent, wxWindowID winid, int width, int scale, const wxPoint& pos, const wxSize& size) 16TileWidget::TileWidget(wxWindow* parent, wxWindowID winid, int width, int scale, const wxPoint& pos, const wxSize& size)
17 : wxScrolledWindow(parent, winid, pos, size), numTilesWidth(width), scale(scale) 17 : wxScrolledCanvas(parent, winid, pos, size), numTilesWidth(width), scale(scale)
18{ 18{
19 Init(); 19 Init();
20} 20}
diff --git a/tools/mapedit/src/tile_widget.h b/tools/mapedit/src/tile_widget.h index f4bbc07..2f1872d 100644 --- a/tools/mapedit/src/tile_widget.h +++ b/tools/mapedit/src/tile_widget.h
@@ -9,7 +9,7 @@
9 9
10#include "map.h" 10#include "map.h"
11 11
12class TileWidget : public wxScrolledWindow { 12class TileWidget : public wxScrolledCanvas {
13 public: 13 public:
14 TileWidget(); 14 TileWidget();
15 TileWidget(wxWindow* parent, wxWindowID winid, int width, int scale, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize); 15 TileWidget(wxWindow* parent, wxWindowID winid, int width, int scale, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);