Files
2026-09-16 14:07:40 +08:00

55 lines
1.0 KiB
C++

#pragma once
#include <dl.h>
using namespace dl;
class UIAudio : public UI::Scene
{
public:
UIAudio()
{
//g_midi->Play(CreateBufferView(File::GetBuffer("sound/waltz.mid")));
UI::Panel* panel = CreatePanel("root");
panel->SetPosScale({ 0.0f, 0.0f });
panel->SetPosPixel(POS_CONTENT);
UI::Panel* panel_menu = g_ui->CreatePanel();
panel_menu->SetLocator(createLocatorX(128));
g_ui->SetPanelParent(panel_menu, panel);
{
UI::ListBox* lst = g_ui->CreateListBoxDefault(false);
lst->SetItemCallback([](UI::Panel* item, Value v) {
if (v)
item->ExSetString(v.ToString());
else
item->ExSetString({});
});
_allSound = g_audio->GetAllSound();
lst->SetItemData(_allSound);
panel->Add(lst);
_edt = lst;
}
}
virtual void Render() override
{
Value v = _edt->GetSelectClickDouble();
if (v)
{
if (_snd)
_snd->Stop();
_snd = snd_play(v.ToString());
}
}
~UIAudio()
{
}
private:
std::vector<std::string> _allSound;
UI::ListBox* _edt;
gcSound _snd;
};