diff --git a/BizHawk.Client.EmuHawk/MainForm.Events.cs b/BizHawk.Client.EmuHawk/MainForm.Events.cs index 3d9ceafc39..ad0ab26dcb 100644 --- a/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -1372,7 +1372,6 @@ namespace BizHawk.Client.EmuHawk RamSearchMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["RAM Search"].Bindings; HexEditorMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Hex Editor"].Bindings; LuaConsoleMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Lua Console"].Bindings; - LuaConsoleMenuItem.Enabled = GlobalWin.Tools.IsAvailable(); CheatsMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Cheats"].Bindings; TAStudioMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["TAStudio"].Bindings; VirtualPadMenuItem.ShortcutKeyDisplayString = Global.Config.HotkeyBindings["Virtual Pad"].Bindings; diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs index 54a712d951..214d69d665 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs @@ -114,10 +114,7 @@ namespace BizHawk.Client.EmuHawk public bool IsRunning { get; set; } public bool FrameAdvanceRequested { get; private set; } - public override LuaFunctionList GetRegisteredFunctions() - { - return EventsLibrary.RegisteredFunctions; - } + public override LuaFunctionList RegisteredFunctions => EventsLibrary.RegisteredFunctions; public override void WindowClosed(IntPtr handle) { diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/NotReallyLuaLibrary.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/NotReallyLuaLibrary.cs index e47b7e750b..156a47cfe5 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/NotReallyLuaLibrary.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/NotReallyLuaLibrary.cs @@ -35,10 +35,7 @@ namespace BizHawk.Client.EmuHawk { } private static readonly LuaFunctionList EmptyLuaFunList = new LuaFunctionList(); - public override LuaFunctionList GetRegisteredFunctions() - { - return EmptyLuaFunList; - } + public override LuaFunctionList RegisteredFunctions => EmptyLuaFunList; public override void Restart(IEmulatorServiceProvider newServiceProvider) { } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/PlatformEmuLuaLibrary.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/PlatformEmuLuaLibrary.cs index 0921a103db..d831bbd078 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/PlatformEmuLuaLibrary.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/PlatformEmuLuaLibrary.cs @@ -11,6 +11,7 @@ namespace BizHawk.Client.EmuHawk public abstract class PlatformEmuLuaLibrary { public readonly LuaDocumentation Docs = new LuaDocumentation(); + public abstract LuaFunctionList RegisteredFunctions { get; } public GuiLuaLibrary GuiLibrary => (GuiLuaLibrary) Libraries[typeof(GuiLuaLibrary)]; protected readonly Dictionary Libraries = new Dictionary(); public IEnumerable RunningScripts => ScriptList.Where(lf => lf.Enabled); @@ -27,7 +28,6 @@ namespace BizHawk.Client.EmuHawk public abstract void Close(); public abstract void EndLuaDrawing(); public abstract void ExecuteString(string command); - public abstract LuaFunctionList GetRegisteredFunctions(); public abstract void Restart(IEmulatorServiceProvider newServiceProvider); public abstract EmuLuaLibrary.ResumeResult ResumeScriptFromThreadOf(LuaFile lf); public abstract void SpawnAndSetFileThread(string pathToLoad, LuaFile lf); diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index 01e38c2b0d..d00974ee8f 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -176,7 +176,7 @@ namespace BizHawk.Client.EmuHawk { LuaImp.CallExitEvent(file); - LuaImp.GetRegisteredFunctions().RemoveAll(lf => lf.Lua == file.Thread); + LuaImp.RegisteredFunctions.RemoveAll(lf => lf.Lua == file.Thread); UpdateRegisteredFunctionsDialog(); @@ -795,7 +795,7 @@ namespace BizHawk.Client.EmuHawk SelectAllMenuItem.Enabled = LuaImp.ScriptList.Any(); StopAllScriptsMenuItem.Enabled = LuaImp.ScriptList.Any(script => script.Enabled); - RegisteredFunctionsMenuItem.Enabled = LuaImp.GetRegisteredFunctions().Any(); + RegisteredFunctionsMenuItem.Enabled = LuaImp.RegisteredFunctions.Any(); } private void NewScriptMenuItem_Click(object sender, EventArgs e) @@ -857,7 +857,7 @@ namespace BizHawk.Client.EmuHawk foreach (var selectedItem in SelectedItems) { var temp = selectedItem; - LuaImp.GetRegisteredFunctions().RemoveAll(lf => lf.Lua == temp.Thread); + LuaImp.RegisteredFunctions.RemoveAll(lf => lf.Lua == temp.Thread); UpdateRegisteredFunctionsDialog(); } @@ -865,7 +865,7 @@ namespace BizHawk.Client.EmuHawk file.Stop(); if (Global.Config.RemoveRegisteredFunctionsOnToggle) { - LuaImp.GetRegisteredFunctions().ClearAll(); + LuaImp.RegisteredFunctions.ClearAll(); } } } @@ -945,7 +945,7 @@ namespace BizHawk.Client.EmuHawk foreach (var item in items) { var temp = item; - LuaImp.GetRegisteredFunctions().RemoveAll(x => x.Lua == temp.Thread); + LuaImp.RegisteredFunctions.RemoveAll(x => x.Lua == temp.Thread); LuaImp.ScriptList.Remove(item); } @@ -1064,7 +1064,7 @@ namespace BizHawk.Client.EmuHawk private void RegisteredFunctionsMenuItem_Click(object sender, EventArgs e) { - if (LuaImp.GetRegisteredFunctions().Any()) + if (LuaImp.RegisteredFunctions.Any()) { var alreadyOpen = false; foreach (Form form in Application.OpenForms) @@ -1221,7 +1221,7 @@ namespace BizHawk.Client.EmuHawk private void ConsoleContextMenu_Opening(object sender, CancelEventArgs e) { - RegisteredFunctionsContextItem.Enabled = LuaImp.GetRegisteredFunctions().Any(); + RegisteredFunctionsContextItem.Enabled = LuaImp.RegisteredFunctions.Any(); CopyContextItem.Enabled = OutputBox.SelectedText.Any(); ClearConsoleContextItem.Enabled = SelectAllContextItem.Enabled = diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.cs index b6c838e4c0..c42dc73fae 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.cs @@ -17,7 +17,7 @@ namespace BizHawk.Client.EmuHawk public void UpdateValues() { - if (GlobalWin.Tools.LuaConsole.LuaImp.GetRegisteredFunctions().Any()) + if (GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.Any()) { PopulateListView(); } @@ -46,7 +46,7 @@ namespace BizHawk.Client.EmuHawk { FunctionView.Items.Clear(); - var nlfs = GlobalWin.Tools.LuaConsole.LuaImp.GetRegisteredFunctions().OrderBy(x => x.Event).ThenBy(x => x.Name); + var nlfs = GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.OrderBy(x => x.Event).ThenBy(x => x.Name); foreach (var nlf in nlfs) { var item = new ListViewItem { Text = nlf.Event }; @@ -76,7 +76,7 @@ namespace BizHawk.Client.EmuHawk foreach (int index in indices) { var guid = FunctionView.Items[index].SubItems[2].Text; - GlobalWin.Tools.LuaConsole.LuaImp.GetRegisteredFunctions()[guid].Call(); + GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions[guid].Call(); } } } @@ -89,8 +89,8 @@ namespace BizHawk.Client.EmuHawk foreach (int index in indices) { var guid = FunctionView.Items[index].SubItems[2].Text; - var nlf = GlobalWin.Tools.LuaConsole.LuaImp.GetRegisteredFunctions()[guid]; - GlobalWin.Tools.LuaConsole.LuaImp.GetRegisteredFunctions().Remove(nlf); + var nlf = GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions[guid]; + GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.Remove(nlf); } PopulateListView(); @@ -109,7 +109,7 @@ namespace BizHawk.Client.EmuHawk private void RemoveAllBtn_Click(object sender, EventArgs e) { - GlobalWin.Tools.LuaConsole.LuaImp.GetRegisteredFunctions().ClearAll(); + GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.ClearAll(); PopulateListView(); } @@ -118,7 +118,7 @@ namespace BizHawk.Client.EmuHawk var indexes = FunctionView.SelectedIndices; CallButton.Enabled = indexes.Count > 0; RemoveButton.Enabled = indexes.Count > 0; - RemoveAllBtn.Enabled = GlobalWin.Tools.LuaConsole.LuaImp.GetRegisteredFunctions().Any(); + RemoveAllBtn.Enabled = GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.Any(); } private void FunctionView_KeyDown(object sender, KeyEventArgs e) diff --git a/Bizware/BizHawk.Bizware.BizwareGL.OpenTK/IGL_TK.cs b/Bizware/BizHawk.Bizware.BizwareGL.OpenTK/IGL_TK.cs index 9a5eca933a..33971f2807 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL.OpenTK/IGL_TK.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL.OpenTK/IGL_TK.cs @@ -303,7 +303,7 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.OpenTK { int size, length; ActiveUniformType type; - string name = new System.Text.StringBuilder(1024).ToString().ToString(); + string name = new System.Text.StringBuilder(1024).ToString(); GL.GetActiveUniform(pid, i, 1024, out length, out size, out type, out name); errcode = GL.GetError(); int loc = GL.GetUniformLocation(pid, name); diff --git a/Bizware/BizHawk.Bizware.BizwareGL.SlimDX/IGL_SlimDX9.cs b/Bizware/BizHawk.Bizware.BizwareGL.SlimDX/IGL_SlimDX9.cs index 912d9ba634..b88cb2164f 100644 --- a/Bizware/BizHawk.Bizware.BizwareGL.SlimDX/IGL_SlimDX9.cs +++ b/Bizware/BizHawk.Bizware.BizwareGL.SlimDX/IGL_SlimDX9.cs @@ -298,35 +298,29 @@ namespace BizHawk.Bizware.BizwareGL.Drivers.SlimDX Blend ConvertBlendArg(gl.BlendingFactorDest glmode) { return ConvertBlendArg((gl.BlendingFactorSrc)glmode); } - Blend ConvertBlendArg(gl.BlendingFactorSrc glmode) + Blend ConvertBlendArg(gl.BlendingFactorSrc glmode) => glmode switch { - if(glmode == gl.BlendingFactorSrc.Zero) return Blend.Zero; - if(glmode == gl.BlendingFactorSrc.One) return Blend.One; - if(glmode == gl.BlendingFactorSrc.SrcColor) return Blend.SourceColor; - if(glmode == gl.BlendingFactorSrc.OneMinusSrcColor) return Blend.InverseSourceColor; - if(glmode == gl.BlendingFactorSrc.SrcAlpha) return Blend.SourceAlpha; - if(glmode == gl.BlendingFactorSrc.OneMinusSrcAlpha) return Blend.InverseSourceAlpha; - if(glmode == gl.BlendingFactorSrc.DstAlpha) return Blend.DestinationAlpha; - if(glmode == gl.BlendingFactorSrc.OneMinusDstAlpha) return Blend.InverseDestinationAlpha; - if(glmode == gl.BlendingFactorSrc.DstColor) return Blend.DestinationColor; - if(glmode == gl.BlendingFactorSrc.OneMinusDstColor) return Blend.InverseDestinationColor; - if(glmode == gl.BlendingFactorSrc.SrcAlphaSaturate) return Blend.SourceAlphaSaturated; - if(glmode == gl.BlendingFactorSrc.ConstantColor) return Blend.BlendFactor; - if(glmode == gl.BlendingFactorSrc.OneMinusConstantColor) return Blend.InverseBlendFactor; - if(glmode == gl.BlendingFactorSrc.ConstantAlpha) throw new NotSupportedException(); - if(glmode == gl.BlendingFactorSrc.OneMinusConstantAlpha) throw new NotSupportedException(); - if(glmode == gl.BlendingFactorSrc.Src1Alpha) throw new NotSupportedException(); - if(glmode == gl.BlendingFactorSrc.Src1Color) throw new NotSupportedException(); - if(glmode == gl.BlendingFactorSrc.OneMinusSrc1Color) throw new NotSupportedException(); - if (glmode == gl.BlendingFactorSrc.OneMinusSrc1Alpha) throw new NotSupportedException(); - /* Compiles when commented - if(glmode == gl.BlendingFactorSrc.ConstantColorExt) throw new NotSupportedException(); - if(glmode == gl.BlendingFactorSrc.OneMinusConstantColorExt) throw new NotSupportedException(); - if(glmode == gl.BlendingFactorSrc.ConstantAlphaExt) throw new NotSupportedException(); - if(glmode == gl.BlendingFactorSrc.OneMinusConstantAlphaExt) throw new NotSupportedException(); - */ - throw new ArgumentOutOfRangeException(); - } + gl.BlendingFactorSrc.Zero => Blend.Zero, + gl.BlendingFactorSrc.One => Blend.One, + gl.BlendingFactorSrc.SrcColor => Blend.SourceColor, + gl.BlendingFactorSrc.OneMinusSrcColor => Blend.InverseSourceColor, + gl.BlendingFactorSrc.SrcAlpha => Blend.SourceAlpha, + gl.BlendingFactorSrc.OneMinusSrcAlpha => Blend.InverseSourceAlpha, + gl.BlendingFactorSrc.DstAlpha => Blend.DestinationAlpha, + gl.BlendingFactorSrc.OneMinusDstAlpha => Blend.InverseDestinationAlpha, + gl.BlendingFactorSrc.DstColor => Blend.DestinationColor, + gl.BlendingFactorSrc.OneMinusDstColor => Blend.InverseDestinationColor, + gl.BlendingFactorSrc.SrcAlphaSaturate => Blend.SourceAlphaSaturated, + gl.BlendingFactorSrc.ConstantColor => Blend.BlendFactor, + gl.BlendingFactorSrc.OneMinusConstantColor => Blend.InverseBlendFactor, + gl.BlendingFactorSrc.ConstantAlpha => throw new NotSupportedException(), + gl.BlendingFactorSrc.OneMinusConstantAlpha => throw new NotSupportedException(), + gl.BlendingFactorSrc.Src1Alpha => throw new NotSupportedException(), + gl.BlendingFactorSrc.Src1Color => throw new NotSupportedException(), + gl.BlendingFactorSrc.OneMinusSrc1Color => throw new NotSupportedException(), + gl.BlendingFactorSrc.OneMinusSrc1Alpha => throw new NotSupportedException(), + _ => throw new ArgumentOutOfRangeException() + }; public void SetBlendState(IBlendState rsBlend) {