2026-05-25 02:48:30 -07:00
|
|
|
/* Copyright (C) 2026 Wildfire Games.
|
2023-12-02 16:30:12 -08:00
|
|
|
* This file is part of 0 A.D.
|
2017-04-08 19:12:20 -07:00
|
|
|
*
|
2023-12-02 16:30:12 -08:00
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
2017-04-08 19:12:20 -07:00
|
|
|
* 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.
|
|
|
|
|
*
|
2023-12-02 16:30:12 -08:00
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
2017-04-08 19:12:20 -07:00
|
|
|
* 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
|
2023-12-02 16:30:12 -08:00
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
2017-04-08 19:12:20 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
|
|
#include "Cinema.h"
|
|
|
|
|
|
2025-08-09 03:01:01 -07:00
|
|
|
#include "tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h"
|
|
|
|
|
#include "tools/atlas/AtlasUI/ScenarioEditor/Sections/Common/Sidebar.h"
|
2026-06-18 12:10:27 -07:00
|
|
|
#include "tools/atlas/AtlasUI/ScenarioEditor/StyleSheet.h"
|
2025-08-09 03:01:01 -07:00
|
|
|
#include "tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Tools.h"
|
|
|
|
|
#include "tools/atlas/GameInterface/Messages.h"
|
|
|
|
|
#include "tools/atlas/GameInterface/Shareable.h"
|
|
|
|
|
#include "tools/atlas/GameInterface/SharedTypes.h"
|
|
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <wx/button.h>
|
|
|
|
|
#include <wx/chartype.h>
|
|
|
|
|
#include <wx/checkbox.h>
|
|
|
|
|
#include <wx/listbox.h>
|
|
|
|
|
#include <wx/scrolwin.h>
|
|
|
|
|
#include <wx/sizer.h>
|
2025-08-17 10:56:35 -07:00
|
|
|
#include <wx/statbox.h>
|
2025-08-09 03:01:01 -07:00
|
|
|
#include <wx/string.h>
|
|
|
|
|
#include <wx/textctrl.h>
|
|
|
|
|
#include <wx/toolbar.h>
|
|
|
|
|
#include <wx/translation.h>
|
|
|
|
|
#include <wx/window.h>
|
2017-04-08 19:12:20 -07:00
|
|
|
|
|
|
|
|
using AtlasMessage::Shareable;
|
|
|
|
|
|
|
|
|
|
CinemaSidebar::CinemaSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer)
|
|
|
|
|
: Sidebar(scenarioEditor, sidebarContainer, bottomBarContainer)
|
|
|
|
|
{
|
2026-07-29 10:24:06 -07:00
|
|
|
{
|
|
|
|
|
auto* sizer = new wxStaticBoxSizer(wxVERTICAL, this, _T("Common settings"));
|
|
|
|
|
|
2026-07-30 10:22:27 -07:00
|
|
|
m_DrawPath = new wxCheckBox(sizer->GetStaticBox(), wxID_ANY, _("Draw all paths"));
|
2026-07-29 10:24:06 -07:00
|
|
|
m_DrawPath->SetToolTip(_("Display every cinematic path added to the map"));
|
2026-07-30 10:22:27 -07:00
|
|
|
m_DrawPath->Bind(wxEVT_CHECKBOX, [this](auto&){ SetPathsDrawing(m_DrawPath->IsChecked()); });
|
2026-07-29 10:24:06 -07:00
|
|
|
|
|
|
|
|
sizer->Add(m_DrawPath, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
|
|
|
|
|
|
|
|
|
|
m_MainSizer->Add(sizer, wxSizerFlags().Expand());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
auto* boxSizer = new wxStaticBoxSizer(wxVERTICAL, this, _T("Paths"));
|
|
|
|
|
auto* box = boxSizer->GetStaticBox();
|
2017-04-08 19:12:20 -07:00
|
|
|
|
2026-07-30 10:22:27 -07:00
|
|
|
m_PathList = new wxListBox(box, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE | wxLB_SORT);
|
2017-04-08 19:12:20 -07:00
|
|
|
|
2026-07-30 10:22:27 -07:00
|
|
|
auto* deleteButton = new wxButton(box, wxID_ANY, _("Delete"));
|
2026-07-29 10:24:06 -07:00
|
|
|
deleteButton->SetToolTip(_T("Delete selected path"));
|
2026-07-30 10:22:27 -07:00
|
|
|
deleteButton->Bind(wxEVT_BUTTON, [this](auto&){ DeleteSelectedPath(); });
|
2017-04-08 19:12:20 -07:00
|
|
|
|
2026-07-30 10:22:27 -07:00
|
|
|
auto* newPathName = new wxTextCtrl(box, wxID_ANY);
|
2017-04-17 20:30:16 -07:00
|
|
|
|
2026-07-30 10:22:27 -07:00
|
|
|
auto* addButton = new wxButton(box, wxID_ANY, _("Add"));
|
|
|
|
|
addButton->Bind(wxEVT_BUTTON, [this, newPathName](auto&){ AddPath(newPathName->GetValue()); newPathName->Clear(); });
|
2026-06-18 12:10:27 -07:00
|
|
|
|
2026-07-29 10:24:06 -07:00
|
|
|
wxFlexGridSizer* pathsSizer = new wxFlexGridSizer(1, 5, 5);
|
|
|
|
|
pathsSizer->AddGrowableCol(0);
|
|
|
|
|
pathsSizer->Add(m_PathList, wxSizerFlags().Proportion(1).Expand());
|
|
|
|
|
pathsSizer->Add(deleteButton, wxSizerFlags().Expand());
|
2026-07-30 10:22:27 -07:00
|
|
|
pathsSizer->Add(newPathName, wxSizerFlags().Expand());
|
2026-07-29 10:24:06 -07:00
|
|
|
pathsSizer->Add(addButton, wxSizerFlags().Expand());
|
2026-05-25 02:48:30 -07:00
|
|
|
|
2026-07-29 10:24:06 -07:00
|
|
|
boxSizer->Add(pathsSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING));
|
2017-04-17 20:30:16 -07:00
|
|
|
|
2026-07-29 10:24:06 -07:00
|
|
|
m_MainSizer->Add(boxSizer, wxSizerFlags().Expand());
|
|
|
|
|
}
|
2017-04-08 19:12:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CinemaSidebar::OnFirstDisplay()
|
|
|
|
|
{
|
|
|
|
|
m_DrawPath->SetValue(false);
|
2017-04-17 20:30:16 -07:00
|
|
|
|
|
|
|
|
ReloadPathList();
|
2017-04-08 19:12:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CinemaSidebar::OnMapReload()
|
|
|
|
|
{
|
|
|
|
|
m_DrawPath->SetValue(false);
|
2017-04-17 20:30:16 -07:00
|
|
|
|
|
|
|
|
ReloadPathList();
|
2017-04-08 19:12:20 -07:00
|
|
|
}
|
|
|
|
|
|
2026-07-30 10:22:27 -07:00
|
|
|
void CinemaSidebar::SetPathsDrawing(const bool enable)
|
2017-04-08 19:12:20 -07:00
|
|
|
{
|
2026-07-30 10:22:27 -07:00
|
|
|
POST_COMMAND(SetCinemaPathsDrawing, (enable));
|
2017-04-08 19:12:20 -07:00
|
|
|
}
|
|
|
|
|
|
2026-07-30 10:22:27 -07:00
|
|
|
void CinemaSidebar::AddPath(wxString name)
|
2017-04-17 20:30:16 -07:00
|
|
|
{
|
2026-07-30 10:22:27 -07:00
|
|
|
if (name.empty())
|
2017-04-17 20:30:16 -07:00
|
|
|
return;
|
|
|
|
|
|
2026-07-30 10:22:27 -07:00
|
|
|
POST_COMMAND(AddCinemaPath, (name.ToStdWstring()));
|
2017-04-17 20:30:16 -07:00
|
|
|
ReloadPathList();
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-30 10:22:27 -07:00
|
|
|
void CinemaSidebar::DeleteSelectedPath()
|
2017-04-17 20:30:16 -07:00
|
|
|
{
|
|
|
|
|
int index = m_PathList->GetSelection();
|
|
|
|
|
if (index < 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
wxString pathName = m_PathList->GetString(index);
|
|
|
|
|
if (pathName.empty())
|
|
|
|
|
return;
|
|
|
|
|
|
2026-07-19 10:06:49 -07:00
|
|
|
POST_COMMAND(DeleteCinemaPath, (pathName.ToStdWstring()));
|
2017-04-17 20:30:16 -07:00
|
|
|
ReloadPathList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CinemaSidebar::ReloadPathList()
|
|
|
|
|
{
|
2026-07-25 04:41:35 -07:00
|
|
|
const wxString selection = m_PathList->GetStringSelection();
|
2017-04-17 20:30:16 -07:00
|
|
|
|
|
|
|
|
AtlasMessage::qGetCinemaPaths query_paths;
|
|
|
|
|
query_paths.Post();
|
|
|
|
|
|
|
|
|
|
m_PathList->Clear();
|
|
|
|
|
for (const AtlasMessage::sCinemaPath& path : *query_paths.paths)
|
|
|
|
|
m_PathList->Append(*path.name);
|
2026-07-25 04:41:35 -07:00
|
|
|
|
|
|
|
|
m_PathList->SetStringSelection(selection);
|
2017-04-17 20:30:16 -07:00
|
|
|
}
|