Skip to content

Commit

Permalink
Fixed Conflict Issue with Debug Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
HerpDerpinstine committed Nov 25, 2021
1 parent a2cdb8e commit 845c598
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 12 deletions.
3 changes: 1 addition & 2 deletions Bootstrap/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ void Core::Initialize(HINSTANCE hinstDLL)
Hook::Attach(&(LPVOID&)Mono::Exports::mono_jit_init_version, Mono::Hooks::mono_jit_init_version);
}

if (!Debug::Enabled)
Console::NullHandles();
Console::NullHandles();
}

bool Core::CheckPathASCII()
Expand Down
9 changes: 9 additions & 0 deletions Bootstrap/Managers/InternalCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@
void InternalCalls::Initialize()
{
Debug::Msg("Initializing Internal Calls...");
MelonDebug::AddInternalCalls();
MelonLogger::AddInternalCalls();
MelonUtils::AddInternalCalls();
GameVersionHandler::AddInternalCalls();
IIl2CppAssemblyGenerator::AddInternalCalls();
}

#pragma region MelonDebug
bool InternalCalls::MelonDebug::IsEnabled() { return Debug::Enabled; }
void InternalCalls::MelonDebug::AddInternalCalls()
{
Mono::AddInternalCall("MelonLoader.MelonDebug::IsEnabled", IsEnabled);
}
#pragma endregion

#pragma region MelonLogger
void InternalCalls::MelonLogger::Internal_Msg(Console::Color meloncolor, Console::Color txtcolor, Mono::String* namesection, Mono::String* txt)
{
Expand Down
7 changes: 7 additions & 0 deletions Bootstrap/Managers/InternalCalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ class InternalCalls
public:
static void Initialize();

class MelonDebug
{
public:
static void AddInternalCalls();
static bool IsEnabled();
};

class MelonLogger
{
public:
Expand Down
18 changes: 9 additions & 9 deletions MelonLoader/MelonLaunchOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ public static class MelonLaunchOptions
{
internal static void Load()
{
#if DEBUG
Core.DebugMode = true;
#endif
//#if DEBUG
// Core.DebugMode = true;
//#endif

string[] args = Environment.GetCommandLineArgs();
if ((args == null)
Expand All @@ -28,11 +28,11 @@ internal static void Load()
switch (arg)
{
// Core
#if !DEBUG
case "--melonloader.debug":
Core.DebugMode = true;
goto default;
#endif
//#if !DEBUG
// case "--melonloader.debug":
// Core.DebugMode = true;
// goto default;
//#endif
case "--quitfix":
Core.QuitFix = true;
goto default;
Expand Down Expand Up @@ -115,7 +115,7 @@ public enum LoadModeEnum
}
public static LoadModeEnum LoadMode_Plugins { get; internal set; }
public static LoadModeEnum LoadMode_Mods { get; internal set; }
public static bool DebugMode { get; internal set; }
//public static bool DebugMode { get; internal set; }
public static bool QuitFix { get; internal set; }
public static bool StartScreen { get; internal set; } = true;
}
Expand Down
6 changes: 5 additions & 1 deletion MelonLoader/Utils/MelonDebug.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Runtime.CompilerServices;

namespace MelonLoader
{
Expand Down Expand Up @@ -36,6 +37,9 @@ public static void Error(string txt)

public static event Action<ConsoleColor, string> MsgCallbackHandler;
public static event Action<string> ErrorCallbackHandler;
public static bool IsEnabled() => MelonLaunchOptions.Core.DebugMode;
//public static bool IsEnabled() => MelonLaunchOptions.Core.DebugMode;

[MethodImpl(MethodImplOptions.InternalCall)]
public extern static bool IsEnabled();
}
}
1 change: 1 addition & 0 deletions SM_Il2Cpp/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private static ISupportModule_To Initialize(ISupportModule_From interface_from)

ClassInjector.Detour = new UnhollowerDetour();
InitializeUnityVersion();

ConsoleCleaner();

try
Expand Down

0 comments on commit 845c598

Please sign in to comment.