public override void OnMenuLoad() { try { CreateSettingsUI(); } catch (Exception e) { ModUI.ShowMessage( $"Fatal error:{Environment.NewLine}<color=orange>{e.Message}</color>{Environment.NewLine}Please install modloader correctly.", "Fatal Error"); } }
public override void OnMenuLoad() { try { CreateConsoleUI(); } catch (System.Exception e) { ModUI.ShowMessage($"Fatal error:{System.Environment.NewLine}<color=orange>{e.Message}</color>{System.Environment.NewLine}Please install modloader correctly.", "Fatal Error"); } console.controller = new ConsoleController(); ConsoleCommand.cc = console.controller; console.setVisibility(false); console.viewContainer.transform.GetChild(5).gameObject.GetComponent <ConsoleUIResizer>().LoadConsoleSize(); ConsoleCommand.Add(new CommandVersion()); ConsoleCommand.Add(new CommandLogAll()); ConsoleCommand.Add(new ManifestCommand()); }
/// <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 sAuthCheckCompleted(object sender, DownloadStringCompletedEventArgs e) { try { if (e.Error != null) { throw new Exception(e.Error.Message); } string result = e.Result; if (result != string.Empty) { string[] ed = result.Split('|'); if (ed[0] == "error") { switch (ed[1]) { case "0": throw new Exception("Getting steamID failed."); case "1": throw new Exception("steamID rejected."); default: throw new Exception("Unknown error."); } } else if (ed[0] == "ok") { SaveOtk s = new SaveOtk(); s.k1 = ed[1]; s.k2 = ed[2]; System.Runtime.Serialization.Formatters.Binary.BinaryFormatter f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); string sp = Path.Combine(ConfigFolder, @"MSCLoader_Settings\otk.bin"); FileStream st = new FileStream(sp, FileMode.Create); f.Serialize(st, s); st.Close(); } else { UnityEngine.Debug.Log("Unknown: " + ed[0]); throw new Exception("Unknown server response."); } } bool ret = Steamworks.SteamApps.GetCurrentBetaName(out string Name, 128); if (ret && (bool)ModSettings_menu.expWarning.GetValue()) { if (Name != "default_32bit") //32bit is NOT experimental branch { 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"); } } UnityEngine.Debug.Log(string.Format("MSC buildID: <b>{0}</b>", Steamworks.SteamApps.GetAppBuildId())); } catch (Exception ex) { string sp = Path.Combine(ConfigFolder, @"MSCLoader_Settings\otk.bin"); if (e.Error != null) { if (File.Exists(sp)) { System.Runtime.Serialization.Formatters.Binary.BinaryFormatter f = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); FileStream st = new FileStream(sp, FileMode.Open); SaveOtk s = f.Deserialize(st) as SaveOtk; st.Close(); string murzyn = "otk_" + MurzynskaMatematyka(string.Format("{0}{1}", steamID, s.k1)); if (s.k2.CompareTo(murzyn) != 0) { File.Delete(sp); steamID = null; ModConsole.Error("SteamAPI failed with error: " + ex.Message); } } else { steamID = null; ModConsole.Error("SteamAPI failed with error: " + ex.Message); } } else { if (File.Exists(sp)) { File.Delete(sp); } steamID = null; ModConsole.Error("SteamAPI failed with error: " + ex.Message); if (devMode) { ModConsole.Error(ex.ToString()); } } UnityEngine.Debug.Log(ex); } }