public AssetModifier(IModHelper helper, IMonitor monitor, int desertWarpX) { this.helper = helper; this.desertWarpX = desertWarpX; IManifest loadedManifest = null; foreach (var contentPack in helper.GetContentPacks()) { if (loadedManifest != null) { monitor.Log( $"Could not load obelisk texture from {contentPack.Manifest.Name} ({contentPack.Manifest.UniqueID}) because {loadedManifest.Name} ({loadedManifest.UniqueID}) is already loaded.", LogLevel.Warn); continue; } try { this.obeliskTexture = contentPack.LoadAsset <Texture2D>("assets/Desert Obelisk.png"); loadedManifest = contentPack.Manifest; monitor.Log($"Loaded obelisk texture from {loadedManifest.Name} ({loadedManifest.UniqueID}).", LogLevel.Debug); } catch { monitor.Log( $"Could not load obelisk texture from {contentPack.Manifest.Name} ({contentPack.Manifest.UniqueID}) because no valid texture was found.", LogLevel.Warn); monitor.Log( "The accepted format is an image named 'Desert Obelisk.png' inside a folder named 'assets' in the root content pack folder.", LogLevel.Warn); } } if (this.obeliskTexture == null) { if (helper.ModRegistry.IsLoaded("Lita.StarblueValley")) { monitor.Log( "No valid content pack was found but Starblue Valley is installed, using Starblue obelisk texture.", LogLevel.Trace); this.obeliskTexture = helper.Content.Load <Texture2D>("assets/Desert Obelisk Starblue.png"); } else { monitor.Log( "Loaded default obelisk texture because no content packs or Starblue Valley were found/valid.", LogLevel.Trace); this.obeliskTexture = helper.Content.Load <Texture2D>("assets/Desert Obelisk.png"); } } helper.Content.AssetLoaders.Add(this); helper.Content.AssetEditors.Add(this); this.ModifyMap(); }
/// <summary>Gets all valid <see cref="ArtisanGoodTextureProvider"/>s that can be used to get artisan good icons.</summary> internal static IEnumerable <ArtisanGoodTextureProvider> GetTextureProviders(IModHelper helper, IMonitor monitor) { //Load content packs first so vanilla icons can be overwritten foreach (IContentPack pack in helper.GetContentPacks()) { foreach (ArtisanGoodTextureProvider provider in TryLoadContentSource(new ContentPackSource(pack), monitor)) { yield return(provider); } } //Load vanilla icons foreach (ArtisanGoodTextureProvider provider in TryLoadContentSource(new ModSource(helper), monitor)) { yield return(provider); } }
public override void Entry(IModHelper helper) { foreach (IContentPack pack in helper.GetContentPacks()) { foreach (CustomPathConfig path in pack.ReadJsonFile <List <CustomPathConfig> >("paths.json")) { string key = pack.Manifest.UniqueID + "<" + path.Name + ">"; if (CustomPathsMod.Map.ContainsKey(key)) { this.Monitor.Log("Encountered duplicate path name `" + path.Name + "` in the `" + pack.Manifest.UniqueID + "` Content Pack, duplicate is being skipped", LogLevel.Warn); continue; } if (path.Seasonal) { Dictionary <string, Texture2D> textures = new Dictionary <string, Texture2D>(); foreach (string season in CustomPathsMod.Seasons) { textures.Add(season, pack.LoadAsset <Texture2D>(path.File + "_" + season + ".png")); } CustomPathsMod.Map.Add(key, new CustomPathInfo(textures, path)); } else { CustomPathsMod.Map.Add(key, new CustomPathInfo(pack.LoadAsset <Texture2D>(path.File + ".png"), path)); } this.Monitor.Log("Path added: " + key, LogLevel.Trace); } } if (CustomPathsMod.Map.Any(a => !string.IsNullOrEmpty(a.Value.Salesman))) { this.Monitor.Log("One or more paths are for sale, enabling menu hook", LogLevel.Trace); MenuEvents.MenuChanged += this.Event_MenuChanged; } if (CustomPathsMod.Map.Any(a => a.Value.Speed > 0)) { this.Monitor.Log("One or more paths give a speed boost, enabling update hook", LogLevel.Trace); GameEvents.UpdateTick += this.GameEvents_UpdateTick; } }
internal ContentPackManager(IModHelper helper, IMonitor monitor, IEnumerable <string> imagesToLoad) { foreach (IContentPack pack in helper.GetContentPacks()) { foreach (string image in imagesToLoad) { try { Texture2D texture = pack.LoadAsset <Texture2D>($"assets/{image}.png"); if (this.loadedTextures.TryGetValue(image, out Tuple <IManifest, Texture2D> loaded)) { monitor.Log($"Couldn't load {image} from {pack.Manifest.Name} ({pack.Manifest.UniqueID}) because {image} from {loaded.Item1.Name} ({loaded.Item1.UniqueID}) was already loaded.", LogLevel.Warn); } else { this.loadedTextures[image] = new Tuple <IManifest, Texture2D>(pack.Manifest, texture); monitor.Log($"Loaded {image} from {pack.Manifest.Name} ({pack.Manifest.UniqueID}).", LogLevel.Trace); } } catch { monitor.Log($"Couldn't load assets/{image}.png from {pack.Manifest.Name} ({pack.Manifest.UniqueID}).", LogLevel.Trace); } } } foreach (string image in imagesToLoad) { if (!this.loadedTextures.ContainsKey(image)) { this.loadedTextures[image] = new Tuple <IManifest, Texture2D>(null, helper.Content.Load <Texture2D>($"assets/{image}.png")); monitor.Log($"Loaded default {image}.", LogLevel.Trace); } } }