[XMP] Fixed issue with xmp_default_volume not being correctly applied
- Added menu to modify XMP volume and state
This commit is contained in:
@@ -645,6 +645,62 @@ void EmulatorWindow::ContentInstallDialog::OnDraw(ImGuiIO& io) {
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void EmulatorWindow::XMPConfigDialog::OnDraw(ImGuiIO& io) {
|
||||
ImGui::SetNextWindowPos(ImVec2(20, 20), ImGuiCond_FirstUseEver);
|
||||
ImGui::SetNextWindowSize(ImVec2(20, 20), ImGuiCond_FirstUseEver);
|
||||
|
||||
bool dialog_open = true;
|
||||
if (!ImGui::Begin("Audio Player Menu", &dialog_open,
|
||||
ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_AlwaysAutoResize |
|
||||
ImGuiWindowFlags_HorizontalScrollbar)) {
|
||||
Close();
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
|
||||
auto audio_player = emulator_window_.emulator_->audio_media_player();
|
||||
using xmp_state = kernel::xam::apps::XmpApp::State;
|
||||
if (audio_player) {
|
||||
ImGui::Text("Audio player status:");
|
||||
ImGui::SameLine();
|
||||
switch (audio_player->GetState()) {
|
||||
case xmp_state::kIdle:
|
||||
ImGui::Text("Idle");
|
||||
break;
|
||||
case xmp_state::kPaused:
|
||||
ImGui::Text("Paused");
|
||||
break;
|
||||
case xmp_state::kPlaying:
|
||||
ImGui::Text("Playing");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (audio_player->IsPlaying()) {
|
||||
if (ImGui::Button("Pause")) {
|
||||
audio_player->Pause();
|
||||
}
|
||||
} else if (audio_player->IsPaused()) {
|
||||
if (ImGui::Button("Resume")) {
|
||||
audio_player->Continue();
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::SliderFloat("Audio player volume", &volume_, 0.0f, 1.0f)) {
|
||||
audio_player->SetVolume(volume_);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
|
||||
if (!dialog_open) {
|
||||
emulator_window_.ToggleXMPConfigDialog();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool EmulatorWindow::Initialize() {
|
||||
window_->AddListener(&window_listener_);
|
||||
window_->AddInputListener(&window_listener_, kZOrderEmulatorWindowInput);
|
||||
@@ -777,6 +833,11 @@ bool EmulatorWindow::Initialize() {
|
||||
}
|
||||
main_menu->AddChild(std::move(hid_menu));
|
||||
|
||||
// XMP menu
|
||||
main_menu->AddChild(MenuItem::Create(
|
||||
MenuItem::Type::kString, "&XMP", "",
|
||||
std::bind(&EmulatorWindow::ToggleXMPConfigDialog, this)));
|
||||
|
||||
// Help menu.
|
||||
auto help_menu = MenuItem::Create(MenuItem::Type::kPopup, "&Help");
|
||||
{
|
||||
@@ -1468,6 +1529,15 @@ void EmulatorWindow::ToggleProfilesConfigDialog() {
|
||||
}
|
||||
}
|
||||
|
||||
void EmulatorWindow::ToggleXMPConfigDialog() {
|
||||
if (!xmp_config_dialog_) {
|
||||
xmp_config_dialog_ = std::unique_ptr<XMPConfigDialog>(
|
||||
new XMPConfigDialog(imgui_drawer_.get(), *this));
|
||||
} else {
|
||||
xmp_config_dialog_.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void EmulatorWindow::ToggleControllerVibration() {
|
||||
auto input_sys = emulator()->input_system();
|
||||
if (input_sys) {
|
||||
|
||||
@@ -93,6 +93,7 @@ class EmulatorWindow {
|
||||
const xe::ui::RawImage& image);
|
||||
|
||||
void ToggleProfilesConfigDialog();
|
||||
void ToggleXMPConfigDialog();
|
||||
void SetHotkeysState(bool enabled) { disable_hotkeys_ = !enabled; }
|
||||
|
||||
// Types of button functions for hotkeys.
|
||||
@@ -208,6 +209,24 @@ class EmulatorWindow {
|
||||
EmulatorWindow& emulator_window_;
|
||||
};
|
||||
|
||||
class XMPConfigDialog final : public ui::ImGuiDialog {
|
||||
public:
|
||||
XMPConfigDialog(ui::ImGuiDrawer* imgui_drawer,
|
||||
EmulatorWindow& emulator_window)
|
||||
: ui::ImGuiDialog(imgui_drawer), emulator_window_(emulator_window) {
|
||||
if (emulator_window_.emulator_->audio_media_player()) {
|
||||
volume_ = emulator_window_.emulator_->audio_media_player()->GetVolume();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
void OnDraw(ImGuiIO& io) override;
|
||||
|
||||
private:
|
||||
EmulatorWindow& emulator_window_;
|
||||
float volume_ = 0.0f;
|
||||
};
|
||||
|
||||
explicit EmulatorWindow(Emulator* emulator,
|
||||
ui::WindowedAppContext& app_context, uint32_t width,
|
||||
uint32_t height);
|
||||
@@ -294,6 +313,8 @@ class EmulatorWindow {
|
||||
// messages back to guest.
|
||||
std::unique_ptr<ProfileConfigDialog> profile_config_dialog_;
|
||||
|
||||
std::unique_ptr<XMPConfigDialog> xmp_config_dialog_;
|
||||
|
||||
std::vector<RecentTitleEntry> recently_launched_titles_;
|
||||
};
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ class AudioMediaPlayer {
|
||||
XmpApp::PlaybackMode playback_mode_ = XmpApp::PlaybackMode::kInOrder;
|
||||
XmpApp::RepeatMode repeat_mode_ = XmpApp::RepeatMode::kPlaylist;
|
||||
XmpApp::PlaybackFlags playback_flags_ = XmpApp::PlaybackFlags::kDefault;
|
||||
float volume_ = 1.0f;
|
||||
float volume_ = 0.0f;
|
||||
uint32_t dash_init_state = 0;
|
||||
|
||||
std::unordered_map<uint32_t, std::unique_ptr<XmpApp::Playlist>> playlists_;
|
||||
|
||||
Reference in New Issue
Block a user