Fix content patch logic
This commit is contained in:
parent
bdd506b0db
commit
f628466adb
|
@ -412,17 +412,28 @@ namespace StardewModdingAPI.Framework
|
||||||
// cached assets
|
// cached assets
|
||||||
foreach (IContentManager contentManager in this.ContentManagers)
|
foreach (IContentManager contentManager in this.ContentManagers)
|
||||||
{
|
{
|
||||||
|
#if SMAPI_FOR_MOBILE
|
||||||
|
HashSet<IAssetName> removingAssets = new HashSet<IAssetName>();
|
||||||
|
#endif
|
||||||
foreach ((string key, object asset) in contentManager.GetCachedAssets())
|
foreach ((string key, object asset) in contentManager.GetCachedAssets())
|
||||||
{
|
{
|
||||||
if (!predicate(contentManager, key, asset.GetType()))
|
if (!predicate(contentManager, key, asset.GetType()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
AssetName assetName = this.ParseAssetName(key, allowLocales: true);
|
AssetName assetName = this.ParseAssetName(key, allowLocales: true);
|
||||||
|
#if !SMAPI_FOR_MOBILE
|
||||||
contentManager.InvalidateCache(assetName, dispose);
|
contentManager.InvalidateCache(assetName, dispose);
|
||||||
|
#else
|
||||||
|
removingAssets.Add(assetName);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!invalidatedAssets.ContainsKey(assetName))
|
if (!invalidatedAssets.ContainsKey(assetName))
|
||||||
invalidatedAssets[assetName] = asset.GetType();
|
invalidatedAssets[assetName] = asset.GetType();
|
||||||
}
|
}
|
||||||
|
#if SMAPI_FOR_MOBILE
|
||||||
|
foreach (IAssetName assetName in removingAssets)
|
||||||
|
contentManager.InvalidateCache(assetName, dispose);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// forget localized flags
|
// forget localized flags
|
||||||
|
|
|
@ -1,9 +1,24 @@
|
||||||
using Microsoft.Xna.Framework.Audio;
|
using System.Reflection;
|
||||||
|
using Microsoft.Xna.Framework.Audio;
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
|
||||||
namespace StardewModdingAPI.Framework.ModLoading.RewriteFacades;
|
namespace StardewModdingAPI.Framework.ModLoading.RewriteFacades;
|
||||||
|
|
||||||
public interface ISoundBankMethods : ISoundBank
|
public interface ISoundBankMethods : ISoundBank
|
||||||
{
|
{
|
||||||
CueDefinition GetCueDefinition(string name);
|
void AddCue(CueDefinition cueDefinition)
|
||||||
|
{
|
||||||
|
SoundBank soundBank = (SoundBank)this.GetType()
|
||||||
|
.GetField("soundBank", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
|
||||||
|
?.GetValue(this);
|
||||||
|
soundBank?.AddCue(cueDefinition);
|
||||||
|
}
|
||||||
|
|
||||||
|
CueDefinition GetCueDefinition(string name)
|
||||||
|
{
|
||||||
|
SoundBank soundBank = (SoundBank)this.GetType()
|
||||||
|
.GetField("soundBank", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
|
||||||
|
?.GetValue(this);
|
||||||
|
return soundBank?.GetCueDefinition(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -654,25 +654,19 @@ namespace StardewModdingAPI.Metadata
|
||||||
{
|
{
|
||||||
Texture2D texture = content.Load<Texture2D>(assetName.BaseName);
|
Texture2D texture = content.Load<Texture2D>(assetName.BaseName);
|
||||||
|
|
||||||
#if SMAPI_FOR_MOBILE
|
|
||||||
this.Reflection.GetField<Texture2D>(titleMenu, "titleButtonsTexture").SetValue(texture);
|
|
||||||
titleMenu.backButton.texture = texture;
|
|
||||||
titleMenu.aboutButton.texture = texture;
|
|
||||||
this.Reflection.GetField<Texture2D>(titleMenu, "languageButton").SetValue(texture);
|
|
||||||
foreach (ClickableTextureComponent button in titleMenu.buttons)
|
|
||||||
button.texture = texture;
|
|
||||||
foreach (TemporaryAnimatedSprite bird in this.Reflection.GetField<List<TemporaryAnimatedSprite>>(titleMenu, "birds").GetValue())
|
|
||||||
bird.texture = texture;
|
|
||||||
#else
|
|
||||||
titleMenu.titleButtonsTexture = texture;
|
titleMenu.titleButtonsTexture = texture;
|
||||||
|
#if SMAPI_FOR_MOBILE
|
||||||
|
if (titleMenu.backButton != null)
|
||||||
titleMenu.backButton.texture = texture;
|
titleMenu.backButton.texture = texture;
|
||||||
|
#else
|
||||||
|
titleMenu.backButton.texture = texture;
|
||||||
|
#endif
|
||||||
titleMenu.aboutButton.texture = texture;
|
titleMenu.aboutButton.texture = texture;
|
||||||
titleMenu.languageButton.texture = texture;
|
titleMenu.languageButton.texture = texture;
|
||||||
foreach (ClickableTextureComponent button in titleMenu.buttons)
|
foreach (ClickableTextureComponent button in titleMenu.buttons)
|
||||||
button.texture = texture;
|
button.texture = texture;
|
||||||
foreach (TemporaryAnimatedSprite bird in titleMenu.birds)
|
foreach (TemporaryAnimatedSprite bird in titleMenu.birds)
|
||||||
bird.texture = texture;
|
bird.texture = texture;
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue