Skip to content

Commit

Permalink
Fix: #26 and add in-game GMCM config change support. (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
WuZhuoran authored Apr 21, 2024
1 parent 49f4b22 commit 33eeac1
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 25 deletions.
94 changes: 71 additions & 23 deletions AnimalSitter/AnimalSitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,78 +120,127 @@ private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
name: () => I18n.Config_KeyBind(),
tooltip: () => I18n.Config_KeyBind_Description(),
getValue: () => SButtonExtensions.ToSButton((Keys)Enum.Parse(typeof(Keys), this.Config.KeyBind)),
setValue: value => this.Config.KeyBind = value.ToString());
setValue: value =>
{
this.Config.KeyBind = value.ToString();
this.ImportConfiguration();
});

configMenu.AddBoolOption(
mod: this.ModManifest,
name: () => I18n.Config_GrowUpEnabled(),
tooltip: () => I18n.Config_GrowUpEnabled_Description(),
getValue: () => this.Config.GrowUpEnabled,
setValue: value => this.Config.GrowUpEnabled = value
setValue: value =>
{
// this.GrowUpEnabled = value;
this.Config.GrowUpEnabled = value;
this.ImportConfiguration();
}
);

configMenu.AddBoolOption(
mod: this.ModManifest,
name: () => I18n.Config_MaxHappinessEnabled(),
tooltip: () => I18n.Config_MaxHappinessEnabled_Description(),
getValue: () => this.Config.MaxHappinessEnabled,
setValue: value => this.Config.MaxHappinessEnabled = value
setValue: value =>
{
// this.MaxHappinessEnabled = value;
this.Config.MaxHappinessEnabled = value;
this.ImportConfiguration();
}
);

configMenu.AddBoolOption(
mod: this.ModManifest,
name: () => I18n.Config_MaxFullnessEnabled(),
tooltip: () => I18n.Config_MaxFullnessEnabled_Description(),
getValue: () => this.Config.MaxFullnessEnabled,
setValue: value => this.Config.MaxFullnessEnabled = value
setValue: value =>
{
// this.MaxFullnessEnabled = value;
this.Config.MaxFullnessEnabled = value;
this.ImportConfiguration();
}
);

configMenu.AddBoolOption(
mod: this.ModManifest,
name: () => I18n.Config_HarvestEnabled(),
tooltip: () => I18n.Config_HarvestEnabled_Description(),
getValue: () => this.Config.HarvestEnabled,
setValue: value => this.Config.HarvestEnabled = value
setValue: value =>
{
// this.HarvestEnabled = value;
this.Config.HarvestEnabled = value;
this.ImportConfiguration();
}
);

configMenu.AddBoolOption(
mod: this.ModManifest,
name: () => I18n.Config_PettingEnabled(),
tooltip: () => I18n.Config_PettingEnabled_Description(),
getValue: () => this.Config.PettingEnabled,
setValue: value => this.Config.PettingEnabled = value
setValue: value =>
{
// this.PettingEnabled = value;
this.Config.PettingEnabled = value;
this.ImportConfiguration();
}
);

configMenu.AddBoolOption(
mod: this.ModManifest,
name: () => I18n.Config_PettingPetEnabled(),
tooltip: () => I18n.Config_PettingPetEnabled_Description(),
getValue: () => this.Config.PettingPetEnabled,
setValue: value => this.Config.PettingPetEnabled = value
setValue: value =>
{
// this.PettingPetEnabled = value;
this.Config.PettingPetEnabled = value;
this.ImportConfiguration();
}
);

configMenu.AddBoolOption(
mod: this.ModManifest,
name: () => I18n.Config_MaxFriendshipEnabled(),
tooltip: () => I18n.Config_MaxFriendshipEnabled_Description(),
getValue: () => this.Config.MaxFriendshipEnabled,
setValue: value => this.Config.MaxFriendshipEnabled = value
setValue: value =>
{
// this.MaxFriendshipEnabled = value;
this.Config.MaxFriendshipEnabled = value;
this.ImportConfiguration();
}
);

configMenu.AddNumberOption(
mod: this.ModManifest,
name: () => I18n.Config_CostPerAction(),
tooltip: () => I18n.Config_CostPerAction_Description(),
getValue: () => this.Config.CostPerAction,
setValue: value => this.Config.CostPerAction = value
setValue: value =>
{
// this.CostPerAnimal = value;
this.Config.CostPerAction = value;
this.ImportConfiguration();
}
);

configMenu.AddTextOption(
mod: this.ModManifest,
name: () => I18n.Config_WhoChecks(),
tooltip: () => I18n.Config_WhoChecks_Description(),
getValue: () => this.Config.WhoChecks,
setValue: value => this.Config.WhoChecks = value,
setValue: value =>
{
// this.Checker = value;
this.Config.WhoChecks = value;
this.ImportConfiguration();
},
allowedValues: new string[] { "spouse", "pet", "Shane", "Haley", "Alex", "Leah", "Marnie" }
);

Expand All @@ -200,15 +249,25 @@ private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
name: () => I18n.Config_EnableMessages(),
tooltip: () => I18n.Config_EnableMessages_Description(),
getValue: () => this.Config.EnableMessages,
setValue: value => this.Config.EnableMessages = value
setValue: value =>
{
// this.MessagesEnabled = value;
this.Config.EnableMessages = value;
this.ImportConfiguration();
}
);

configMenu.AddBoolOption(
mod: this.ModManifest,
name: () => I18n.Config_TakeTrufflesFromPigs(),
tooltip: () => I18n.Config_TakeTrufflesFromPigs_Description(),
getValue: () => this.Config.TakeTrufflesFromPigs,
setValue: value => this.Config.TakeTrufflesFromPigs = value
setValue: value =>
{
// this.TakeTrufflesFromPigs = value;
this.Config.TakeTrufflesFromPigs = value;
this.ImportConfiguration();
}
);
}

Expand Down Expand Up @@ -312,21 +371,10 @@ private void IterateOverAnimals()
this.WaterPetBowl();
}



foreach (FarmAnimal animal in this.GetAnimals())
{
try
{
if (animal.wasPet.Value && this.PettingPetEnabled)
{
this.Monitor.Log($"{animal.Name}");
animal.pet(Game1.player);
stats.AnimalsPet++;

this.Monitor.Log(I18n.Log_PettingAnimal(animal_name: animal.Name), LogLevel.Trace);
}

if (!animal.wasPet.Value && this.PettingEnabled)
{
animal.pet(Game1.player);
Expand Down
2 changes: 1 addition & 1 deletion AnimalSitter/AnimalSitter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>AnimalSitter</AssemblyName>
<RootNamespace>AnimalSitter</RootNamespace>
<Version>2.3.0</Version>
<Version>2.3.1</Version>
<TargetFramework>net6.0</TargetFramework>
<Platforms>AnyCPU</Platforms>
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
2 changes: 1 addition & 1 deletion AnimalSitter/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "Animal Sitter LTS",
"Author": "oliver",
"Version": "2.3.0",
"Version": "2.3.1",
"Description": "Long Term Support Mod Version for Animal Sitter Mod. Let someone else pet all those pesky animals!",
"UniqueID": "oliver.AnimalSitterLTS",
"EntryDll": "AnimalSitter.dll",
Expand Down

0 comments on commit 33eeac1

Please sign in to comment.