From 0cc025f6757ee8f0fc90c6408846f68f5e3110b6 Mon Sep 17 00:00:00 2001 From: Vantha Date: Wed, 18 Mar 2026 11:23:19 +0100 Subject: [PATCH] Indicate if a tutorial step is already done If a new tutorial step has already been completed by the player it isn't skipped, but instead shown with the continue button, so that the player can manually switch to the next one. However, it wasn't well communicated to the player that this was the case and why the continue button was shown at the same time as the instruction. This patch adds a hint "You have already done this." to explain the this to the player. --- .../gui/session/tutorial/TutorialPanel.js | 26 +++++++++---------- .../data/mods/public/maps/scripts/Tutorial.js | 18 ++++++------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/binaries/data/mods/public/gui/session/tutorial/TutorialPanel.js b/binaries/data/mods/public/gui/session/tutorial/TutorialPanel.js index 40acc4c7e4..21c7d5ac37 100644 --- a/binaries/data/mods/public/gui/session/tutorial/TutorialPanel.js +++ b/binaries/data/mods/public/gui/session/tutorial/TutorialPanel.js @@ -35,23 +35,20 @@ class TutorialPanel displayStep(step) { this.text.caption = step.text; + this.button.hidden = !step.showContinueButton; - if (step.showContinueButton) + if (step.isLast) { - this.button.hidden = false; - if (step.isLast) - { - this.hint.caption = this.HintCaptions.Quit; - this.button.caption = this.ButtonCaptions.Quit; - } - else - this.hint.caption = this.HintCaptions.Continue; - } - else - { - this.hint.caption = this.HintCaptions.Instruction; - this.button.hidden = true; + this.hint.caption = this.HintCaptions.Quit; + this.button.caption = this.ButtonCaptions.Quit; + return; } + + this.hint.caption = step.isDone ? + this.HintCaptions.Done : + step.showContinueButton ? + this.HintCaptions.Continue : + this.HintCaptions.Instruction; } } @@ -65,5 +62,6 @@ TutorialPanel.prototype.ButtonCaptions = { TutorialPanel.prototype.HintCaptions = { "Continue": translate("Click to continue."), "Instruction": translate("Follow the instructions."), + "Done": translate("You have already done this."), "Quit": translate("Click to quit this tutorial.") }; diff --git a/binaries/data/mods/public/maps/scripts/Tutorial.js b/binaries/data/mods/public/maps/scripts/Tutorial.js index 4913ea3707..c16dd8f451 100644 --- a/binaries/data/mods/public/maps/scripts/Tutorial.js +++ b/binaries/data/mods/public/maps/scripts/Tutorial.js @@ -8,7 +8,7 @@ Engine.RegisterGlobal("TUTORIAL_STEP_TYPE", TUTORIAL_STEP_TYPE); Trigger.prototype.InitTutorial = function(data) { - this.stepIndex = 0; + this.stepIndex = -1; this.tutorialEvents = []; // Register needed triggers @@ -36,7 +36,7 @@ Trigger.prototype.InitTutorial = function(data) Trigger.prototype.NextStep = function(deserializing = false) { - if (this.stepIndex > this.tutorialSteps.length) + if (++this.stepIndex >= this.tutorialSteps.length) return; const step = this.tutorialSteps[this.stepIndex]; @@ -67,15 +67,17 @@ Trigger.prototype.NextStep = function(deserializing = false) } Trigger.prototype.IsDone = step.IsDone || (() => false); - const showContinueButton = this.IsDone() || (step.panelData.showContinueButton === undefined ? + const isDone = this.IsDone(); + const isLast = this.stepIndex === this.tutorialSteps.length - 1; + const showContinueButton = isDone || isLast || (step.panelData.showContinueButton === undefined ? this.tutorialEvents.every(event => !step[event]) : step.panelData.showContinueButton ); - this.DisplayStep(step, showContinueButton, ++this.stepIndex == this.tutorialSteps.length); + this.DisplayStep(step, showContinueButton, isDone, isLast); }; -Trigger.prototype.DisplayStep = function(step, showContinueButton = false, isLast = false) +Trigger.prototype.DisplayStep = function(step, showContinueButton = false, isDone = false, isLast = false) { const cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); cmpGUIInterface.PushNotification({ @@ -84,9 +86,7 @@ Trigger.prototype.DisplayStep = function(step, showContinueButton = false, isLas "step": { "type": step.type, "panelData": { - ...step.panelData, - "showContinueButton": showContinueButton, - "isLast": isLast + ...step.panelData, showContinueButton, isDone, isLast } } }); @@ -113,7 +113,7 @@ Trigger.prototype.DeserializedAction = function() this.stepIndex = Math.max(0, this.stepIndex - 1); // Display messages from already processed steps - for (let i = 0; i < this.stepIndex; ++i) + for (let i = 0; i <= this.stepIndex; ++i) this.DisplayStep(this.tutorialSteps[i], false, false); this.NextStep(true);