Back to Home

ESO Lua File v100036

ingame/scrying/ingamescrying.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
111
112
113
114
115
116
117
118
119
--------------------
-- Scrying Ingame --
--------------------
local ANTIQUITY_SCRYING_INTERACTION =
{
    type = "Antiquity Scrying",
    interactTypes = { INTERACTION_ANTIQUITY_SCRYING },
}
local function ToggleHelp()
    HELP_MANAGER:ToggleHelp()
end
local KEYBOARD_STYLE =
{
    helpTutorialsDescriptor = 
    {
        keybind = "TOGGLE_HELP",
        callback = ToggleHelp
    }
}
local GAMEPAD_STYLE =
{
    helpTutorialsDescriptor = 
    {
        keybind = "GAMEPAD_SPECIAL_TOGGLE_HELP",
        callback = ToggleHelp
    }
}
-- This object holds the interaction logic between the scrying remote scene and the rest of the ingame UI.
ZO_IngameScrying = ZO_Object:Subclass()
function ZO_IngameScrying:New(...)
    local object = ZO_Object.New(self)
    object:Initialize(...)
    return object
end
function ZO_IngameScrying:Initialize(control)
    self.control = control
    SCRYING_SCENE = ZO_RemoteInteractScene:New("Scrying", SCENE_MANAGER, ANTIQUITY_SCRYING_INTERACTION)
    SCRYING_FRAGMENT = ZO_SimpleSceneFragment:New(control) -- intro/outro animation handled by C++
    SCRYING_SCENE:AddFragment(SCRYING_FRAGMENT)
    SCRYING_SCENE:RegisterCallback("StateChange", function(oldState, newState)
        if newState == SCENE_SHOWING then
            self:RefreshInputModeFragments()
        end
    end)
    SCRYING_SCENE:SetHideSceneConfirmationCallback(function(scene, nextSceneName, bypassHideSceneConfirmationReason)
        if bypassHideSceneConfirmationReason == nil and IsScryingInProgress() then
            RequestScryingExit()
        else
            SCRYING_SCENE:AcceptHideScene()
        end
    end)
    SCRYING_SCENE:SetHandleGamepadPreferredModeChangedCallback(function()
        -- Input mode switching is also partially handled in internalingame
        self:RefreshInputModeFragments()
        local HANDLED = true
        return HANDLED
    end)
    local overlaySceneInfo =
    {
        systemFilters = { UI_SYSTEM_ANTIQUITY_SCRYING },
    }
    HELP_MANAGER:AddOverlayScene("Scrying", overlaySceneInfo)
    SCRYING_ACTIONS_FRAGMENT = ZO_ActionLayerFragment:New("ScryingActions")
    local function OnScryingExitResponse(_, accept)
        if accept then
            SCRYING_SCENE:AcceptHideScene()
        else
            SCRYING_SCENE:RejectHideScene()
        end
    end
    EVENT_MANAGER:RegisterForEvent("ZO_IngameScrying", EVENT_SCRYING_EXIT_RESPONSE, OnScryingExitResponse)
    self.helpTutorialsButton = control:GetNamedChild("HelpTutorialsKeybindButton")
    self.platformStyle = ZO_PlatformStyle:New(function(style) self:ApplyPlatformStyle(style) end, KEYBOARD_STYLE, GAMEPAD_STYLE)
end
function ZO_IngameScrying:ApplyPlatformStyle(style)
    self.helpTutorialsButton:SetKeybindButtonDescriptor(style.helpTutorialsDescriptor)
    ApplyTemplateToControl(self.helpTutorialsButton, ZO_GetPlatformTemplate("ZO_KeybindButton"))
    --Reset the text here to handle the force uppercase on gamepad
    self.helpTutorialsButton:SetText(GetString(SI_HELP_TUTORIALS))
end
function ZO_IngameScrying:RefreshInputModeFragments()
    if SCRYING_ACTIONS_FRAGMENT:IsShowing() then
        --Remove the scrying actions fragment so it can be on top of the gamepad UI mode fragment
        SCENE_MANAGER:RemoveFragment(SCRYING_ACTIONS_FRAGMENT)
        SCENE_MANAGER:RemoveFragment(SPECIAL_TOGGLE_HELP_ACTION_LAYER_FRAGMENT)
    end
    if IsInGamepadPreferredMode() then
        SCENE_MANAGER:AddFragment(GAMEPAD_UI_MODE_FRAGMENT)
        SCENE_MANAGER:AddFragment(HIDE_MOUSE_FRAGMENT)
    else
        SCENE_MANAGER:RemoveFragment(GAMEPAD_UI_MODE_FRAGMENT)
        SCENE_MANAGER:RemoveFragment(HIDE_MOUSE_FRAGMENT)
    end
    -- Re-add the scrying actions fragment so it can be on top of the gamepad UI mode fragment
    SCENE_MANAGER:AddFragment(SCRYING_ACTIONS_FRAGMENT)
    SCENE_MANAGER:AddFragment(SPECIAL_TOGGLE_HELP_ACTION_LAYER_FRAGMENT)
end
    INGAME_SCRYING = ZO_IngameScrying:New(control)
end