Skip to content

Commit

Permalink
Add schedule to NPC lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
b3nk3lly committed Sep 22, 2024
1 parent 6d11d25 commit 29317f3
Show file tree
Hide file tree
Showing 18 changed files with 137 additions and 32 deletions.
64 changes: 32 additions & 32 deletions LookupAnything/DataParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,38 @@ public FriendshipModel GetFriendshipForAnimal(SFarmer player, FarmAnimal animal,
return new FriendshipModel(animal.friendshipTowardFarmer.Value, metadata.Constants.AnimalFriendshipPointsPerLevel, metadata.Constants.AnimalFriendshipMaxPoints);
}

/// <summary>Get the translated display name for a location and optional fish area.</summary>
/// <param name="id">The location's internal name.</param>
/// <param name="data">The location data.</param>
/// <param name="fishAreaId">The fish area ID within the location, if applicable.</param>
public string GetLocationDisplayName(string id, LocationData data, string? fishAreaId)
{
// special cases
{
// skip: no area set
if (string.IsNullOrWhiteSpace(fishAreaId))
return this.GetLocationDisplayName(id, data);

// special case: mine level
if (string.Equals(id, "UndergroundMine", StringComparison.OrdinalIgnoreCase))
return I18n.Location_UndergroundMine_Level(level: id);
}

// get base data
string locationName = this.GetLocationDisplayName(id, data);
string areaName = TokenParser.ParseText(data.FishAreas?.GetValueOrDefault(fishAreaId)?.DisplayName);

// build translation
string displayName = I18n.GetByKey($"location.{id}.{fishAreaId}", new { locationName }).UsePlaceholder(false); // predefined translation
if (string.IsNullOrWhiteSpace(displayName))
{
displayName = !string.IsNullOrWhiteSpace(areaName)
? I18n.Location_FishArea(locationName: locationName, areaName: areaName)
: I18n.Location_UnknownFishArea(locationName: locationName, id: fishAreaId);
}
return displayName;
}

/// <summary>Parse monster data.</summary>
/// <remarks>Reverse engineered from <see cref="StardewValley.Monsters.Monster.parseMonsterInfo"/>, <see cref="GameLocation.monsterDrop"/>, and the <see cref="Debris"/> constructor.</remarks>
public IEnumerable<MonsterData> GetMonsters()
Expand Down Expand Up @@ -608,38 +640,6 @@ from result in itemQueryResults
/*********
** Private methods
*********/
/// <summary>Get the translated display name for a location and optional fish area.</summary>
/// <param name="id">The location's internal name.</param>
/// <param name="data">The location data.</param>
/// <param name="fishAreaId">The fish area ID within the location, if applicable.</param>
private string GetLocationDisplayName(string id, LocationData data, string? fishAreaId)
{
// special cases
{
// skip: no area set
if (string.IsNullOrWhiteSpace(fishAreaId))
return this.GetLocationDisplayName(id, data);

// special case: mine level
if (string.Equals(id, "UndergroundMine", StringComparison.OrdinalIgnoreCase))
return I18n.Location_UndergroundMine_Level(level: id);
}

// get base data
string locationName = this.GetLocationDisplayName(id, data);
string areaName = TokenParser.ParseText(data.FishAreas?.GetValueOrDefault(fishAreaId)?.DisplayName);

// build translation
string displayName = I18n.GetByKey($"location.{id}.{fishAreaId}", new { locationName }).UsePlaceholder(false); // predefined translation
if (string.IsNullOrWhiteSpace(displayName))
{
displayName = !string.IsNullOrWhiteSpace(areaName)
? I18n.Location_FishArea(locationName: locationName, areaName: areaName)
: I18n.Location_UnknownFishArea(locationName: locationName, id: fishAreaId);
}
return displayName;
}

/// <summary>Get the translated display name for a location.</summary>
/// <param name="id">The location's internal name.</param>
/// <param name="data">The location data.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,11 @@ private IEnumerable<ICustomField> GetDataForVillager(NPC npc)
if (this.ShowGiftTastes.Hated)
yield return this.GetGiftTasteField(I18n.Npc_HatesGifts(), giftTastes, ownedItems, GiftTaste.Hate);
}

if (npc.TryLoadSchedule())
{
yield return new ScheduleField(npc.Schedule, this.GameHelper);
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions LookupAnything/GameHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using StardewValley.GameData.Crafting;
using StardewValley.GameData.Crops;
using StardewValley.GameData.FishPonds;
using StardewValley.GameData.Locations;
using StardewValley.Locations;
using StardewValley.Menus;
using StardewValley.Objects;
Expand Down Expand Up @@ -375,6 +376,15 @@ public FriendshipModel GetFriendshipForAnimal(Farmer player, FarmAnimal animal)
return this.DataParser.GetFriendshipForAnimal(player, animal, this.Metadata);
}

/// <summary>Get the translated display name for a location and optional fish area.</summary>
/// <param name="id">The location's internal name.</param>
/// <param name="data">The location data.</param>
/// <param name="fishAreaId">The fish area ID within the location, if applicable.</param>
public string GetLocationDisplayName(string id, LocationData data, string? fishAreaId = null)
{
return this.DataParser.GetLocationDisplayName(id, data, fishAreaId);
}

