Skip to content

Commit

Permalink
feat: added a setting to hide the Hysteresis tab from the game
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyvion committed May 21, 2024
1 parent f36c8ea commit c462866
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added a setting to hide the Hysteresis tab from the game.

### Changed

- Removed farming hysteresis text from inspect strings as well as the "configure hysteresis" gizmo and related dialog. Both concepts were unified into an inspect tab that is now added instead.
Expand Down
1 change: 1 addition & 0 deletions Common/Defs/MainTabDefs/MainTabWindow_Hysteresis.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<description>hysteresis.description</description>
<tabWindowClass>FarmingHysteresis.MainTabWindow_Hysteresis</tabWindowClass>
<order>20</order>
<workerClass>FarmingHysteresis.MainButtonWorker_Hysteresis</workerClass>
</MainButtonDef>

</Defs>
2 changes: 2 additions & 0 deletions Common/Languages/English/Keyed/FarmingHysteresis.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<FarmingHysteresis.HysteresisMode>Hysteresis mode</FarmingHysteresis.HysteresisMode>
<FarmingHysteresis.ShowOldCommands>Show old command buttons</FarmingHysteresis.ShowOldCommands>
<FarmingHysteresis.ShowOldCommandsTooltip>In version 0.6, the mod switched from using command buttons to a dialog for configuring hysteresis parameters. Enable this setting to also show the old command buttons.</FarmingHysteresis.ShowOldCommandsTooltip>
<FarmingHysteresis.ShowHysteresisMainTab>Show hysteresis tab</FarmingHysteresis.ShowHysteresisMainTab>
<FarmingHysteresis.ShowHysteresisMainTabTooltip>Disabling this setting hides the Hysteresis tab from the game.\n\nWhile it is currently only used as a convenient location to configure global hysteresis values in one place, there are plans to add more features to this tab later. Hiding it will thus prevent access to these features and is generally not recommended.</FarmingHysteresis.ShowHysteresisMainTabTooltip>

<FarmingHysteresis.ConfigureHysteresis>Configure hysteresis parameters</FarmingHysteresis.ConfigureHysteresis>
<FarmingHysteresis.ConfigureHysteresisDesc>Configure hysteresis parameters such as the upper and lower bounds.</FarmingHysteresis.ConfigureHysteresisDesc>
Expand Down
2 changes: 2 additions & 0 deletions Common/Languages/Norwegian/Keyed/FarmingHysteresis.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<FarmingHysteresis.HysteresisMode>Hysteresemodus</FarmingHysteresis.HysteresisMode>
<FarmingHysteresis.ShowOldCommands>Vis gamle kommandoknapper</FarmingHysteresis.ShowOldCommands>
<FarmingHysteresis.ShowOldCommandsTooltip>I versjon 0.6 gikk moden fra å bruke kommandoknapper til å bruke en dialog for å stille inn hystereseparametere. Skru på dette valget for å også vise de gamle kommandoknappene.</FarmingHysteresis.ShowOldCommandsTooltip>
<FarmingHysteresis.ShowHysteresisMainTab>Vis hysterese-fane</FarmingHysteresis.ShowHysteresisMainTab>
<FarmingHysteresis.ShowHysteresisMainTabTooltip>Hysterese-fanen skjules fra spillet dersom dette valget skrus av.\n\nSelv om denne fanen kun brukes til å konfigurere globale hysteresegrenser nå, er det planer om å legge til flere funksjoner til denne fanen over tid. Det å skjule den vil derfor kunne hindre tilgang til disse funksjonene og er generelt ikke å anbefale.</FarmingHysteresis.ShowHysteresisMainTabTooltip>

<FarmingHysteresis.ConfigureHysteresis>Konfigurer hystereseparametere</FarmingHysteresis.ConfigureHysteresis>
<FarmingHysteresis.ConfigureHysteresisDesc>Konfigurer hystereseparametere som f.eks. øvre og nedre grensenivå.</FarmingHysteresis.ConfigureHysteresisDesc>
Expand Down
29 changes: 19 additions & 10 deletions Source/FarmingHysteresis/Core/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ public class Settings : ModSettings
private static bool _useGlobalValuesByDefault = true;
private static HysteresisMode _hysteresisMode = HysteresisMode.Sowing;
private static bool _showOldCommands = false;
private static bool _showHysteresisMainTab = true;

