summary refs log tree commit diff stats
path: root/tools/mapedit/src/frame.h
blob: f1e4efc7b4ff5d79d6328bd319919f95de578d96 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef FRAME_H
#define FRAME_H

#include <wx/wxprec.h>

#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif

#include "map.h"
#include "widget.h"
#include "tile_widget.h"
#include <list>
#include <wx/notebook.h>
#include <memory>
#include <wx/treectrl.h>

class MapPtrCtr : public wxTreeItemData {
  public:
    Map* map;
  
    MapPtrCtr(Map* map) : map(map) {}
};

class MapeditFrame : public wxFrame {
  public:
    MapeditFrame() {}
    MapeditFrame(std::unique_ptr<World> world);
    
    MapeditWidget* GetMapEditor();
    void StartAddingEntity();
    void FinishAddingEntity();
    void MapDirtyDidChange(bool dirty);
    
    static void NewWorld();
    static void OpenWorld(std::string filename);
    
    std::list<wxWindow*>::iterator closer;

  private:
    static void LaunchWindow(std::unique_ptr<World> world);
    void populateMapTree(wxTreeItemId node, std::list<std::shared_ptr<Map>> maps);
    void SelectMap(Map* map);
    wxTreeItemId MoveTreeNode(wxTreeItemId toCopy, wxTreeItemId newParent);
      
    void ZoomIn(wxCommandEvent& event);
    void ZoomOut(wxCommandEvent& event);
    void OnNew(wxCommandEvent& event);
    void OnOpen(wxCommandEvent& event);
    void OnSave(wxCommandEvent& event);
    void OnClose(wxCommandEvent& event);
    void OnExit(wxCloseEvent& event);
    void OnQuit(wxCommandEvent& event);
    void OnTitleChange(wxCommandEvent& event);
    void OnTabChange(wxBookCtrlEvent& event);
    void OnTabChanging(wxBookCtrlEvent& event);
    void OnAddEntity(wxCommandEvent& event);
    void OnCancelAddEntity(wxCommandEvent& event);
    void OnAddRoot(wxCommandEvent& event);
    void OnAddChild(wxCommandEvent& event);
    void OnDidSelectMap(wxTreeEvent& event);
    void OnWillSelectMap(wxTreeEvent& event);
    void OnWillDragMap(wxTreeEvent& event);
    void OnDidDragMap(wxTreeEvent& event);
    
    std::unique_ptr<World> world;
    Map* currentMap;
    MapeditWidget* mapEditor;
    TileWidget* tileEditor;
    wxTextCtrl* titleBox;
    std::string filename;
    wxNotebook* notebook;
    wxChoice* entityTypeBox;
    wxButton* addEntityButton;
    wxButton* cancelEntityButton;
    wxToolBar* toolbar;
    wxMenu* menuFile;
    wxTreeCtrl* mapTree;
    wxTreeItemId dragMap;
    
    bool addingEntity = false;
    
    wxDECLARE_EVENT_TABLE();
};

#endif