From bc5d22e35774d4d420673113bf7e1c3b25b1187c Mon Sep 17 00:00:00 2001 From: Kelsi Date: Thu, 7 May 2026 14:28:52 -0700 Subject: [PATCH] feat(editor): zone audio panel gets "Play" preview buttons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a small "Play" button next to the music and ambience dropdowns that hands the selected file off to the OS default audio player — 'open' on macOS, 'xdg-open' on Linux, 'start ""' on Windows. Buttons only appear when a file is set. Avoids pulling SDL_mixer (or any new dep) into the editor binary just for the preview workflow. Designers already have a working audio player; this just routes the file there with one click instead of having them hunt through Data/Sound/Music in their file manager. Closes the third leg of the original "dropdown + browse + play audio to hear it" ask: dropdown is the auto-scanned combo from the prior commit; browse-via-real-files works through the dropdown; play preview works now via OS shell. --- tools/editor/editor_ui.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/editor/editor_ui.cpp b/tools/editor/editor_ui.cpp index 311be3df..112c09b5 100644 --- a/tools/editor/editor_ui.cpp +++ b/tools/editor/editor_ui.cpp @@ -3000,6 +3000,29 @@ void EditorUI::renderPropertiesPanel(EditorApp& app) { } ImGui::EndCombo(); } + // "Play preview" via OS default audio player. Avoids + // pulling SDL_mixer into the editor binary just for the + // preview workflow — the user already has a working audio + // player and this hands the file off to it. macOS uses + // 'open', most Linux desktops use 'xdg-open', Windows + // uses 'start ""'. + auto playFile = [](const std::string& path) { + if (path.empty()) return; +#if defined(__APPLE__) + std::string cmd = "open \"" + path + "\" >/dev/null 2>&1 &"; +#elif defined(_WIN32) + std::string cmd = "start \"\" \"" + path + "\""; +#else + std::string cmd = "xdg-open \"" + path + "\" >/dev/null 2>&1 &"; +#endif + std::system(cmd.c_str()); + }; + if (!manifest.musicTrack.empty()) { + ImGui::SameLine(); + if (ImGui::SmallButton("Play##music")) playFile(manifest.musicTrack); + if (ImGui::IsItemHovered()) + ImGui::SetTooltip("Open in OS default audio player"); + } // Day-ambience dropdown. if (ImGui::BeginCombo("Ambience File##audio", manifest.ambienceDay.empty() @@ -3019,6 +3042,10 @@ void EditorUI::renderPropertiesPanel(EditorApp& app) { } ImGui::EndCombo(); } + if (!manifest.ambienceDay.empty()) { + ImGui::SameLine(); + if (ImGui::SmallButton("Play##ambDay")) playFile(manifest.ambienceDay); + } if (ImGui::InputText("Music##audio", musicBuf, sizeof(musicBuf))) manifest.musicTrack = musicBuf;