Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Almanac for 1.6.10 Without Random Features #35

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Almanac/Almanac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

<EnableHarmony>true</EnableHarmony>
<EnableTranslation>true</EnableTranslation>

<UseCommon>Crafting;BCInventory;Inventory;GMCM;Mutex;Overlay;UI;SimpleLayout;Flow;SpookyAction;ThemeManager</UseCommon>
</PropertyGroup>

<Import Project="..\Common\Common.projitems" Label="Shared" />
Expand Down
4 changes: 2 additions & 2 deletions Almanac/Crops/CropPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public CropPage(AlmanacMenu menu, ModEntry mod) : base(menu, mod) {
rightNeighborID = ClickableComponent.SNAP_AUTOMATIC
};
tabSeedsSprite = Game1.random.Next(2 * AlmanacMenu.TABS.Length);
spriteSeeds = SpriteHelper.GetSprite(InventoryHelper.CreateItemById("(O)495", 1));
spriteSeeds = SpriteHelper.GetSprite(ItemRegistry.Create("(O)495"));

// Cache Agriculturist status.
Agriculturist = Game1.player.professions.Contains(Farmer.agriculturist);
Expand Down Expand Up @@ -350,7 +350,7 @@ public override void Update() {
break;
}

spriteSeeds = SpriteHelper.GetSprite(InventoryHelper.CreateItemById(seasonSeeds, 1));
spriteSeeds = SpriteHelper.GetSprite(ItemRegistry.Create(seasonSeeds));

LastDays = new List<CropInfo>[ModEntry.DaysPerMonth];

Expand Down
29 changes: 20 additions & 9 deletions Almanac/FishHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public static Dictionary<string, Dictionary<SubLocation, List<int>>> GetFishLoca
//Dictionary<SubLocation, seasons>
Dictionary<string, Dictionary<SubLocation, List<int>>> result = new();
//Dictionary<locationId, locationData>
var locations = Game1.content.Load<Dictionary<string, LocationData>>("Data\\Locations");
var locations = Game1.content.Load<Dictionary<string, LocationData>>(@"Data\Locations");

