Skip to content

Commit

Permalink
fix mods with weird callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
radistmorse committed Nov 21, 2019
1 parent 05d6747 commit 7dca403
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion AdjustableModPanel.version
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"VERSION": {
"MAJOR": 1,
"MINOR": 5,
"PATCH": 3,
"PATCH": 4,
"BUILD": 0
},
"KSP_VERSION": {
Expand Down
10 changes: 9 additions & 1 deletion ModPanelComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"))
Expand Down
6 changes: 3 additions & 3 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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("")]

Expand All @@ -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")]

0 comments on commit 7dca403

Please sign in to comment.