-
-
Notifications
You must be signed in to change notification settings - Fork 491
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Welcome Message, Engine Agnostic Launch Options
- Loading branch information
1 parent
0f99afd
commit e179c05
Showing
15 changed files
with
405 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using MelonLoader.Properties; | ||
|
||
[assembly: AssemblyTitle(BuildInfo.Description)] | ||
[assembly: AssemblyDescription(BuildInfo.Description)] | ||
[assembly: AssemblyCompany(BuildInfo.Company)] | ||
[assembly: AssemblyProduct(BuildInfo.Name)] | ||
[assembly: AssemblyCopyright("Created by " + BuildInfo.Author)] | ||
[assembly: AssemblyTrademark(BuildInfo.Company)] | ||
[assembly: Guid("A662769A-B294-434F-83B5-176FC4795334")] | ||
[assembly: AssemblyVersion(BuildInfo.Version)] | ||
[assembly: AssemblyFileVersion(BuildInfo.Version)] | ||
|
||
[assembly: InternalsVisibleTo("MelonLoader.Bootstrap")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace MelonLoader.Properties; | ||
|
||
public static class BuildInfo | ||
{ | ||
public const string Name = "MelonLoader"; | ||
public const string Description = "MelonLoader"; | ||
public const string Author = "Lava Gang"; | ||
public const string Company = "discord.gg/2Wn3N2P"; | ||
public const string Version = "1.0.0"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 173 additions & 0 deletions
173
MelonLoader/MelonLoader.Shared/Utils/MelonLaunchOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace MelonLoader.Utils; | ||
|
||
public static class MelonLaunchOptions | ||
{ | ||
private static Dictionary<string, Action> WithoutArg = new Dictionary<string, Action>(); | ||
private static Dictionary<string, Action<string>> WithArg = new Dictionary<string, Action<string>>(); | ||
|
||
static MelonLaunchOptions() | ||
{ | ||
AnalyticsBlocker.Setup(); | ||
Core.Setup(); | ||
Console.Setup(); | ||
Logger.Setup(); | ||
} | ||
|
||
internal static void Load() | ||
{ | ||
var foundOptions = new List<string>(); | ||
|
||
using var argEnumerator = (IEnumerator<string>)Environment.GetCommandLineArgs().GetEnumerator(); | ||
while (argEnumerator.MoveNext()) | ||
{ | ||
string fullcmd = argEnumerator.Current; | ||
if (string.IsNullOrEmpty(fullcmd)) | ||
continue; | ||
|
||
if (!fullcmd.StartsWith("--")) | ||
continue; | ||
|
||
string cmd = fullcmd.Remove(0, 2); | ||
|
||
if (WithoutArg.TryGetValue(cmd, out Action withoutArgFunc)) | ||
{ | ||
foundOptions.Add(fullcmd); | ||
withoutArgFunc(); | ||
} | ||
else if (WithArg.TryGetValue(cmd, out Action<string> withArgFunc)) | ||
{ | ||
if (!argEnumerator.MoveNext()) | ||
continue; | ||
|
||
string cmdArg = argEnumerator.Current; | ||
if (string.IsNullOrEmpty(cmdArg)) | ||
continue; | ||
|
||
if (cmdArg.StartsWith("--")) | ||
continue; | ||
|
||
foundOptions.Add($"{fullcmd} = {cmdArg}"); | ||
withArgFunc(cmdArg); | ||
} | ||
} | ||
|
||
if (foundOptions.Count <= 0) | ||
return; | ||
} | ||
|
||
#region Args | ||
|
||
public static class AnalyticsBlocker | ||
{ | ||
public static bool ShouldDAB { get; internal set; } | ||
|
||
internal static void Setup() | ||
{ | ||
WithoutArg["melonloader.dab"] = () => ShouldDAB = true; | ||
} | ||
} | ||
|
||
public static class Core | ||
{ | ||
public enum LoadModeEnum | ||
{ | ||
NORMAL, | ||
DEV, | ||
BOTH | ||
} | ||
|
||
public static LoadModeEnum LoadMode_Plugins { get; internal set; } | ||
public static LoadModeEnum LoadMode_Mods { get; internal set; } | ||
public static bool QuitFix { get; internal set; } | ||
public static bool StartScreen { get; internal set; } = true; | ||
public static bool IsDebug { get; internal set; } | ||
public static bool UserWantsDebugger { get; internal set; } | ||
public static bool ShouldDisplayAnalyticsBlocker { get; internal set; } | ||
|
||
internal static void Setup() | ||
{ | ||
WithoutArg["quitfix"] = () => QuitFix = true; | ||
WithoutArg["melonloader.disablestartscreen"] = () => StartScreen = false; | ||
WithArg["melonloader.loadmodeplugins"] = (string arg) => | ||
{ | ||
if (int.TryParse(arg, out int valueint)) | ||
LoadMode_Plugins = | ||
(LoadModeEnum)MelonUtils.Clamp(valueint, (int)LoadModeEnum.NORMAL, (int)LoadModeEnum.BOTH); | ||
}; | ||
WithArg["melonloader.loadmodemods"] = (string arg) => | ||
{ | ||
if (int.TryParse(arg, out int valueint)) | ||
LoadMode_Mods = | ||
(LoadModeEnum)MelonUtils.Clamp(valueint, (int)LoadModeEnum.NORMAL, (int)LoadModeEnum.BOTH); | ||
}; | ||
WithoutArg["melonloader.debug"] = () => IsDebug = true; | ||
WithoutArg["melonloader.launchdebugger"] = () => UserWantsDebugger = true; | ||
WithoutArg["melonloader.dab"] = () => ShouldDisplayAnalyticsBlocker = true; | ||
} | ||
} | ||
|
||
public static class Console | ||
{ | ||
public enum DisplayMode | ||
{ | ||
NORMAL, | ||
MAGENTA, | ||
RAINBOW, | ||
RANDOMRAINBOW, | ||
LEMON | ||
}; | ||
|
||
public static DisplayMode Mode { get; internal set; } | ||
public static bool CleanUnityLogs { get; internal set; } = true; | ||
public static bool ShouldSetTitle { get; internal set; } = true; | ||
public static bool AlwaysOnTop { get; internal set; } | ||
public static bool ShouldHide { get; internal set; } | ||
public static bool HideWarnings { get; internal set; } | ||
|
||
internal static void Setup() | ||
{ | ||
WithoutArg["melonloader.disableunityclc"] = () => CleanUnityLogs = false; | ||
WithoutArg["melonloader.consoledst"] = () => ShouldSetTitle = false; | ||
WithoutArg["melonloader.consoleontop"] = () => AlwaysOnTop = true; | ||
WithoutArg["melonloader.hideconsole"] = () => ShouldHide = true; | ||
WithoutArg["melonloader.hidewarnings"] = () => HideWarnings = true; | ||
|
||
WithArg["melonloader.consolemode"] = (string arg) => | ||
{ | ||
if (int.TryParse(arg, out int valueint)) | ||
Mode = (DisplayMode)MelonUtils.Clamp(valueint, (int)DisplayMode.NORMAL, (int)DisplayMode.LEMON); | ||
}; | ||
} | ||
} | ||
|
||
public static class Logger | ||
{ | ||
public static int MaxLogs { get; internal set; } = 10; | ||
public static int MaxWarnings { get; internal set; } = 10; | ||
public static int MaxErrors { get; internal set; } = 10; | ||
|
||
internal static void Setup() | ||
{ | ||
WithArg["melonloader.maxlogs"] = (string arg) => | ||
{ | ||
if (int.TryParse(arg, out int valueint)) | ||
MaxLogs = valueint; | ||
}; | ||
WithArg["melonloader.maxwarnings"] = (string arg) => | ||
{ | ||
if (int.TryParse(arg, out int valueint)) | ||
MaxWarnings = valueint; | ||
}; | ||
WithArg["melonloader.maxerrors"] = (string arg) => | ||
{ | ||
if (int.TryParse(arg, out int valueint)) | ||
MaxErrors = valueint; | ||
}; | ||
} | ||
} | ||
|
||
#endregion | ||
} |
Oops, something went wrong.