From ae90718c0fe77024e2a3aab3a24b0244703d62b8 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 27 Aug 2020 13:52:16 +0900 Subject: [PATCH] Ensure only one callback is called KSP 1.10.1 brought back the file selected callback, but this messes with the multi-version fix, so if the new callback exists, don't set the old. What a mess. --- Source/GUI/CraftBrowser.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/GUI/CraftBrowser.cs b/Source/GUI/CraftBrowser.cs index d4102b34..db69e105 100644 --- a/Source/GUI/CraftBrowser.cs +++ b/Source/GUI/CraftBrowser.cs @@ -48,6 +48,8 @@ public class ELCraftBrowser : CraftBrowserDialog [SerializeField] private Toggle tabSub; + private SelectFileCallback onFileSelected; + static EditorFacility []craftFacility = new EditorFacility[] { EditorFacility.VAB, EditorFacility.SPH, @@ -148,7 +150,7 @@ static void CreatePrefab () void selCB (ConfigNode n, LoadType t) { Debug.Log($"[CraftBrowserDialog] OnConfigNodeSelected - " + selectedEntry.fullFilePath); - OnFileSelected(selectedEntry.fullFilePath, t); + onFileSelected(selectedEntry.fullFilePath, t); } public static ELCraftBrowser Spawn (ELCraftType type, string profile, SelectFileCallback onFileSelected, CancelledCallback onCancel, bool showMergeOption) @@ -164,10 +166,12 @@ public static ELCraftBrowser Spawn (ELCraftType type, string profile, SelectFile cb.facility = craftFacility[(int) type]; cb.showMergeOption = showMergeOption; cb.OnBrowseCancelled = onCancel; - cb.OnFileSelected = onFileSelected; + cb.onFileSelected = onFileSelected; if (onConfigNodeSelected != null) { var callback = Delegate.CreateDelegate (onConfigNodeSelected.FieldType, cb, typeof(ELCraftBrowser).GetMethod("selCB", bindingFlags)); onConfigNodeSelected.SetValue (cb, callback); + } else { + cb.OnFileSelected = onFileSelected; } cb.title = "Select a craft to load"; cb.profile = profile;