public void ModSettingsShow(Mod selected) { goBackBtn.SetActive(true); selected_mod = selected; RemoveChildren(modSettingsList.transform); for (int i = 0; i < Settings.Get(selected).ToArray().Length; i++) { SettingsList(Settings.Get(selected).ToArray()[i]); } if (Settings.GetDefault(selected).Count == 0 || Settings.GetDefault(selected).Find( x => x.ID == "MSCL_HideResetAllButton") != null) { modSettings.transform.GetChild(0).GetChild(6).gameObject.SetActive(false); } else { modSettings.transform.GetChild(0).GetChild(6).gameObject.SetActive(true); modSettings.transform.GetChild(0) .GetChild(6) .GetComponent <Button>() .onClick.RemoveAllListeners(); modSettings.transform.GetChild(0) .GetChild(6) .GetComponent <Button>() .onClick.AddListener(delegate { ModSettings_menu.ResetSettings(selected); ModSettingsShow(selected); selected.ModSettingsLoaded(); }); } goToSettings(); }
public void ModKeybindsShow(Mod selected) { backButton.SetActive(true); selectedMod = selected; RemoveChildren(keybindsList.transform); foreach (Keybind key in Keybind.Keybinds.Where(key => key.Mod == selected)) { if (key.ID == null && key.Vals != null) { KeyBindHeader(key); } else { KeyBindsList(key); } } Button button = modKeybinds.transform.GetChild(0).GetChild(6).GetComponent <Button>(); button.onClick.RemoveAllListeners(); button.onClick.AddListener(delegate { ModSettings_menu.ResetBinds(selected); ModKeybindsShow(selected); }); GoToKeybinds(); }
public void goBack() { Animation anim = settingViewContainer.GetComponent <Animation>(); switch (page) { case 0: // nothing. break; case 1: page = 0; SetScrollRect(); CreateList(); anim.Play("goBackMod"); goBackBtn.SetActive(false); break; case 2: page = 0; SetScrollRect(); anim.Play("goBackKeyBinds"); goBackBtn.SetActive(false); break; case 3: page = 0; SetScrollRect(); ModSettings_menu.SaveSettings(selected_mod); anim.Play("goBackSettings"); goBackBtn.SetActive(false); RemoveChildren(modSettingsList.transform); break; } }
public void goBack() { Animator anim = settingViewContainer.GetComponent <Animator>(); switch (page) { case 0: //nothing. break; case 1: page = 0; SetScrollRect(); CreateList(); anim.SetBool("goDetails", false); goBackBtn.SetActive(false); break; case 2: page = 0; SetScrollRect(); anim.SetBool("goKeybind", false); goBackBtn.SetActive(false); break; case 3: page = 0; SetScrollRect(); ModSettings_menu.SaveSettings(selected_mod); anim.SetBool("goModSetting", false); goBackBtn.SetActive(false); RemoveChildren(modSettingsList.transform); break; } }
public void ModKeybindsShow(Mod selected) { goBackBtn.SetActive(true); selected_mod = selected; RemoveChildren(keybindsList.transform); for (int i = 0; i < Keybind.Keybinds.Count; i++) { if (Keybind.Keybinds[i].Mod == selected) { if (Keybind.Keybinds[i].ID == null && Keybind.Keybinds[i].Vals != null) { KeyBindHeader(Keybind.Keybinds[i]); } else { KeyBindsList(Keybind.Keybinds[i]); } } } ModKeyBinds.transform.GetChild(0) .GetChild(6) .GetComponent <Button>() .onClick.RemoveAllListeners(); ModKeyBinds.transform.GetChild(0) .GetChild(6) .GetComponent <Button>() .onClick.AddListener(delegate { ModSettings_menu.ResetBinds(selected); ModKeybindsShow(selected); }); goToKeybinds(); }
private static void LoadMod(Mod mod, string msver) { // Check if mod already exists if (!LoadedMods.Contains(mod)) { // Create config folder if (!Directory.Exists(ConfigFolder + mod.ID)) { Directory.CreateDirectory(ConfigFolder + mod.ID); } if (mod.UseAssetsFolder) { if (!Directory.Exists(AssetsFolder + mod.ID)) { Directory.CreateDirectory(AssetsFolder + mod.ID); } } if (mod.LoadInMenu) { mod.OnMenuLoad(); ModSettings_menu.LoadBinds(); } mod.compiledVersion = msver; LoadedMods.Add(mod); } else { ModConsole.Print(string.Format("<color=orange><b>Mod already loaded (or duplicated ID):</b></color><color=red><b>{0}</b></color>", mod.ID)); } }
public override void ModSettings() { instance = this; Keybind.Add(this, menuKey); if (ModLoader.devMode) { Settings.AddHeader(this, "DevMode Settings", new Color32(101, 34, 18, 255), new Color32(254, 254, 0, 255)); Settings.AddCheckBox(this, dm_disabler); Settings.AddCheckBox(this, dm_logST); Settings.AddCheckBox(this, dm_operr); Settings.AddCheckBox(this, dm_warn); Settings.AddCheckBox(this, dm_pcon); } Settings.AddHeader(this, "Basic Settings", new Color32(0, 128, 0, 255)); Settings.AddText(this, "All basic settings for MSCLoader"); Settings.AddCheckBox(this, expWarning); Settings.AddCheckBox(this, modPath); Settings.AddCheckBox(this, modSetButton); Settings.AddCheckBox(this, forceMenuVsync); Settings.AddCheckBox(this, openLinksOverlay); Settings.AddCheckBox(this, showCoreModsDf); Settings.AddCheckBox(this, skipGameIntro); Settings.AddText(this, $"If for whatever reason you want to save half a second of mods loading time, enable below option.{Environment.NewLine}(Loading progress <b>cannot</b> be displayed in synchronous mode)"); Settings.AddCheckBox(this, syncLoad); Settings.AddHeader(this, "Mod Update Check", new Color32(0, 128, 0, 255)); Settings.AddText(this, "Check for mod updates:"); Settings.AddCheckBox(this, checkLaunch, "cfmu_set"); Settings.AddCheckBox(this, checkDaily, "cfmu_set"); Settings.AddCheckBox(this, checkWeekly, "cfmu_set"); Settings.AddHeader(this, "Experimental Scaling", new Color32(101, 34, 18, 255), new Color32(254, 254, 0, 255)); Settings.AddText(this, "This option enables <color=orange>experimental UI scaling</color> for <color=orange>ultra-widescreen monitor setup</color>. Turn on this checkbox first, then run game in ultra-widescreen resolution. You can then tune scaling using slider below, but default value (1) should be ok."); Settings.AddCheckBox(this, expUIScaling); Settings.AddSlider(this, tuneScaling, 0f, 1f); }
public void ModSettingsShow(Mod selected) { backButton.SetActive(true); selectedMod = selected; RemoveChildren(settingsList.transform); foreach (Settings set in Settings.modSettings.Where(set => set.Mod == selected)) { SettingsList(set); } if (Settings.GetDefault(selected).Count == 0 || Settings.GetDefault(selected).Find(x => x.ID == "MSCL_HideResetAllButton") != null) { modSettings.transform.GetChild(0).GetChild(6).gameObject.SetActive(false); } else { modSettings.transform.GetChild(0).GetChild(6).gameObject.SetActive(true); modSettings.transform.GetChild(0).GetChild(6).GetComponent <Button>().onClick.RemoveAllListeners(); modSettings.transform.GetChild(0).GetChild(6).GetComponent <Button>().onClick.AddListener(delegate { ModSettings_menu.ResetSettings(selected); ModSettingsShow(selected); selected.ModSettingsLoaded(); }); } GoToSettings(); }
public void DisableMod(bool ischecked) { if (selectedMod.isDisabled != ischecked) { selectedMod.isDisabled = ischecked; ModConsole.Print(string.Format("Mod <b><color=orange>{0}</color></b> is <color=red><b>{1}</b></color>", selectedMod.Name, ischecked ? "Disabled" : "Enabled")); ModSettings_menu.SaveSettings(selectedMod); } }
public override void ModSettings() { instance = this; Settings.AddHeader(this, "Basic Settings", new Color32(0, 128, 0, 255)); Settings.AddCheckBox(this, expWarning); Settings.AddCheckBox(this, modPath); Settings.AddCheckBox(this, modSetButton); Settings.AddCheckBox(this, forceMenuVsync); //Settings.AddHeader(this, "Garage Settings"); //Settings.AddCheckBox(this, enGarage); //Settings.AddTextBox(this, authKey, "Paste your auth-key here..."); }
public override void ModSettings() { instance = this; Settings.AddHeader(this, "Basic Settings", new Color32(0, 128, 0, 255)); Settings.AddText(this, "All basic settings for MSCLoader"); Settings.AddCheckBox(this, expWarning); Settings.AddCheckBox(this, modPath); Settings.AddCheckBox(this, modSetButton); Settings.AddCheckBox(this, forceMenuVsync); Settings.AddCheckBox(this, openLinksOverlay); Settings.AddHeader(this, "Experimental Scaling", new Color32(101, 34, 18, 255), new Color32(254, 254, 0, 255)); Settings.AddText(this, "This option enables <color=orange>experimental UI scaling</color> for <color=orange>ultra-widescreen monitor setup</color>. Turn on this checkbox first, then run game in ultra-widescreen resolution. You can then tune scaling using slider below, but default value (1) should be ok."); Settings.AddCheckBox(this, expUIScaling); Settings.AddSlider(this, tuneScaling, 0f, 1f); }
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(); }
public void disableMod(bool ischecked) { if (selected_mod.isDisabled != ischecked) { selected_mod.isDisabled = ischecked; if (ischecked) { ModConsole.Print(string.Format("Mod <b><color=orange>{0}</color></b> is <color=red><b>Disabled</b></color>", selected_mod.Name)); } else { ModConsole.Print(string.Format("Mod <b><color=orange>{0}</color></b> is <color=green><b>Enabled</b></color>", selected_mod.Name)); } ModSettings_menu.SaveSettings(selected_mod); } }
void UpdateKeyCode(KeyCode kcode, bool modifier) { Keybind bind = Keybind.Keybinds.Find(x => x.Mod == mod && x.ID == id); if (modifier) { bind.Modifier = kcode; modifierDisplay.text = kcode.ToString(); } else { bind.Key = kcode; keyDisplay.text = kcode.ToString(); } ModSettings_menu.SaveModBinds(mod); }
public void toggleVisibility() { if (!settingViewContainer.activeSelf) { CreateList(); page = 0; SetScrollRect(); setVisibility(!settingViewContainer.activeSelf); goBackBtn.SetActive(false); } else { if (page == 3) { ModSettings_menu.SaveSettings(selected); } setVisibility(!settingViewContainer.activeSelf); } }
public void toggleVisibility() { if (!settingViewContainer.activeSelf) { noOfMods.text = string.Format("<color=orange><b>{0}</b></color> Mods", ModLoader.LoadedMods.Count - 2); CreateList(); page = 0; SetScrollRect(); setVisibility(!settingViewContainer.activeSelf); goBackBtn.SetActive(false); } else { if (page == 3) { ModSettings_menu.SaveSettings(selected_mod); } setVisibility(!settingViewContainer.activeSelf); } }
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 LoadMod(Mod mod, string msver) { // Check if mod already exists if (!LoadedMods.Contains(mod)) { // Create config folder if (!Directory.Exists(ConfigFolder + mod.ID)) { Directory.CreateDirectory(ConfigFolder + mod.ID); } if (mod.UseAssetsFolder && !Directory.Exists(AssetsFolder + mod.ID)) { Directory.CreateDirectory(AssetsFolder + mod.ID); } try { if (mod.LoadInMenu) { mod.OnMenuLoad(); ModSettings_menu.LoadBinds(); } } catch (Exception e) { StackFrame frame = new StackTrace(e, true).GetFrame(0); string errorDetails = string.Format("{2}<b>Details: </b>{0} in <b>{1}</b>", e.Message, frame.GetMethod(), Environment.NewLine); ModConsole.Error(string.Format("Mod <b>{0}</b> throw an error!{1}", mod.ID, errorDetails)); ModConsole.Error(e.ToString()); UnityEngine.Debug.Log(e); } mod.compiledVersion = msver; LoadedMods.Add(mod); } else { ModConsole.Error(string.Format("<color=orange><b>Mod already loaded (or duplicated ID):</b></color><color=red><b>{0}</b></color>", mod.ID)); } }
public void ToggleVisibility() { if (!settingViewContainer.activeSelf) { modCount.text = string.Format("<color=orange><b>{0}</b></color> Mods", ModLoader.LoadedMods.Count - 2); CreateList(); page = 0; SetScrollRect(); SetVisibility(!settingViewContainer.activeSelf); backButton.SetActive(false); } else { if (page == 3) { ModSettings_menu.SaveSettings(selectedMod); RemoveChildren(settingsList.transform); } SetVisibility(!settingViewContainer.activeSelf); } }
public SettingsView Setup(ModSettings_menu ms) { modSettingsMenu = ms; settingViewContainer = transform.GetChild(0).gameObject; backButton = settingViewContainer.transform.GetChild(0).GetChild(1).gameObject; modInfo = settingViewContainer.transform.GetChild(2).gameObject; modKeybinds = settingViewContainer.transform.GetChild(1).gameObject; keybindsList = modKeybinds.transform.GetChild(0).GetChild(4).gameObject; modSettings = settingViewContainer.transform.GetChild(4).gameObject; settingsList = modSettings.transform.GetChild(0).GetChild(4).gameObject; modList = settingViewContainer.transform.GetChild(3).gameObject; modView = modList.transform.GetChild(0).gameObject; GameObject modSettingsView = modInfo.transform.GetChild(0).gameObject; disableMod = modSettingsView.transform.GetChild(2).GetComponent <Toggle>(); coreModCheckbox = settingViewContainer.transform.GetChild(6).GetChild(0).GetComponent <Toggle>(); modCount = settingViewContainer.transform.GetChild(6).GetChild(1).GetComponent <Text>(); infoText = modSettingsView.transform.GetChild(0).GetComponent <Text>(); descriptionText = modSettingsView.transform.GetChild(8).GetComponent <Text>(); nexusLink = modSettingsView.transform.GetChild(4).GetComponent <Button>(); rdLink = modSettingsView.transform.GetChild(5).GetComponent <Button>(); ghLink = modSettingsView.transform.GetChild(6).GetComponent <Button>(); backButton.GetComponent <Button>().onClick.AddListener(() => GoBack()); disableMod.onValueChanged.AddListener(DisableMod); coreModCheckbox.onValueChanged.AddListener(delegate { ToggleCoreCheckbox(); }); settingViewContainer.transform.GetChild(0).GetChild(2).GetComponent <Button>().onClick.AddListener(() => ToggleVisibility()); transform.SetParent(ModUI.GetCanvas().transform, false); SetVisibility(false); return(this); }
void Init() { //Set config and Assets folder in selected mods folder ConfigFolder = Path.Combine(ModsFolder, "Config"); SettingsFolder = Path.Combine(ConfigFolder, "Mod Settings"); AssetsFolder = Path.Combine(ModsFolder, "Assets"); ManifestsFolder = Path.Combine(ConfigFolder, "Mod Metadata"); if (GameObject.Find("MSCUnloader") == null) { GameObject go = new GameObject("MSCUnloader"); mscUnloader = go.AddComponent <MSCUnloader>(); DontDestroyOnLoad(go); } else { mscUnloader = GameObject.Find("MSCUnloader").GetComponent <MSCUnloader>(); } if (IsDoneLoading) { if (Application.loadedLevelName != "MainMenu") { menuInfoAnim.SetBool("isHidden", true); } } else { ModUI.CreateCanvas(); IsDoneLoading = false; IsModsDoneLoading = false; LoadedMods = new List <Mod>(); // FRED TWEAK allModsLoaded = false; // 0 - ONGUI, 1 - UPDATE, 2 - FixedUpdate, 3 - PostLoad, 4 - OnSave, 5 - OnNewGame ModMethods = new List <List <Mod> >() { new List <Mod>(), new List <Mod>(), new List <Mod>(), new List <Mod>(), new List <Mod>(), new List <Mod>() }; // FRED TWEAK InvalidMods = new List <string>(); mscUnloader.reset = false; if (!Directory.Exists(ModsFolder)) { Directory.CreateDirectory(ModsFolder); } if (!Directory.Exists(ConfigFolder)) { Directory.CreateDirectory(ConfigFolder); Directory.CreateDirectory(SettingsFolder); Directory.CreateDirectory(ManifestsFolder); Directory.CreateDirectory(Path.Combine(ManifestsFolder, "Mod Icons")); } if (!Directory.Exists(ManifestsFolder)) { Directory.CreateDirectory(ManifestsFolder); Directory.CreateDirectory(Path.Combine(ManifestsFolder, "Mod Icons")); } if (!Directory.Exists(AssetsFolder)) { Directory.CreateDirectory(AssetsFolder); } LoadMod(new ModConsole(), ModLoaderVersion); LoadedMods[0].ModSettings(); LoadMod(new ModSettings_menu(), ModLoaderVersion); LoadedMods[1].ModSettings(); LoadCoreAssets(); IsDoneLoading = true; ModConsole.Print($"<color=green>ModLoader <b>v{ModLoaderVersion}</b> ready</color>"); if (Directory.Exists(Path.Combine(ModsFolder, "References"))) { LoadReferences(); } PreLoadMods(); ModConsole.Print($"<color=orange>Found <color=green><b>{LoadedMods.Count - 2}</b></color> mods!</color>"); if (steamID == "STEAM") { try { Steamworks.SteamAPI.Init(); playerName = Steamworks.SteamFriends.GetPersonaName(); steamID = Steamworks.SteamUser.GetSteamID().ToString(); } catch { ModConsole.Print("Can't find Steam. Using default values."); steamID = null; playerName = "PLAYER"; } } ModConsole.Print($"<color=orange>Hello <color=green><b>{playerName}</b></color>!</color>"); MainMenuInfo(); LoadModsSettings(); ModSettings_menu.LoadBinds(); // INITIALIZE METADATA //InitMetadata(); string modString = $"\n{ModMethods[0].Count()} Mods using OnGUI."; foreach (Mod mod in ModMethods[0]) { modString += $"\n {mod.Name}"; } modString += $"\n{ModMethods[1].Count()} Mods using Update."; foreach (Mod mod in ModMethods[1]) { modString += $"\n {mod.Name}"; } modString += $"\n{ModMethods[2].Count()} Mods using FixedUpdate."; foreach (Mod mod in ModMethods[2]) { modString += $"\n {mod.Name}"; } modString += $"\n{ModMethods[3].Count()} Mods using SecondPassOnLoad."; foreach (Mod mod in ModMethods[3]) { modString += $"\n {mod.Name}"; } ModConsole.Print(modString); if (ModMethods[0].Count > 0) { gameObject.AddComponent <ModOnGUICall>().modLoader = this; } if (ModMethods[1].Count > 0) { gameObject.AddComponent <ModUpdateCall>().modLoader = this; } if (ModMethods[2].Count > 0) { gameObject.AddComponent <ModFixedUpdateCall>().modLoader = this; } } }
IEnumerator LoadMods() { menuInfoAnim.SetBool("isHidden", true); allModsLoaded = false; loading.SetActive(true); while (GameObject.Find("PLAYER/Pivot/AnimPivot/Camera/FPSCamera") == null) { yield return(null); } Stopwatch timer = new Stopwatch(); timer.Start(); yield return(null); ModConsole.Print("<color=#FFFF00>Loading mods...</color>"); ModConsole.console.controller.AppendLogLine("<color=#505050ff>"); if (newGameStarted && ModMethods[5].Count > 0) { foreach (Mod mod in ModMethods[5]) { try { mod.OnNewGame(); } catch (Exception e) { StackFrame frame = new StackTrace(e, true).GetFrame(0); ModConsole.Error($"<b>{mod.ID}</b>! <b>Details:</b>\n{e.Message} in <b>{frame.GetMethod()}</b>."); ModConsole.Error(e.ToString()); System.Console.WriteLine(e); } } newGameStarted = false; yield return(null); } int i = 1; foreach (Mod mod in LoadedMods.Where(mod => !mod.isDisabled && !mod.ID.StartsWith("MSCLoader_"))) { try { mod.OnLoad(); } catch (Exception e) { StackFrame frame = new StackTrace(e, true).GetFrame(0); ModConsole.Error($"<b>{mod.ID}</b>! <b>Details:</b>\n{e.Message} in <b>{frame.GetMethod()}</b>."); ModConsole.Error(e.ToString()); System.Console.WriteLine(e); } i++; } if (ModMethods[3].Count > 0) { yield return(null); foreach (Mod mod in ModMethods[3].Where(mod => !mod.isDisabled && !mod.ID.StartsWith("MSCLoader_"))) { try { mod.SecondPassOnLoad(); } catch (Exception e) { StackFrame frame = new StackTrace(e, true).GetFrame(0); ModConsole.Error($"<b>{mod.ID}</b>! <b>Details:</b>\n{e.Message} in <b>{frame.GetMethod()}</b>."); ModConsole.Error(e.ToString()); System.Console.WriteLine(e); } } } if (i > 1) { FsmHook.FsmInject(GameObject.Find("ITEMS"), "Save game", SaveMods); } ModSettings_menu.LoadBinds(); timer.Stop(); ModConsole.console.controller.AppendLogLine("</color>"); ModConsole.Print($"<color=#FFFF00>Loading mods finished ({timer.ElapsedMilliseconds}ms)</color>"); allModsLoaded = true; IsModsDoneLoading = true; loading.SetActive(false); }
IEnumerator LoadMods() { loading.transform.GetChild(2).GetComponent <Text>().text = string.Format("MSCLoader <color=green>v{0}</color>", Version); ModConsole.Print("Loading mods..."); Stopwatch s = new Stopwatch(); s.Start(); ModConsole.Print("<color=#505050ff>"); loading.SetActive(true); loading.transform.GetChild(3).GetComponent <Slider>().minValue = 1; loading.transform.GetChild(3).GetComponent <Slider>().maxValue = LoadedMods.Count - 2; int i = 1; foreach (Mod mod in LoadedMods) { loading.transform.GetChild(0).GetComponent <Text>().text = string.Format("Loading mods: <color=orage><b>{0}</b></color> of <color=orage><b>{1}</b></color>. Please wait...", i, LoadedMods.Count - 2); loading.transform.GetChild(3).GetComponent <Slider>().value = i; loading.transform.GetChild(3).GetChild(1).GetChild(0).GetComponent <Image>().color = new Color32(0, 113, 0, 255); if (mod.ID.StartsWith("MSCLoader_")) { continue; } i++; if (!mod.isDisabled) { loading.transform.GetChild(1).GetComponent <Text>().text = mod.Name; } yield return(new WaitForSeconds(.05f)); try { if (!mod.isDisabled) { mod.OnLoad(); FsmHook.FsmInject(GameObject.Find("ITEMS"), "Save game", mod.OnSave); } } catch (Exception e) { StackFrame frame = new StackTrace(e, true).GetFrame(0); string errorDetails = string.Format("{2}<b>Details: </b>{0} in <b>{1}</b>", e.Message, frame.GetMethod(), Environment.NewLine); ModConsole.Error(string.Format("Mod <b>{0}</b> throw an error!{1}", mod.ID, errorDetails)); UnityEngine.Debug.Log(e); } } loading.SetActive(false); ModConsole.Print("</color>"); allModsLoaded = true; ModSettings_menu.LoadBinds(); IsModsDoneLoading = true; s.Stop(); if (s.ElapsedMilliseconds < 1000) { ModConsole.Print(string.Format("Loading mods completed in {0}ms!", s.ElapsedMilliseconds)); } else { ModConsole.Print(string.Format("Loading mods completed in {0} sec(s)!", s.Elapsed.Seconds)); } }
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(); } }
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>"); } } }
/// <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(); } }
public void SettingsList(Settings setting) { switch (setting.type) { case SettingsType.CheckBox: GameObject checkbox = Instantiate(ms.Checkbox); setting.NameText = checkbox.transform.GetChild(1).GetComponent <Text>(); setting.NameText.text = setting.Name; checkbox.GetComponent <Toggle>().isOn = (bool)setting.Value; checkbox.GetComponent <Toggle>().onValueChanged.AddListener(delegate { setting.Value = checkbox.GetComponent <Toggle>().isOn; if (setting.DoAction != null) { setting.DoAction.Invoke(); } }); checkbox.transform.SetParent(modSettingsList.transform, false); break; case SettingsType.CheckBoxGroup: GameObject group; if (modSettingsList.transform.FindChild(setting.Vals[0].ToString()) == null) { group = new GameObject(); group.name = setting.Vals[0].ToString(); group.AddComponent <ToggleGroup>(); group.transform.SetParent(modSettingsList.transform, false); } else { group = modSettingsList.transform.FindChild(setting.Vals[0].ToString()) .gameObject; } GameObject checkboxG = Instantiate(ms.Checkbox); setting.NameText = checkboxG.transform.GetChild(1).GetComponent <Text>(); setting.NameText.text = setting.Name; checkboxG.GetComponent <Toggle>().group = group.GetComponent <ToggleGroup>(); checkboxG.GetComponent <Toggle>().isOn = (bool)setting.Value; if ((bool)setting.Value) { checkboxG.GetComponent <Toggle>().group.NotifyToggleOn( checkboxG.GetComponent <Toggle>()); } checkboxG.GetComponent <Toggle>().onValueChanged.AddListener(delegate { setting.Value = checkboxG.GetComponent <Toggle>().isOn; if (setting.DoAction != null) { setting.DoAction.Invoke(); } }); checkboxG.transform.SetParent(modSettingsList.transform, false); break; case SettingsType.Button: GameObject btn = Instantiate(ms.setBtn); setting.NameText = btn.transform.GetChild(0).GetChild(0).GetComponent <Text>(); setting.NameText.text = setting.Name; btn.transform.GetChild(1).GetComponent <Text>().text = setting.Vals[0].ToString(); btn.transform.GetChild(1).GetComponent <Text>().color = (Color)setting.Vals[4]; if (setting.Vals[0].ToString() == null || setting.Vals[0].ToString() == string.Empty) { btn.transform.GetChild(1).gameObject.SetActive(false); } btn.transform.GetChild(0).GetComponent <Button>().onClick.AddListener( setting.DoAction.Invoke); ColorBlock cb = btn.transform.GetChild(0).GetComponent <Button>().colors; cb.normalColor = (Color)setting.Vals[1]; cb.highlightedColor = (Color)setting.Vals[2]; cb.pressedColor = (Color)setting.Vals[3]; btn.transform.GetChild(0).GetComponent <Button>().colors = cb; btn.transform.SetParent(modSettingsList.transform, false); break; case SettingsType.RButton: GameObject rbtn = Instantiate(ms.setBtn); setting.NameText = rbtn.transform.GetChild(0).GetChild(0).GetComponent <Text>(); setting.NameText.text = setting.Name; rbtn.transform.GetChild(0).GetChild(0).GetComponent <Text>().color = Color.black; rbtn.transform.GetChild(1).gameObject.SetActive(false); rbtn.transform.GetChild(0).GetComponent <Button>().onClick.AddListener( delegate { ModSettings_menu.ResetSpecificSettings( setting.Mod, (Settings[])setting.Vals[0]); ModSettingsShow(setting.Mod); setting.Mod.ModSettingsLoaded(); }); ColorBlock rcb = rbtn.transform.GetChild(0).GetComponent <Button>().colors; rcb.normalColor = new Color32(255, 187, 5, 255); rcb.highlightedColor = new Color32(255, 230, 5, 255); rcb.pressedColor = new Color32(255, 230, 5, 255); rbtn.transform.GetChild(0).GetComponent <Button>().colors = rcb; rbtn.transform.SetParent(modSettingsList.transform, false); break; case SettingsType.Slider: GameObject modViewLabel = Instantiate(ms.ModLabel); setting.NameText = modViewLabel.GetComponent <Text>(); setting.NameText.text = setting.Name; modViewLabel.transform.SetParent(modSettingsList.transform, false); GameObject slidr = Instantiate(ms.slider); slidr.transform.GetChild(1).GetComponent <Text>().text = setting.Value.ToString(); slidr.transform.GetChild(0).GetComponent <Slider>().minValue = float.Parse(setting.Vals[0].ToString()); slidr.transform.GetChild(0).GetComponent <Slider>().maxValue = float.Parse(setting.Vals[1].ToString()); slidr.transform.GetChild(0).GetComponent <Slider>().value = float.Parse(setting.Value.ToString()); slidr.transform.GetChild(0).GetComponent <Slider>().wholeNumbers = (bool)setting.Vals[2]; if (setting.Vals[3] != null) { slidr.transform.GetChild(1).GetComponent <Text>().text = ((string[])setting.Vals[3])[int.Parse(setting.Value.ToString())]; } slidr.transform.GetChild(0) .GetComponent <Slider>() .onValueChanged.AddListener(delegate { if ((bool)setting.Vals[2]) { setting.Value = slidr.transform.GetChild(0).GetComponent <Slider>().value; } else { setting.Value = Math.Round( slidr.transform.GetChild(0).GetComponent <Slider>().value, int.Parse(setting.Vals[4].ToString())); } if (setting.Vals[3] == null) { slidr.transform.GetChild(1).GetComponent <Text>().text = setting.Value.ToString(); } else { slidr.transform.GetChild(1).GetComponent <Text>().text = ((string[])setting.Vals[3])[int.Parse(setting.Value.ToString())]; } if (setting.DoAction != null) { setting.DoAction.Invoke(); } }); slidr.transform.SetParent(modSettingsList.transform, false); break; case SettingsType.TextBox: GameObject modViewLabels = Instantiate(ms.ModLabel); setting.NameText = modViewLabels.GetComponent <Text>(); setting.NameText.text = setting.Name; modViewLabels.GetComponent <Text>().color = (Color)setting.Vals[1]; modViewLabels.transform.SetParent(modSettingsList.transform, false); GameObject txt = Instantiate(ms.textBox); txt.transform.GetChild(0).GetComponent <Text>().text = setting.Vals[0].ToString(); txt.GetComponent <InputField>().contentType = (InputField.ContentType)setting.Vals[2]; txt.GetComponent <InputField>().text = setting.Value.ToString(); txt.GetComponent <InputField>().onValueChange.AddListener( delegate { setting.Value = txt.GetComponent <InputField>().text; }); txt.transform.SetParent(modSettingsList.transform, false); break; case SettingsType.Header: GameObject hdr = Instantiate(ms.header); setting.NameText = hdr.transform.GetChild(0).GetComponent <Text>(); setting.NameText.text = setting.Name; hdr.GetComponent <Image>().color = (Color)setting.Vals[1]; hdr.transform.GetChild(0).GetComponent <Text>().color = (Color)setting.Vals[2]; hdr.transform.SetParent(modSettingsList.transform, false); break; case SettingsType.Text: GameObject tx = Instantiate(ms.ModLabel); setting.NameText = tx.GetComponent <Text>(); setting.NameText.text = setting.Name; tx.transform.SetParent(modSettingsList.transform, false); break; } }