From 7dca40300c1ad2b9f1c84c8de5be3138fddc08f2 Mon Sep 17 00:00:00 2001 From: morse Date: Thu, 21 Nov 2019 19:46:57 +0300 Subject: [PATCH] fix mods with weird callbacks --- AdjustableModPanel.version | 2 +- ModPanelComponent.cs | 10 +++++++++- Properties/AssemblyInfo.cs | 6 +++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/AdjustableModPanel.version b/AdjustableModPanel.version index 58d2815..55cd351 100644 --- a/AdjustableModPanel.version +++ b/AdjustableModPanel.version @@ -9,7 +9,7 @@ "VERSION": { "MAJOR": 1, "MINOR": 5, - "PATCH": 3, + "PATCH": 4, "BUILD": 0 }, "KSP_VERSION": { diff --git a/ModPanelComponent.cs b/ModPanelComponent.cs index 57b7ff4..cbcd7e3 100644 --- a/ModPanelComponent.cs +++ b/ModPanelComponent.cs @@ -24,6 +24,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Linq; using UnityEngine; namespace AdjustableModPanel { @@ -89,7 +90,14 @@ public void Update () { if (texture == null) continue; - var func = button.onTrue.GetInvocationList ()[1]; + // try any non-null callback in order + var func = new Callback[] { button.onTrue, button.onHover, button.onLeftClick, button.onEnable, button.onFalse, button.onHoverOut, button.onDisable } + .Select(cb => cb.GetInvocationList().Skip(1).FirstOrDefault()).Where(m => m != null).FirstOrDefault(); + + // button with no callbacks. Ignore. + if (func == null) + continue; + var method = func.Method.Name; var module = func.Method.Module.Name; if (module.EndsWith (".dll")) diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 4285721..cd03194 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("AdjustableModPanel")] -[assembly: AssemblyCopyright("Copyright © 2017-2018")] +[assembly: AssemblyCopyright("Copyright © 2017-2019")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.5.3.0")] -[assembly: AssemblyFileVersion("1.5.3.0")] +[assembly: AssemblyVersion("1.5.4.0")] +[assembly: AssemblyFileVersion("1.5.4.0")]