Skip to content

Commit

Permalink
Revert "Cleanup"
Browse files Browse the repository at this point in the history
This reverts commit 05e7bd2.
  • Loading branch information
HerpDerpinstine committed Dec 8, 2021
1 parent 05e7bd2 commit 74d5677
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 47 deletions.
5 changes: 3 additions & 2 deletions Bootstrap/Utils/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ bool Console::Initialize()
if (Core::IsRunningInWine())
UseLegacyColoring = true;

mode |= ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT;
mode |= 0x3;
if (!SetConsoleMode(OutputHandle, mode))
{
UseLegacyColoring = true;
mode &= ~ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT;
mode &= ~0x3;
}
else
{
Expand All @@ -73,6 +73,7 @@ bool Console::Initialize()
mode &= ~ENABLE_VIRTUAL_TERMINAL_PROCESSING;
}
}

mode |= ENABLE_EXTENDED_FLAGS;
mode &= ~ENABLE_MOUSE_INPUT;
mode &= ~ENABLE_WINDOW_INPUT;
Expand Down
8 changes: 5 additions & 3 deletions SM_Il2Cpp/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private static ISupportModule_To Initialize(ISupportModule_From interface_from)
}
catch (Exception ex) { MelonLogger.Error($"SceneManager.sceneUnloaded override failed: {ex}"); }

/*
try
{
Camera.onPostRender = (
Expand All @@ -66,8 +67,9 @@ private static ISupportModule_To Initialize(ISupportModule_From interface_from)
);
}
catch (Exception ex) { MelonLogger.Error($"Camera.onPostRender override failed: {ex}"); }
*/

//MonoEnumeratorWrapper.Register();
MonoEnumeratorWrapper.Register();

ClassInjector.RegisterTypeInIl2Cpp<SM_Component>();
SM_Component.Create();
Expand All @@ -77,8 +79,8 @@ private static ISupportModule_To Initialize(ISupportModule_From interface_from)
private static void OnSceneLoad(Scene scene, LoadSceneMode mode) { if (scene == null) return; if (MelonUtils.IsBONEWORKS) BONEWORKS_SceneHandler.OnSceneLoad(scene.buildIndex, scene.name); else Interface.OnSceneWasLoaded(scene.buildIndex, scene.name); }
private static void OnSceneUnload(Scene scene) { if (scene == null) return; Interface.OnSceneWasUnloaded(scene.buildIndex, scene.name); }

private static Camera OnPostRenderCam = null;
private static void OnPostRender(Camera cam) { if (OnPostRenderCam == null) OnPostRenderCam = cam; if (OnPostRenderCam == cam) Coroutines.ProcessWaitForEndOfFrame(); }
//private static Camera OnPostRenderCam = null;
//private static void OnPostRender(Camera cam) { if (OnPostRenderCam == null) OnPostRenderCam = cam; if (OnPostRenderCam == cam) Coroutines.ProcessWaitForEndOfFrame(); }

private static Assembly Il2Cppmscorlib = null;
private static Type streamType = null;
Expand Down
9 changes: 3 additions & 6 deletions SM_Il2Cpp/MonoEnumeratorWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@ public MonoEnumeratorWrapper(IntPtr ptr) : base(ptr) { }
public MonoEnumeratorWrapper(IEnumerator _enumerator) : base(ClassInjector.DerivedConstructorPointer<MonoEnumeratorWrapper>())
{
ClassInjector.DerivedConstructorBody(this);
enumerator = _enumerator ?? throw new NullReferenceException("routine is null");
enumerator = _enumerator ?? throw new NullReferenceException("routine is null");;
}

public Il2CppSystem.Object /*IEnumerator.*/Current
{
get
{
return enumerator.Current switch
get => enumerator.Current switch
{
null => null,
IEnumerator next => new MonoEnumeratorWrapper(next),
Il2CppSystem.Object il2cppObject => il2cppObject,
null => null,
_ => throw new NotSupportedException($"{enumerator.GetType()}: Unsupported type {enumerator.Current.GetType()}"),
};
}
}

public bool MoveNext() => enumerator.MoveNext();
Expand Down
10 changes: 3 additions & 7 deletions SM_Il2Cpp/SM_Component.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,22 @@ internal void Destroy()
void Start() => SiblingFix();
void Awake()
{
/*
foreach (var queuedCoroutine in SupportModule_To.QueuedCoroutines)
if (queuedCoroutine != null)
StartCoroutine(new Il2CppSystem.Collections.IEnumerator(new MonoEnumeratorWrapper(queuedCoroutine).Pointer));
StartCoroutine(new Il2CppSystem.Collections.IEnumerator(new MonoEnumeratorWrapper(queuedCoroutine).Pointer));
SupportModule_To.QueuedCoroutines.Clear();
SupportModule_To.ShouldUseQueue = false;
*/
}
void Update()
{
SiblingFix();
if (MelonUtils.IsBONEWORKS)
BONEWORKS_SceneHandler.OnUpdate();
Main.Interface.Update();
Coroutines.Process();
//Coroutines.Process();
}
void FixedUpdate()
{
Main.Interface.FixedUpdate();
Coroutines.ProcessWaitForFixedUpdate();
//Coroutines.ProcessWaitForFixedUpdate();
}
void LateUpdate() => Main.Interface.LateUpdate();
void OnGUI() => Main.Interface.OnGUI();
Expand Down
31 changes: 2 additions & 29 deletions SM_Il2Cpp/SupportModule_To.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ namespace MelonLoader.Support
{
internal class SupportModule_To : ISupportModule_To
{
internal static bool ShouldUseQueue = true;
internal static readonly List<IEnumerator> QueuedCoroutines = new List<IEnumerator>();

/*
public object StartCoroutine(IEnumerator coroutine)
{
if (Main.component != null)
Expand All @@ -24,34 +22,9 @@ public void StopCoroutine(object coroutineToken)
else
Main.component.StopCoroutine(coroutineToken as Coroutine);
}
*/

/*
public object StartCoroutine(IEnumerator coroutine)
{
if (coroutine != null)
{
if (!ShouldUseQueue)
return Main.component.StartCoroutine(new Il2CppSystem.Collections.IEnumerator(new MonoEnumeratorWrapper(coroutine).Pointer));
QueuedCoroutines.Add(coroutine);
}
return coroutine;
}
public void StopCoroutine(object coroutineToken)
{
if (coroutineToken != null)
{
if (ShouldUseQueue)
QueuedCoroutines.Remove(coroutineToken as IEnumerator);
else
Main.component.StopCoroutine(coroutineToken as Coroutine);
}
}
*/

public object StartCoroutine(IEnumerator coroutine) => Coroutines.Start(coroutine);
public void StopCoroutine(object coroutineToken) => Coroutines.Stop((IEnumerator)coroutineToken);
//public object StartCoroutine(IEnumerator coroutine) => Coroutines.Start(coroutine);
//public void StopCoroutine(object coroutineToken) => Coroutines.Stop((IEnumerator)coroutineToken);

public void UnityDebugLog(string msg) => Debug.Log(msg);
}
Expand Down

0 comments on commit 74d5677

Please sign in to comment.