Debian Codegraph @

source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PickWaterHeight.cpp

raw
1 /* Copyright (C) 2025 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 #include "precompiled.h"
19
20 #include "tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h"
21 #include "tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/Environment.h"
22 #include "tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Tools.h"
23 #include "tools/atlas/GameInterface/Messages.h"
24 #include "tools/atlas/GameInterface/SharedTypes.h"
25
26 #include <wx/debug.h>
27 #include <wx/defs.h>
28 #include <wx/event.h>
29 #include <wx/object.h>
30
31 using AtlasMessage::Position;
32
33 class PickWaterHeight : public StateDrivenTool<PickWaterHeight>
34 {
35 DECLARE_DYNAMIC_CLASS(PickWaterHeight);
36
37 public:
38 PickWaterHeight()
39 {
40 SetState(&Waiting);
41 }
42
43 virtual void Init(void* initData, ScenarioEditor* scenarioEditor)
44 {
45 StateDrivenTool<PickWaterHeight>::Init(initData, scenarioEditor);
46
47 wxASSERT(initData);
48 Waiting.m_Sidebar = static_cast<EnvironmentSidebar*>(initData);
49 }
50
51 struct sWaiting : public State
52 {
53 // Uses a workaround to notify the environment settings directly, because
54 // we don't have any way to update them on the engine state change.
55 EnvironmentSidebar* m_Sidebar = nullptr;
56 bool OnMouse(PickWaterHeight* WXUNUSED(obj), wxMouseEvent& evt)
57 {
58 if (evt.LeftDown() && m_Sidebar)
59 {
60 POST_COMMAND(PickWaterHeight, (evt.GetPosition()));
61 m_Sidebar->UpdateEnvironmentSettings();
62 return true;
63 }
64 return false;
65 }
66 }
67 Waiting;
68 };
69
70 IMPLEMENT_DYNAMIC_CLASS(PickWaterHeight, StateDrivenTool<PickWaterHeight>);