/* Copyright (C) 2026 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 . */ #include "precompiled.h" #include "Cinema.h" #include "tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h" #include "tools/atlas/AtlasUI/ScenarioEditor/Sections/Common/Sidebar.h" #include "tools/atlas/AtlasUI/ScenarioEditor/StyleSheet.h" #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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include using AtlasMessage::Shareable; enum { ID_PathsDrawing, ID_PathsList, ID_AddPath, ID_DeletePath }; // Helper function for adding tooltips static wxWindow* Tooltipped(wxWindow* window, const wxString& tip) { window->SetToolTip(tip); return window; } CinemaSidebar::CinemaSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer) : Sidebar(scenarioEditor, sidebarContainer, bottomBarContainer) { wxStaticBoxSizer* commonSizer = new wxStaticBoxSizer(wxVERTICAL, this, _T("Common settings")); m_MainSizer->Add(commonSizer, wxSizerFlags().Expand()); wxFlexGridSizer* gridSizer = new wxFlexGridSizer(1, 5, 5); gridSizer->AddGrowableCol(0); gridSizer->Add(Tooltipped(m_DrawPath = new wxCheckBox(commonSizer->GetStaticBox(), ID_PathsDrawing, _("Draw all paths")), _("Display every cinematic path added to the map"))); commonSizer->Add(gridSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING)); // Paths list panel wxStaticBoxSizer* pathsBoxSizer = new wxStaticBoxSizer(wxVERTICAL, commonSizer->GetStaticBox(), _T("Paths")); wxStaticBox* pathsBox = pathsBoxSizer->GetStaticBox(); gridSizer->Add(pathsBoxSizer, wxSizerFlags().Proportion(1).Expand()); wxFlexGridSizer* pathsSizer = new wxFlexGridSizer(1, 5, 5); pathsSizer->AddGrowableCol(0); pathsBoxSizer->Add(pathsSizer, wxSizerFlags().Expand().Border(wxALL, Atlas::Style::STATICBOX_PADDING)); pathsSizer->Add(m_PathList = new wxListBox(pathsBox, ID_PathsList, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE | wxLB_SORT), wxSizerFlags().Proportion(1).Expand()); commonSizer->AddSpacer(3); pathsSizer->Add(Tooltipped(new wxButton(pathsBox, ID_DeletePath, _("Delete")), _T("Delete selected path")), wxSizerFlags().Expand()); pathsSizer->Add(m_NewPathName = new wxTextCtrl(pathsBox, wxID_ANY), wxSizerFlags().Expand()); pathsSizer->Add(new wxButton(pathsBox, ID_AddPath, _("Add")), wxSizerFlags().Expand()); } void CinemaSidebar::OnFirstDisplay() { m_DrawPath->SetValue(false); ReloadPathList(); } void CinemaSidebar::OnMapReload() { m_DrawPath->SetValue(false); ReloadPathList(); } void CinemaSidebar::OnTogglePathsDrawing(wxCommandEvent& evt) { POST_COMMAND(SetCinemaPathsDrawing, (evt.IsChecked())); } void CinemaSidebar::OnAddPath(wxCommandEvent&) { if (m_NewPathName->GetValue().empty()) return; POST_COMMAND(AddCinemaPath, (m_NewPathName->GetValue().ToStdWstring())); m_NewPathName->Clear(); ReloadPathList(); } void CinemaSidebar::OnDeletePath(wxCommandEvent&) { int index = m_PathList->GetSelection(); if (index < 0) return; wxString pathName = m_PathList->GetString(index); if (pathName.empty()) return; POST_COMMAND(DeleteCinemaPath, (pathName.ToStdWstring())); ReloadPathList(); } void CinemaSidebar::ReloadPathList() { const wxString selection = m_PathList->GetStringSelection(); AtlasMessage::qGetCinemaPaths query_paths; query_paths.Post(); m_PathList->Clear(); for (const AtlasMessage::sCinemaPath& path : *query_paths.paths) m_PathList->Append(*path.name); m_PathList->SetStringSelection(selection); } wxBEGIN_EVENT_TABLE(CinemaSidebar, Sidebar) EVT_CHECKBOX(ID_PathsDrawing, CinemaSidebar::OnTogglePathsDrawing) EVT_BUTTON(ID_AddPath, CinemaSidebar::OnAddPath) EVT_BUTTON(ID_DeletePath, CinemaSidebar::OnDeletePath) wxEND_EVENT_TABLE();