/// <summary>Parse monster data.</summary>
public IEnumerable<MonsterData> GetMonsterData()
{
Expand Down
6 changes: 6 additions & 0 deletions LookupAnything/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
"location.forest.island-tip": "Waldfluss (Südspitze der großen Insel)",
"location.forest.lake": "Waldteich",
"location.forest.river": "Waldfluss",
"location.HarveyRoom": "Harvey's Room", // TODO
"location.LeoTreeHouse": "Treehouse", // TODO
"location.SandyHouse": "Oasis", // TODO
"location.SebastianRoom": "Sebastian's Room", // TODO
"location.submarine": "Nachtmarkt Tiefsee-U-Boot",
"location.town.northmost-bridge": "Stadt (Nord-östliche Brücke)",
"location.undergroundMine": "Mine",
Expand Down Expand Up @@ -490,6 +494,7 @@
"npc.neutral-gifts": "Neutrale Geschenke",
"npc.dislikes-gifts": "Nicht gemochte Geschenke",
"npc.hates-gifts": "Gehasste Geschenke",
"npc.schedule": "Today's schedule", // TODO

// values
"npc.can-romance.married": "Du bist verheiratet! <", // < turns into a heart
Expand All @@ -499,6 +504,7 @@
"npc.friendship.need-points": "nächstes in {{count}} Punkten",
"npc.undiscovered-gift-taste": "{{count}} unaufgedeckte Gegenstände",
"npc.unowned-gift-taste": "{{count}} nicht bessesene Gegenstände",
"npc.schedule.all-day": "All day", // TODO


/*********
Expand Down
6 changes: 6 additions & 0 deletions LookupAnything/i18n/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
"location.forest.island-tip": "{{locationName}} (river near south tip of large island)",
"location.forest.lake": "{{locationName}} (pond)",
"location.forest.river": "{{locationName}} (river)",
"location.HarveyRoom": "Harvey's Room",
"location.LeoTreeHouse": "Treehouse",
"location.SandyHouse": "Oasis",
"location.SebastianRoom": "Sebastian's Room",
"location.submarine": "Night Market Submarine",
"location.town.northmost-bridge": "{{locationName}} (northmost bridge)",
"location.undergroundMine": "Mines",
Expand Down Expand Up @@ -490,6 +494,7 @@
"npc.neutral-gifts": "Neutral gifts",
"npc.dislikes-gifts": "Dislikes gifts",
"npc.hates-gifts": "Hates gifts",
"npc.schedule": "Today's schedule",

// values
"npc.can-romance.married": "You're married! <", // < turns into a heart
Expand All @@ -499,6 +504,7 @@
"npc.friendship.need-points": "next in {{count}} pts",
"npc.undiscovered-gift-taste": "{{count}} unrevealed items",
"npc.unowned-gift-taste": "{{count}} unowned items",
"npc.schedule.all-day": "All day",


/*********
Expand Down
6 changes: 6 additions & 0 deletions LookupAnything/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
"location.forest.island-tip": "río de bosque (en la punta sureña de la gran isla)",
"location.forest.lake": "estanque de bosque",
"location.forest.river": "río de bosque",
"location.HarveyRoom": "Harvey's Room", // TODO
"location.LeoTreeHouse": "Treehouse", // TODO
"location.SandyHouse": "Oasis", // TODO
"location.SebastianRoom": "Sebastian's Room", // TODO
"location.submarine": "submarino del Mercado de Noche",
"location.town.northmost-bridge": "pueblo (en el puente más al norte)",
"location.undergroundMine": "minas",
Expand Down Expand Up @@ -491,6 +495,7 @@
"npc.neutral-gifts": "Regalos neutrales",
"npc.dislikes-gifts": "Regalos que no le gustaron",
"npc.hates-gifts": "Regalos odiados",
"npc.schedule": "Today's schedule", // TODO

// values
"npc.can-romance.married": "¡Estás casado! <", // < turns into a heart
Expand All @@ -500,6 +505,7 @@
"npc.friendship.need-points": "siguiente en {{count}} puntos",
"npc.undiscovered-gift-taste": "{{count}} items sin revelar",
"npc.unowned-gift-taste": "{{count}} objetos no obtenidos",
"npc.schedule.all-day": "All day", // TODO


/*********
Expand Down
6 changes: 6 additions & 0 deletions LookupAnything/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@
"location.forest.island-tip": "rivière de la forêt (pointe sud de la grande île)",
"location.forest.lake": "étang de la forêt",
"location.forest.river": "rivère de la forêt",
"location.HarveyRoom": "Harvey's Room", // TODO
"location.LeoTreeHouse": "Treehouse", // TODO
"location.SandyHouse": "Oasis", // TODO
"location.SebastianRoom": "Sebastian's Room", // TODO
"location.submarine": "sous-marin du marché de nuit",
"location.town.northmost-bridge": "ville (pont le plus au nord)",
"location.undergroundMine": "mines",
Expand Down Expand Up @@ -493,6 +497,7 @@
"npc.neutral-gifts": "Cadeaux neutres",
"npc.dislikes-gifts": "Cadeaux non appréciés",
"npc.hates-gifts": "Cadeaux détestés",
"npc.schedule": "Today's schedule", // TODO

// values
"npc.can-romance.married": "Vous êtes mariés ! <", // < turns into a heart
Expand All @@ -502,6 +507,7 @@
"npc.friendship.need-points": "manque {{count}} pts",
"npc.undiscovered-gift-taste": "{{count}} goût(s) non révelé(s)",
"npc.unowned-gift-taste": "{{count}} unowned items", // TODO
"npc.schedule.all-day": "All day", // TODO


/*********
Expand Down
6 changes: 6 additions & 0 deletions LookupAnything/i18n/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
"location.forest.island-tip": "erdei folyó (nagy sziget déli csücske)",
"location.forest.lake": "erdei tó",
"location.forest.river": "erdei folyó",
"location.HarveyRoom": "Harvey's Room", // TODO
"location.LeoTreeHouse": "Treehouse", // TODO
"location.SandyHouse": "Oasis", // TODO
"location.SebastianRoom": "Sebastian's Room", // TODO
"location.submarine": "Éjszakai Piac tengeralattjáró",
"location.town.northmost-bridge": "város (legészakibb híd)",
"location.undergroundMine": "bányák",
Expand Down Expand Up @@ -493,6 +497,7 @@
"npc.neutral-gifts": "Semleges ajándékok",
"npc.dislikes-gifts": "Ajándékok, melyeket nem szeret",
"npc.hates-gifts": "Ajándékok, melyeket utál",
"npc.schedule": "Today's schedule", // TODO

// values
"npc.can-romance.married": "Házastársak vagytok! <", // < turns into a heart
Expand All @@ -502,6 +507,7 @@
"npc.friendship.need-points": "Következő szint {{count}} pont múlva",
"npc.undiscovered-gift-taste": "{{count}} fel nem fedezett dolog",
"npc.unowned-gift-taste": "{{count}} unowned items", // TODO
"npc.schedule.all-day": "All day", // TODO


/*********
Expand Down
6 changes: 6 additions & 0 deletions LookupAnything/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@
"location.forest.island-tip": "fiume nella foresta (punta Sud dell'isola maggiore)",
"location.forest.lake": "laghetto nella foresta",
"location.forest.river": "fiume nella foresta",
"location.HarveyRoom": "Harvey's Room", // TODO
"location.LeoTreeHouse": "Treehouse", // TODO
"location.SandyHouse": "Oasis", // TODO
"location.SebastianRoom": "Sebastian's Room", // TODO
"location.submarine": "sottomarino",
"location.town.northmost-bridge": "paese (ponte Nord)",
"location.undergroundMine": "miniera",
Expand Down Expand Up @@ -489,6 +493,7 @@
"npc.neutral-gifts": "Regali neutrali",
"npc.dislikes-gifts": "Regali che non piacciono",
"npc.hates-gifts": "Regali che odia",
"npc.schedule": "Today's schedule", // TODO

// values
"npc.can-romance.married": "Siete sposati! <", // < turns into a heart
Expand All @@ -498,6 +503,7 @@
"npc.friendship.need-points": "prossimo fra {{count}} pti",
"npc.undiscovered-gift-taste": "{{count}} oggetti non rivelati",
"npc.unowned-gift-taste": "{{count}} oggetti non posseduti",
"npc.schedule.all-day": "All day", // TODO


/*********
Expand Down
6 changes: 6 additions & 0 deletions LookupAnything/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
"location.forest.island-tip": "森の川(南の小島の南端)",
"location.forest.lake": "森の池",
"location.forest.river": "森の川",
"location.HarveyRoom": "Harvey's Room", // TODO
"location.LeoTreeHouse": "Treehouse", // TODO
"location.SandyHouse": "Oasis", // TODO
"location.SebastianRoom": "Sebastian's Room", // TODO
"location.submarine": "夜の市 潜水艦",
"location.town.northmost-bridge": "ペリカンタウン(北端の橋)",
"location.undergroundMine": "鉱山",
Expand Down Expand Up @@ -490,6 +494,7 @@
"npc.neutral-gifts": "普通の贈り物",
"npc.dislikes-gifts": "嫌いな贈り物",
"npc.hates-gifts": "大嫌いな贈り物",
"npc.schedule": "Today's schedule", // TODO

// values
"npc.can-romance.married": "あなたと結婚しました!", // < turns into a heart
Expand All @@ -499,6 +504,7 @@
"npc.friendship.need-points": "次のハートまで{{count}}ポイント必要",
"npc.undiscovered-gift-taste": "{{count}}個の贈った事のないアイテム",
"npc.unowned-gift-taste": "{{count}}個のアイテムは未所有",
"npc.schedule.all-day": "All day", // TODO


/*********
Expand Down
6 changes: 6 additions & 0 deletions LookupAnything/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
"location.forest.island-tip": "섬 (큰 섬의 남쪽 끝)",
"location.forest.lake": "숲 호수",
"location.forest.river": "숲 강",
"location.HarveyRoom": "Harvey's Room", // TODO
"location.LeoTreeHouse": "Treehouse", // TODO
"location.SandyHouse": "Oasis", // TODO
"location.SebastianRoom": "Sebastian's Room", // TODO
"location.submarine": "야시장 잠수함",
"location.town.northmost-bridge": "마을 (최북단의 다리)",
"location.undergroundMine": "광산",
Expand Down Expand Up @@ -490,6 +494,7 @@
"npc.neutral-gifts": "그저그런 선물",
"npc.dislikes-gifts": "싫어하는 선물",
"npc.hates-gifts": "혐오하는 선물",
"npc.schedule": "Today's schedule", // TODO

// values
"npc.can-romance.married": "당신은 이미 결혼했다!", // < turns into a heart (Korean does not support emoji)
Expand All @@ -499,6 +504,7 @@
"npc.friendship.need-points": "호감도 UP까지 {{count}}점",
"npc.undiscovered-gift-taste": "공개되지 않은 품목 {{count}}개",
"npc.unowned-gift-taste": "소유하지 않은 품목 {{count}}개",
"npc.schedule.all-day": "All day", // TODO


/*********
Expand Down
6 changes: 6 additions & 0 deletions LookupAnything/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
"location.forest.island-tip": "leśna rzeka (południowy kraniec dużej wyspy)",
"location.forest.lake": "leśny staw",
"location.forest.river": "leśna rzeka",
"location.HarveyRoom": "Harvey's Room", // TODO
"location.LeoTreeHouse": "Treehouse", // TODO
"location.SandyHouse": "Oasis", // TODO
"location.SebastianRoom": "Sebastian's Room", // TODO
"location.submarine": "łódź podwodna Nocnego Rynku",
"location.town.northmost-bridge": "miasto (kładka na północy)",
"location.undergroundMine": "kopalnia",
Expand Down Expand Up @@ -493,6 +497,7 @@
"npc.neutral-gifts": "Neutralne prezenty",
"npc.dislikes-gifts": "Nielubiane prezenty",
"npc.hates-gifts": "Znienawidzone prezenty",
"npc.schedule": "Today's schedule", // TODO

// values
"npc.can-romance.married": "Jesteście małżeństwem! <", // < turns into a heart
Expand All @@ -502,6 +507,7 @@
"npc.friendship.need-points": "następne za {{count}} pkt",
"npc.undiscovered-gift-taste": "{{count}} nieodkrytych przedmiotów",
"npc.unowned-gift-taste": "{{count}} unowned items", // TODO
"npc.schedule.all-day": "All day", // TODO


/*********
Expand Down
6 changes: 6 additions & 0 deletions LookupAnything/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
"location.forest.island-tip": "Rio da Floresta Cinzaseiva (ponta sul da ilha grande)",
"location.forest.lake": "Lagoa da Floresta Cinzaseiva",
"location.forest.river": "Rio da Floresta Cinzaseiva",
"location.HarveyRoom": "Harvey's Room", // TODO
"location.LeoTreeHouse": "Treehouse", // TODO
"location.SandyHouse": "Oasis", // TODO
"location.SebastianRoom": "Sebastian's Room", // TODO
"location.submarine": "Submarino de Pesca do Mercado Noturno",
"location.town.northmost-bridge": "Cidade (ponte mais ao norte)",
"location.undergroundMine": "Minas",
Expand Down Expand Up @@ -491,6 +495,7 @@
"npc.neutral-gifts": "Presentes neutros",
"npc.dislikes-gifts": "Presentes que não gosta",
"npc.hates-gifts": "Presentes que odeia",
"npc.schedule": "Today's schedule", // TODO

// values
"npc.can-romance.married": "Você é casado! <", // < turns into a heart
Expand All @@ -500,6 +505,7 @@
"npc.friendship.need-points": "Precisa de {{count}} pontos para prosseguir",
"npc.undiscovered-gift-taste": "{{count}} itens não revelados",
"npc.unowned-gift-taste": "{{count}} itens não possuídos",
"npc.schedule.all-day": "All day", // TODO


/*********
Expand Down
Loading

0 comments on commit 29317f3

Please sign in to comment.