internal static void Initialize() { try { string basedir = Path.Combine(Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CumLoader"), "Dependencies"), "SupportModules"); string filepath = null; if (Imports.IsIl2CppGame()) { filepath = Path.Combine(basedir, "CumLoader.Support.Il2Cpp.dll"); } else { if (File.Exists(Path.Combine(Imports.GetAssemblyDirectory(), "UnityEngine.CoreModule.dll"))) { filepath = Path.Combine(basedir, "CumLoader.Support.Mono.dll"); } else { if (IsOldUnity()) { filepath = Path.Combine(basedir, "CumLoader.Support.Mono.Pre2017.2.dll"); } else { filepath = Path.Combine(basedir, "CumLoader.Support.Mono.Pre2017.dll"); } } } if (File.Exists(filepath)) { byte[] data = File.ReadAllBytes(filepath); if (data.Length > 0) { assembly = Assembly.Load(data); if (!assembly.Equals(null)) { type = assembly.GetType("CumLoader.Support.Main"); if (!type.Equals(null)) { MethodInfo method = type.GetMethod("Initialize", BindingFlags.NonPublic | BindingFlags.Static); if (!method.Equals(null)) { supportModule = (ISupportModule)method.Invoke(null, new object[0]); } } } } } else { CumLogger.LogError("Unable to load Support Module! Support Module is Missing!"); CumLogger.Log("------------------------------"); } } catch (Exception e) { CumLogger.LogError("Unable to load Support Module!\n" + e.ToString()); CumLogger.Log("------------------------------"); } }
public static void SaveConfig() { foreach (KeyValuePair <string, Dictionary <string, CumPreference> > prefsInSection in prefs) { foreach (KeyValuePair <string, CumPreference> pref in prefsInSection.Value) { pref.Value.Value = pref.Value.ValueEdited; ConfigFile.SetString(prefsInSection.Key, pref.Key, pref.Value.Value); } } CumHandler.OnModSettingsApplied(); CumLogger.Log("Config Saved!"); }
private static bool Initialize() { string GeneratorProcessPath = Path.Combine(Path.Combine(Path.Combine(Path.Combine(Imports.GetGameDirectory(), "CumLoader"), "Dependencies"), "AssemblyGenerator"), "CumLoader.AssemblyGenerator.exe"); if (!File.Exists(GeneratorProcessPath)) { CumLogger.LogError("CumLoader.AssemblyGenerator.exe does not Exist!"); return(false); } var generatorProcessInfo = new ProcessStartInfo(GeneratorProcessPath); generatorProcessInfo.Arguments = $"\"{CumLoaderBase.UnityVersion}\" {"\"" + Regex.Replace(Imports.GetGameDirectory(), @"(\\+)$", @"$1$1") + "\""} {"\"" + Regex.Replace(Imports.GetGameDataDirectory(), @"(\\+)$", @"$1$1") + "\""} {(Force_Regenerate() ? "true" : "false")} {(string.IsNullOrEmpty(Force_Version_Unhollower()) ? "" : Force_Version_Unhollower())}"; generatorProcessInfo.UseShellExecute = false; generatorProcessInfo.RedirectStandardOutput = true; generatorProcessInfo.CreateNoWindow = true; Process process = null; try { process = Process.Start(generatorProcessInfo); } catch (Exception e) { CumLogger.LogError(e.ToString()); CumLogger.LogError("Unable to Start Assembly Generator!"); return(false); } var stdout = process.StandardOutput; while (!stdout.EndOfStream) { CumLogger.Log(stdout.ReadLine()); } while (!process.HasExited) { Thread.Sleep(100); } if (process.ExitCode != 0) { CumLogger.Native_ThrowInternalError($"Assembly Generator exited with code {process.ExitCode}"); return(false); } if (Imports.IsDebugMode()) { CumLogger.Log($"Assembly Generator ran Successfully!"); } return(true); }