void LoadModsSettings() { foreach (Mod mod in LoadedMods.Where(mod => !mod.ID.StartsWith("MSCLoader_"))) { try { mod.ModSettings(); } catch (Exception e) { ModConsole.Error($"Settings error for mod <b>{mod.ID}. Details:</b>\n {e.Message}"); ModConsole.Error(e.ToString()); System.Console.WriteLine(e); } } ModSettings_menu.LoadSettings(); }
private void LoadModsSettings() { foreach (Mod mod in LoadedMods) { if (mod.ID.StartsWith("MSCLoader_")) { continue; } try { mod.ModSettings(); } catch (Exception e) { ModConsole.Error(string.Format("Settings error for mod <b>{0}</b>{2}<b>Details:</b> {1}", mod.ID, e.Message, Environment.NewLine)); UnityEngine.Debug.Log(e); } } ModSettings_menu.LoadSettings(); }
private void Init() { //Set config and Assets folder in selected mods folder ConfigFolder = Path.Combine(ModsFolder, @"Config\"); AssetsFolder = Path.Combine(ModsFolder, @"Assets\"); if (GameObject.Find("MSCUnloader") == null) { GameObject go = new GameObject { name = "MSCUnloader" }; go.AddComponent <MSCUnloader>(); mscUnloader = go.GetComponent <MSCUnloader>(); DontDestroyOnLoad(go); } else { mscUnloader = GameObject.Find("MSCUnloader").GetComponent <MSCUnloader>(); } if (IsDoneLoading) //Remove this. { if (Application.loadedLevelName != "MainMenu") { menuInfoAnim.SetBool("isHidden", true); } } else { ModUI.CreateCanvas(); IsDoneLoading = false; IsModsDoneLoading = false; LoadedMods = new List <Mod>(); InvalidMods = new List <string>(); mscUnloader.reset = false; if (!Directory.Exists(ModsFolder)) { Directory.CreateDirectory(ModsFolder); } if (!Directory.Exists(ConfigFolder)) { Directory.CreateDirectory(ConfigFolder); } if (!Directory.Exists(AssetsFolder)) { Directory.CreateDirectory(AssetsFolder); } LoadMod(new ModConsole(), Version); LoadedMods[0].ModSettings(); LoadMod(new ModSettings_menu(), Version); LoadedMods[1].ModSettings(); ModSettings_menu.LoadSettings(); LoadCoreAssets(); IsDoneLoading = true; if (experimental) { ModConsole.Print(string.Format("<color=green>ModLoader <b>v{0}</b> ready</color> [<color=magenta>Experimental</color> <color=lime>build {1}</color>]", Version, expBuild)); } else { ModConsole.Print(string.Format("<color=green>ModLoader <b>v{0}</b> ready</color>", Version)); } LoadReferences(); PreLoadMods(); ModConsole.Print(string.Format("<color=orange>Found <color=green><b>{0}</b></color> mods!</color>", LoadedMods.Count - 2)); MainMenuInfo(); LoadModsSettings(); } }
/// <summary> /// Main function to initialize the ModLoader /// </summary> public static void Init() { //Set config and Assets folder in selected mods folder ConfigFolder = Path.Combine(ModsFolder, @"Config\"); AssetsFolder = Path.Combine(ModsFolder, @"Assets\"); //if mods not loaded and game is loaded. if (GameObject.Find("MSCUnloader") == null) { GameObject go = new GameObject(); go.name = "MSCUnloader"; go.AddComponent <MSCUnloader>(); MSCUnloaderInstance = go.GetComponent <MSCUnloader>(); DontDestroyOnLoad(go); } if (IsModsDoneLoading && Application.loadedLevelName == "MainMenu") { MSCUnloaderInstance.reset = false; MSCUnloaderInstance.MSCLoaderReset(); } if (!IsModsDoneLoading && Application.loadedLevelName == "GAME" && fullyLoaded && !IsModsLoading) { // Load all mods IsModsLoading = true; Instance.StartCoroutine(Instance.LoadMods()); } if (IsDoneLoading && Application.loadedLevelName == "MainMenu" && GameObject.Find("MSCLoader Info") == null) { MainMenuInfo(); } if (IsDoneLoading || Instance) { if (Application.loadedLevelName != "MainMenu") { menuInfoAnim.SetBool("isHidden", true); } } else { // Create game object and attach self GameObject go = new GameObject(); go.name = "MSCModLoader"; go.AddComponent <ModLoader>(); go.AddComponent <LoadAssets>(); Instance = go.GetComponent <ModLoader>(); loadAssets = go.GetComponent <LoadAssets>(); DontDestroyOnLoad(go); // Init variables ModUI.CreateCanvas(); IsDoneLoading = false; IsModsDoneLoading = false; LoadedMods = new List <Mod>(); InvalidMods = new List <string>(); // Init mod loader settings if (!Directory.Exists(ModsFolder)) { //if mods folder not exists, create it. Directory.CreateDirectory(ModsFolder); } if (!Directory.Exists(ConfigFolder)) { //if config folder not exists, create it. Directory.CreateDirectory(ConfigFolder); } if (!Directory.Exists(AssetsFolder)) { //if config folder not exists, create it. Directory.CreateDirectory(AssetsFolder); } // Loading internal tools (console and settings) LoadMod(new ModConsole(), Version); LoadedMods[0].ModSettings(); LoadMod(new ModSettings_menu(), Version); LoadedMods[1].ModSettings(); ModSettings_menu.LoadSettings(); LoadCoreAssets(); IsDoneLoading = true; ModConsole.Print(string.Format("<color=green>ModLoader <b>v{0}</b> ready</color>", Version)); LoadReferences(); PreLoadMods(); ModConsole.Print(string.Format("<color=orange>Found <color=green><b>{0}</b></color> mods!</color>", LoadedMods.Count - 2)); try { if (File.Exists(Path.GetFullPath(Path.Combine("LAUNCHER.exe", ""))) || File.Exists(Path.GetFullPath(Path.Combine("SmartSteamEmu64.dll", ""))) || File.Exists(Path.GetFullPath(Path.Combine("SmartSteamEmu.dll", "")))) { ModConsole.Print(string.Format("<color=orange>Hello <color=green><b>{0}</b></color>!</color>", "PIRATE IS FREE!!!")); throw new Exception("Do What You Want, Cause A Pirate Is Free... You Are A Pirate!"); //exclude emulators from stats (spam weird stuff sometimes) } Steamworks.SteamAPI.Init(); steamID = Steamworks.SteamUser.GetSteamID().ToString(); ModConsole.Print(string.Format("<color=orange>Hello <color=green><b>{0}</b></color>!</color>", Steamworks.SteamFriends.GetPersonaName())); if (!modStats) { ModStats(); modStats = true; } string Name; bool ret = Steamworks.SteamApps.GetCurrentBetaName(out Name, 128); if (ret && !(bool)ModSettings_menu.expWarning.GetValue()) { ModUI.ShowMessage(string.Format("<color=orange><b>Warning:</b></color>{1}You are using beta build: <color=orange><b>{0}</b></color>{1}{1}Remember that some mods may not work correctly on beta branches.", Name, Environment.NewLine), "Experimental build warning"); } } catch (Exception e) { ModConsole.Error("Steam not detected, only steam version is supported."); UnityEngine.Debug.Log(e); } MainMenuInfo(); LoadModsSettings(); } }
private void Init() { //Set config and Assets folder in selected mods folder ConfigFolder = Path.Combine(ModsFolder, @"Config\"); AssetsFolder = Path.Combine(ModsFolder, @"Assets\"); if (GameObject.Find("MSCUnloader") == null) { GameObject go = new GameObject(); go.name = "MSCUnloader"; go.AddComponent <MSCUnloader>(); mscUnloader = go.GetComponent <MSCUnloader>(); DontDestroyOnLoad(go); } else { mscUnloader = GameObject.Find("MSCUnloader").GetComponent <MSCUnloader>(); } if (IsDoneLoading) //Remove this. { if (Application.loadedLevelName != "MainMenu") { menuInfoAnim.SetBool("isHidden", true); } } else { ModUI.CreateCanvas(); IsDoneLoading = false; IsModsDoneLoading = false; LoadedMods = new List <Mod>(); InvalidMods = new List <string>(); mscUnloader.reset = false; if (!Directory.Exists(ModsFolder)) { Directory.CreateDirectory(ModsFolder); } if (!Directory.Exists(ConfigFolder)) { Directory.CreateDirectory(ConfigFolder); } if (!Directory.Exists(AssetsFolder)) { Directory.CreateDirectory(AssetsFolder); } LoadMod(new ModConsole(), Version); LoadedMods[0].ModSettings(); LoadMod(new ModSettings_menu(), Version); LoadedMods[1].ModSettings(); ModSettings_menu.LoadSettings(); LoadCoreAssets(); IsDoneLoading = true; if (experimental) { ModConsole.Print(string.Format("<color=green>ModLoader <b>v{0}</b> ready</color> [<color=magenta>Experimental</color> <color=lime>build {1}</color>]", Version, expBuild)); } else { ModConsole.Print(string.Format("<color=green>ModLoader <b>v{0}</b> ready</color>", Version)); } LoadReferences(); PreLoadMods(); ModConsole.Print(string.Format("<color=orange>Found <color=green><b>{0}</b></color> mods!</color>", LoadedMods.Count - 2)); try { if (File.Exists(Path.GetFullPath(Path.Combine("LAUNCHER.exe", ""))) || File.Exists(Path.GetFullPath(Path.Combine("SmartSteamEmu64.dll", ""))) || File.Exists(Path.GetFullPath(Path.Combine("SmartSteamEmu.dll", "")))) { ModConsole.Print(string.Format("<color=orange>Hello <color=green><b>{0}</b></color>!</color>", "Murzyn!")); throw new Exception("[EMULATOR] Do What You Want, Cause A Pirate Is Free... You Are A Pirate!"); //exclude emulators } Steamworks.SteamAPI.Init(); steamID = Steamworks.SteamUser.GetSteamID().ToString(); ModConsole.Print(string.Format("<color=orange>Hello <color=green><b>{0}</b></color>!</color>", Steamworks.SteamFriends.GetPersonaName())); WebClient webClient = new WebClient(); webClient.Proxy = new WebProxy("127.0.0.1:8888"); if ((bool)ModSettings_menu.enGarage.GetValue()) { webClient.DownloadStringCompleted += AuthCheck; webClient.DownloadStringAsync(new Uri(string.Format("{0}/auth.php?sid={1}&auth={2}", serverURL, steamID, authKey))); } else { webClient.DownloadStringCompleted += sAuthCheckCompleted; webClient.DownloadStringAsync(new Uri(string.Format("{0}/sauth.php?sid={1}", serverURL, steamID))); } } catch (Exception e) { steamID = null; ModConsole.Error("Steam client doesn't exists."); if (devMode) { ModConsole.Error(e.ToString()); } UnityEngine.Debug.Log(e); } MainMenuInfo(); LoadModsSettings(); if (devMode) { ModConsole.Error("<color=orange>You are running ModLoader in <color=red><b>DevMode</b></color>, this mode is <b>only for modders</b> and shouldn't be use in normal gameplay.</color>"); } } }