Differential D825 Diff 12828 ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Terrain/Terrain.cpp
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Terrain/Terrain.cpp
/* Copyright (C) 2019 Wildfire Games. | /* Copyright (C) 2020 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 | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
Show All 11 Lines | |||||
#include "Buttons/ToolButton.h" | #include "Buttons/ToolButton.h" | ||||
#include "ScenarioEditor/ScenarioEditor.h" | #include "ScenarioEditor/ScenarioEditor.h" | ||||
#include "ScenarioEditor/Tools/Common/Brushes.h" | #include "ScenarioEditor/Tools/Common/Brushes.h" | ||||
#include "ScenarioEditor/Tools/Common/MiscState.h" | #include "ScenarioEditor/Tools/Common/MiscState.h" | ||||
#include "GameInterface/Messages.h" | #include "GameInterface/Messages.h" | ||||
#include "wx/spinctrl.h" | #include <wx/spinctrl.h> | ||||
#include "wx/listctrl.h" | #include <wx/listctrl.h> | ||||
#include "wx/image.h" | #include <wx/image.h> | ||||
#include "wx/imaglist.h" | #include <wx/imaglist.h> | ||||
#include "wx/busyinfo.h" | #include <wx/busyinfo.h> | ||||
#include "wx/notebook.h" | #include <wx/notebook.h> | ||||
class TextureNotebook; | class TextureNotebook; | ||||
class TerrainBottomBar : public wxPanel | class TerrainBottomBar : public wxPanel | ||||
{ | { | ||||
public: | public: | ||||
TerrainBottomBar(ScenarioEditor& scenarioEditor, wxWindow* parent); | TerrainBottomBar(ScenarioEditor& scenarioEditor, wxWindow* parent); | ||||
void LoadTerrain(); | void LoadTerrain(); | ||||
private: | private: | ||||
TextureNotebook* m_Textures; | TextureNotebook* m_Textures; | ||||
}; | }; | ||||
enum | enum | ||||
{ | { | ||||
ID_Passability = 1, | ID_Passability = 1, | ||||
ID_ShowPriorities, | ID_ShowPriorities | ||||
ID_ResizeMap | |||||
}; | }; | ||||
// Helper function for adding tooltips | // Helper function for adding tooltips | ||||
static wxWindow* Tooltipped(wxWindow* window, const wxString& tip) | static wxWindow* Tooltipped(wxWindow* window, const wxString& tip) | ||||
{ | { | ||||
window->SetToolTip(tip); | window->SetToolTip(tip); | ||||
return window; | return window; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Lines | m_MainSizer->Add(scrolledWindow, wxSizerFlags().Proportion(1).Expand()); | ||||
visSizer->Add(Tooltipped(m_PassabilityChoice, | visSizer->Add(Tooltipped(m_PassabilityChoice, | ||||
_("View passability classes")), wxSizerFlags().Expand()); | _("View passability classes")), wxSizerFlags().Expand()); | ||||
visSizer->Add(new wxStaticText(scrolledWindow, wxID_ANY, _("Priorities")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT)); | visSizer->Add(new wxStaticText(scrolledWindow, wxID_ANY, _("Priorities")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT)); | ||||
visSizer->Add(Tooltipped(new wxCheckBox(scrolledWindow, ID_ShowPriorities, _("")), | visSizer->Add(Tooltipped(new wxCheckBox(scrolledWindow, ID_ShowPriorities, _("")), | ||||
_("Show terrain texture priorities"))); | _("Show terrain texture priorities"))); | ||||
} | } | ||||
{ | |||||
///////////////////////////////////////////////////////////////////////// | |||||
// Misc tools | |||||
wxSizer* sizer = new wxStaticBoxSizer(wxVERTICAL, scrolledWindow, _("Misc tools")); | |||||
sizer->Add(new wxButton(scrolledWindow, ID_ResizeMap, _("Resize map")), wxSizerFlags().Expand()); | |||||
scrollSizer->Add(sizer, wxSizerFlags().Expand().Border(wxTOP, 10)); | |||||
} | |||||
m_BottomBar = new TerrainBottomBar(scenarioEditor, bottomBarContainer); | m_BottomBar = new TerrainBottomBar(scenarioEditor, bottomBarContainer); | ||||
} | } | ||||
void TerrainSidebar::OnFirstDisplay() | void TerrainSidebar::OnFirstDisplay() | ||||
{ | { | ||||
AtlasMessage::qGetTerrainPassabilityClasses qry; | AtlasMessage::qGetTerrainPassabilityClasses qry; | ||||
qry.Post(); | qry.Post(); | ||||
std::vector<std::wstring> passClasses = *qry.classNames; | std::vector<std::wstring> passClasses = *qry.classNames; | ||||
Show All 12 Lines | else | ||||
POST_MESSAGE(SetViewParamS, (AtlasMessage::eRenderView::GAME, L"passability", (std::wstring)evt.GetString().wc_str())); | POST_MESSAGE(SetViewParamS, (AtlasMessage::eRenderView::GAME, L"passability", (std::wstring)evt.GetString().wc_str())); | ||||
} | } | ||||
void TerrainSidebar::OnShowPriorities(wxCommandEvent& evt) | void TerrainSidebar::OnShowPriorities(wxCommandEvent& evt) | ||||
{ | { | ||||
POST_MESSAGE(SetViewParamB, (AtlasMessage::eRenderView::GAME, L"priorities", evt.IsChecked())); | POST_MESSAGE(SetViewParamB, (AtlasMessage::eRenderView::GAME, L"priorities", evt.IsChecked())); | ||||
} | } | ||||
void TerrainSidebar::OnResizeMap(wxCommandEvent& WXUNUSED(evt)) | |||||
{ | |||||
wxArrayString sizeNames; | |||||
std::vector<size_t> sizeTiles; | |||||
// Load the map sizes list | |||||
AtlasMessage::qGetMapSizes qrySizes; | |||||
qrySizes.Post(); | |||||
AtObj sizes = AtlasObject::LoadFromJSON(*qrySizes.sizes); | |||||
for (AtIter s = sizes["Data"]["item"]; s.defined(); ++s) | |||||
{ | |||||
sizeNames.Add(wxString::FromUTF8(s["Name"])); | |||||
sizeTiles.push_back((*s["Tiles"]).getLong()); | |||||
} | |||||
// TODO: set default based on current map size | |||||
wxSingleChoiceDialog dlg(this, _("Select new map size. WARNING: This probably only works reliably on blank maps."), | |||||
_("Resize map"), sizeNames); | |||||
if (dlg.ShowModal() != wxID_OK) | |||||
return; | |||||
size_t tiles = sizeTiles.at(dlg.GetSelection()); | |||||
POST_COMMAND(ResizeMap, (tiles)); | |||||
} | |||||
BEGIN_EVENT_TABLE(TerrainSidebar, Sidebar) | BEGIN_EVENT_TABLE(TerrainSidebar, Sidebar) | ||||
EVT_CHOICE(ID_Passability, TerrainSidebar::OnPassabilityChoice) | EVT_CHOICE(ID_Passability, TerrainSidebar::OnPassabilityChoice) | ||||
EVT_CHECKBOX(ID_ShowPriorities, TerrainSidebar::OnShowPriorities) | EVT_CHECKBOX(ID_ShowPriorities, TerrainSidebar::OnShowPriorities) | ||||
EVT_BUTTON(ID_ResizeMap, TerrainSidebar::OnResizeMap) | |||||
END_EVENT_TABLE(); | END_EVENT_TABLE(); | ||||
////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////// | ||||
class TextureNotebookPage : public wxPanel | class TextureNotebookPage : public wxPanel | ||||
{ | { | ||||
private: | private: | ||||
static const int imageWidth = 120; | static const int imageWidth = 120; | ||||
▲ Show 20 Lines • Show All 217 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator