Back to Home

ESO Lua File v100030

ingame/interactwindow/interactwindow.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
ZO_INTERACTION_SYSTEM_NAME = "interact"
--Interaction Manager
---------------------
ZO_InteractionManager = ZO_CallbackObject:Subclass()
function ZO_InteractionManager:New(...)
    local manager = ZO_CallbackObject.New(self)
    manager:Initialize(...)
    return manager
end
function ZO_InteractionManager:Initialize()
    ZO_SceneManager_Leader.AddBypassHideSceneConfirmationReason("ARRESTED")
end
function ZO_InteractionManager:OnBeginInteraction(interaction)
    if(self.currentInteraction and (interaction.type ~= self.currentInteraction.type) and self.currentInteraction.End) then
        self.currentInteraction.End()
    end
    self.currentInteraction = interaction
end
function ZO_InteractionManager:OnEndInteraction(interaction)
    if(self.currentInteraction == interaction) then
        self:TerminateClientInteraction(interaction)
        self.currentInteraction = nil
    end
end
function ZO_InteractionManager:TerminateClientInteraction(interaction)
    local interactTypes = interaction.interactTypes
    if(interactTypes) then
        for i = 1, #interactTypes do
            EndInteraction(interactTypes[i])
        end
    end
end
function ZO_InteractionManager:IsInteracting(interaction)
    if interaction == nil then
        return self.currentInteraction ~= nil
    else
        return self.currentInteraction and (self.currentInteraction.type == interaction.type)
    end
end
function ZO_InteractionManager:ShowInteractWindow(bodyText)
    local sceneName = SYSTEMS:GetRootSceneName(ZO_INTERACTION_SYSTEM_NAME)
    if IsUnderArrest() then
        PushActionLayerByName("SceneChangeInterceptLayer")
        --Bypass any hide confirmations with the arrested reason
        local DONT_PUSH = false
        SCENE_MANAGER:Show(sceneName, DONT_PUSH, nil, nil, ZO_BHSCR_ARRESTED)
        self:FireCallbacks("Shown")
    else
        SCENE_MANAGER:ShowWithFollowup(sceneName, function(allowed)
            if allowed then
                self:FireCallbacks("Shown")
            else
                -- If we're trying to bring up the conversation window but we rejected the request, we want to end that conversation
                -- However, we don't want to end conversations if we were rejected by an already ongoing conversation
                local isNotAlreadyInConversationInteractScene = true
                if self.currentInteraction then
                    for _, interactType in ipairs(self.currentInteraction.interactTypes) do
                        if interactType == INTERACTION_CONVERSATION then
                            isNotAlreadyInConversationInteractScene = false
                            break
                        end
                    end
                end
                if isNotAlreadyInConversationInteractScene then
                    EndInteraction(INTERACTION_CONVERSATION)
                end
            end
        end)
    end
end
function ZO_InteractionManager:IsShowingInteraction()
    local obj = SYSTEMS:GetObject(ZO_INTERACTION_SYSTEM_NAME)
    if obj then
        return SCENE_MANAGER:IsShowing(obj.sceneName)
    end
    --if the object doesn't exist then it won't be showing
    return false
end
-- function wrappers as this manager function is called from
-- multiple files. Now just redirects it to the proper object
-------------------------------------------------------------
function ZO_InteractionManager:SelectChatterOptionByIndex(optionIndex)
     local obj = SYSTEMS:GetObjectBasedOnCurrentScene(ZO_INTERACTION_SYSTEM_NAME)
end
function ZO_InteractionManager:SelectLastChatterOption(optionIndex)
     local obj = SYSTEMS:GetObjectBasedOnCurrentScene(ZO_INTERACTION_SYSTEM_NAME)
     obj:SelectLastChatterOption()
end
-- Globals
-------------------------------------------------------------
INTERACT_WINDOW = ZO_InteractionManager:New()