Skip to content

Commit

Permalink
feat: feature complexity warning message box
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyvion committed Jun 9, 2024
1 parent 3f7bc83 commit 69ae179
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions Common/Languages/English/Keyed/RealisticOrbitalTrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@
<RealisticOrbitalTrade.OldTradeNonRenegotiable>(only trades made after renegotiation was added to the mod can be renegotiated)</RealisticOrbitalTrade.OldTradeNonRenegotiable>
<RealisticOrbitalTrade.DidYouMeanToCancel>You've set all exchange of goods to zero. Did you intend to cancel the trade rather than renegotiate?</RealisticOrbitalTrade.DidYouMeanToCancel>
<RealisticOrbitalTrade.NegotiatorTradeDialogInfo>Original negotiator: {0} (+{1})</RealisticOrbitalTrade.NegotiatorTradeDialogInfo>
<RealisticOrbitalTrade.RenegotiationWarning>I've done my very best to test this feature thoroughly, but it is quite complex, so I might have missed some detail or messed up somewhere. I strongly recommend you save your game each time before you use this feature until you've convinced yourself it works 100% correctly. If you encounter any unexpected or incorrect behavior I would very much appreciate it if you reported it to me.\n\nIf you choose "Confirm" below, this message will not show again.</RealisticOrbitalTrade.RenegotiationWarning>
</LanguageData>
8 changes: 5 additions & 3 deletions Source/RealisticOrbitalTrade/Core/RealisticOrbitalTradeMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ namespace RealisticOrbitalTrade;

internal class RealisticOrbitalTradeMod : Mod
{
private readonly ModContentPack content;
#pragma warning disable CS8618 // Set by constructor
internal static RealisticOrbitalTradeMod instance;
#pragma warning restore CS8618

public RealisticOrbitalTradeMod(ModContentPack content) : base(content)
{
this.content = content;
instance = this;

// if (!ModsConfig.RoyaltyActive)
// {
Expand All @@ -41,7 +43,7 @@ public override void DoSettingsWindowContents(Rect inRect)

public override string SettingsCategory()
{
return content.Name;
return Content.Name;
}

public static void Message(string msg)
Expand Down
8 changes: 7 additions & 1 deletion Source/RealisticOrbitalTrade/Core/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ namespace RealisticOrbitalTrade
internal class Settings : ModSettings
{
private static bool _printDevMessages = false;
private static bool _renegotiationWarningShown = false;
private static bool _activeTradePausesDepartureTimer = false;
private static int _minTicksUntilDepartureBeforeGraceTime = 20000;
private static int _departureGraceTimeTicks = 40000;

internal static bool PrintDevMessages { get => _printDevMessages; set => _printDevMessages = value; }
internal static bool RenegotiationWarningShown { get => _renegotiationWarningShown; set => _renegotiationWarningShown = value; }
internal static bool ActiveTradePausesDepartureTimer { get => _activeTradePausesDepartureTimer; set => _activeTradePausesDepartureTimer = value; }
internal static int MinTicksUntilDepartureBeforeGraceTime { get => _minTicksUntilDepartureBeforeGraceTime; set => _minTicksUntilDepartureBeforeGraceTime = value; }
internal static int DepartureGraceTimeTicks { get => _departureGraceTimeTicks; set => _departureGraceTimeTicks = value; }
Expand All @@ -19,7 +21,11 @@ public override void ExposeData()
{
base.ExposeData();

// Meta
Scribe_Values.Look(ref _printDevMessages, "printDevMessages", false);
Scribe_Values.Look(ref _renegotiationWarningShown, "renegotiationWarningShown", false);

// Mod
Scribe_Values.Look(ref _activeTradePausesDepartureTimer, "activeTradePausesDepartureTimer", false);
Scribe_Values.Look(ref _minTicksUntilDepartureBeforeGraceTime, "minTicksUntilDeparture", 20000);
Scribe_Values.Look(ref _departureGraceTimeTicks, "departureGraceTimeTicks", 40000);
Expand All @@ -32,7 +38,7 @@ public static void DoSettingsWindowContents(Rect inRect)

if (Prefs.DevMode)
{
listingStandard.CheckboxLabeled("DEV: Print dev messages", ref _printDevMessages);
listingStandard.CheckboxLabeled("DEV: Print dev log messages (rather verbose)", ref _printDevMessages);
}

listingStandard.CheckboxLabeled(
Expand Down
10 changes: 10 additions & 0 deletions Source/RealisticOrbitalTrade/Dialogs/Dialog_RenegotiateTrade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,20 @@ public override void PreOpen()
quickSearchWidget.Reset();
}

private bool renegotiationMessageShown = false;
public override void PostOpen()
{
base.PostOpen();
CacheTradeables();

if (!Settings.RenegotiationWarningShown && !renegotiationMessageShown)
{
Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("RealisticOrbitalTrade.RenegotiationWarning".Translate(), () =>
{
Settings.RenegotiationWarningShown = true;
RealisticOrbitalTradeMod.instance.WriteSettings();
}));
}
}

public override void PostClose()
Expand Down

0 comments on commit 69ae179

Please sign in to comment.