diff --git a/src/UI/Dialog/DialogBox.cs b/src/UI/Dialog/DialogBox.cs index ca750c2..7353cfb 100644 --- a/src/UI/Dialog/DialogBox.cs +++ b/src/UI/Dialog/DialogBox.cs @@ -308,6 +308,26 @@ namespace Cthangover.Mods.Dialog ScheduleWaitTimer(); } + /// + /// Moves a running dialog to another action and holds it there + /// (): a pending wait timer and an open + /// answer box are dropped, since they belong to the action left behind; + /// the shown text stays until the new action replaces it. + /// + public bool MoveTo(int queueIndex) + { + if (!IsRunning) + return false; + + ClearWaitTimer(); + if (answerBox != null) + { + answerBox.Hide(); + answerBox = null; + } + return Runtime.MoveTo(queueIndex); + } + /// /// Stops the running dialog without finishing it () /// and frees the box for another queue: closes the answer box, hides diff --git a/src/UI/Dialog/DialogRuntime.cs b/src/UI/Dialog/DialogRuntime.cs index 6f4178f..95e2147 100644 --- a/src/UI/Dialog/DialogRuntime.cs +++ b/src/UI/Dialog/DialogRuntime.cs @@ -187,6 +187,31 @@ namespace Cthangover.Mods.Dialog End(); } + /// + /// Debugger "set next statement": makes the action at + /// the next one to run and holds the + /// runtime before it (), so nothing runs until + /// . The current action is destructed like + /// on a goto; actions between the old and the new position neither run + /// nor roll back — variables and game state stay as they are. Jumping + /// back to an action that already ran re-runs it, exactly like a + /// looping goto does. Returns false for an index outside the queue. + /// + public bool MoveTo(int queueIndex) + { + if (Lists.IsEmpty(dialogQueue) || queueIndex < 0 || queueIndex >= dialogQueue.Count) + return false; + + var current = index >= 0 && index < dialogQueue.Count ? dialogQueue[index] : null; + if (current != null && current.IsConstructed && current.DestructType == DestructType.OnEndAction) + current.Destruct(); + + index = queueIndex; + isLastGoTo = false; + IsHeld = true; + return true; + } + /// /// Main execution loop. Iterates through actions, calling on each and advancing /// automatically for actions. Stops the loop on any wait-type action (WaitClick, WaitSelect,