Skip to content
Merged
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
7 changes: 4 additions & 3 deletions WitcherScriptMerger/Forms/MainForm.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -882,18 +882,19 @@ void HideProgressScreen()
public DialogResult ShowMessage(string text,
string title = "",
MessageBoxButtons buttons = MessageBoxButtons.OK,
MessageBoxIcon icon = MessageBoxIcon.None)
MessageBoxIcon icon = MessageBoxIcon.None,
MessageBoxDefaultButton defaultButton = MessageBoxDefaultButton.Button1)
{
this.ActivateSafely();

if (this.InvokeRequired)
{
return (DialogResult)this.Invoke(new Func<DialogResult>(
() => { return MessageBox.Show(this, text, title, buttons, icon); }));
() => { return MessageBox.Show(this, text, title, buttons, icon, defaultButton); }));
}
else
{
return MessageBox.Show(this, text, title, buttons, icon);
return MessageBox.Show(this, text, title, buttons, icon, defaultButton);
}
}

Expand Down
11 changes: 10 additions & 1 deletion WitcherScriptMerger/HeadlessMergeNotifier.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,10 +14,19 @@ class HeadlessMergeNotifier : IMergeNotifier
public DialogResult ShowMessage(string text,
string title = "",
MessageBoxButtons buttons = MessageBoxButtons.OK,
MessageBoxIcon icon = MessageBoxIcon.None)
MessageBoxIcon icon = MessageBoxIcon.None,
MessageBoxDefaultButton defaultButton = MessageBoxDefaultButton.Button1)
{
Write(text, title, icon);

// defaultButton is intentionally unused here: it only affects which
// button has interactive UI focus (Enter-key behavior), and headless
// mode has no UI to focus. The DialogResult below is chosen per
// buttons set instead, per this class's own fixed, non-destructive
// default for each verb - not by the caller's requested default
// button. A call site relying on defaultButton to signal "this is the
// safe answer" for a MessageBoxButtons combination not covered below
// will get whatever the catch-all case returns instead.
return buttons switch
{
MessageBoxButtons.OK => DialogResult.OK,
Expand Down
3 changes: 2 additions & 1 deletion WitcherScriptMerger/IMergeNotifier.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,8 @@ interface IMergeNotifier
DialogResult ShowMessage(string text,
string title = "",
MessageBoxButtons buttons = MessageBoxButtons.OK,
MessageBoxIcon icon = MessageBoxIcon.None);
MessageBoxIcon icon = MessageBoxIcon.None,
MessageBoxDefaultButton defaultButton = MessageBoxDefaultButton.Button1);

DialogResult ShowError(string text, string title = "Error");

Expand Down
26 changes: 18 additions & 8 deletions WitcherScriptMerger/LoadOrder/LoadOrderValidator.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,29 +21,39 @@ public static void ValidateAndFix(CustomLoadOrder loadOrder)
{
PrioritizeMergedMod(loadOrder, mergedMod);
}
else if (choice == DialogResult.Cancel) // Never
else if (choice == DialogResult.Cancel && Program.Notifier.IsInteractive) // Never
{
// IsInteractive guard: HeadlessMergeNotifier's fixed default for
// YesNoCancel is Cancel, which would otherwise persist this setting
// on every headless run that reaches here.
Program.Settings.Set("ValidateCustomLoadOrder", false);
Program.Settings.Save();
}
}

static DialogResult PromptToPrioritizeMergedMod(string modsSettingsPath)
{
MessageBoxManager.Cancel = "Ne&ver";
MessageBoxManager.Register();

var choice = MessageBox.Show(
// Known, accepted regression: the Cancel button used to be relabeled
// "Ne&ver" via MessageBoxManager.Register()/Unregister(), which worked
// only because the old MessageBox.Show call ran on the same background
// thread (Register()'s SetWindowsHookEx is thread-affine) as this
// method. Program.Notifier.ShowMessage (MainForm.ShowMessage) Invokes
// the actual MessageBox.Show onto the UI thread, so that hook can no
// longer see the dialog's window messages - relabeling can't be
// preserved without adding custom button-text support to
// IMergeNotifier, which is out of scope here. The Cancel button now
// reads "Cancel"; clicking it still permanently disables this check
// (see the IsInteractive-guarded branch above), just without a label
// saying so. DialogResult semantics and this method's return value are
// otherwise unchanged.
return Program.Notifier.ShowMessage(
$"{modsSettingsPath}\n\n" +
"Detected custom load order in the file above, and merged files aren't configured to load first.\n\n" +
"Would you like Script Merger to modify your custom load order so that your merged files have top priority?",
"Custom Load Order Problem",
MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Exclamation,
MessageBoxDefaultButton.Button2);

MessageBoxManager.Unregister();
return choice;
}

static void PrioritizeMergedMod(CustomLoadOrder loadOrder, ModLoadSetting mergedModSetting)
Expand Down