Merge branch '4.0.0-alpha' of https://github.com/sinai-dev/Explorer into 4.0.0-alpha

This commit is contained in:
Sinai 2021-05-03 21:02:09 +10:00
commit 302ff29e36
2 changed files with 36 additions and 5 deletions

View File

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

View File

@ -1,6 +1,5 @@
#if ML
using MelonLoader;
using MelonLoader.Tomlyn.Model;
using System;
using System.Collections.Generic;
using System.Linq;
@ -9,6 +8,13 @@ using UnityEngine;
using UnityExplorer.Core;
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
{
public class MelonLoaderConfigHandler : ConfigHandler
@ -21,9 +27,12 @@ namespace UnityExplorer.Loader.ML
{
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(MenuPagesReader, MenuPagesWriter); } catch { }
// ML 0.3.1 SUPPORT
//try { TomletMain.RegisterMapper(KeycodeWriter, KeycodeReader); } catch { }
}
public override void LoadConfig()
@ -79,7 +88,6 @@ namespace UnityExplorer.Loader.ML
}
// TEMPORARY - JUST REQUIRED UNTIL ML 0.3.1 RELEASED
public static KeyCode KeycodeReader(TomlObject value)
{
try
@ -102,6 +110,23 @@ namespace UnityExplorer.Loader.ML
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)
//{
// try