mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-08 01:53:52 +00:00
feat(editor): zone audio panel gets "Play" preview buttons
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.
This commit is contained in:
parent
96ec734d06
commit
bc5d22e357
1 changed files with 27 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue