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.
This commit is contained in:
Vantha
2026-03-18 11:23:19 +01:00
committed by Vantha
parent 05d434830f
commit 0cc025f675
2 changed files with 21 additions and 23 deletions
@@ -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.")
};
@@ -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);