Added ML v0.3.1 Support and Commented it Out

This commit is contained in:
Herp Derpinstine 2021-05-03 01:13:43 -05:00 committed by GitHub
parent ad61ff243a
commit f5c0b339ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 5 deletions

View File

@ -1,7 +1,6 @@
#if ML #if ML
using System; using System;
using System.IO; using System.IO;
using Harmony;
using MelonLoader; using MelonLoader;
using UnityEngine; using UnityEngine;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
@ -11,6 +10,12 @@ using UnityExplorer.Core.Config;
using UnityExplorer.Core.Input; using UnityExplorer.Core.Input;
using UnityExplorer.Loader.ML; using UnityExplorer.Loader.ML;
// TEMPORARY - JUST REQUIRED UNTIL ML 0.3.1 RELEASED
using Harmony;
// ML 0.3.1 SUPPORT
//using HarmonyLib;
[assembly: MelonInfo(typeof(ExplorerMelonMod), ExplorerCore.NAME, ExplorerCore.VERSION, ExplorerCore.AUTHOR)] [assembly: MelonInfo(typeof(ExplorerMelonMod), ExplorerCore.NAME, ExplorerCore.VERSION, ExplorerCore.AUTHOR)]
[assembly: MelonGame(null, null)] [assembly: MelonGame(null, null)]
//[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.UNIVERSAL)] //[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.UNIVERSAL)]
@ -31,6 +36,7 @@ namespace UnityExplorer
public Action<object> OnLogWarning => MelonLogger.Warning; public Action<object> OnLogWarning => MelonLogger.Warning;
public Action<object> OnLogError => MelonLogger.Error; public Action<object> OnLogError => MelonLogger.Error;
// TEMPORARY - JUST REQUIRED UNTIL ML 0.3.1 RELEASED
public Harmony.HarmonyInstance HarmonyInstance => Instance.Harmony; public Harmony.HarmonyInstance HarmonyInstance => Instance.Harmony;
public override void OnApplicationStart() public override void OnApplicationStart()
@ -73,7 +79,7 @@ namespace UnityExplorer
try try
{ {
var prop = type.GetProperty(property); var prop = type.GetProperty(property);
this.Harmony.Patch(prop.GetSetMethod(), prefix: prefix); HarmonyInstance.Patch(prop.GetSetMethod(), prefix: prefix);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -1,6 +1,5 @@
#if ML #if ML
using MelonLoader; using MelonLoader;
using MelonLoader.Tomlyn.Model;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -9,6 +8,13 @@ using UnityEngine;
using UnityExplorer.Core; using UnityExplorer.Core;
using UnityExplorer.Core.Config; using UnityExplorer.Core.Config;
// TEMPORARY - JUST REQUIRED UNTIL ML 0.3.1 RELEASED
using MelonLoader.Tomlyn.Model;
// ML 0.3.1 SUPPORT
//using Tomlet;
//using Tomlet.Models;
namespace UnityExplorer.Loader.ML namespace UnityExplorer.Loader.ML
{ {
public class MelonLoaderConfigHandler : ConfigHandler public class MelonLoaderConfigHandler : ConfigHandler
@ -21,9 +27,12 @@ namespace UnityExplorer.Loader.ML
{ {
prefCategory = MelonPreferences.CreateCategory(CTG_NAME, $"{CTG_NAME} Settings"); prefCategory = MelonPreferences.CreateCategory(CTG_NAME, $"{CTG_NAME} Settings");
// temporary until melonloader 0.3.1 released // TEMPORARY - JUST REQUIRED UNTIL ML 0.3.1 RELEASED
try { MelonPreferences.Mapper.RegisterMapper(KeycodeReader, KeycodeWriter); } catch { } try { MelonPreferences.Mapper.RegisterMapper(KeycodeReader, KeycodeWriter); } catch { }
//try { MelonPreferences.Mapper.RegisterMapper(MenuPagesReader, MenuPagesWriter); } catch { } //try { MelonPreferences.Mapper.RegisterMapper(MenuPagesReader, MenuPagesWriter); } catch { }
// ML 0.3.1 SUPPORT
//try { TomletMain.RegisterMapper(KeycodeWriter, KeycodeReader); } catch { }
} }
public override void LoadConfig() public override void LoadConfig()
@ -79,7 +88,6 @@ namespace UnityExplorer.Loader.ML
} }
// TEMPORARY - JUST REQUIRED UNTIL ML 0.3.1 RELEASED // TEMPORARY - JUST REQUIRED UNTIL ML 0.3.1 RELEASED
public static KeyCode KeycodeReader(TomlObject value) public static KeyCode KeycodeReader(TomlObject value)
{ {
try try
@ -102,6 +110,23 @@ namespace UnityExplorer.Loader.ML
return MelonPreferences.Mapper.ToToml(value.ToString()); return MelonPreferences.Mapper.ToToml(value.ToString());
} }
// ML 0.3.1 SUPPORT
/*
public static TomlValue KeycodeWriter(KeyCode value) => TomletMain.ValueFrom(value.ToString());
public static KeyCode KeycodeReader(TomlValue value)
{
try
{
KeyCode kc = (KeyCode)Enum.Parse(typeof(KeyCode), value.StringValue);
if (kc == default)
throw new Exception();
return kc;
}
catch { }
return KeyCode.F7;
}
*/
//public static UI.Main.MenuPages MenuPagesReader(TomlObject value) //public static UI.Main.MenuPages MenuPagesReader(TomlObject value)
//{ //{
// try // try