diff --git a/binaries/data/mods/public/gui/session/messages.js b/binaries/data/mods/public/gui/session/messages.js index fae1a0c1a7..a65d42ba16 100644 --- a/binaries/data/mods/public/gui/session/messages.js +++ b/binaries/data/mods/public/gui/session/messages.js @@ -164,7 +164,7 @@ var g_NotificationsTypes = }, "tutorial": function(notification, player) { - g_Tutorial.update(notification); + g_Tutorial.handleNotification(notification); }, "tribute": function(notification, player) { diff --git a/binaries/data/mods/public/gui/session/tutorial/Tutorial.js b/binaries/data/mods/public/gui/session/tutorial/Tutorial.js index 92350878b3..ae8f36a64f 100644 --- a/binaries/data/mods/public/gui/session/tutorial/Tutorial.js +++ b/binaries/data/mods/public/gui/session/tutorial/Tutorial.js @@ -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"); diff --git a/binaries/data/mods/public/maps/scripts/Tutorial.js b/binaries/data/mods/public/maps/scripts/Tutorial.js index abf2cf4185..cb2c4fc258 100644 --- a/binaries/data/mods/public/maps/scripts/Tutorial.js +++ b/binaries/data/mods/public/maps/scripts/Tutorial.js @@ -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 + } }); };