Back to Home

ESO Lua File v101042

ingame/endlessdungeon/endlessdungeonhudtracker.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
ZO_EndlessDungeonHUDTracker = ZO_HUDTracker_Base:Subclass()
function ZO_EndlessDungeonHUDTracker:Initialize(...)
    ZO_HUDTracker_Base.Initialize(self, ...)
    local fragment = self:GetFragment()
    ENDLESS_DUNGEON_HUD_TRACKER_FRAGMENT = fragment
    fragment:SetHiddenForReason("InactiveDungeon", true)
    local function OnAddOnLoaded(_, name)
        if name == "ZO_Ingame" then
            if ENDLESS_DUNGEON_MANAGER:IsEndlessDungeonStarted() then
                self:UpdateProgress()
            end
            EVENT_MANAGER:UnregisterForEvent("ZO_EndlessDungeonHUDTracker", EVENT_ADD_ON_LOADED)
        end
    end
    EVENT_MANAGER:RegisterForEvent("ZO_EndlessDungeonHUDTracker", EVENT_ADD_ON_LOADED, OnAddOnLoaded)
end
function ZO_EndlessDungeonHUDTracker:DeferredInitialize(...)
    self.showBuffTrackerKeybindDescriptor =
    {
        -- Even though this is an ethereal keybind, the name will still be read during screen narration
        keybind = "TOGGLE_ENDLESS_DUNGEON_BUFF_TRACKER",
        ethereal = true,
        narrateEthereal = true,
        etherealNarrationOrder = 1,
        callback = function()
            SYSTEMS:ShowScene("endlessDungeonBuffTracker")
        end,
        visible = function()
            return ENDLESS_DUNGEON_MANAGER:IsEndlessDungeonStarted()
        end,
    }
    self.showBuffTrackerKeybindButton = self.container:GetNamedChild("ShowBuffTracker")
    self.showBuffTrackerKeybindButton:SetKeybindButtonDescriptor(self.showBuffTrackerKeybindDescriptor)
    ZO_HUDTracker_Base.DeferredInitialize(self, ...)
    self:Update()
end
function ZO_EndlessDungeonHUDTracker:InitializeStyles()
    -- Intentional override of ZO_HUDTracker_Base behavior.
    self.styles =
    {
        keyboard =
        {
            CONTAINER_PRIMARY_ANCHOR = ZO_Anchor:New(TOPLEFT),
            CONTAINER_SECONDARY_ANCHOR = ZO_Anchor:New(TOPRIGHT),
            CONTAINER_RESIZE_TO_FIT_PADDING = {0, 20},
            FONT_HEADER = "ZoFontGameShadow",
            FONT_SUBLABEL = "ZoFontGameShadow",
            HEADER_PRIMARY_ANCHOR = ZO_Anchor:New(TOPLEFT, self.container),
            HEADER_SECONDARY_ANCHOR = ZO_Anchor:New(TOPRIGHT, self.container),
            KEYBIND_ANCHOR = ZO_Anchor:New(TOPRIGHT, self.headerLabel, TOPLEFT, 0, -7),
            KEYBIND_BUTTON_TEMPLATE = "ZO_KeybindButton_Keyboard_Template",
            SUBLABEL_PRIMARY_ANCHOR = ZO_Anchor:New(TOPLEFT, self.headerLabel, BOTTOMLEFT, 10, 2),
            SUBLABEL_SECONDARY_ANCHOR = ZO_Anchor:New(TOPRIGHT, self.headerLabel, BOTTOMRIGHT, 0, 2),
            TEXT_HORIZONTAL_ALIGNMENT = TEXT_ALIGN_LEFT,
            TEXT_TYPE_HEADER = MODIFY_TEXT_TYPE_NONE,
            TOP_LEVEL_PRIMARY_ANCHOR = ZO_Anchor:New(TOPLEFT, GuiRoot, TOPRIGHT, -230, 90),
            TOP_LEVEL_SECONDARY_ANCHOR = ZO_Anchor:New(TOPRIGHT, GuiRoot, nil, 0, 90),
        },
        gamepad =
        {
            CONTAINER_PRIMARY_ANCHOR = ZO_Anchor:New(TOPLEFT),
            CONTAINER_SECONDARY_ANCHOR = ZO_Anchor:New(TOPRIGHT, nil, nil, -15, 0),
            CONTAINER_RESIZE_TO_FIT_PADDING = {0, 30},
            FONT_HEADER = "ZoFontGamepadBold27",
            FONT_SUBLABEL = "ZoFontGamepad34",
            HEADER_PRIMARY_ANCHOR = ZO_Anchor:New(TOPRIGHT, self.container),
            KEYBIND_ANCHOR = ZO_Anchor:New(RIGHT, self.headerLabel, LEFT, -5, 5),
            KEYBIND_BUTTON_TEMPLATE = "ZO_KeybindButton_Gamepad_Template",
            SUBLABEL_PRIMARY_ANCHOR = ZO_Anchor:New(TOPRIGHT, self.headerLabel, BOTTOMRIGHT, 0, 10),
            TEXT_HORIZONTAL_ALIGNMENT = TEXT_ALIGN_RIGHT,
            TEXT_TYPE_HEADER = MODIFY_TEXT_TYPE_UPPERCASE,
            TOP_LEVEL_PRIMARY_ANCHOR = ZO_Anchor:New(TOPLEFT, GuiRoot, TOPRIGHT, -275, 0),
            TOP_LEVEL_SECONDARY_ANCHOR = ZO_Anchor:New(TOPRIGHT, GuiRoot, nil, 0, 100),
        },
    }
    self.platformStyle = ZO_PlatformStyle:New(function(style)
        self:ApplyPlatformStyle(style)
    end, self.styles.keyboard, self.styles.gamepad)
    self.platformStyle:Apply()
