Unify Get/SetSoundOn across Lua and C# APIs (resolves #1817)

This commit is contained in:
YoshiRulz 2020-03-13 08:46:45 +10:00
parent f7caa414b6
commit 9e514dcebd
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 6 additions and 16 deletions

View File

@ -530,13 +530,10 @@ namespace BizHawk.Client.ApiHawk
public static void SetSoundOn(bool enable)
{
Global.Config.SoundEnabled = enable;
if (enable != Global.Config.SoundEnabled) InvokeMainFormMethod("ToggleSound");
}
public static bool GetSoundOn()
{
return Global.Config.SoundEnabled;
}
public static bool GetSoundOn() => Global.Config.SoundEnabled;
public static bool IsPaused()
{

View File

@ -2374,7 +2374,7 @@ namespace BizHawk.Client.EmuHawk
Config.DisplayInput ^= true;
}
private void ToggleSound()
public void ToggleSound()
{
Config.SoundEnabled ^= true;
Sound.StopSound();

View File

@ -9,6 +9,7 @@ using System.Threading;
using System.Diagnostics;
using BizHawk.Common;
using BizHawk.Client.ApiHawk;
// ReSharper disable StringLiteralTypo
// ReSharper disable UnusedMember.Global
@ -173,19 +174,11 @@ namespace BizHawk.Client.EmuHawk
[LuaMethodExample("client.SetSoundOn( true );")]
[LuaMethod("SetSoundOn", "Sets the state of the Sound On toggle")]
public static void SetSoundOn(bool enable)
{
Global.Config.SoundEnabled = enable;
GlobalWin.Sound.StopSound();
GlobalWin.Sound.StartSound();
}
public static void SetSoundOn(bool enable) => ClientApi.SetSoundOn(enable);
[LuaMethodExample("if ( client.GetSoundOn( ) ) then\r\n\tconsole.log( \"Gets the state of the Sound On toggle\" );\r\nend;")]
[LuaMethod("GetSoundOn", "Gets the state of the Sound On toggle")]
public static bool GetSoundOn()
{
return Global.Config.SoundEnabled;
}
public static bool GetSoundOn() => ClientApi.GetSoundOn();
[LuaMethodExample("client.SetClientExtraPadding( 5, 10, 15, 20 );")]
[LuaMethod("SetClientExtraPadding", "Sets the extra padding added to the 'native' surface so that you can draw HUD elements in predictable placements")]