foreach (var lp in locations) {
if (SkipLocation(lp.Key))
Expand Down Expand Up @@ -164,7 +164,7 @@ public static Dictionary<string, Dictionary<SubLocation, List<int>>> GetFishLoca
public static Dictionary<string, List<SubLocation>> GetFishLocations(int season) {
Dictionary<string, List<SubLocation>> result = new();

var locations = Game1.content.Load<Dictionary<string, LocationData>>("Data\\Locations");
var locations = Game1.content.Load<Dictionary<string, LocationData>>(@"Data\Locations");
foreach (var lp in locations) {
if (SkipLocation(lp.Key))
continue;
Expand Down Expand Up @@ -197,7 +197,7 @@ public static Dictionary<string, List<string>> GetLocationFish(string key, int s
if (key == "BeachNightMarket")
key = "Beach";

locations ??= Game1.content.Load<Dictionary<string, LocationData>>("Data\\Locations");
locations ??= Game1.content.Load<Dictionary<string, LocationData>>(@"Data\Locations");
Dictionary<string, List<string>> result;
GameLocation loc;
if (locations.ContainsKey(key) && ContainsFish(locations[key]))
Expand Down Expand Up @@ -262,7 +262,7 @@ public static Dictionary<string, List<string>> GetLocationFish(string key, int s
}
}
try{
GetLocationFish(season, locations[Game1.GetFarmTypeKey()], result);
GetLocationFish(season, locations[Game1.GetFarmTypeID()], result);
} catch {
ModEntry.Instance.Log($"Error at {getLocName(locations[Game1.GetFarmTypeKey()])}, farm key section.", LogLevel.Warn);
}
Expand All @@ -288,10 +288,10 @@ public static Dictionary<string, List<string>> GetLocationFish(int season, Locat
if (data.Equals(null))
return existing;

string name = getLocName(data);
string name = data.DisplayName;
List<SpawnFishData> entries = data.Fish;
if (!data.Equals(Game1.content.Load<Dictionary<string, LocationData>>("Data\\Locations")["Default"])) {
LocationData Default = Game1.content.Load<Dictionary<string, LocationData>>("Data\\Locations")["Default"];
if (!data.Equals(DataLoader.Locations(Game1.content)["Default"])) {
LocationData Default = DataLoader.Locations(Game1.content)["Default"];
foreach (SpawnFishData f in Default.Fish)
if (!entries.Contains(f))
entries.Add(f);
Expand All @@ -316,8 +316,19 @@ public static bool ContainsFish(LocationData loc) {
return false;
}
private static string getLocName(LocationData data) {
string name = data.DisplayName == null ? "No DisplayName" : data.DisplayName;
string name = data.DisplayName ?? "No DisplayName";
string endCheck = name.Substring(name.Length - 7);
switch (name) {
case "Farm_Standard":
case "Farm_Forest":
case "Farm_FourCorners":
case "Farm_Hilltop":
case "Farm_Riverland":
case "Farm_Wilderness":
case "Farm_Beach":
name = "Farm";
break;
}
switch (endCheck) {
case "Name]]]":
name = "Farm";
Expand All @@ -344,7 +355,7 @@ private static string getLocName(LocationData data) {
name = "Woods";
break;
}
if (name.Length > 25) name = endCheck;
//if (name.Length > 25) name = endCheck;
return name;
}
private static bool canAddFish(SpawnFishData fish, int season, LocationData data) {
Expand Down
9 changes: 5 additions & 4 deletions Almanac/Managers/LuckManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#nullable enable

/*
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
Expand Down Expand Up @@ -229,7 +229,7 @@ public double GetModifiedLuckForDate(ulong seed, WorldDate date) {

#region Events

public IRichEvent? HydrateEvent(LocalNotice notice, WorldDate date, Common.GameStateQuery.GameState state, string? key = null) {
public IRichEvent? HydrateEvent(LocalNotice notice, WorldDate date, GameStateQuery state, string? key = null) {
if (notice == null)
return null;

Expand Down Expand Up @@ -280,7 +280,7 @@ public double GetModifiedLuckForDate(ulong seed, WorldDate date) {
}

// Condition Validation
if (!string.IsNullOrEmpty(notice.Condition) && !Common.GameStateQuery.CheckConditions(notice.Condition, state))
if (!string.IsNullOrEmpty(notice.Condition) && !GameStateQuery.CheckConditions(notice.Condition))
return null;

// Get icon
Expand Down Expand Up @@ -535,7 +535,7 @@ public IEnumerable<IRichEvent> GetEventsForDate(ulong seed, WorldDate date) {
I18n.Page_Fortune_Event_Ufo(),
null,
SpriteHelper.GetSprite(new SObject(Vector2.Zero, 96))
);*/
);

return null;
}
Expand Down Expand Up @@ -605,3 +605,4 @@ public IEnumerable<IRichEvent> GetEventsForDate(ulong seed, WorldDate date) {
#endregion

}
*/
3 changes: 2 additions & 1 deletion Almanac/Managers/NoticesManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#nullable enable
/*#nullable enable

using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -805,3 +805,4 @@ public static bool IsBooksellerVisiting(WorldDate date) {
#endregion

}
*/
4 changes: 2 additions & 2 deletions Almanac/Menus/BookCollectionMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void DiscoverBooks() {
if (value == null || !value.Enable)
continue;

bool locked = !string.IsNullOrEmpty(value.Condition) && !Common.GameStateQuery.CheckConditions(value.Condition);
bool locked = !string.IsNullOrEmpty(value.Condition) && !GameStateQuery.CheckConditions(value.Condition);
if (value.Secret && locked)
continue;

Expand Down Expand Up @@ -520,7 +520,7 @@ public override void draw(SpriteBatch b) {
if (LockedBooks[book])
continue;

var sprite = SpriteHelper.GetSprite(InventoryHelper.CreateItemById($"(O){idx}", 1));
var sprite = SpriteHelper.GetSprite(ItemRegistry.Create($"(O){idx}"));
idx++;

float scale = cmp.scale - 1;
Expand Down
17 changes: 10 additions & 7 deletions Almanac/ModAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public interface IAlmanacAPI {
/// itself doesn't have the ability.
/// </summary>
int DaysPerMonth { get; }

/*
#region Custom Pages

/*void RegisterPage(
void RegisterPage(
IManifest manifest,
string id,
// State
Expand Down Expand Up @@ -74,9 +74,10 @@ public interface IAlmanacAPI {
Action<IClickableMenu, int, int, WorldDate, Rectangle, Action<string>, Action<Item>> onCellHover = null
);

void UnregisterPage(IManifest manifest, string id);*/
void UnregisterPage(IManifest manifest, string id);

#endregion
*/

#region Crops Page

Expand Down Expand Up @@ -174,6 +175,7 @@ IReadOnlyCollection<SpriteInfo> phaseSprites

#endregion

/*
#region Fortunes Page

/// <summary>
Expand Down Expand Up @@ -289,6 +291,7 @@ IReadOnlyCollection<SpriteInfo> phaseSprites
string GetWeatherForDate(WorldDate date, string context = "Default");

#endregion
*/
}

public class ModAPI : IAlmanacAPI {
Expand Down Expand Up @@ -514,7 +517,7 @@ public List<CropInfo> GetSeasonCrops(string season) {
}

#endregion

/*
#region Fortune Telling

public void SetFortuneHook(IManifest manifest, Func<ulong, WorldDate, IEnumerable<Tuple<bool, string, Texture2D, Rectangle?, Item>>> hook) {
Expand All @@ -530,7 +533,7 @@ public void ClearFortuneHook(IManifest manifest) {
}

#endregion

#region Local Notices

public void SetNoticesHook(IManifest manifest, Func<int, WorldDate, IEnumerable<Tuple<string, Texture2D, Rectangle?, Item>>> hook) {
Expand All @@ -546,7 +549,7 @@ public void ClearNoticesHook(IManifest manifest) {
}

#endregion

#region Weather

public string GetWeatherForDate(WorldDate date, GameLocation location) {
Expand Down Expand Up @@ -587,6 +590,6 @@ public string GetWeatherForDate(WorldDate date, string context = "Default") {
}

#endregion

*/
}
}
Loading