1 | Index: source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp
|
---|
2 | ===================================================================
|
---|
3 | --- source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp (revision 15914)
|
---|
4 | +++ source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp (working copy)
|
---|
5 | @@ -361,6 +361,7 @@
|
---|
6 | , m_FileHistory(_T("Scenario Editor"))
|
---|
7 | , m_ObjectSettings(g_SelectedObjects, AtlasMessage::eRenderView::GAME)
|
---|
8 | , m_ToolManager(this)
|
---|
9 | +, m_needsSave(false)
|
---|
10 | {
|
---|
11 | // Global application initialisation:
|
---|
12 |
|
---|
13 | @@ -537,6 +538,9 @@
|
---|
14 | // else to do))
|
---|
15 | m_Timer.SetOwner(this);
|
---|
16 | m_Timer.Start(20);
|
---|
17 | +
|
---|
18 | + //Add Observer for any changes
|
---|
19 | + m_ObjectSettings.RegisterObserver(0, &ScenarioEditor::OnObjectSettingsChanged, this);
|
---|
20 | }
|
---|
21 |
|
---|
22 | wxToolBar* ScenarioEditor::OnCreateToolBar(long style, wxWindowID id, const wxString& WXUNUSED(name))
|
---|
23 | @@ -567,9 +571,28 @@
|
---|
24 | return 1.f;
|
---|
25 | }
|
---|
26 |
|
---|
27 | +void ScenarioEditor::NotifyOnMapChanges()
|
---|
28 | +{
|
---|
29 | + m_needsSave = true;
|
---|
30 | +}
|
---|
31 |
|
---|
32 | -void ScenarioEditor::OnClose(wxCloseEvent&)
|
---|
33 | +void ScenarioEditor::OnObjectSettingsChanged(const ObjectSettings& WXUNUSED(obj))
|
---|
34 | {
|
---|
35 | + m_needsSave = true;
|
---|
36 | +}
|
---|
37 | +
|
---|
38 | +void ScenarioEditor::OnClose(wxCloseEvent& event)
|
---|
39 | +{
|
---|
40 | + //check if you start a map and not save yet
|
---|
41 | + if (event.CanVeto() && (m_needsSave || GetCommandProc().IsDirty()))
|
---|
42 | + {
|
---|
43 | + if (wxMessageBox(_T("You have unsaved changes. Are you sure you want to quit?"), _T("Discard unsaved changes?"), wxICON_QUESTION | wxYES_NO) != wxYES)
|
---|
44 | + {
|
---|
45 | + event.Veto();
|
---|
46 | + return;
|
---|
47 | + }
|
---|
48 | + }
|
---|
49 | +
|
---|
50 | m_ToolManager.SetCurrentTool(_T(""));
|
---|
51 |
|
---|
52 | m_FileHistory.SaveToSubDir(*wxConfigBase::Get());
|
---|
53 | @@ -736,6 +759,10 @@
|
---|
54 | // Wait for it to finish saving
|
---|
55 | qPing qry;
|
---|
56 | qry.Post();
|
---|
57 | +
|
---|
58 | + //Change the flag
|
---|
59 | + GetCommandProc().MarkAsSaved();
|
---|
60 | + m_needsSave = false;
|
---|
61 | }
|
---|
62 | }
|
---|
63 |
|
---|
64 | @@ -758,6 +785,10 @@
|
---|
65 | // Wait for it to finish saving
|
---|
66 | qPing qry;
|
---|
67 | qry.Post();
|
---|
68 | +
|
---|
69 | + //change the flag
|
---|
70 | + GetCommandProc().MarkAsSaved();
|
---|
71 | + m_needsSave = false;
|
---|
72 | }
|
---|
73 | }
|
---|
74 |
|
---|
75 | @@ -770,6 +801,9 @@
|
---|
76 |
|
---|
77 | if (! filename.IsEmpty())
|
---|
78 | m_FileHistory.AddFileToHistory(filename);
|
---|
79 | +
|
---|
80 | + //set the flag in false when open a file
|
---|
81 | + m_needsSave = false;
|
---|
82 | }
|
---|
83 |
|
---|
84 | void ScenarioEditor::NotifyOnMapReload()
|
---|
85 | Index: source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h
|
---|
86 | ===================================================================
|
---|
87 | --- source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h (revision 15914)
|
---|
88 | +++ source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h (working copy)
|
---|
89 | @@ -70,6 +70,9 @@
|
---|
90 | ToolManager& GetToolManager() { return m_ToolManager; }
|
---|
91 |
|
---|
92 | void SelectPage(const wxString& classname) { m_SectionLayout.SelectPage(classname); }
|
---|
93 | +
|
---|
94 | + void NotifyOnMapChanges();
|
---|
95 | + void OnObjectSettingsChanged(const ObjectSettings&);
|
---|
96 |
|
---|
97 | private:
|
---|
98 |
|
---|
99 | @@ -85,6 +88,7 @@
|
---|
100 | void SetOpenFilename(const wxString& filename);
|
---|
101 | wxString m_OpenFilename;
|
---|
102 | FileHistory m_FileHistory;
|
---|
103 | + bool m_needsSave;
|
---|
104 |
|
---|
105 | wxIcon m_Icon;
|
---|
106 | Index: source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp
|
---|
107 | ===================================================================
|
---|
108 | --- source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp (revision 15914)
|
---|
109 | +++ source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp (working copy)
|
---|
110 | @@ -547,6 +547,7 @@
|
---|
111 | }
|
---|
112 |
|
---|
113 | m_ScenarioEditor.NotifyOnMapReload();
|
---|
114 | + m_ScenarioEditor.NotifyOnMapChanges();
|
---|
115 | }
|
---|
116 |
|
---|
117 | void MapSidebar::OnOpenPlayerPanel(wxCommandEvent& WXUNUSED(evt))
|
---|
118 | Index: source/tools/atlas/AtlasUI/ScenarioEditor/Tools/AlterElevation.cpp
|
---|
119 | ===================================================================
|
---|
120 | --- source/tools/atlas/AtlasUI/ScenarioEditor/Tools/AlterElevation.cpp (revision 15914)
|
---|
121 | +++ source/tools/atlas/AtlasUI/ScenarioEditor/Tools/AlterElevation.cpp (working copy)
|
---|
122 | @@ -1,4 +1,4 @@
|
---|
123 | -/* Copyright (C) 2009 Wildfire Games.
|
---|
124 | +/* Copyright (C) 2014 Wildfire Games.
|
---|
125 | * This file is part of 0 A.D.
|
---|
126 | *
|
---|
127 | * 0 A.D. is free software: you can redistribute it and/or modify
|
---|
128 | @@ -115,6 +115,11 @@
|
---|
129 | {
|
---|
130 | POST_COMMAND(AlterElevation, (obj->m_Pos, dt*4096.f*GetDirection()*g_Brush_Elevation.GetStrength()));
|
---|
131 | obj->m_Pos = Position::Unchanged();
|
---|
132 | +
|
---|
133 | + //notify changes
|
---|
134 | + if (GetDirection() != 0)
|
---|
135 | + obj->GetScenarioEditor().NotifyOnMapChanges();
|
---|
136 | +
|
---|
137 | }
|
---|
138 |
|
---|
139 | virtual bool IsMouseUp(wxMouseEvent& evt) = 0;
|
---|
140 | Index: source/tools/atlas/AtlasUI/ScenarioEditor/Tools/FillTerrain.cpp
|
---|
141 | ===================================================================
|
---|
142 | --- source/tools/atlas/AtlasUI/ScenarioEditor/Tools/FillTerrain.cpp (revision 15914)
|
---|
143 | +++ source/tools/atlas/AtlasUI/ScenarioEditor/Tools/FillTerrain.cpp (working copy)
|
---|
144 | @@ -1,4 +1,4 @@
|
---|
145 | -/* Copyright (C) 2011 Wildfire Games.
|
---|
146 | +/* Copyright (C) 2014 Wildfire Games.
|
---|
147 | * This file is part of 0 A.D.
|
---|
148 | *
|
---|
149 | * 0 A.D. is free software: you can redistribute it and/or modify
|
---|
150 | @@ -51,7 +51,7 @@
|
---|
151 |
|
---|
152 | struct sWaiting : public State
|
---|
153 | {
|
---|
154 | - bool OnMouse(FillTerrain* WXUNUSED(obj), wxMouseEvent& evt)
|
---|
155 | + bool OnMouse(FillTerrain* obj, wxMouseEvent& evt)
|
---|
156 | {
|
---|
157 | if (evt.LeftDown())
|
---|
158 | {
|
---|
159 | @@ -58,6 +58,10 @@
|
---|
160 | Position pos(evt.GetPosition());
|
---|
161 | POST_MESSAGE(BrushPreview, (true, pos));
|
---|
162 | POST_COMMAND(FillTerrain, (pos, (std::wstring)g_SelectedTexture.wc_str()));
|
---|
163 | +
|
---|
164 | + //Notify Changes
|
---|
165 | + obj->GetScenarioEditor().NotifyOnMapChanges();
|
---|
166 | +
|
---|
167 | return true;
|
---|
168 | }
|
---|
169 | else if (evt.Moving())
|
---|
170 | Index: source/tools/atlas/AtlasUI/ScenarioEditor/Tools/FlattenElevation.cpp
|
---|
171 | ===================================================================
|
---|
172 | --- source/tools/atlas/AtlasUI/ScenarioEditor/Tools/FlattenElevation.cpp (revision 15914)
|
---|
173 | +++ source/tools/atlas/AtlasUI/ScenarioEditor/Tools/FlattenElevation.cpp (working copy)
|
---|
174 | @@ -1,4 +1,4 @@
|
---|
175 | -/* Copyright (C) 2009 Wildfire Games.
|
---|
176 | +/* Copyright (C) 2014 Wildfire Games.
|
---|
177 | * This file is part of 0 A.D.
|
---|
178 | *
|
---|
179 | * 0 A.D. is free software: you can redistribute it and/or modify
|
---|
180 | @@ -108,6 +108,9 @@
|
---|
181 | {
|
---|
182 | POST_COMMAND(FlattenElevation, (obj->m_Pos, dt*4096.f*g_Brush_Elevation.GetStrength()));
|
---|
183 | obj->m_Pos = Position::Unchanged();
|
---|
184 | +
|
---|
185 | + //notify changes
|
---|
186 | + obj->GetScenarioEditor().NotifyOnMapChanges();
|
---|
187 | }
|
---|
188 | }
|
---|
189 | Flattening;
|
---|
190 | Index: source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PaintTerrain.cpp
|
---|
191 | ===================================================================
|
---|
192 | --- source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PaintTerrain.cpp (revision 15914)
|
---|
193 | +++ source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PaintTerrain.cpp (working copy)
|
---|
194 | @@ -1,4 +1,4 @@
|
---|
195 | -/* Copyright (C) 2012 Wildfire Games.
|
---|
196 | +/* Copyright (C) 2014 Wildfire Games.
|
---|
197 | * This file is part of 0 A.D.
|
---|
198 | *
|
---|
199 | * 0 A.D. is free software: you can redistribute it and/or modify
|
---|
200 | @@ -136,6 +136,9 @@
|
---|
201 | {
|
---|
202 | POST_MESSAGE(BrushPreview, (true, obj->m_Pos));
|
---|
203 | POST_COMMAND(PaintTerrain, (obj->m_Pos, (std::wstring)g_SelectedTexture.wc_str(), GetPriority()));
|
---|
204 | +
|
---|
205 | + //Notofy Changes
|
---|
206 | + obj->GetScenarioEditor().NotifyOnMapChanges();
|
---|
207 | }
|
---|
208 |
|
---|
209 | virtual bool IsMouseUp(wxMouseEvent& evt) = 0;
|
---|
210 | Index: source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PikeElevation.cpp
|
---|
211 | ===================================================================
|
---|
212 | --- source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PikeElevation.cpp (revision 15914)
|
---|
213 | +++ source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PikeElevation.cpp (working copy)
|
---|
214 | @@ -1,4 +1,4 @@
|
---|
215 | -/* Copyright (C) 2013 Wildfire Games.
|
---|
216 | +/* Copyright (C) 2014 Wildfire Games.
|
---|
217 | * This file is part of 0 A.D.
|
---|
218 | *
|
---|
219 | * 0 A.D. is free software: you can redistribute it and/or modify
|
---|
220 | @@ -115,6 +115,10 @@
|
---|
221 | {
|
---|
222 | POST_COMMAND(PikeElevation, (obj->m_Pos, dt*4096.f*GetDirection()*g_Brush_Elevation.GetStrength()));
|
---|
223 | obj->m_Pos = Position::Unchanged();
|
---|
224 | +
|
---|
225 | + //Notify Changes
|
---|
226 | + if (GetDirection() != 0)
|
---|
227 | + obj->GetScenarioEditor().NotifyOnMapChanges();
|
---|
228 | }
|
---|
229 |
|
---|
230 | virtual bool IsMouseUp(wxMouseEvent& evt) = 0;
|
---|
231 | Index: source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PlaceObject.cpp
|
---|
232 | ===================================================================
|
---|
233 | --- source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PlaceObject.cpp (revision 15914)
|
---|
234 | +++ source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PlaceObject.cpp (working copy)
|
---|
235 | @@ -1,4 +1,4 @@
|
---|
236 | -/* Copyright (C) 2013 Wildfire Games.
|
---|
237 | +/* Copyright (C) 2014 Wildfire Games.
|
---|
238 | * This file is part of 0 A.D.
|
---|
239 | *
|
---|
240 | * 0 A.D. is free software: you can redistribute it and/or modify
|
---|
241 | @@ -55,6 +55,10 @@
|
---|
242 | POST_COMMAND(CreateObject, ((std::wstring)m_ObjectID.wc_str(), GetScenarioEditor().GetObjectSettings().GetSettings(), m_ObjPos, useTarget, m_Target, g_DefaultAngle, m_ActorSeed));
|
---|
243 | RandomizeActorSeed();
|
---|
244 | }
|
---|
245 | +
|
---|
246 | + //Notify Changes on Map
|
---|
247 | + if (!preview)
|
---|
248 | + GetScenarioEditor().NotifyOnMapChanges();
|
---|
249 | }
|
---|
250 |
|
---|
251 | virtual void Init(void* initData, ScenarioEditor* scenarioEditor)
|
---|
252 | Index: source/tools/atlas/AtlasUI/ScenarioEditor/Tools/ReplaceTerrain.cpp
|
---|
253 | ===================================================================
|
---|
254 | --- source/tools/atlas/AtlasUI/ScenarioEditor/Tools/ReplaceTerrain.cpp (revision 15914)
|
---|
255 | +++ source/tools/atlas/AtlasUI/ScenarioEditor/Tools/ReplaceTerrain.cpp (working copy)
|
---|
256 | @@ -1,4 +1,4 @@
|
---|
257 | -/* Copyright (C) 2011 Wildfire Games.
|
---|
258 | +/* Copyright (C) 2014 Wildfire Games.
|
---|
259 | * This file is part of 0 A.D.
|
---|
260 | *
|
---|
261 | * 0 A.D. is free software: you can redistribute it and/or modify
|
---|
262 | @@ -51,7 +51,7 @@
|
---|
263 |
|
---|
264 | struct sWaiting : public State
|
---|
265 | {
|
---|
266 | - bool OnMouse(ReplaceTerrain* WXUNUSED(obj), wxMouseEvent& evt)
|
---|
267 | + bool OnMouse(ReplaceTerrain* obj, wxMouseEvent& evt)
|
---|
268 | {
|
---|
269 | if (evt.LeftDown())
|
---|
270 | {
|
---|
271 | @@ -58,6 +58,9 @@
|
---|
272 | Position pos(evt.GetPosition());
|
---|
273 | POST_MESSAGE(BrushPreview, (true, pos));
|
---|
274 | POST_COMMAND(ReplaceTerrain, (pos, (std::wstring)g_SelectedTexture.wc_str()));
|
---|
275 | +
|
---|
276 | + //Notify Changes
|
---|
277 | + obj->GetScenarioEditor().NotifyOnMapChanges();
|
---|
278 | return true;
|
---|
279 | }
|
---|
280 | else if (evt.Moving())
|
---|
281 | Index: source/tools/atlas/AtlasUI/ScenarioEditor/Tools/SmoothElevation.cpp
|
---|
282 | ===================================================================
|
---|
283 | --- source/tools/atlas/AtlasUI/ScenarioEditor/Tools/SmoothElevation.cpp (revision 15914)
|
---|
284 | +++ source/tools/atlas/AtlasUI/ScenarioEditor/Tools/SmoothElevation.cpp (working copy)
|
---|
285 | @@ -1,4 +1,4 @@
|
---|
286 | -/* Copyright (C) 2010 Wildfire Games.
|
---|
287 | +/* Copyright (C) 2014 Wildfire Games.
|
---|
288 | * This file is part of 0 A.D.
|
---|
289 | *
|
---|
290 | * 0 A.D. is free software: you can redistribute it and/or modify
|
---|
291 | @@ -116,6 +116,10 @@
|
---|
292 | {
|
---|
293 | POST_COMMAND(SmoothElevation, (obj->m_Pos, dt*4096.f*GetDirection()*g_Brush_Elevation.GetStrength()));
|
---|
294 | obj->m_Pos = Position::Unchanged();
|
---|
295 | +
|
---|
296 | + //Notify Changes
|
---|
297 | + if (GetDirection() != 0)
|
---|
298 | + obj->GetScenarioEditor().NotifyOnMapChanges();
|
---|
299 | }
|
---|
300 |
|
---|
301 | virtual bool IsMouseUp(wxMouseEvent& evt) = 0;
|
---|
302 | Index: source/tools/atlas/AtlasUI/ScenarioEditor/Tools/TransformObject.cpp
|
---|
303 | ===================================================================
|
---|
304 | --- source/tools/atlas/AtlasUI/ScenarioEditor/Tools/TransformObject.cpp (revision 15914)
|
---|
305 | +++ source/tools/atlas/AtlasUI/ScenarioEditor/Tools/TransformObject.cpp (working copy)
|
---|
306 | @@ -201,6 +201,9 @@
|
---|
307 | currentSelection.Post();
|
---|
308 |
|
---|
309 | g_SelectedObjects = *currentSelection.ids;
|
---|
310 | +
|
---|
311 | + //Notify Change Maps
|
---|
312 | + GetScenarioEditor().NotifyOnMapChanges();
|
---|
313 | }
|
---|
314 |
|
---|
315 |
|
---|
316 | @@ -290,6 +293,9 @@
|
---|
317 | Position pos(evt.GetPosition());
|
---|
318 | for (size_t i = 0; i < g_SelectedObjects.size(); ++i)
|
---|
319 | POST_COMMAND(RotateObject, (g_SelectedObjects[i], true, pos, 0.f));
|
---|
320 | +
|
---|
321 | + //Notify Change Maps
|
---|
322 | + obj->GetScenarioEditor().NotifyOnMapChanges();
|
---|
323 |
|
---|
324 | return true;
|
---|
325 | }
|
---|
326 | @@ -376,6 +382,10 @@
|
---|
327 | Position pos(evt.GetPosition() + wxPoint(obj->m_dx, obj->m_dy));
|
---|
328 |
|
---|
329 | POST_COMMAND(MoveObjects, (g_SelectedObjects, obj->m_lastSelected, pos));
|
---|
330 | +
|
---|
331 | + //Notify Change Maps
|
---|
332 | + obj->GetScenarioEditor().NotifyOnMapChanges();
|
---|
333 | +
|
---|
334 | return true;
|
---|
335 | }
|
---|
336 | else
|
---|