private static void TriggersPage_ctor(On.DevInterface.TriggersPage.orig_ctor orig, global::DevInterface.TriggersPage self, global::DevInterface.DevUI owner, string IDstring, global::DevInterface.DevUINode parentNode, string name) { orig(self, owner, IDstring, parentNode, name); foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks) { string songsPath = CRExtras.BuildPath(keyValues.Value, CRExtras.CustomFolder.Songs); DirectoryInfo directoryInfo = new DirectoryInfo(songsPath); CustomWorldMod.Log($"[TriggerPage] Loading custom triggers for [{keyValues.Key}]", false, CustomWorldMod.DebugLevel.FULL); if (directoryInfo.Exists) { CustomWorldMod.Log($"[TriggerPage] Found custom triggers for [{keyValues.Key}]", false, CustomWorldMod.DebugLevel.MEDIUM); FileInfo[] files = directoryInfo.GetFiles().Where(x => !x.Extension.Equals(".meta")).ToArray(); if (files.Length < 1) { // No songs in folder continue; } int previousIndex = 0; if (self.songNames == null) { self.songNames = new string[files.Length]; } else { previousIndex = self.songNames.Length; Array.Resize(ref self.songNames, previousIndex + files.Length); } try { for (int j = 0; j < files.Length; j++) { self.songNames[previousIndex + j] = Path.GetFileNameWithoutExtension(files[j].Name); } CustomWorldMod.Log($"[TriggerPage] Loaded ({self.songNames.Length - previousIndex}) sound triggers from [{keyValues.Key}]"); } catch (Exception e) { CustomWorldMod.Log($"Could not load song names in TriggerPage. " + $"PreviousIndex [{previousIndex}], array length [{self.songNames.Length}]. Exception: \n {e}", true); } } } }
private static void CustomDecalRepresentation_ctor(On.DevInterface.CustomDecalRepresentation.orig_ctor orig, global::DevInterface.CustomDecalRepresentation self, global::DevInterface.DevUI owner, string IDstring, global::DevInterface.DevUINode parentNode, PlacedObject pObj, string name) { orig(self, owner, IDstring, parentNode, pObj, name); List <string> customDecalFiles = null; string customFilePath = string.Empty; foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks) { customFilePath = CRExtras.BuildPath(keyValues.Value, CRExtras.CustomFolder.Decals); CustomWorldMod.Log($"Looking for decals at [{customFilePath}]"); if (Directory.Exists(customFilePath)) { DirectoryInfo directoryInfo = new DirectoryInfo(customFilePath); if (customDecalFiles == null) { customDecalFiles = new List <string>(); } foreach (FileInfo file in directoryInfo.GetFiles()) { if (!file.Name.Contains(".png")) { continue; } string decalName = file.Name.Substring(0, file.Name.IndexOf(".png")); if (!file.Name.Contains("meta") && !customDecalFiles.Contains(decalName) && !self.decalFiles.Contains(decalName)) { customDecalFiles.Add(decalName); } } } } if (customDecalFiles != null) { int pointerDecal = self.decalFiles.Length; Array.Resize(ref self.decalFiles, pointerDecal + customDecalFiles.Count); for (int i = 0; i < customDecalFiles.Count; i++) { self.decalFiles[pointerDecal + i] = customDecalFiles[i]; } CustomWorldMod.Log($"Loaded custom decals for DevInterface: [{string.Join(", ", customDecalFiles.ToArray())}]", false, CustomWorldMod.DebugLevel.MEDIUM); } }