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); } }
private static void MapRenderOutput_Signal(On.DevInterface.MapRenderOutput.orig_Signal orig, global::DevInterface.MapRenderOutput self, global::DevInterface.DevUISignalType type, global::DevInterface.DevUINode sender, string message) { string pathToMapFile = string.Empty; // From a Custom Region foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks) { string customFilePath = CRExtras.BuildPath(keyValues.Value, CRExtras.CustomFolder.RegionID, regionID: self.owner.game.world.name); if (Directory.Exists(customFilePath)) { pathToMapFile = customFilePath + "map_" + self.owner.game.world.name + ".png"; CustomWorldMod.Log($"[DEV] Saving custom Map Config to map_XX.png from [{keyValues.Value}] to [{pathToMapFile}]"); PNGSaver.SaveTextureToFile(self.texture, pathToMapFile); self.ClearSprites(); (self.parentNode as MapPage).renderOutput = null; (self.parentNode as MapPage).modeSpecificNodes.Remove(self); self.parentNode.subNodes.Remove(self); return; } } CustomWorldMod.Log($"[DEV] No custom region folder found for [{self.owner.game.world.name}], using vanilla..."); orig(self, type, sender, message); }
private static void MapRenderOutput_Signal(On.DevInterface.MapRenderOutput.orig_Signal orig, global::DevInterface.MapRenderOutput self, global::DevInterface.DevUISignalType type, global::DevInterface.DevUINode sender, string message) { string customFilePath = string.Empty; /* * string pathToRegion = Custom.RootFolderDirectory() + * "World" + Path.DirectorySeparatorChar + "Regions" + Path.DirectorySeparatorChar + self.owner.game.world.name; */ //if (!File.Exists(pathToRegion)) //{ // From a Custom Region foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks) { customFilePath = Custom.RootFolderDirectory() + CustomWorldMod.resourcePath + keyValues.Value + Path.DirectorySeparatorChar + "World" + Path.DirectorySeparatorChar + "Regions" + Path.DirectorySeparatorChar + self.owner.game.world.name; CustomWorldMod.Log($"[DEV] Searching folder to render map...[{customFilePath}]"); if (Directory.Exists(customFilePath)) { string pathToMapFile = customFilePath + Path.DirectorySeparatorChar + "map_" + self.owner.game.world.name + ".png"; CustomWorldMod.Log($"[DEV] Saving custom Map Config to map_XX.png from [{keyValues.Value}] to [{pathToMapFile}]"); PNGSaver.SaveTextureToFile(self.texture, pathToMapFile); self.ClearSprites(); (self.parentNode as MapPage).renderOutput = null; (self.parentNode as MapPage).modeSpecificNodes.Remove(self); self.parentNode.subNodes.Remove(self); return; } } //} CustomWorldMod.Log($"[DEV] No custom region folder found for [{self.owner.game.world.name}], using vanilla..."); orig(self, type, sender, message); }
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); } } } }