/// <summary> /// Lets you define a xnb file to completely replace with another /// </summary> /// <param name="helper">The <see cref="IContentHelper"/> this extension method is attached to</param> /// <param name="assetName">The asset (Relative to Content and without extension) to replace</param> /// <param name="replacementAssetName">The asset (Relative to your mod directory and without extension) to use instead</param> public static void RegisterXnbReplacement(this IContentHelper helper, string assetName, string replacementAssetName) { assetName = helper.GetActualAssetKey(assetName, ContentSource.GameContent); replacementAssetName = helper.GetActualAssetKey(replacementAssetName, ContentSource.GameContent); if (XnbLoader._Map.ContainsKey(assetName)) { EntoaroxFrameworkMod.Logger.Log("[IContentHelper] The `" + Globals.GetModName(helper) + "` mod's attempt to register a replacement asset for the `" + assetName + "` asset failed, as another mod has already done so.", LogLevel.Error); } else { XnbLoader._Map.Add(assetName, (helper, replacementAssetName)); helper.InvalidateCache(assetName); } }
/// <summary> /// If none of the build in content handlers are sufficient, and making a custom one is overkill, this method lets you handle the loading for one specific asset /// </summary> /// <typeparam name="T">The Type the asset is loaded as</typeparam> /// <param name="helper">The <see cref="IContentHelper"/> this extension method is attached to</param> /// <param name="assetName">The asset (Relative to Content and without extension) to handle</param> /// <param name="assetLoader">The delegate assigned to handle loading for this asset</param> public static void RegisterLoader <T>(this IContentHelper helper, string assetName, AssetLoader <T> assetLoader) { assetName = helper.GetActualAssetKey(assetName, ContentSource.GameContent); if (DeferredAssetHandler._LoadMap.ContainsKey((typeof(T), assetName))) { EntoaroxFrameworkMod.Logger.Log("[IContentHelper] The `" + Globals.GetModName(helper) + "` mod's attempt to register a replacement asset for the `" + assetName + "` asset of type `" + typeof(T).FullName + "` failed, as another mod has already done so.", LogLevel.Error); }
public WorkbenchGeodeMenu(IContentHelper content) : base(null, true, true, 12, 132) { _content = content; if (yPositionOnScreen == borderWidth + spaceToClearTopBorder) { movePosition(0, -spaceToClearTopBorder); } inventory.highlightMethod = HighlightGeodes; GeodeSpot = new ClickableComponent(new Rectangle( xPositionOnScreen + spaceToClearSideBorder + borderWidth / 2, yPositionOnScreen + spaceToClearTopBorder + 4, 560, 308), "") { myID = 998, downNeighborID = 0 }; _clint = new AnimatedSprite(_content.GetActualAssetKey("assets/Empty.png"), 8, 32, 48); if (inventory.inventory != null && inventory.inventory.Count >= 12) { for (var index = 0; index < 12; ++index) { if (inventory.inventory[index] != null) { inventory.inventory[index] .upNeighborID = 998; } } } if (trashCan != null) { trashCan.myID = 106; } if (okButton != null) { okButton.leftNeighborID = 11; } if (!Game1.options.SnappyMenus) { return; } populateClickableComponentList(); snapToDefaultClickableComponent(); }
/// <summary> /// Lets you replace a region of pixels in one texture with the contents of another texture /// </summary> /// <param name="helper">The <see cref="IContentHelper"/> this extension method is attached to</param> /// <param name="assetName">The texture asset (Relative to Content and without extension) that you wish to modify</param> /// <param name="patchAssetName">The texture used for the modification</param> /// <param name="region">The area you wish to replace</param> /// <param name="source">The area you wish to use for replacement, if omitted the full patch texture is used</param> public static void RegisterTexturePatch(this IContentHelper helper, string assetName, Texture2D patchAsset, Rectangle?destination = null, Rectangle?source = null) { assetName = helper.GetActualAssetKey(assetName, ContentSource.GameContent); if (!TextureInjector._Map.ContainsKey(assetName)) { TextureInjector._Map.Add(assetName, new List <(Texture2D, Rectangle?, Rectangle?)>()); } TextureInjector._Map[assetName].Add((patchAsset, source, destination)); helper.InvalidateCache(assetName); }
/// <summary>If none of the build in content handlers are sufficient, and making a custom one is overkill, this method lets you handle the injection for one specific asset.</summary> /// <typeparam name="T">The Type the asset is loaded as.</typeparam> /// <param name="helper">The <see cref="IContentHelper" /> this extension method is attached to.</param> /// <param name="assetName">The asset (Relative to Content and without extension) to handle.</param> /// <param name="assetInjector">The delegate assigned to handle injection for this asset.</param> public static void RegisterInjector <T>(this IContentHelper helper, string assetName, AssetInjector <T> assetInjector) { assetName = helper.GetActualAssetKey(assetName, ContentSource.GameContent); if (!DeferredAssetHandler.EditMap.ContainsKey(assetName)) { DeferredAssetHandler.EditMap.Add(assetName, new List <DeferredAssetInfo>()); } DeferredAssetHandler.EditMap[assetName].Add(new DeferredAssetInfo(typeof(T), assetInjector)); helper.InvalidateCache(assetName); }
/// <summary> /// Lets you define a xnb file to completely replace with another /// </summary> /// <param name="helper">The <see cref="IContentHelper"/> this extension method is attached to</param> /// <param name="assetMapping">Dictionary with the asset (Relative to Content and without extension) to replace as key, and the asset (Relative to your mod directory and without extension) to use instead as value</param> public static void RegisterXnbReplacements(this IContentHelper helper, Dictionary <string, string> assetMapping) { List <string> matchedAssets = new List <string>(); foreach (var pair in assetMapping) { string asset = helper.GetActualAssetKey(pair.Key, ContentSource.GameContent); string replacement = helper.GetActualAssetKey(pair.Value, ContentSource.GameContent); if (XnbLoader._Map.ContainsKey(asset)) { EntoaroxFrameworkMod.Logger.Log("[IContentHelper] The `" + Globals.GetModName(helper) + "` mod's attempt to register a replacement asset for the `" + pair.Key + "` asset failed, as another mod has already done so.", LogLevel.Error); } else { XnbLoader._Map.Add(asset, (helper, replacement)); matchedAssets.Add(asset); } } helper.InvalidateCache((assetInfo) => matchedAssets.Contains(assetInfo.AssetName)); }
/// <summary>If none of the build in content handlers are sufficient, and making a custom one is overkill, this method lets you handle the loading for one specific asset.</summary> /// <typeparam name="T">The Type the asset is loaded as.</typeparam> /// <param name="helper">The <see cref="IContentHelper" /> this extension method is attached to.</param> /// <param name="assetName">The asset (Relative to Content and without extension) to handle.</param> /// <param name="assetLoader">The delegate assigned to handle loading for this asset.</param> public static void RegisterLoader <T>(this IContentHelper helper, string assetName, AssetLoader <T> assetLoader) { assetName = helper.GetActualAssetKey(assetName, ContentSource.GameContent); if (DeferredAssetHandler.LoadMap.ContainsKey(assetName)) { EntoaroxFrameworkMod.Logger.Log($"[IContentHelper] The `{Globals.GetModName(helper)}` mod\'s attempt to register a replacement asset for the `{assetName}` asset of type `{typeof(T).FullName}` failed, as another mod has already done so.", LogLevel.Error); } else { DeferredAssetHandler.LoadMap.Add(assetName, new DeferredAssetInfo(typeof(T), assetLoader)); helper.InvalidateCache(assetName); } }
public static void RegisterDictionaryPatch <TKey, TValue>(this IContentHelper helper, string assetName, Dictionary <TKey, TValue> patchAsset) { try { var check = Game1.content.Load <Dictionary <TKey, TValue> >(assetName); assetName = helper.GetActualAssetKey(assetName, ContentSource.GameContent); if (!DictionaryInjector._Map.ContainsKey(assetName)) { DictionaryInjector._Map.Add(assetName, new DictionaryWrapper <TKey, TValue>()); } (DictionaryInjector._Map[assetName] as DictionaryWrapper <TKey, TValue>).Register(helper, patchAsset); helper.InvalidateCache(assetName); } catch { EntoaroxFrameworkMod.Logger.Log("[IContentHelper] The `" + Globals.GetModName(helper) + "` mod's attempt to inject data into the `" + assetName + "` asset failed, as the TKey and TValue of the injected asset do not match the original.", LogLevel.Error); } }
public MoonLandingArea(IContentHelper content) : base(content, "MoonLandingArea", "MoonLandingArea") { ufoTexPath = content.GetActualAssetKey("assets/ufo-big.png"); }
public UfoInterior(IContentHelper content) : base(content.GetActualAssetKey("assets/maps/UfoInterior.tmx"), "Custom_MM_UfoInterior") { }
public MountainTop(IContentHelper content) : base(content.GetActualAssetKey("assets/maps/InactiveCaldera.tmx"), "Custom_MM_MountainTop") { ufoTexPath = content.GetActualAssetKey("assets/ufo-big.png"); }