end
function ZO_EndlessDungeonHUDTracker:ApplyPlatformStyle(style)
    ZO_HUDTracker_Base.ApplyPlatformStyle(self, style)
    self.container:SetResizeToFitPadding(unpack(style.CONTAINER_RESIZE_TO_FIT_PADDING))
    -- Order matters:
    self.headerLabel:SetHorizontalAlignment(style.TEXT_HORIZONTAL_ALIGNMENT)
    self.headerLabel:SetText(GetString(SI_ENDLESS_DUNGEON_HUD_TRACKER_TITLE))
    self.showBuffTrackerKeybindButton:ClearAnchors()
    style.KEYBIND_ANCHOR:AddToControl(self.showBuffTrackerKeybindButton)
    ApplyTemplateToControl(self.showBuffTrackerKeybindButton, style.KEYBIND_BUTTON_TEMPLATE)
end
function ZO_EndlessDungeonHUDTracker:GetPrimaryAnchor()
    return self.currentStyle.TOP_LEVEL_PRIMARY_ANCHOR
end
function ZO_EndlessDungeonHUDTracker:GetSecondaryAnchor()
    return self.currentStyle.TOP_LEVEL_SECONDARY_ANCHOR
end
function ZO_EndlessDungeonHUDTracker:OnDungeonStateChanged(newState, oldState)
    self:Update()
end
function ZO_EndlessDungeonHUDTracker:OnHiding()
    KEYBIND_STRIP:RemoveKeybindButton(self.showBuffTrackerKeybindDescriptor)
end
function ZO_EndlessDungeonHUDTracker:OnShown()
    KEYBIND_STRIP:AddKeybindButton(self.showBuffTrackerKeybindDescriptor)
    self:RefreshAnchors()
end
function ZO_EndlessDungeonHUDTracker:RegisterEvents(...)
    ZO_HUDTracker_Base.RegisterEvents(self, ...)
    ENDLESS_DUNGEON_MANAGER:RegisterCallback("StateChanged", self.OnDungeonStateChanged, self)
    ENDLESS_DUNGEON_MANAGER:RegisterCallback("DungeonInitialized", self.UpdateProgress, self)
end
function ZO_EndlessDungeonHUDTracker:Update()
    local hidden = not ENDLESS_DUNGEON_MANAGER:IsEndlessDungeonStarted()
    self:GetFragment():SetHiddenForReason("InactiveDungeon", hidden, DEFAULT_HUD_DURATION, DEFAULT_HUD_DURATION)
    return true
end
function ZO_EndlessDungeonHUDTracker:UpdateProgress()
    if ENDLESS_DUNGEON_MANAGER:IsEndlessDungeonStarted() then
        local USE_THICK_OUTLINE = true
        self.subLabel:SetText(ENDLESS_DUNGEON_MANAGER:GetCurrentProgressionText(USE_THICK_OUTLINE))
    else
        self.subLabel:SetText("")
    end
end
function ZO_EndlessDungeonHUDTracker.OnInitialized(control)
    ENDLESS_DUNGEON_HUD_TRACKER = ZO_EndlessDungeonHUDTracker:New(control)
end