mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-08-15 14:43:32 -07:00
Improve internal naming of tutorial triggers
Make the naming consistent with e.g. the Triggers Demo map Remove the "On" at the start, since it's otherwise used for message handlers, and replace "Trigger" at the end with "Action", since that more accurately describes what it is.
This commit is contained in:
parent
702e3f1113
commit
6e6864fd7c
1 changed files with 7 additions and 7 deletions
|
|
@ -11,8 +11,8 @@ Trigger.prototype.InitTutorial = function(data)
|
||||||
this.tutorialEvents = [];
|
this.tutorialEvents = [];
|
||||||
|
|
||||||
// Register needed triggers
|
// Register needed triggers
|
||||||
this.RegisterTrigger("OnDeserialized", "OnDeserializedTrigger", { "enabled": true });
|
this.RegisterTrigger("OnDeserialized", "DeserializedAction", { "enabled": true });
|
||||||
this.RegisterTrigger("OnPlayerCommand", "OnPlayerCommandTrigger", { "enabled": false });
|
this.RegisterTrigger("OnPlayerCommand", "PlayerCommandAction", { "enabled": false });
|
||||||
this.tutorialEvents.push("OnPlayerCommand");
|
this.tutorialEvents.push("OnPlayerCommand");
|
||||||
|
|
||||||
for (const step of this.tutorialSteps)
|
for (const step of this.tutorialSteps)
|
||||||
|
|
@ -25,7 +25,7 @@ Trigger.prototype.InitTutorial = function(data)
|
||||||
continue;
|
continue;
|
||||||
if (key == "IsDone")
|
if (key == "IsDone")
|
||||||
continue;
|
continue;
|
||||||
const action = key + "Trigger";
|
const action = key.substring(2) + "Action";
|
||||||
this.RegisterTrigger(key, action, { "enabled": false });
|
this.RegisterTrigger(key, action, { "enabled": false });
|
||||||
this.tutorialEvents.push(key);
|
this.tutorialEvents.push(key);
|
||||||
}
|
}
|
||||||
|
|
@ -46,7 +46,7 @@ Trigger.prototype.NextStep = function(deserializing = false)
|
||||||
|
|
||||||
for (const event of this.tutorialEvents)
|
for (const event of this.tutorialEvents)
|
||||||
{
|
{
|
||||||
const action = event + "Trigger";
|
const action = event.substring(2) + "Action";
|
||||||
if (step[event])
|
if (step[event])
|
||||||
{
|
{
|
||||||
Trigger.prototype[action] = step[event];
|
Trigger.prototype[action] = step[event];
|
||||||
|
|
@ -64,8 +64,8 @@ Trigger.prototype.NextStep = function(deserializing = false)
|
||||||
|
|
||||||
if (showContinueButton)
|
if (showContinueButton)
|
||||||
{
|
{
|
||||||
this.EnableTrigger("OnPlayerCommand", "OnPlayerCommandTrigger");
|
this.EnableTrigger("OnPlayerCommand", "PlayerCommandAction");
|
||||||
Trigger.prototype.OnPlayerCommandTrigger = function(msg)
|
Trigger.prototype.PlayerCommandAction = function(msg)
|
||||||
{
|
{
|
||||||
if (msg.cmd.type == "dialog-answer" && msg.cmd.tutorial && msg.cmd.tutorial == "continue")
|
if (msg.cmd.type == "dialog-answer" && msg.cmd.tutorial && msg.cmd.tutorial == "continue")
|
||||||
this.NextStep();
|
this.NextStep();
|
||||||
|
|
@ -102,7 +102,7 @@ Trigger.prototype.DisplayWarning = function(warning)
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Trigger.prototype.OnDeserializedTrigger = function()
|
Trigger.prototype.DeserializedAction = function()
|
||||||
{
|
{
|
||||||
this.index = Math.max(0, this.index - 1);
|
this.index = Math.max(0, this.index - 1);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue