Skip to content

Commit

Permalink
Rename Content.ContentData to ItemDefinition.
Browse files Browse the repository at this point in the history
  • Loading branch information
b-b-blueberry committed Aug 8, 2021
1 parent 2f82525 commit e169f3a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions RaisedGardenBeds/AssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Game data
// Patch in dummy object entries after generic object entry
for (int i = 1; i < ModEntry.ItemDefinitions.Count; ++i)
{
Content.ContentData d = ModEntry.ItemDefinitions[ModEntry.ItemDefinitions.Keys.ElementAt(i)];
ItemDefinition d = ModEntry.ItemDefinitions[ModEntry.ItemDefinitions.Keys.ElementAt(i)];
name = Translations.GetNameTranslation(data: d);
fields = data[id].Split('/');
fields[4] = description;
Expand All @@ -194,11 +194,11 @@ Game data

// Add crafting recipes for all object variants
var data = asset.AsDictionary<string, string>().Data;
foreach (KeyValuePair<string, Content.ContentData> idAndFields in ModEntry.ItemDefinitions)
foreach (KeyValuePair<string, ItemDefinition> idAndFields in ModEntry.ItemDefinitions)
{
string[] newFields = new string[]
{ // Crafting ingredients:
Content.ContentData.ParseRecipeIngredients(data: idAndFields.Value),
ItemDefinition.ParseRecipeIngredients(data: idAndFields.Value),
// Unused field:
"blue berry",
// Crafted item ID and quantity:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System.Collections.Generic;
using System.Linq;

namespace RaisedGardenBeds.Content
namespace RaisedGardenBeds
{
public class ContentData
public class ItemDefinition
{
/***************
Required entries
Expand Down Expand Up @@ -71,7 +71,7 @@ Optional entries
[JsonIgnore]
public int SpriteIndex { get; set; }
/// <summary>
/// The <see cref="ContentData.RecipeIngredients"/> dictionary aggregated to a string
/// The <see cref="ItemDefinition.RecipeIngredients"/> dictionary aggregated to a string
/// with all "Object" fields parsed to their equivalent <see cref="StardewValley.Object.ParentSheetIndex"/>.
/// Has no entry in the content data file.
/// </summary>
Expand All @@ -89,7 +89,7 @@ Internal values
Internal methods
***************/

internal static string ParseRecipeIngredients(ContentData data)
internal static string ParseRecipeIngredients(ItemDefinition data)
{
List<string> ingredients = new List<string>();
foreach (Dictionary<string, string> entry in data.RecipeIngredients)
Expand Down
12 changes: 6 additions & 6 deletions RaisedGardenBeds/ModEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ModEntry : Mod
/// Shared object variant dictionary containing entries provided by the content pack, as well as some metadata about the content pack itself.
/// Entries are keyed by <see cref="OutdoorPot.VariantIndex".
/// </summary>
internal static Dictionary<string, Content.ContentData> ItemDefinitions = null;
internal static Dictionary<string, ItemDefinition> ItemDefinitions = null;
/// <summary>
/// Shared object spritesheet dictionary containing object icon, world sprite component, object breakage, and watered/unwatered soil sprites.
/// Entries are keyed by <see cref="OutdoorPot.VariantIndex".
Expand Down Expand Up @@ -233,7 +233,7 @@ private void SaveLoadedBehaviours()

public void LoadContentPacks()
{
ItemDefinitions = new Dictionary<string, Content.ContentData>();
ItemDefinitions = new Dictionary<string, ItemDefinition>();
Sprites = new Dictionary<string, Texture2D>();

List<IContentPack> contentPacks = Helper.ContentPacks.GetOwned().ToList();
Expand All @@ -242,10 +242,10 @@ public void LoadContentPacks()
string packKey = contentPack.Manifest.UniqueID;
var sprites = contentPack.LoadAsset
<Texture2D>
(Content.ContentData.SpritesFile);
(ItemDefinition.SpritesFile);
var data = contentPack.ReadJsonFile
<Dictionary<string, Content.ContentData>>
(Content.ContentData.DefinitionsFile);
<Dictionary<string, ItemDefinition>>
(ItemDefinition.DefinitionsFile);

// For some quality assurance, we check that there are an equal number of entries in the
// ItemDefinitions dictionary as there are sprites in the shared framework spritesheet.
Expand Down Expand Up @@ -289,7 +289,7 @@ public void LoadContentPacks()
}

int parentSheetIndex = 0;
foreach (KeyValuePair<string, Content.ContentData> entry in data)
foreach (KeyValuePair<string, ItemDefinition> entry in data)
{
string variantKey = $"{packKey}.{entry.Key}";

Expand Down
2 changes: 1 addition & 1 deletion RaisedGardenBeds/Translations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static string GetTranslation(string key, object[] tokens = null)
/// Return the display name for an item definition in the <see cref="Translations.ItemTranslations"/> dictionary.
/// </summary>
/// <param name="data">Item definition entry.</param>
public static string GetNameTranslation(Content.ContentData data)
public static string GetNameTranslation(ItemDefinition data)
{
string pack = data.ContentPack.Manifest.UniqueID;
string item = data.LocalName;
Expand Down

0 comments on commit e169f3a

Please sign in to comment.