mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-25 15:33:03 +00:00
Separate handling of tutorial goals and warnings
This is more explicit and makes the code cleaner.
This commit is contained in:
@@ -164,7 +164,7 @@ var g_NotificationsTypes =
|
||||
},
|
||||
"tutorial": function(notification, player)
|
||||
{
|
||||
g_Tutorial.update(notification);
|
||||
g_Tutorial.handleNotification(notification);
|
||||
},
|
||||
"tribute": function(notification, player)
|
||||
{
|
||||
|
||||
@@ -17,28 +17,35 @@ class Tutorial
|
||||
this.panel.hidden = !this.panel.hidden || !this.text.caption;
|
||||
}
|
||||
|
||||
update(notification)
|
||||
handleNotification(notification)
|
||||
{
|
||||
if (notification.goal)
|
||||
this.displayGoal(notification.goal);
|
||||
if (notification.warning)
|
||||
this.displayWarning(notification.warning);
|
||||
}
|
||||
|
||||
displayWarning(warning)
|
||||
{
|
||||
this.warning.caption = coloredText(translate(warning), "orange");
|
||||
}
|
||||
|
||||
displayGoal(goal)
|
||||
{
|
||||
this.panel.hidden = false;
|
||||
|
||||
if (notification.warning)
|
||||
{
|
||||
this.warning.caption = coloredText(translate(notification.warning), "orange");
|
||||
return;
|
||||
}
|
||||
|
||||
const notificationText =
|
||||
notification.instructions.reduce((instructions, item) =>
|
||||
goal.instructions.reduce((instructions, item) =>
|
||||
instructions + (typeof item === "string" ? translate(item) : colorizeHotkey(translate(item.text), item.hotkey)),
|
||||
"");
|
||||
|
||||
this.text.caption = this.instructions.concat(setStringTags(notificationText, this.NewInstructionTags)).join("\n");
|
||||
this.instructions.push(notificationText);
|
||||
|
||||
if (notification.readyButton)
|
||||
if (goal.readyButton)
|
||||
{
|
||||
this.readyButton.hidden = false;
|
||||
if (notification.leave)
|
||||
if (goal.leave)
|
||||
{
|
||||
this.warning.caption = translate("Click to quit this tutorial.");
|
||||
this.readyButton.caption = translate("Quit");
|
||||
|
||||
@@ -85,9 +85,11 @@ Trigger.prototype.GoalMessage = function(instructions, readyButton=false, leave=
|
||||
cmpGUIInterface.PushNotification({
|
||||
"type": "tutorial",
|
||||
"players": [1],
|
||||
"instructions": typeof instructions === "string" ? [instructions] : instructions,
|
||||
"readyButton": readyButton,
|
||||
"leave": leave
|
||||
"goal": {
|
||||
"instructions": typeof instructions === "string" ? [instructions] : instructions,
|
||||
"readyButton": readyButton,
|
||||
"leave": leave
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user