internal static int DefaultHysteresisLowerBound { get => _defaultHysteresisLowerBound; set => _defaultHysteresisLowerBound = value; }
internal static int DefaultHysteresisUpperBound { get => _defaultHysteresisUpperBound; set => _defaultHysteresisUpperBound = value; }
internal static bool EnabledByDefault { get => _enabledByDefault; set => _enabledByDefault = value; }
internal static bool UseGlobalValuesByDefault { get => _useGlobalValuesByDefault; set => _useGlobalValuesByDefault = value; }
internal static HysteresisMode HysteresisMode { get => _hysteresisMode; set => _hysteresisMode = value; }
internal static bool ShowOldCommands { get => _showOldCommands; set => _showOldCommands = value; }
internal static bool ShowHysteresisMainTab { get => _showHysteresisMainTab; set => _showHysteresisMainTab = value; }

internal static bool ControlSowing => _hysteresisMode == HysteresisMode.Sowing || _hysteresisMode == HysteresisMode.SowingAndHarvesting;
internal static bool ControlHarvesting => _hysteresisMode == HysteresisMode.Harvesting || _hysteresisMode == HysteresisMode.SowingAndHarvesting;
Expand All @@ -37,6 +39,7 @@ public override void ExposeData()
Scribe_Values.Look(ref _useGlobalValuesByDefault, "useGlobalValuesByDefault", true);
Scribe_Values.Look(ref _hysteresisMode, "hysteresisMode", HysteresisMode.Sowing);
Scribe_Values.Look(ref _showOldCommands, "showOldCommands", false);
Scribe_Values.Look(ref _showHysteresisMainTab, "showHysteresisMainTab", true);
}

public static void DoSettingsWindowContents(Rect inRect)
Expand All @@ -50,6 +53,10 @@ public static void DoSettingsWindowContents(Rect inRect)
"FarmingHysteresis.ShowOldCommands".Translate(),
ref _showOldCommands,
"FarmingHysteresis.ShowOldCommandsTooltip".Translate());
listingStandard.CheckboxLabeled(
"FarmingHysteresis.ShowHysteresisMainTab".Translate(),
ref _showHysteresisMainTab,
"FarmingHysteresis.ShowHysteresisMainTabTooltip".Translate());

#if v1_3
if (listingStandard.ButtonTextLabeled(
Expand All @@ -64,16 +71,18 @@ public static void DoSettingsWindowContents(Rect inRect)
TextAnchor.MiddleLeft))
{
#endif
List<FloatMenuOption> list = new();
list.Add(new FloatMenuOption(
"FarmingHysteresis.Control".Translate("FarmingHysteresis.Sowing".Translate()),
() => _hysteresisMode = HysteresisMode.Sowing));
list.Add(new FloatMenuOption(
"FarmingHysteresis.Control".Translate("FarmingHysteresis.Harvesting".Translate()),
() => _hysteresisMode = HysteresisMode.Harvesting));
list.Add(new FloatMenuOption(
"FarmingHysteresis.Control".Translate("FarmingHysteresis.SowingAndHarvesting".Translate()),
() => _hysteresisMode = HysteresisMode.SowingAndHarvesting));
List<FloatMenuOption> list = new()
{
new FloatMenuOption(
"FarmingHysteresis.Control".Translate("FarmingHysteresis.Sowing".Translate()),
() => _hysteresisMode = HysteresisMode.Sowing),
new FloatMenuOption(
"FarmingHysteresis.Control".Translate("FarmingHysteresis.Harvesting".Translate()),
() => _hysteresisMode = HysteresisMode.Harvesting),
new FloatMenuOption(
"FarmingHysteresis.Control".Translate("FarmingHysteresis.SowingAndHarvesting".Translate()),
() => _hysteresisMode = HysteresisMode.SowingAndHarvesting)
};
Find.WindowStack.Add(new FloatMenu(list));
}

Expand Down
5 changes: 5 additions & 0 deletions Source/FarmingHysteresis/MainTabWindow_Hysteresis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

namespace FarmingHysteresis
{
public class MainButtonWorker_Hysteresis : MainButtonWorker_ToggleTab
{
public override bool Visible => Settings.ShowHysteresisMainTab;
}

public class MainTabWindow_Hysteresis : MainTabWindow
{
private enum HysteresisTab : byte
Expand Down

0 comments on commit c462866

Please sign in to comment.