#pragma warning restore SA1310 // Field names should not contain underscore /// <summary> /// Edits the secret note and ForgeMenuChoice's tooltips to match. /// </summary> /// <param name="e">Event params.</param> internal static void EditAssets(AssetRequestedEventArgs e) { if (e.NameWithoutLocale.IsEquivalentTo(FORGE_MENU_CHOICE)) { e.Edit(EditForgeMenu); } else if (e.NameWithoutLocale.IsEquivalentTo(SECRET_NOTE_LOCATION)) { e.Edit(EditSecretNote); } }
internal static void OnAssetRequested(object sender, AssetRequestedEventArgs e) { AssetManager.Load(e: e); if (Game1.player is null || AssetManager.AssetsToEdit.All(s => !e.NameWithoutLocale.IsEquivalentTo(s))) { return; } e.Edit(apply: AssetManager.EditAsset, priority: AssetEditPriority.Late); }
private void OnAssetRequested(object?sender, AssetRequestedEventArgs e) { // Events if (e.Name.StartsWith(EventPath)) { Load(e.Name.LocaleCode); if (ModEvents == null) { return; } string[] bits = PathUtilities.GetSegments(e.Name.BaseName); string end = bits[^ 1];
private void OnContentAssetRequested(object sender, AssetRequestedEventArgs e) { if (e.DataType == typeof(TokenModel)) { var companionModel = CompanionManager.companionModels.FirstOrDefault(c => e.Name.IsEquivalentTo($"{CustomCompanions.TOKEN_HEADER}{c.GetId()}")); if (companionModel is null) { return; } e.LoadFrom(() => new TokenModel() { Companion = JsonParser.Serialize <object>(companionModel) }, AssetLoadPriority.Exclusive, companionModel.Owner); } }
private static void Load(AssetRequestedEventArgs e) { if (e.NameWithoutLocale.IsEquivalentTo(AssetManager.GameContentSpriteSheetPath)) { e.LoadFromModFile <Texture2D>( relativePath: $"{AssetManager.LocalSpriteSheetPath}.png", priority: AssetLoadPriority.Exclusive); } if (e.NameWithoutLocale.IsEquivalentTo(AssetManager.GameContentIngredientBuffDataPath)) { e.LoadFromModFile <Dictionary <string, string> >( relativePath: $"{AssetManager.LocalIngredientBuffDataPath}.json", priority: AssetLoadPriority.Exclusive); } if (e.NameWithoutLocale.IsEquivalentTo(AssetManager.GameContentBushSpriteSheetPath)) { e.LoadFromModFile <Texture2D>( relativePath: $"{AssetManager.LocalBushSpriteSheetPath}.png", priority: AssetLoadPriority.Exclusive); } if (e.NameWithoutLocale.IsEquivalentTo(AssetManager.GameContentDefinitionsPath)) { e.LoadFromModFile <Dictionary <string, List <string> > >( relativePath: $"{AssetManager.LocalDefinitionsPath}.json", priority: AssetLoadPriority.Exclusive); } if (e.NameWithoutLocale.IsEquivalentTo(AssetManager.GameContentSkillRecipeTablePath)) { e.LoadFromModFile <Dictionary <string, List <string> > >( relativePath: $"{AssetManager.LocalSkillRecipeTablePath}.json", priority: AssetLoadPriority.Exclusive); } if (e.NameWithoutLocale.IsEquivalentTo(AssetManager.GameContentSkillValuesPath)) { e.LoadFromModFile <Dictionary <string, string> >( relativePath: $"{AssetManager.LocalSkillValuesPath}.json", priority: AssetLoadPriority.Exclusive); } if (e.NameWithoutLocale.IsEquivalentTo(AssetManager.GameContentContextTagDataPath)) { e.LoadFromModFile <Dictionary <string, string> >( relativePath: $"{AssetManager.LocalContextTagDataPath}.json", priority: AssetLoadPriority.Exclusive); } }
/// <inheritdoc cref="IContentEvents.AssetRequested"/> /// <param name="e">The event data.</param> public void OnAssetRequested(AssetRequestedEventArgs e) { // Allow for garages from older versions that didn't get normalized correctly. // This can be removed once support for legacy data is dropped. if (e.NameWithoutLocale.IsEquivalentTo("Buildings/TractorGarage") && this.GarageTexture != null) { e.LoadFrom(() => this.GarageTexture, AssetLoadPriority.Low); } // load tractor or garage texture if (e.NameWithoutLocale.IsEquivalentTo($"{this.PublicAssetBasePath}/Tractor") || e.NameWithoutLocale.IsEquivalentTo($"{this.PublicAssetBasePath}/Garage")) { string key = PathUtilities.GetSegments(e.NameWithoutLocale.Name).Last(); e.LoadFrom( () => this.TryLoadFromFile(key, out Texture2D? texture, out string?error) ? texture : throw new InvalidOperationException(error), AssetLoadPriority.Exclusive ); } }
private void OnAssetRequested(object sender, AssetRequestedEventArgs e) { if (e.NameWithoutLocale.IsEquivalentTo("Data\\Blueprints")) { e.Edit(asset => { var data = asset.AsDictionary <string, string>().Data; String[] greenhouse = data["Greenhouse"].Split("/"); String buildableGreenhouseName = greenhouse[8]; String buildableGreenhouseDescription = greenhouse[9]; data.Add("BuildableGreenhouse", $"{BuildMaterialsToString()}/7/6/3/5/-1/-1/Greenhouse/{buildableGreenhouseName}/{buildableGreenhouseDescription}/Buildings/none/64/96/20/null/Farm/{this.Config.BuildPrice}/false"); }); } if (e.Name.IsEquivalentTo("Buildings\\BuildableGreenhouse")) { e.LoadFrom(() => { Texture2D greenhouseTexture = this.Helper.GameContent.Load <Texture2D>("Buildings\\Greenhouse"); Rectangle newBounds = greenhouseTexture.Bounds; newBounds.Y += 160; newBounds.Width -= 128; newBounds.Height -= 160; Texture2D greenhouse = new Texture2D(graphicsDevice, newBounds.Width, newBounds.Height); Color[] data = new Color[newBounds.Width * newBounds.Height]; greenhouseTexture.GetData(0, newBounds, data, 0, newBounds.Width * newBounds.Height); greenhouse.SetData(data); return(greenhouse); }, AssetLoadPriority.High); } if (e.Name.IsEquivalentTo("Maps\\BuildableGreenhouse")) { e.LoadFrom(() => this.Helper.GameContent.Load <Map>("Maps\\Greenhouse"), AssetLoadPriority.High); } }
internal static void OnAssetRequested(object sender, AssetRequestedEventArgs e) { if (e.NameWithoutLocale.IsEquivalentTo("Characters/Junimo")) { e.Edit(asset => { var editor = asset.AsImage(); if (BetterJunimos.Config.FunChanges.JunimosAlwaysHaveLeafUmbrellas || Game1.isRaining) { var rectangle = new Rectangle(0, 0, 128, 128); var umbrella = BetterJunimos.Config.FunChanges.MoreColorfulLeafUmbrellas ? "JunimoUmbrellaOnly_Grayscale" : "JunimoUmbrellaOnly"; var customTexture = BetterJunimos.SHelper.ModContent.Load <Texture2D>($"assets/{umbrella}.png"); editor.PatchImage(customTexture, rectangle, rectangle, PatchMode.Overlay); return; } if (Game1.IsWinter) { var rectangle = new Rectangle(0, 0, 128, 128); var customTexture = BetterJunimos.SHelper.ModContent.Load <Texture2D>($"assets/JunimoBeanie.png"); editor.PatchImage(customTexture, rectangle, rectangle, PatchMode.Overlay); } }); } }
private void OnAssetRequested(object sender, AssetRequestedEventArgs e) { JojaEventAssetEditor.Edit(e); MCTHelperFunctions.LoadRepeatTopics(e); }
private void OnAssetRequested(object?sender, AssetRequestedEventArgs e) => AssetEditor.HandleAssetRequested(e);
private void OnAssetRequested(object?sender, AssetRequestedEventArgs e) => AssetEditor.Edit(e, this.Helper.ModRegistry, this.Helper.DirectoryPath);
/// <inheritdoc cref="IContentEvents.AssetRequested"/> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> private void OnAssetRequested(object?sender, AssetRequestedEventArgs e) { this.TextureManager.OnAssetRequested(e); }
private void AssetRequested(object sender, AssetRequestedEventArgs e) { if (e.NameWithoutLocale.IsEquivalentTo($"Data\\SpecialOrders")) { e.Edit(asset => { var specialorder = asset.Data as Dictionary <string, SpecialOrderData>; /* Remove collection count from special order, not removed from Robin2 * as this would cause the order to be completed immediately with no reward */ void RemoveCount(string order) { specialorder[order].Objectives[0].RequiredCount = "0"; } if (this.config.RemoveCollectionObjective == true) { RemoveCount("Willy"); RemoveCount("Pam"); RemoveCount("Pierre"); RemoveCount("Robin"); RemoveCount("Gus"); RemoveCount("Lewis"); RemoveCount("Linus"); RemoveCount("Evelyn"); RemoveCount("Gunther"); RemoveCount("Caroline"); this.Monitor.Log("Removed collection requirements from two part special orders..."); } // Create easier requirements for given QiChallenge based on config settings if (this.config.EasierQiChallenges.ShipLessQiFruit == true) { specialorder["QiChallenge2"].Objectives[0].RequiredCount = "300"; this.Monitor.Log("Lowered number of qi fruit to ship to 300"); } if (this.config.EasierQiChallenges.LowerJunimoKartScore == true) { specialorder["QiChallenge3"].Objectives[0].RequiredCount = "25000"; this.Monitor.Log("Lowered required Junimo Kart score to 25,000"); } if (this.config.EasierQiChallenges.DonateLessPrismaticShards == true) { specialorder["QiChallenge4"].Objectives[0].RequiredCount = "2"; this.Monitor.Log("Lowered prismatic shards to donate to 2"); } if (this.config.EasierQiChallenges.ShipLessCookedItems == true) { specialorder["QiChallenge6"].Objectives[0].RequiredCount = "50000"; this.Monitor.Log("Lowered value of cooked items to ship to 50,000"); } if (this.config.EasierQiChallenges.GiveLessGifts == true) { specialorder["QiChallenge7"].Objectives[0].RequiredCount = "30"; this.Monitor.Log("Lowered number of loved gifts to give to 30"); } if (this.config.EasierQiChallenges.MoreTimeForExtendedFamily == true) { specialorder["QiChallenge8"].Duration = "Week"; this.Monitor.Log("Time limit for Extended Family set to one week"); } if (this.config.EasierQiChallenges.LessItemsForQisPrismaticGrange == true) { foreach (var objective in specialorder["QiChallenge12"].Objectives) { objective.RequiredCount = "50"; } this.Monitor.Log("Lowered number of coloured items to 50 each"); } }); } else if (e.NameWithoutLocale.IsEquivalentTo($"Strings\\SpecialOrderStrings")) { e.Edit(asset => { var data = asset.AsDictionary <string, string>().Data; this.Monitor.Log("Fixing special order strings to show any requirement changes"); if (this.config.RemoveCollectionObjective == true) { data["Willy_Objective_0_Text"] = ""; data["Willy_Objective_1_Text"] = "Place 100 bug meat in the barrel next to Willy's house."; data["Pam_Objective_0_Text"] = ""; data["Pam_Objective_1_Text"] = "Place 12 potato juice in Pam's kitchen."; data["Pierre_Objective_0_Text"] = ""; data["Pierre_Objective_1_Text"] = "Place 25 gold-quality vegetables in the empty produce box in Pierre's shop."; data["Robin_Objective_0_Text"] = ""; data["Robin_Objective_1_Text"] = "Add 80 hardwood to the stockpile in Robin's house."; data["Gus_Objective_0_Text"] = ""; data["Gus_Objective_1_Text"] = "Put 24 eggs in Gus' fridge."; data["Lewis_Objective_1_Text"] = ""; data["Linus_Objective_0_Text"] = ""; data["Linus_Objective_1_Text"] = "Dump 20 trash in the recycling bin behind the train platform."; data["Evelyn_Objective_0_Text"] = ""; data["Evelyn_Objective_1_Text"] = "Place 12 leeks in Evelyn's kitchen."; data["Gunther_Objective_1_Text"] = ""; data["Gunther_Objective_0_Text"] = "Place 100 bones in the drop box at the museum counter."; } if (this.config.EasierQiChallenges.ShipLessQiFruit == true) { data["QiChallenge2_Text"] = data["QiChallenge2_Text"].Replace("500", "300"); data["QiChallenge2_Objective_0_Text"] = data["QiChallenge2_Objective_0_Text"].Replace("500", "300"); } if (this.config.EasierQiChallenges.LowerJunimoKartScore == true) { data["QiChallenge3_Text"] = data["QiChallenge3_Text"].Replace("50,000", "25,000"); data["QiChallenge3_Objective_0_Text"] = data["QiChallenge3_Objective_0_Text"].Replace("50,000", "25,000"); } if (this.config.EasierQiChallenges.DonateLessPrismaticShards == true) { data["QiChallenge4_Name"] = "Two Precious Stones"; data["QiChallenge4_Text"] = data["QiChallenge4_Text"].Replace("4", "2"); data["QiChallenge4_Objective_0_Text"] = data["QiChallenge4_Objective_0_Text"].Replace("4", "2"); } if (this.config.EasierQiChallenges.ShipLessCookedItems == true) { data["QiChallenge6_Text"] = data["QiChallenge6_Text"].Replace("100,000", "50,000"); data["QiChallenge6_Objective_0_Text"] = data["QiChallenge6_Objective_0_Text"].Replace("100,000", "50,000"); } if (this.config.EasierQiChallenges.GiveLessGifts == true) { data["QiChallenge7_Text"] = data["QiChallenge7_Text"].Replace("50", "30"); data["QiChallenge7_Objective_0_Text"] = data["QiChallenge7_Objective_0_Text"].Replace("50", "30"); } if (this.config.EasierQiChallenges.MoreTimeForExtendedFamily == true) { data["QiChallenge8_Text"] = data["QiChallenge8_Text"].Replace("three days", "one week"); } if (this.config.EasierQiChallenges.LessItemsForQisPrismaticGrange == true) { data["QiChallenge12_Text"] = data["QiChallenge12_Text"].Replace("100", "50"); for (int i = 0; i < 6; i++) { data[$"QiChallenge12_Objective_{i}_Text"] = data[$"QiChallenge12_Objective_{i}_Text"].Replace("100", "50"); } } }); } }
/********* ** Private methods *********/ /// <inheritdoc cref="IContentEvents.AssetRequested"/> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> private void OnAssetRequested(object?sender, AssetRequestedEventArgs e) { // add farm type if (e.NameWithoutLocale.IsEquivalentTo("Data/AdditionalFarms")) { e.Edit(editor => { var data = editor.GetData <List <ModFarmType> >(); data.Add(new() { ID = this.ModManifest.UniqueID, TooltipStringPath = "Strings/UI:Pathoschild_BeachFarm_Description", MapName = "Pathoschild_SmallBeachFarm" }); }); } // add farm description else if (e.NameWithoutLocale.IsEquivalentTo("Strings/UI")) { e.Edit(editor => { var data = editor.AsDictionary <string, string>().Data; data["Pathoschild_BeachFarm_Description"] = $"{I18n.Farm_Name()}_{I18n.Farm_Description()}"; }); } // load map else if (e.NameWithoutLocale.IsEquivalentTo("Maps/Pathoschild_SmallBeachFarm")) { e.LoadFrom( () => { // load map Map map = this.Helper.ModContent.Load <Map>("assets/farm.tmx"); IAssetDataForMap editor = this.Helper.ModContent.GetPatchHelper(map).AsMap(); TileSheet outdoorTilesheet = map.GetTileSheet("untitled tile sheet"); Layer buildingsLayer = map.GetLayer("Buildings"); Layer backLayer = map.GetLayer("Back"); // add islands if (this.Config.EnableIslands) { Map islands = this.Helper.ModContent.Load <Map>("assets/overlay_islands.tmx"); Size size = islands.GetSizeInTiles(); editor.PatchMap(source: islands, targetArea: new Rectangle(0, 26, size.Width, size.Height)); } // add campfire if (this.Config.AddCampfire) { buildingsLayer.Tiles[65, 23] = new StaticTile(buildingsLayer, map.GetTileSheet("zbeach"), BlendMode.Alpha, 157); // driftwood pile buildingsLayer.Tiles[64, 22] = new StaticTile(buildingsLayer, outdoorTilesheet, BlendMode.Alpha, 242); // campfire } // remove shipping bin path if (!this.Config.ShippingBinPath) { for (int x = 71; x <= 72; x++) { for (int y = 14; y <= 15; y++) { backLayer.Tiles[x, y] = new StaticTile(backLayer, outdoorTilesheet, BlendMode.Alpha, 175); // grass tile } } } // add fishing pier if (this.Config.AddFishingPier) { // load overlay Map pier = this.Helper.ModContent.Load <Map>("assets/overlay_pier.tmx"); Size size = pier.GetSizeInTiles(); // get target position Point position = this.Config.CustomFishingPierPosition; if (position == Point.Zero) { position = new Point(70, 26); } // remove building tiles which block movement on the pier { var pierBack = pier.GetLayer("Back"); for (int x = 0; x < size.Width; x++) { for (int y = 0; y < size.Height; y++) { if (pierBack.Tiles[x, y] is not null) { buildingsLayer.Tiles[position.X + x, position.Y + y] = null; } } } } // apply overlay editor.PatchMap(source: pier, targetArea: new Rectangle(position.X, position.Y, size.Width, size.Height)); } // apply tilesheet recolors foreach (TileSheet tilesheet in map.TileSheets) { IAssetName imageSource = this.Helper.GameContent.ParseAssetName(tilesheet.ImageSource); if (imageSource.StartsWith($"{this.TilesheetsPath}/_default/")) { tilesheet.ImageSource = PathUtilities.NormalizeAssetName($"{this.FakeAssetPrefix}/{Path.GetFileNameWithoutExtension(tilesheet.ImageSource)}"); } } return(map); }, AssetLoadPriority.Exclusive ); } // load tilesheet else if (e.NameWithoutLocale.StartsWith(this.FakeAssetPrefix)) { e.LoadFrom( () => { string filename = Path.GetFileName(e.NameWithoutLocale.Name); if (!Path.HasExtension(filename)) { filename += ".png"; } // get relative path to load string?relativePath = new DirectoryInfo(this.GetFullPath(this.TilesheetsPath)) .EnumerateDirectories() .FirstOrDefault(p => p.Name != "_default" && this.Helper.ModRegistry.IsLoaded(p.Name)) ?.Name; relativePath = Path.Combine(this.TilesheetsPath, relativePath ?? "_default", filename); // load asset Texture2D tilesheet = this.Helper.ModContent.Load <Texture2D>(relativePath); return(tilesheet); }, AssetLoadPriority.Exclusive ); } }