Back to Home

ESO Lua File v101045

internalingame/tutorial/tutorial_manager.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
local Tutorial_Manager = ZO_InitializingCallbackObject:Subclass()
function Tutorial_Manager:CanShowTutorial(tutorialId)
    return CanTutorialBeSeen(tutorialId) and (not HasSeenTutorial(tutorialId))
end
function Tutorial_Manager:GetTutorialId(tutorialTrigger)
    if type(tutorialTrigger) == "table" then
        return GetTutorialId(tutorialTrigger.trigger, tutorialTrigger.param)
    else
        return GetTutorialId(tutorialTrigger)
    end
end
function Tutorial_Manager:CanTutorialTriggerFire(tutorialTrigger)
    local tutorialId = self:GetTutorialId(tutorialTrigger)
    return self:CanShowTutorial(tutorialId)
end
function Tutorial_Manager:RemoveTutorialByTrigger(tutorialTrigger)
    RemoveTutorial(tutorialTrigger)
end
--[[
Supportes either a TUTORIAL_TRIGGER enum or a table. Table format should include these fields:
trigger - (required) the TUTORIAL_TRIGGER enum value
param - (optional) the param to use with TriggerTutorialWithParam
anchorPosition, screenX, screenY - (optional) the arguments to use with TriggerTutorialWithPosition
--]]
function Tutorial_Manager:ShowTutorial(tutorialTrigger)
    if type(tutorialTrigger) == "table" then
        if tutorialTrigger.param then
            return self:ShowTutorialWithParam(tutorialTrigger, tutorialTrigger.param)
        elseif tutorialTrigger.anchorPosition then
            return self:ShowTutorialWithPosition(tutorialTrigger, tutorialTrigger.anchorPosition, tutorialTrigger.screenX, tutorialTrigger.screenY)
        end
    end
    if self:CanTutorialTriggerFire(triggerType) then
        local triggerType = type(tutorialTrigger) == "table" and tutorialTrigger.trigger or tutorialTrigger
        return TriggerTutorial(triggerType)
    end
    return false
end
function Tutorial_Manager:ShowTutorialWithParam(tutorialTrigger, param)
    if self:CanTutorialTriggerFire(tutorialTrigger) then
        local triggerType = type(tutorialTrigger) == "table" and tutorialTrigger.trigger or tutorialTrigger
        return TriggerTutorialWithParam(triggerType, param)
    end
    return false
end
function Tutorial_Manager:ShowTutorialWithPosition(tutorialTrigger, anchorPosition, screenX, screenY)
    if self:CanTutorialTriggerFire(tutorialTrigger) then
        local triggerType = type(tutorialTrigger) == "table" and tutorialTrigger.trigger or tutorialTrigger
        return TriggerTutorialWithPosition(triggerType, anchorPosition, screenX, screenY)
    end
    return false
end
TUTORIAL_MANAGER = Tutorial_Manager:New()