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); } }
protected IntranetMemberServiceBase( IMediaService mediaService, IMemberService memberService, UmbracoContext umbracoContext, ICacheService cacheService, IIntranetUserService <IntranetUser> intranetUserService, IIntranetMemberGroupService intranetMemberGroupService, IContentHelper contentHelper ) { _mediaService = mediaService; _memberService = memberService; _umbracoContext = umbracoContext; _cacheService = cacheService; _intranetUserService = intranetUserService; _intranetMemberGroupService = intranetMemberGroupService; _contentHelper = contentHelper; }
public Icons(IContentHelper helper) { LeafSprites = helper.Load <Texture2D>(Path.Combine("assets", "DebrisSpritesFull.png")); WeatherSource = helper.Load <Texture2D>(Path.Combine("assets", "WeatherIcons.png")); //windows is *maybe* having some issues with the .xnb if (Constants.TargetPlatform == "Windows") { FogTexture = helper.Load <Texture2D>(Path.Combine("assets", "PastelFogTexture.png")); } else { FogTexture = helper.Load <Texture2D>(Path.Combine("assets", "ThickerFog.xnb")); } DarudeTexture = helper.Load <Texture2D>(Path.Combine("assets", "low_sand.png")); source2 = Game1.mouseCursors; }
/// <summary>Get the name for today's day event (e.g. wedding or festival) from the game data.</summary> /// <param name="contentHelper">The content helper from which to load festival data.</param> private string GetDayEvent(IContentHelper contentHelper) { // marriage if (SaveGame.loaded?.weddingToday ?? Game1.weddingToday) { return("wedding"); } // festival IDictionary <string, string> festivalDates = contentHelper.Load <Dictionary <string, string> >("Data\\Festivals\\FestivalDates", ContentSource.GameContent); if (festivalDates.TryGetValue($"{Game1.currentSeason}{Game1.dayOfMonth}", out string festivalName)) { return(festivalName); } return(null); }
public CookieHelper(IContentHelper contentHelper, IHttpContextAccessor httpContextAccessor, IMemoryCache memoryCache) { if (contentHelper == null) { throw new ArgumentNullException(nameof(contentHelper)); } if (httpContextAccessor == null) { throw new ArgumentNullException(nameof(httpContextAccessor)); } if (memoryCache == null) { throw new ArgumentNullException(nameof(memoryCache)); } _contentHelper = contentHelper; _httpContextAccessor = httpContextAccessor; _memoryCache = memoryCache; }
/**** ** Methods ****/ /// <summary>Update the current context.</summary> private void UpdateContext() { // get context IContentHelper contentHelper = this.Helper.Content; LocalizedContentManager.LanguageCode language = contentHelper.CurrentLocaleConstant; SDate date = null; Weather?weather = null; if (Context.IsWorldReady) { date = SDate.Now(); weather = this.GetCurrentWeather(); } // update context this.VerboseLog($"Context: date={(date != null ? $"{date.DayOfWeek} {date.Season} {date.Day}" : "none")}, weather={(weather != null ? weather.ToString() : "none")}, locale={language}."); this.PatchManager.UpdateContext(contentHelper, language, date, weather); }
/// <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)); }
public ItemResearchArea(IContentHelper content, IMonitor monitor, int x, int y) { // _researchTexture = content.Load<Texture2D>("assets/images/search-button.png"); // _sellTexture = content.Load<Texture2D>("assets/images/sell-button.png"); _researchTexture = content.Load <Texture2D>(Path.Combine("assets", "images", "search-button")); _sellTexture = content.Load <Texture2D>(Path.Combine("assets", "images", "sell-button.png")); _researchArea = new ClickableComponent(new Rectangle(x, y, Game1.tileSize + 60, Game1.tileSize + 50), ""); _researchButton = new ClickableTextureComponent( new Rectangle( RenderHelpers.GetChildCenterPosition(x, _researchArea.bounds.Width + 2 * UIConstants.BorderWidth, _researchTexture.Width), _researchArea.bounds.Height + 38 + y, _researchTexture.Width, _researchTexture.Height), _researchTexture, new Rectangle(0, 0, _researchTexture.Width, _researchTexture.Height), 1f); ProgressionManager.OnStackChanged += OnStackChanged; }
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(); }
internal static void Load(IContentHelper content) { Assets.RadioactiveTools = content.Load <Texture2D>("assets/tools-radioactive.png"); Assets.MythiciteTools = content.Load <Texture2D>("assets/tools-mythicite.png"); Assets.AnimalGauntlets = content.Load <Texture2D>("assets/animal-gauntlets.png"); Assets.LunarKey = content.Load <Texture2D>("assets/key.png"); Assets.Necklaces = content.Load <Texture2D>("assets/necklaces.png"); Assets.LaunchBackground = content.Load <Texture2D>("assets/launch.png"); Assets.LaunchUfo = content.Load <Texture2D>("assets/ufo-small.png"); Assets.LaunchMoon = content.Load <Texture2D>("assets/moon.png"); Assets.Ufo = content.Load <Texture2D>("assets/ufo-big.png"); Assets.AsteroidsSmall = content.Load <Texture2D>("assets/asteroids-small.png"); Assets.AsteroidsBig = content.Load <Texture2D>("assets/asteroids-large.png"); Assets.HoeDirt = content.Load <Texture2D>("assets/hoedirt.png"); Assets.NecklaceBg = content.Load <Texture2D>("assets/necklace-bg.png"); }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="modID">The mod's unique ID.</param> /// <param name="modDirectory">The full path to the mod's folder.</param> /// <param name="jsonHelper">Encapsulate SMAPI's JSON parsing.</param> /// <param name="contentHelper">An API for loading content assets.</param> /// <param name="commandHelper">An API for managing console commands.</param> /// <param name="modRegistry">an API for fetching metadata about loaded mods.</param> /// <param name="reflectionHelper">An API for accessing private game code.</param> /// <param name="translationHelper">An API for reading translations stored in the mod's <c>i18n</c> folder.</param> /// <exception cref="ArgumentNullException">An argument is null or empty.</exception> /// <exception cref="InvalidOperationException">The <paramref name="modDirectory"/> path does not exist on disk.</exception> public ModHelper(string modID, string modDirectory, JsonHelper jsonHelper, IContentHelper contentHelper, ICommandHelper commandHelper, IModRegistry modRegistry, IReflectionHelper reflectionHelper, ITranslationHelper translationHelper) : base(modID) { // validate directory if (string.IsNullOrWhiteSpace(modDirectory)) { throw new ArgumentNullException(nameof(modDirectory)); } if (!Directory.Exists(modDirectory)) { throw new InvalidOperationException("The specified mod directory does not exist."); } // initialise this.DirectoryPath = modDirectory; this.JsonHelper = jsonHelper ?? throw new ArgumentNullException(nameof(jsonHelper)); this.Content = contentHelper ?? throw new ArgumentNullException(nameof(contentHelper)); this.ModRegistry = modRegistry ?? throw new ArgumentNullException(nameof(modRegistry)); this.ConsoleCommands = commandHelper ?? throw new ArgumentNullException(nameof(commandHelper)); this.Reflection = reflectionHelper ?? throw new ArgumentNullException(nameof(reflectionHelper)); this.Translation = translationHelper ?? throw new ArgumentNullException(nameof(translationHelper)); }
public SpawnMenu(SpawnableItem[] spawnableItems, IContentHelper content, IModHelper helper, IMonitor monitor) : base( inventory: new List <Item>(), reverseGrab: false, showReceivingMenu: true, highlightFunction: item => true, behaviorOnItemGrab: (item, player) => { }, behaviorOnItemSelectFunction: (item, player) => { }, message: null, canBeExitedWithKey: true, showOrganizeButton: false, source: IsAndroid ? source_chest : source_none ) { _monitor = monitor; _content = content; _helper = helper; _spawnableItems = spawnableItems; _itemsInView = ItemsToGrabMenu.actualInventory; ItemsToGrabMenu.highlightMethod = item => !_dropdownExpanded && (ModManager.Instance.ModMode == ModMode.Spawn || ModManager.Instance.GetItemPrice(item, true) <= Game1.player._money); drawBG = false; // disable to draw default ui over new menu behaviorOnItemGrab = OnItemGrab; InitializeComponents(); UpdateView(true); ModManager.Instance.OnUpdateMenuView += OnUpdateMenuView; _categorySelector.OnDropdownToggle += OnDropdownToggle; _helper.Events.Input.ButtonsChanged += OnButtonChanged; }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="spawnableItems">The items available to spawn.</param> /// <param name="content">The content helper for loading assets.</param> /// <param name="monitor">Handles writing to the SMAPI console and log.</param> public ItemMenu(SpawnableItem[] spawnableItems, IContentHelper content, IMonitor monitor) : base( inventory: new List <Item>(), reverseGrab: false, showReceivingMenu: true, highlightFunction: item => true, behaviorOnItemGrab: (item, player) => { }, behaviorOnItemSelectFunction: (item, player) => { }, message: null, canBeExitedWithKey: true, showOrganizeButton: false, source: SConstants.TargetPlatform == GamePlatform.Android ? ItemGrabMenu.source_chest : ItemGrabMenu.source_none // needed on Android to avoid a malformed UI ) { // init settings this.BaseDraw = this.GetBaseDraw(); this.ItemsInView = this.ItemsToGrabMenu.actualInventory; this.AllItems = spawnableItems; this.Categories = this.GetDisplayCategories(spawnableItems).ToArray(); this.Monitor = monitor; // init assets this.StarOutlineTexture = content.Load <Texture2D>("assets/empty-quality.png"); this.SortTexture = content.Load <Texture2D>("assets/sort.png"); this.SortLabelIndent = this.GetSpaceIndent(Game1.smallFont, this.SortTexture.Width) + " "; // init base UI if (!this.IsAndroid) { this.drawBG = false; // handled manually to draw arrows between background and menu } this.behaviorOnItemGrab = this.OnItemGrab; // init custom UI this.InitializeComponents(); this.ResetItemView(rebuild: true); }
public HomeController(IDashboardFactory dashboardFactory, IViewModelBuilder <DashboardViewModel, IDashboard> dashboardViewModelBuilder, IModelExporter <DashboardExportModel, IDashboard> dashboardModelExporter, IRedditAccessTokenProviderFactory redditAccessTokenProviderFactory, IContentHelper contentHelper, ICookieHelper cookieHelper) { if (dashboardFactory == null) { throw new ArgumentNullException(nameof(dashboardFactory)); } if (dashboardViewModelBuilder == null) { throw new ArgumentNullException(nameof(dashboardViewModelBuilder)); } if (dashboardModelExporter == null) { throw new ArgumentNullException(nameof(dashboardModelExporter)); } if (redditAccessTokenProviderFactory == null) { throw new ArgumentNullException(nameof(redditAccessTokenProviderFactory)); } if (contentHelper == null) { throw new ArgumentNullException(nameof(contentHelper)); } if (cookieHelper == null) { throw new ArgumentNullException(nameof(cookieHelper)); } _dashboardFactory = dashboardFactory; _dashboardViewModelBuilder = dashboardViewModelBuilder; _dashboardModelExporter = dashboardModelExporter; _redditAccessTokenProviderFactory = redditAccessTokenProviderFactory; _contentHelper = contentHelper; _cookieHelper = cookieHelper; }
public Icons(IContentHelper helper) { LeafSprites = helper.Load <Texture2D>(Path.Combine("assets", "DebrisSpritesFull.png")); //LeafSprites = helper.Load<Texture2D>(Path.Combine("assets", "Testing.png")); Source2 = Game1.mouseCursors; }
/********* ** Public methods *********/ public ItemUtils(IContentHelper content, IDataHelper data, IMonitor monitor) { Content = content; Data = data; Monitor = monitor; }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="monitor">Encapsulates monitoring and logging.</param> /// <param name="contentHelper">The content helper with which to invalidate assets.</param> public InvalidateCommand(IMonitor monitor, IContentHelper contentHelper) : base(monitor, "invalidate") { this.ContentHelper = contentHelper; }
public ComponentsController(IContentHelper contentHelper) { _contentHelper = contentHelper; }
/// <summary>Update the current context.</summary> /// <param name="contentHelper">The content helper through which to invalidate assets.</param> public void UpdateContext(IContentHelper contentHelper) { this.VerboseLog("Propagating context..."); // update patches InvariantHashSet reloadAssetNames = new InvariantHashSet(); string prevAssetName = null; foreach (IPatch patch in this.Patches.OrderByIgnoreCase(p => p.AssetName).ThenByIgnoreCase(p => p.LogName)) { // log asset name if (this.Verbose && prevAssetName != patch.AssetName) { this.VerboseLog($" {patch.AssetName}:"); prevAssetName = patch.AssetName; } // track old values string wasAssetName = patch.AssetName; bool wasApplied = patch.MatchesContext; // update patch IContext tokenContext = this.TokenManager.TrackLocalTokens(patch.ContentPack.Pack); bool changed = patch.UpdateContext(tokenContext); bool shouldApply = patch.MatchesContext; // track patches to reload bool reload = (wasApplied && changed) || (!wasApplied && shouldApply); if (reload) { patch.IsApplied = false; if (wasApplied) { reloadAssetNames.Add(wasAssetName); } if (shouldApply) { reloadAssetNames.Add(patch.AssetName); } } // log change if (this.Verbose) { IList <string> changes = new List <string>(); if (wasApplied != shouldApply) { changes.Add(shouldApply ? "enabled" : "disabled"); } if (wasAssetName != patch.AssetName) { changes.Add($"target: {wasAssetName} => {patch.AssetName}"); } string changesStr = string.Join(", ", changes); this.VerboseLog($" [{(shouldApply ? "X" : " ")}] {patch.LogName}: {(changes.Any() ? changesStr : "OK")}"); } // warn for invalid load patch if (patch is LoadPatch loadPatch && patch.MatchesContext && !patch.ContentPack.FileExists(loadPatch.LocalAsset.Value)) { this.Monitor.Log($"Patch error: {patch.LogName} has a {nameof(PatchConfig.FromFile)} which matches non-existent file '{loadPatch.LocalAsset.Value}'.", LogLevel.Error); } } // rebuild asset name lookup this.PatchesByCurrentTarget = new InvariantDictionary <HashSet <IPatch> >( from patchGroup in this.Patches.GroupByIgnoreCase(p => p.AssetName) let key = patchGroup.Key let value = new HashSet <IPatch>(patchGroup) select new KeyValuePair <string, HashSet <IPatch> >(key, value) ); // reload assets if needed if (reloadAssetNames.Any()) { this.VerboseLog($" reloading {reloadAssetNames.Count} assets: {string.Join(", ", reloadAssetNames.OrderByIgnoreCase(p => p))}"); contentHelper.InvalidateCache(asset => { this.VerboseLog($" [{(reloadAssetNames.Contains(asset.AssetName) ? "X" : " ")}] reload {asset.AssetName}"); return(reloadAssetNames.Contains(asset.AssetName)); }); } }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="contentHelper">The content helper from which to read textures.</param> public DebugOverlay(IContentHelper contentHelper) { this.Content = contentHelper; this.TextureNames = this.GetTextureNames(contentHelper).OrderBy(p => p).ToArray(); this.NextTexture(); }
public ModulesController(IContentHelper contentHelper) { _contentHelper = contentHelper; }
public void Setup() { _fileHelper = MockRepository.GenerateMock<IContentHelper>(); _sut = new ArgumentsValidator(_fileHelper); }
/********* ** Public methods *********/ public DialogueManager(IConfig config, IContentHelper content, IMonitor monitor) { this.Config = config; this.Content = content; this.Monitor = monitor; }
/********* ** Public methods *********/ public DictionaryAssetInfo(IContentHelper contentHelper, IDictionary <TKey, TValue> data) { this.ContentHelper = contentHelper; this.Data = data; }
public override void LoadContent(IContentHelper contentHelper) { dyingSong = contentHelper.GetContent <Song>("Death"); base.LoadContent(contentHelper); }
/********* ** Private methods *********/ /// <summary>Get the global value providers with which to initialise the token manager.</summary> /// <param name="contentHelper">The content helper from which to load data assets.</param> /// <param name="installedMods">The installed mod IDs.</param> private IEnumerable <IValueProvider> GetGlobalValueProviders(IContentHelper contentHelper, IEnumerable <string> installedMods) { bool NeedsBasicInfo() => this.IsBasicInfoLoaded; // date and weather yield return(new ConditionTypeValueProvider(ConditionType.Day, () => SDate.Now().Day.ToString(CultureInfo.InvariantCulture), NeedsBasicInfo, allowedValues: Enumerable.Range(1, 28).Select(p => p.ToString()))); yield return(new ConditionTypeValueProvider(ConditionType.DayEvent, () => this.GetDayEvent(contentHelper), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.DayOfWeek, () => SDate.Now().DayOfWeek.ToString(), NeedsBasicInfo, allowedValues: Enum.GetNames(typeof(DayOfWeek)))); yield return(new ConditionTypeValueProvider(ConditionType.DaysPlayed, () => Game1.stats.DaysPlayed.ToString(CultureInfo.InvariantCulture), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.Season, () => SDate.Now().Season, NeedsBasicInfo, allowedValues: new[] { "Spring", "Summer", "Fall", "Winter" })); yield return(new ConditionTypeValueProvider(ConditionType.Year, () => SDate.Now().Year.ToString(CultureInfo.InvariantCulture), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.Weather, this.GetCurrentWeather, NeedsBasicInfo, allowedValues: Enum.GetNames(typeof(Weather)))); // player yield return(new ConditionTypeValueProvider(ConditionType.HasFlag, this.GetMailFlags, NeedsBasicInfo)); yield return(new HasProfessionValueProvider(NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.HasReadLetter, this.GetReadLetters, NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.HasSeenEvent, this.GetEventsSeen, NeedsBasicInfo)); yield return(new HasWalletItemValueProvider(NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.IsMainPlayer, () => Context.IsMainPlayer.ToString(), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.IsOutdoors, () => Game1.currentLocation?.IsOutdoors.ToString(), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.LocationName, () => Game1.currentLocation?.Name, NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.PlayerGender, () => (Game1.player.IsMale ? Gender.Male : Gender.Female).ToString(), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.PlayerName, () => Game1.player.Name, NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.PreferredPet, () => (Game1.player.catPerson ? PetType.Cat : PetType.Dog).ToString(), NeedsBasicInfo)); yield return(new SkillLevelValueProvider(NeedsBasicInfo)); // relationships yield return(new VillagerHeartsValueProvider()); yield return(new VillagerRelationshipValueProvider()); yield return(new ConditionTypeValueProvider(ConditionType.Spouse, () => Game1.player?.spouse, NeedsBasicInfo)); // world yield return(new ConditionTypeValueProvider(ConditionType.FarmCave, () => this.GetEnum(Game1.player.caveChoice.Value, FarmCaveType.None).ToString(), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.FarmhouseUpgrade, () => Game1.player.HouseUpgradeLevel.ToString(), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.FarmName, () => Game1.player.farmName.Value, NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.FarmType, () => this.GetEnum(Game1.whichFarm, FarmType.Custom).ToString(), NeedsBasicInfo)); yield return(new ConditionTypeValueProvider(ConditionType.IsCommunityCenterComplete, () => this.GetIsCommunityCenterComplete().ToString(), NeedsBasicInfo)); // other yield return(new ImmutableValueProvider(ConditionType.HasMod.ToString(), new InvariantHashSet(installedMods), canHaveMultipleValues: true)); yield return(new HasValueValueProvider()); yield return(new ConditionTypeValueProvider(ConditionType.Language, () => contentHelper.CurrentLocaleConstant.ToString(), allowedValues: Enum.GetNames(typeof(LocalizedContentManager.LanguageCode)).Where(p => p != LocalizedContentManager.LanguageCode.th.ToString()))); }
protected virtual void LoadEnemySpriteSheet(IContentHelper contentHelper) { enemySpriteSheet = enemySpriteSheet ?? contentHelper.GetContent <Texture2D>(this.GetType().Name + "SpriteSheet"); }
/// <summary>Update the current context.</summary> /// <param name="contentHelper">The content helper which manages game assets.</param> /// <param name="language">The current language.</param> /// <param name="date">The current in-game date (if applicable).</param> /// <param name="weather">The current in-game weather (if applicable).</param> /// <param name="spouse">The current player's internal spouse name (if applicable).</param> /// <param name="dayEvent">The day event (e.g. wedding or festival) occurring today (if applicable).</param> /// <param name="seenEvents">The event IDs which the player has seen.</param> /// <param name="mailFlags">The mail flags set for the player.</param> /// <param name="friendships">The current player's friendship details.</param> public void UpdateContext(IContentHelper contentHelper, LocalizedContentManager.LanguageCode language, SDate date, Weather?weather, string dayEvent, string spouse, int[] seenEvents, string[] mailFlags, IEnumerable <KeyValuePair <string, Friendship> > friendships) { this.VerboseLog("Propagating context..."); // update context this.ConditionContext.Set(language: language, date: date, weather: weather, dayEvent: dayEvent, spouse: spouse, seenEvents: seenEvents, mailFlags: mailFlags, friendships: friendships); IDictionary <ConditionKey, string> tokenisableConditions = this.ConditionContext.GetSingleValueConditions(); // update patches InvariantHashSet reloadAssetNames = new InvariantHashSet(); string prevAssetName = null; foreach (IPatch patch in this.Patches.OrderBy(p => p.AssetName).ThenBy(p => p.LogName)) { // log asset name if (this.Verbose && prevAssetName != patch.AssetName) { this.VerboseLog($" {patch.AssetName}:"); prevAssetName = patch.AssetName; } // track old values string wasAssetName = patch.AssetName; bool wasApplied = patch.MatchesContext; // update patch bool changed = patch.UpdateContext(this.ConditionContext, tokenisableConditions); bool shouldApply = patch.MatchesContext; // track patches to reload bool reload = (wasApplied && changed) || (!wasApplied && shouldApply); if (reload) { patch.IsApplied = false; if (wasApplied) { reloadAssetNames.Add(wasAssetName); } if (shouldApply) { reloadAssetNames.Add(patch.AssetName); } } // log change if (this.Verbose) { IList <string> changes = new List <string>(); if (wasApplied != shouldApply) { changes.Add(shouldApply ? "enabled" : "disabled"); } if (wasAssetName != patch.AssetName) { changes.Add($"target: {wasAssetName} => {patch.AssetName}"); } string changesStr = string.Join(", ", changes); this.VerboseLog($" [{(shouldApply ? "X" : " ")}] {patch.LogName}: {(changes.Any() ? changesStr : "OK")}"); } } // rebuild asset name lookup this.PatchesByCurrentTarget = new InvariantDictionary <HashSet <IPatch> >( from patchGroup in this.Patches.GroupBy(p => p.AssetName, StringComparer.InvariantCultureIgnoreCase) let key = patchGroup.Key let value = new HashSet <IPatch>(patchGroup) select new KeyValuePair <string, HashSet <IPatch> >(key, value) ); // reload assets if needed if (reloadAssetNames.Any()) { this.VerboseLog($" reloading {reloadAssetNames.Count} assets: {string.Join(", ", reloadAssetNames.OrderBy(p => p))}"); contentHelper.InvalidateCache(asset => { this.VerboseLog($" [{(reloadAssetNames.Contains(asset.AssetName) ? "X" : " ")}] reload {asset.AssetName}"); return(reloadAssetNames.Contains(asset.AssetName)); }); } }
public JunimoEditor(IContentHelper Content) { this.Content = Content; }
public CommonServices(IMonitor monitor, IModEvents events, ITranslationHelper translationHelper, IReflectionHelper reflectionHelper, IContentHelper contentHelper, IDataHelper dataHelper) { Monitor = monitor ?? throw new ArgumentNullException(nameof(monitor)); Events = events ?? throw new ArgumentNullException(nameof(events)); TranslationHelper = translationHelper ?? throw new ArgumentNullException(nameof(translationHelper)); ReflectionHelper = reflectionHelper ?? throw new ArgumentNullException(nameof(reflectionHelper)); ContentHelper = contentHelper ?? throw new ArgumentNullException(nameof(contentHelper)); DataHelper = dataHelper ?? throw new ArgumentNullException(nameof(dataHelper)); }
public Icons(IContentHelper helper) { MoonSource = helper.Load <Texture2D>(Path.Combine("Assets", "MoonPhases.png")); source2 = Game1.mouseCursors; }