1 /* Copyright (C) 2017 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_SCENARIOEDITOR
19 #define INCLUDED_SCENARIOEDITOR
20 
21 #include "wx/toolbar.h"
22 
23 #include "General/AtlasWindowCommandProc.h"
24 #include "General/Observable.h"
25 #include "Tools/Common/ObjectSettings.h"
26 #include "Tools/Common/Tools.h"
27 #include "CustomControls/FileHistory/FileHistory.h"
28 #include "SectionLayout.h"
29 
30 #include <map>
31 
32 class ScenarioEditor : public wxFrame
33 {
34 public:
35 	ScenarioEditor(wxWindow* parent);
36 	void OnClose(wxCloseEvent& event);
37 	void OnTimer(wxTimerEvent& event);
38 	void OnIdle(wxIdleEvent& event);
39 	wxToolBar* OnCreateToolBar(long style, wxWindowID id, const wxString &name);
40 
41  	void OnNew(wxCommandEvent& event);
42 	void OnOpen(wxCommandEvent& event);
43 	void OnSave(wxCommandEvent& event);
44 	void OnSaveAs(wxCommandEvent& event);
45 	void OnImportHeightmap(wxCommandEvent& event);
46 	void OnMRUFile(wxCommandEvent& event);
47 
48 	void OnQuit(wxCommandEvent& event);
49 	void OnUndo(wxCommandEvent& event);
50 	void OnRedo(wxCommandEvent& event);
51     void OnCopy(wxCommandEvent& event);
52     void OnPaste(wxCommandEvent& event);
53 
54 	void OnWireframe(wxCommandEvent& event);
55 	void OnMessageTrace(wxCommandEvent& event);
56 	void OnScreenshot(wxCommandEvent& event);
57 	void OnMediaPlayer(wxCommandEvent& event);
58 	void OnJavaScript(wxCommandEvent& event);
59 	void OnCameraReset(wxCommandEvent& event);
60 	void OnRenderPath(wxCommandEvent& event);
61 	void OnDumpState(wxCommandEvent& event);
62 	void OnSelectedObjectsChange(const std::vector<AtlasMessage::ObjectID>& selectedObjects);
63 
64 	void OnHelp(wxCommandEvent& event);
65 
66 	void OnMenuOpen(wxMenuEvent& event);
67 
68 	bool OpenFile(const wxString& name, const wxString& filename);
69 
70 	void NotifyOnMapReload();
71 
72 	static AtlasWindowCommandProc& GetCommandProc();
73 
74 	static float GetSpeedModifier();
75 
GetObjectSettings()76 	Observable<ObjectSettings>& GetObjectSettings() { return m_ObjectSettings; }
GetMapSettings()77 	Observable<AtObj>& GetMapSettings() { return m_MapSettings; }
78 
GetToolManager()79 	ToolManager& GetToolManager() { return m_ToolManager; }
80 
SelectPage(const wxString & classname)81 	void SelectPage(const wxString& classname) { m_SectionLayout.SelectPage(classname); }
82 
83 	bool DiscardChangesDialog();
84 
85 private:
86 
87 	ToolManager m_ToolManager;
88 
89 	wxTimer m_Timer;
90 
91 	SectionLayout m_SectionLayout;
92 
93 	Observable<ObjectSettings> m_ObjectSettings;
94 	Observable<AtObj> m_MapSettings;
95 
96 	void SetOpenFilename(const wxString& filename);
97 	wxString m_OpenFilename;
98 	FileHistory m_FileHistory;
99 
100 	wxIcon m_Icon;
101 
102 	struct HelpItem
103 	{
104 		wxString m_Title, m_Tooltip, m_URL;
HelpItemHelpItem105 		HelpItem(const wxString& title, const wxString& tooltip, const wxString& url)
106 			: m_Title(title), m_Tooltip(tooltip), m_URL(url)
107 		{}
108 	};
109 	std::map<int, HelpItem> m_HelpData;
110 
111 	DECLARE_EVENT_TABLE();
112 };
113 
114 #endif // INCLUDED_SCENARIOEDITOR
115