From 243ffef4fc5a3f646e60e26665e196cc7eeba2ef Mon Sep 17 00:00:00 2001 From: Sour Date: Tue, 21 Apr 2020 21:58:07 -0400 Subject: [PATCH] UI: Added shortcuts to increase/decrease master volume --- Core/EmulationSettings.h | 4 +++- Core/ShortcutKeyHandler.cpp | 4 ---- GUI.NET/Config/PreferenceInfo.cs | 3 +++ GUI.NET/Controls/ctrlNsfPlayer.cs | 2 ++ GUI.NET/Dependencies/resources.ca.xml | 2 ++ GUI.NET/Dependencies/resources.en.xml | 2 ++ GUI.NET/Dependencies/resources.es.xml | 2 ++ GUI.NET/Dependencies/resources.fr.xml | 2 ++ GUI.NET/Dependencies/resources.it.xml | 2 ++ GUI.NET/Dependencies/resources.ja.xml | 2 ++ GUI.NET/Dependencies/resources.pt.xml | 2 ++ GUI.NET/Dependencies/resources.ru.xml | 2 ++ GUI.NET/Dependencies/resources.uk.xml | 2 ++ GUI.NET/Dependencies/resources.zh.xml | 2 ++ GUI.NET/Forms/Config/ctrlEmulatorShortcuts.cs | 5 ++++- GUI.NET/Forms/frmMain.cs | 19 ++++++++++++++++++- GUI.NET/InteropEmu.cs | 4 +++- 17 files changed, 53 insertions(+), 8 deletions(-) diff --git a/Core/EmulationSettings.h b/Core/EmulationSettings.h index 6f9fb899..cb83419d 100644 --- a/Core/EmulationSettings.h +++ b/Core/EmulationSettings.h @@ -415,7 +415,6 @@ enum class EmulatorShortcut VsServiceButton2, ToggleCheats, - ToggleAudio, ToggleFastForward, ToggleRewind, ToggleKeyboardMode, @@ -462,6 +461,9 @@ enum class EmulatorShortcut ToggleSprites, ToggleBackground, ToggleDebugInfo, + ToggleAudio, + IncreaseVolume, + DecreaseVolume, LoadRandomGame, SaveStateSlot1, diff --git a/Core/ShortcutKeyHandler.cpp b/Core/ShortcutKeyHandler.cpp index 2a4c5a69..d4440b20 100644 --- a/Core/ShortcutKeyHandler.cpp +++ b/Core/ShortcutKeyHandler.cpp @@ -206,10 +206,6 @@ void ShortcutKeyHandler::CheckMappedKeys() _console->GetNotificationManager()->SendNotification(ConsoleNotificationType::ExecuteShortcut, (void*)EmulatorShortcut::ToggleCheats); } - if(DetectKeyPress(EmulatorShortcut::ToggleAudio)) { - _console->GetNotificationManager()->SendNotification(ConsoleNotificationType::ExecuteShortcut, (void*)EmulatorShortcut::ToggleAudio); - } - if(DetectKeyPress(EmulatorShortcut::RunSingleFrame)) { ProcessRunSingleFrame(); } diff --git a/GUI.NET/Config/PreferenceInfo.cs b/GUI.NET/Config/PreferenceInfo.cs index 9c866692..245465af 100644 --- a/GUI.NET/Config/PreferenceInfo.cs +++ b/GUI.NET/Config/PreferenceInfo.cs @@ -112,6 +112,9 @@ namespace Mesen.GUI.Config ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.DecreaseSpeed, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("-") })); ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.MaxSpeed, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("F9") })); + ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.IncreaseVolume, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("Ctrl"), Key2 = InteropEmu.GetKeyCode("=") })); + ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.DecreaseVolume, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("Ctrl"), Key2 = InteropEmu.GetKeyCode("-") })); + ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.ToggleFps, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("F10") })); ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.ToggleFullscreen, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("F11") })); ShortcutKeys1.Add(new ShortcutKeyInfo(EmulatorShortcut.ToggleKeyboardMode, new KeyCombination() { Key1 = InteropEmu.GetKeyCode("Scroll Lock") })); diff --git a/GUI.NET/Controls/ctrlNsfPlayer.cs b/GUI.NET/Controls/ctrlNsfPlayer.cs index 89808bbd..23414c05 100644 --- a/GUI.NET/Controls/ctrlNsfPlayer.cs +++ b/GUI.NET/Controls/ctrlNsfPlayer.cs @@ -191,6 +191,8 @@ namespace Mesen.GUI.Controls lblSlowMotion.Visible = lblSlowMotionIcon.Visible = InteropEmu.GetEmulationSpeed() < 100 && InteropEmu.GetEmulationSpeed() > 0 && !InteropEmu.CheckFlag(EmulationFlags.Turbo) && !rewinding; lblTime.Text = label; + + trkVolume.Value = (int)ConfigManager.Config.AudioInfo.MasterVolume; } private TimeSpan GetTrackLength(NsfHeader header, int track) diff --git a/GUI.NET/Dependencies/resources.ca.xml b/GUI.NET/Dependencies/resources.ca.xml index 250f16b9..482c432c 100644 --- a/GUI.NET/Dependencies/resources.ca.xml +++ b/GUI.NET/Dependencies/resources.ca.xml @@ -895,6 +895,8 @@ Carrega la partida guardada seleccionada Activa/Desactiva els trucs Activa/Desactiva el so + Increase Volume + Decrease Volume Avança un sol fotograma FDS - Expulsa el disc diff --git a/GUI.NET/Dependencies/resources.en.xml b/GUI.NET/Dependencies/resources.en.xml index a6a53a7d..166c802f 100644 --- a/GUI.NET/Dependencies/resources.en.xml +++ b/GUI.NET/Dependencies/resources.en.xml @@ -928,6 +928,8 @@ Load State Enable/Disable Cheat Codes Enable/Disable Audio + Increase Volume + Decrease Volume Run Single Frame FDS - Eject Disk diff --git a/GUI.NET/Dependencies/resources.es.xml b/GUI.NET/Dependencies/resources.es.xml index 5ec9752f..cb9e923f 100644 --- a/GUI.NET/Dependencies/resources.es.xml +++ b/GUI.NET/Dependencies/resources.es.xml @@ -912,6 +912,8 @@ Cargar partida en la posición actual Habilitar/Deshabilitar códigos de trucos Habilitar/Deshabilitar sonido + Increase Volume + Decrease Volume Ejecutar un solo fotograma FDS - Expulsar disco diff --git a/GUI.NET/Dependencies/resources.fr.xml b/GUI.NET/Dependencies/resources.fr.xml index 4023132f..c45fa854 100644 --- a/GUI.NET/Dependencies/resources.fr.xml +++ b/GUI.NET/Dependencies/resources.fr.xml @@ -926,6 +926,8 @@ Charger l'état de la position courante Activer/désactiver tous les codes Activer/désactiver l'audio + Augmenter le volume + Diminuer le volume Avancer d'une seule image FDS - Éjecter le disque diff --git a/GUI.NET/Dependencies/resources.it.xml b/GUI.NET/Dependencies/resources.it.xml index 9888dbc7..cd1ecb98 100644 --- a/GUI.NET/Dependencies/resources.it.xml +++ b/GUI.NET/Dependencies/resources.it.xml @@ -927,6 +927,8 @@ Carica Stato Attiva/Disattiva Cheat Attiva/Disattiva Audio + Increase Volume + Decrease Volume Avanti Singolo Frame FDS - Espelli Disco diff --git a/GUI.NET/Dependencies/resources.ja.xml b/GUI.NET/Dependencies/resources.ja.xml index 23bb60d4..7790efda 100644 --- a/GUI.NET/Dependencies/resources.ja.xml +++ b/GUI.NET/Dependencies/resources.ja.xml @@ -914,6 +914,8 @@ 選択中スロットからクイックロード チートコードを無効・有効にする 音声を無効・有効にする + 音量を上げる + 音量を下げる 次のフレームを表す FDS - ディスクを取り出す diff --git a/GUI.NET/Dependencies/resources.pt.xml b/GUI.NET/Dependencies/resources.pt.xml index c94e371f..cfc1936f 100644 --- a/GUI.NET/Dependencies/resources.pt.xml +++ b/GUI.NET/Dependencies/resources.pt.xml @@ -928,6 +928,8 @@ Carregar estado Ativar/desativar códigos de trapaça Ativar/desativar áudio + Increase Volume + Decrease Volume Executar um só quadro FDS - Ejetar disco diff --git a/GUI.NET/Dependencies/resources.ru.xml b/GUI.NET/Dependencies/resources.ru.xml index d81a344e..d5b49a50 100644 --- a/GUI.NET/Dependencies/resources.ru.xml +++ b/GUI.NET/Dependencies/resources.ru.xml @@ -914,6 +914,8 @@ Загрузить Enable/Disable Cheat Codes Enable/Disable Audio + Increase Volume + Decrease Volume Run Single Frame FDS - Eject Disk diff --git a/GUI.NET/Dependencies/resources.uk.xml b/GUI.NET/Dependencies/resources.uk.xml index fe6f8c0c..6a96285c 100644 --- a/GUI.NET/Dependencies/resources.uk.xml +++ b/GUI.NET/Dependencies/resources.uk.xml @@ -914,6 +914,8 @@ Завантажити Увімкнути/Вимкнути всі коди Увімкнути/Вимкнути звук + Increase Volume + Decrease Volume Перемістити вперед один кадр FDS - Витягти диск diff --git a/GUI.NET/Dependencies/resources.zh.xml b/GUI.NET/Dependencies/resources.zh.xml index b652e2f4..569d29d9 100644 --- a/GUI.NET/Dependencies/resources.zh.xml +++ b/GUI.NET/Dependencies/resources.zh.xml @@ -940,6 +940,8 @@ 载入进度 启用/禁用作弊码 静音 + Increase Volume + Decrease Volume 帧进 弹出磁盘 diff --git a/GUI.NET/Forms/Config/ctrlEmulatorShortcuts.cs b/GUI.NET/Forms/Config/ctrlEmulatorShortcuts.cs index a747588a..7194284d 100644 --- a/GUI.NET/Forms/Config/ctrlEmulatorShortcuts.cs +++ b/GUI.NET/Forms/Config/ctrlEmulatorShortcuts.cs @@ -79,8 +79,11 @@ namespace Mesen.GUI.Forms.Config EmulatorShortcut.ToggleBackground, EmulatorShortcut.ToggleSprites, EmulatorShortcut.ToggleCheats, - EmulatorShortcut.ToggleAudio, EmulatorShortcut.ToggleKeyboardMode, + + EmulatorShortcut.ToggleAudio, + EmulatorShortcut.IncreaseVolume, + EmulatorShortcut.DecreaseVolume, EmulatorShortcut.MaxSpeed, EmulatorShortcut.IncreaseSpeed, diff --git a/GUI.NET/Forms/frmMain.cs b/GUI.NET/Forms/frmMain.cs index 24cc1859..32e21252 100644 --- a/GUI.NET/Forms/frmMain.cs +++ b/GUI.NET/Forms/frmMain.cs @@ -945,7 +945,6 @@ namespace Mesen.GUI.Forms case EmulatorShortcut.Exit: this.Close(); break; case EmulatorShortcut.ToggleCheats: ToggleCheats(); break; - case EmulatorShortcut.ToggleAudio: ToggleAudio(); break; case EmulatorShortcut.ToggleFps: ToggleFps(); break; case EmulatorShortcut.ToggleBackground: ToggleBackground(); break; case EmulatorShortcut.ToggleSprites: ToggleSprites(); break; @@ -957,6 +956,10 @@ namespace Mesen.GUI.Forms case EmulatorShortcut.ToggleDebugInfo: ToggleDebugInfo(); break; case EmulatorShortcut.MaxSpeed: ToggleMaxSpeed(); break; case EmulatorShortcut.ToggleFullscreen: ToggleFullscreen(); restoreFullscreen = false; break; + + case EmulatorShortcut.ToggleAudio: ToggleAudio(); break; + case EmulatorShortcut.IncreaseVolume: IncreaseVolume(); break; + case EmulatorShortcut.DecreaseVolume: DecreaseVolume(); break; case EmulatorShortcut.OpenFile: OpenFile(); break; case EmulatorShortcut.IncreaseSpeed: InteropEmu.IncreaseEmulationSpeed(); break; @@ -1064,6 +1067,20 @@ namespace Mesen.GUI.Forms ConfigManager.ApplyChanges(); } + private void IncreaseVolume() + { + ConfigManager.Config.AudioInfo.MasterVolume = (uint)Math.Min(100, (int)ConfigManager.Config.AudioInfo.MasterVolume + 10); + AudioInfo.ApplyConfig(); + ConfigManager.ApplyChanges(); + } + + private void DecreaseVolume() + { + ConfigManager.Config.AudioInfo.MasterVolume = (uint)Math.Max(0, (int)ConfigManager.Config.AudioInfo.MasterVolume - 10); + AudioInfo.ApplyConfig(); + ConfigManager.ApplyChanges(); + } + private void ToggleFrameCounter() { ConfigManager.Config.PreferenceInfo.ShowFrameCounter = !ConfigManager.Config.PreferenceInfo.ShowFrameCounter; diff --git a/GUI.NET/InteropEmu.cs b/GUI.NET/InteropEmu.cs index 52930a78..213a0164 100644 --- a/GUI.NET/InteropEmu.cs +++ b/GUI.NET/InteropEmu.cs @@ -1895,7 +1895,6 @@ namespace Mesen.GUI VsServiceButton2, ToggleCheats, - ToggleAudio, ToggleFastForward, ToggleRewind, ToggleKeyboardMode, @@ -1942,6 +1941,9 @@ namespace Mesen.GUI ToggleSprites, ToggleBackground, ToggleDebugInfo, + ToggleAudio, + IncreaseVolume, + DecreaseVolume, LoadRandomGame, SaveStateSlot1,