Adds an tool to pick water high by terrain click in Atlas.
Reviewed By: trompetin17 Differential Revision: https://code.wildfiregames.com/D2037 This was SVN commit r22445.
This commit is contained in:
parent
8a32b0b3d4
commit
09e129bce2
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2017 Wildfire Games.
|
/* Copyright (C) 2019 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -198,7 +198,8 @@ END_EVENT_TABLE()
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ID_RecomputeWaterData
|
ID_RecomputeWaterData,
|
||||||
|
ID_PickWaterHeight
|
||||||
};
|
};
|
||||||
static void SendToGame(const AtlasMessage::sEnvironmentSettings& settings)
|
static void SendToGame(const AtlasMessage::sEnvironmentSettings& settings)
|
||||||
{
|
{
|
||||||
@ -219,6 +220,7 @@ EnvironmentSidebar::EnvironmentSidebar(ScenarioEditor& scenarioEditor, wxWindow*
|
|||||||
waterSizer->Add(new wxButton(scrolledWindow, ID_RecomputeWaterData, _("Reset Water Data")), wxSizerFlags().Expand());
|
waterSizer->Add(new wxButton(scrolledWindow, ID_RecomputeWaterData, _("Reset Water Data")), wxSizerFlags().Expand());
|
||||||
waterSizer->Add(m_WaterTypeList = new VariableListBox(scrolledWindow, _("Water Type"), g_EnvironmentSettings.watertype), wxSizerFlags().Expand());
|
waterSizer->Add(m_WaterTypeList = new VariableListBox(scrolledWindow, _("Water Type"), g_EnvironmentSettings.watertype), wxSizerFlags().Expand());
|
||||||
waterSizer->Add(new VariableSliderBox(scrolledWindow, _("Water height"), g_EnvironmentSettings.waterheight, 0.f, 1.2f), wxSizerFlags().Expand());
|
waterSizer->Add(new VariableSliderBox(scrolledWindow, _("Water height"), g_EnvironmentSettings.waterheight, 0.f, 1.2f), wxSizerFlags().Expand());
|
||||||
|
waterSizer->Add(new wxButton(scrolledWindow, ID_PickWaterHeight, _("Pick Water Height")), wxSizerFlags().Expand());
|
||||||
waterSizer->Add(new VariableSliderBox(scrolledWindow, _("Water waviness"), g_EnvironmentSettings.waterwaviness, 0.f, 10.f), wxSizerFlags().Expand());
|
waterSizer->Add(new VariableSliderBox(scrolledWindow, _("Water waviness"), g_EnvironmentSettings.waterwaviness, 0.f, 10.f), wxSizerFlags().Expand());
|
||||||
waterSizer->Add(new VariableSliderBox(scrolledWindow, _("Water murkiness"), g_EnvironmentSettings.watermurkiness, 0.f, 1.f), wxSizerFlags().Expand());
|
waterSizer->Add(new VariableSliderBox(scrolledWindow, _("Water murkiness"), g_EnvironmentSettings.watermurkiness, 0.f, 1.f), wxSizerFlags().Expand());
|
||||||
waterSizer->Add(new VariableSliderBox(scrolledWindow, _("Wind angle"), g_EnvironmentSettings.windangle, -M_PIf, M_PIf), wxSizerFlags().Expand());
|
waterSizer->Add(new VariableSliderBox(scrolledWindow, _("Wind angle"), g_EnvironmentSettings.windangle, -M_PIf, M_PIf), wxSizerFlags().Expand());
|
||||||
@ -269,20 +271,12 @@ void EnvironmentSidebar::OnFirstDisplay()
|
|||||||
qry_effects.Post();
|
qry_effects.Post();
|
||||||
m_PostEffectList->SetChoices(*qry_effects.posteffects);
|
m_PostEffectList->SetChoices(*qry_effects.posteffects);
|
||||||
|
|
||||||
AtlasMessage::qGetEnvironmentSettings qry_env;
|
UpdateEnvironmentSettings();
|
||||||
qry_env.Post();
|
|
||||||
g_EnvironmentSettings = qry_env.settings;
|
|
||||||
|
|
||||||
g_EnvironmentSettings.NotifyObservers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnvironmentSidebar::OnMapReload()
|
void EnvironmentSidebar::OnMapReload()
|
||||||
{
|
{
|
||||||
AtlasMessage::qGetEnvironmentSettings qry_env;
|
UpdateEnvironmentSettings();
|
||||||
qry_env.Post();
|
|
||||||
g_EnvironmentSettings = qry_env.settings;
|
|
||||||
|
|
||||||
g_EnvironmentSettings.NotifyObservers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnvironmentSidebar::RecomputeWaterData(wxCommandEvent& WXUNUSED(evt))
|
void EnvironmentSidebar::RecomputeWaterData(wxCommandEvent& WXUNUSED(evt))
|
||||||
@ -290,7 +284,22 @@ void EnvironmentSidebar::RecomputeWaterData(wxCommandEvent& WXUNUSED(evt))
|
|||||||
POST_COMMAND(RecalculateWaterData, (0.0f));
|
POST_COMMAND(RecalculateWaterData, (0.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EnvironmentSidebar::UpdateEnvironmentSettings()
|
||||||
|
{
|
||||||
|
AtlasMessage::qGetEnvironmentSettings qry_env;
|
||||||
|
qry_env.Post();
|
||||||
|
g_EnvironmentSettings = qry_env.settings;
|
||||||
|
|
||||||
|
g_EnvironmentSettings.NotifyObservers();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EnvironmentSidebar::OnPickWaterHeight(wxCommandEvent& evt)
|
||||||
|
{
|
||||||
|
m_ScenarioEditor.GetToolManager().SetCurrentTool(_T("PickWaterHeight"), this);
|
||||||
|
}
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(EnvironmentSidebar, Sidebar)
|
BEGIN_EVENT_TABLE(EnvironmentSidebar, Sidebar)
|
||||||
EVT_BUTTON(ID_RecomputeWaterData, EnvironmentSidebar::RecomputeWaterData)
|
EVT_BUTTON(ID_RecomputeWaterData, EnvironmentSidebar::RecomputeWaterData)
|
||||||
|
EVT_BUTTON(ID_PickWaterHeight, EnvironmentSidebar::OnPickWaterHeight)
|
||||||
END_EVENT_TABLE();
|
END_EVENT_TABLE();
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2009 Wildfire Games.
|
/* Copyright (C) 2019 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -26,9 +26,12 @@ class EnvironmentSidebar : public Sidebar
|
|||||||
public:
|
public:
|
||||||
EnvironmentSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer);
|
EnvironmentSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer);
|
||||||
|
|
||||||
|
void OnPickWaterHeight(wxCommandEvent& evt);
|
||||||
virtual void OnMapReload();
|
virtual void OnMapReload();
|
||||||
virtual void RecomputeWaterData(wxCommandEvent& evt);
|
virtual void RecomputeWaterData(wxCommandEvent& evt);
|
||||||
|
|
||||||
|
void UpdateEnvironmentSettings();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnFirstDisplay();
|
virtual void OnFirstDisplay();
|
||||||
|
|
||||||
|
@ -0,0 +1,72 @@
|
|||||||
|
/* Copyright (C) 2019 Wildfire Games.
|
||||||
|
* This file is part of 0 A.D.
|
||||||
|
*
|
||||||
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 0 A.D. is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "precompiled.h"
|
||||||
|
|
||||||
|
#include "Common/Tools.h"
|
||||||
|
#include "Common/MiscState.h"
|
||||||
|
#include "GameInterface/Messages.h"
|
||||||
|
#include "ScenarioEditor/Sections/Environment/Environment.h"
|
||||||
|
#include "ScenarioEditor/ScenarioEditor.h"
|
||||||
|
|
||||||
|
using AtlasMessage::Position;
|
||||||
|
|
||||||
|
class PickWaterHeight : public StateDrivenTool<PickWaterHeight>
|
||||||
|
{
|
||||||
|
DECLARE_DYNAMIC_CLASS(PickWaterHeight);
|
||||||
|
|
||||||
|
// Uses a workaround to notify the environment settings directly, because
|
||||||
|
// we don't have any way to update them on the engine state change.
|
||||||
|
EnvironmentSidebar* m_Sidebar;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PickWaterHeight()
|
||||||
|
: m_Sidebar(nullptr)
|
||||||
|
{
|
||||||
|
SetState(&Waiting);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Init(void* initData, ScenarioEditor* scenarioEditor)
|
||||||
|
{
|
||||||
|
StateDrivenTool<PickWaterHeight>::Init(initData, scenarioEditor);
|
||||||
|
|
||||||
|
wxASSERT(initData);
|
||||||
|
m_Sidebar = static_cast<EnvironmentSidebar*>(initData);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDisable()
|
||||||
|
{
|
||||||
|
if (m_Sidebar)
|
||||||
|
m_Sidebar->UpdateEnvironmentSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sWaiting : public State
|
||||||
|
{
|
||||||
|
bool OnMouse(PickWaterHeight* WXUNUSED(obj), wxMouseEvent& evt)
|
||||||
|
{
|
||||||
|
if (evt.LeftDown())
|
||||||
|
{
|
||||||
|
POST_COMMAND(PickWaterHeight, (evt.GetPosition()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Waiting;
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(PickWaterHeight, StateDrivenTool<PickWaterHeight>);
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2016 Wildfire Games.
|
/* Copyright (C) 2019 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -198,6 +198,43 @@ BEGIN_COMMAND(RecalculateWaterData)
|
|||||||
};
|
};
|
||||||
END_COMMAND(RecalculateWaterData)
|
END_COMMAND(RecalculateWaterData)
|
||||||
|
|
||||||
|
BEGIN_COMMAND(PickWaterHeight)
|
||||||
|
{
|
||||||
|
entity_pos_t m_OldWaterHeight, m_NewWaterHeight;
|
||||||
|
|
||||||
|
void Do()
|
||||||
|
{
|
||||||
|
CmpPtr<ICmpWaterManager> cmpWaterManager(*g_Game->GetSimulation2(), SYSTEM_ENTITY);
|
||||||
|
ENSURE(cmpWaterManager);
|
||||||
|
|
||||||
|
CVector3D worldPos = msg->screenPos->GetWorldSpace();
|
||||||
|
m_OldWaterHeight = cmpWaterManager->GetWaterLevel(
|
||||||
|
entity_pos_t::FromFloat(worldPos.X), entity_pos_t::FromFloat(worldPos.Z));
|
||||||
|
m_NewWaterHeight = entity_pos_t::FromFloat(worldPos.Y);
|
||||||
|
SetWaterHeight(m_NewWaterHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Redo()
|
||||||
|
{
|
||||||
|
SetWaterHeight(m_NewWaterHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Undo()
|
||||||
|
{
|
||||||
|
SetWaterHeight(m_OldWaterHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetWaterHeight(entity_pos_t height)
|
||||||
|
{
|
||||||
|
CmpPtr<ICmpWaterManager> cmpWaterManager(*g_Game->GetSimulation2(), SYSTEM_ENTITY);
|
||||||
|
ENSURE(cmpWaterManager);
|
||||||
|
|
||||||
|
cmpWaterManager->SetWaterLevel(height);
|
||||||
|
cmpWaterManager->RecomputeWaterData();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
END_COMMAND(PickWaterHeight)
|
||||||
|
|
||||||
|
|
||||||
QUERYHANDLER(GetEnvironmentSettings)
|
QUERYHANDLER(GetEnvironmentSettings)
|
||||||
{
|
{
|
||||||
|
@ -505,6 +505,8 @@ COMMAND(SetEnvironmentSettings, MERGE, // merge lots of small changes into one u
|
|||||||
|
|
||||||
COMMAND(RecalculateWaterData, NOMERGE, ((float, unused)));
|
COMMAND(RecalculateWaterData, NOMERGE, ((float, unused)));
|
||||||
|
|
||||||
|
COMMAND(PickWaterHeight, NOMERGE, ((Position, screenPos)));
|
||||||
|
|
||||||
QUERY(GetSkySets,
|
QUERY(GetSkySets,
|
||||||
// no inputs
|
// no inputs
|
||||||
,
|
,
|
||||||
|
Loading…
Reference in New Issue
Block a user