Back to Home

ESO Lua File v100030

ingame/scenes/hudscene.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
local ZO_HUDFragment = ZO_SceneFragment:Subclass()
function ZO_HUDFragment:New(...)
    return ZO_SceneFragment.New(self, ...)
end
function ZO_HUDFragment:Initialize(...)
    ZO_SceneFragment.Initialize(self, ...)
    EVENT_MANAGER:RegisterForEvent("HUDFragment", EVENT_PLAYER_DEAD, function() self:UpdateVisibility() end)
    EVENT_MANAGER:RegisterForEvent("HUDFragment", EVENT_PLAYER_ALIVE, function() self:UpdateVisibility() end)
end
function ZO_HUDFragment:UpdateVisibility()
    if self:GetState() == SCENE_FRAGMENT_HIDDEN then
        return
    end
    local fragmentHidden = not self:IsShowing()
    local playerDead = IsUnitDead("player")
    local hiddenOrDead = fragmentHidden or playerDead
    COMPASS_FRAME:SetCompassHidden(playerDead)
    ZO_PlayerToPlayerArea:SetHidden(fragmentHidden)
    TUTORIAL_SYSTEM:SuppressTutorialType(TUTORIAL_TYPE_HUD_INFO_BOX, fragmentHidden, TUTORIAL_SUPPRESSED_BY_SCENE)
    INSTANCE_KICK_WARNING_DEAD:SetHiddenForReason("hudScene", fragmentHidden)
    HUD_RAID_LIFE:SetHiddenForReason("hudScene", fragmentHidden)
    if GAMEPAD_CHAT_SYSTEM:ShouldOnlyShowOnHUD() then
        GAMEPAD_CHAT_SYSTEM:RefreshVisibility()
    end
    OBJECTIVE_CAPTURE_METER:SetHiddenForReason("hudScene", hiddenOrDead)
    SetFloatingMarkerGlobalAlpha(hiddenOrDead and 0 or 1)
    SHARED_INFORMATION_AREA:SetSupressed(hiddenOrDead)
    RETICLE:RequestHidden(hiddenOrDead)
    HUD_INFAMY_METER:RequestHidden(hiddenOrDead)
    HUD_TELVAR_METER:SetHiddenForReason("hudScene", hiddenOrDead)
    HUD_DAEDRIC_ENERGY_METER:SetHiddenForReason("hudScene", hiddenOrDead)
end
function ZO_HUDFragment:Show()
    self:OnShown()
end
function ZO_HUDFragment:Hide()
    self:OnHidden()
end
HUD_FRAGMENT = ZO_HUDFragment:New()
------------------------
--Reticle Mode Fragment
------------------------
local ZO_ReticleModeFragment = ZO_SceneFragment:Subclass()
function ZO_ReticleModeFragment:New()
    return ZO_SceneFragment.New(self)
end
function ZO_ReticleModeFragment:Show()
    ZO_PlayerToPlayerArea:SetHidden(false)
    self:OnShown()
end
function ZO_ReticleModeFragment:Hide()
    ZO_PlayerToPlayerArea:SetHidden(true)
    self:OnHidden()
end
local RETICLE_MODE_FRAGMENT = ZO_ReticleModeFragment:New()
----------------
--HUD Fragments
----------------
local HUD_FRAGMENT_GROUP =
{
    DEATH_RECAP_FRAGMENT,
    PLAYER_PROGRESS_BAR_FRAGMENT,
    COMPASS_FRAME_FRAGMENT,
    FOCUSED_QUEST_TRACKER_FRAGMENT,
    ACTIVITY_TRACKER_FRAGMENT,
    READY_CHECK_TRACKER_FRAGMENT,
    ACTION_BAR_FRAGMENT,
    HUD_EQUIPMENT_STATUS_FRAGMENT,
    CONTEXTUAL_ACTION_BAR_AREA_FRAGMENT,
    HUD_FRAGMENT,
    DEATH_FRAGMENT,
    UNIT_FRAMES_FRAGMENT,
    PLAYER_ATTRIBUTE_BARS_FRAGMENT,
    PERFORMANCE_METER_FRAGMENT,
    PLAYER_PROGRESS_BAR_GAMEPAD_HIDE_NAME_LOCATION_FRAGMENT,
    SUBTITLE_HUD_FRAGMENT,
    GAMEPAD_LOOT_HISTORY_FRAGMENT,
    KEYBOARD_LOOT_HISTORY_FRAGMENT,
    HOUSING_HUD_FRAGMENT,
    BUFF_DEBUFF_FRAGMENT,
    HOUSING_HUD_ACTION_LAYER_FRAGMENT,
    BATTLEGROUND_HUD_FRAGMENT,
    BATTLEGROUND_HUD_ACTION_LAYER_FRAGMENT,
    ZONE_STORY_TRACKER_FRAGMENT,
}
local NO_DEAD_FRAGMENTS =
{
    FOCUSED_QUEST_TRACKER_FRAGMENT,
    ACTIVITY_TRACKER_FRAGMENT,
    READY_CHECK_TRACKER_FRAGMENT,
    ZONE_STORY_TRACKER_FRAGMENT,
    ACTION_BAR_FRAGMENT,
    HUD_EQUIPMENT_STATUS_FRAGMENT,
    CONTEXTUAL_ACTION_BAR_AREA_FRAGMENT,
    PLAYER_ATTRIBUTE_BARS_FRAGMENT,
    SUBTITLE_HUD_FRAGMENT,
    HOUSING_HUD_FRAGMENT,
    BUFF_DEBUFF_FRAGMENT,
    HOUSING_HUD_ACTION_LAYER_FRAGMENT,
}
local DEAD_ONLY_FRAGMENTS =
{
    DEATH_FRAGMENT,
}
local function UpdateDeathFragments()
    local playerDead = IsUnitDead("player")
    for _, fragment in ipairs(NO_DEAD_FRAGMENTS) do
        fragment:SetHiddenForReason("Dead", playerDead)
    end
    for _, fragment in ipairs(DEAD_ONLY_FRAGMENTS) do
        fragment:SetHiddenForReason("Dead", not playerDead)
    end
end
EVENT_MANAGER:RegisterForEvent("HUDFragments", EVENT_PLAYER_DEAD, UpdateDeathFragments)
EVENT_MANAGER:RegisterForEvent("HUDFragments", EVENT_PLAYER_ALIVE, UpdateDeathFragments)
local HOUSING_ONLY_FRAGMENTS =
{
    HOUSING_HUD_FRAGMENT,
    HOUSING_HUD_ACTION_LAYER_FRAGMENT,
}
local BATTLEGROUND_ONLY_FRAGMENTS =
{
    BATTLEGROUND_HUD_FRAGMENT,
    BATTLEGROUND_HUD_ACTION_LAYER_FRAGMENT,
}
local BATTLEGROUND_EXCLUDED_FRAGMENTS =
{
    FOCUSED_QUEST_TRACKER_FRAGMENT,
    ACTIVITY_TRACKER_FRAGMENT,
    READY_CHECK_TRACKER_FRAGMENT,
    ZONE_STORY_TRACKER_FRAGMENT,
}
    local isHousingZone = GetCurrentZoneHouseId() ~= 0
    for _, fragment in ipairs(HOUSING_ONLY_FRAGMENTS) do
        fragment:SetHiddenForReason("Housing", not isHousingZone)
    end
    local isBattlegroundZone = IsActiveWorldBattleground()
    for _, fragment in ipairs(BATTLEGROUND_ONLY_FRAGMENTS) do
        fragment:SetHiddenForReason("Battleground", not isBattlegroundZone)
    end
    for _, fragment in ipairs(BATTLEGROUND_EXCLUDED_FRAGMENTS) do
        fragment:SetHiddenForReason("Battleground", isBattlegroundZone)
    end
end
EVENT_MANAGER:RegisterForEvent("HUDFragments", EVENT_PLAYER_ACTIVATED, function()
end)
---------------
--ZO_HUDScene
---------------
ZO_HUDScene = ZO_Scene:Subclass()
function ZO_HUDScene:New()
    local scene = ZO_Scene.New(self, "hud", SCENE_MANAGER)
    scene:AddFragment(RETICLE_MODE_FRAGMENT)
    scene:AddFragmentGroup(HUD_FRAGMENT_GROUP)
    return scene
end
HUD_SCENE = ZO_HUDScene:New()
----------------
--ZO_HUDUIScene
----------------
ZO_HUDUIScene = ZO_Scene:Subclass()
function ZO_HUDUIScene:New()
    local scene = ZO_Scene.New(self, "hudui", SCENE_MANAGER)
    SCENE_MANAGER:SetSceneRestoresBaseSceneOnGameMenuToggle("hudui", true)
    scene:AddFragment(MOUSE_UI_MODE_FRAGMENT)
    scene:AddFragmentGroup(HUD_FRAGMENT_GROUP)
    return scene
end
HUD_UI_SCENE = ZO_HUDUIScene:New()
-----------------------
--Loot Scene
-----------------------
LOOT_SCENE:AddFragmentGroup(FRAGMENT_GROUP.MOUSE_DRIVEN_UI_WINDOW_NO_COMBAT_OVERLAY)
LOOT_SCENE:AddFragment(LOOT_WINDOW_FRAGMENT)
LOOT_SCENE:AddFragmentGroup(HUD_FRAGMENT_GROUP)
LOOT_SCENE:AddFragment(FRAME_EMOTE_FRAGMENT_LOOT)
LOOT_SCENE:AddFragment(PLAYER_PROGRESS_BAR_FRAGMENT)
LOOT_SCENE:AddFragment(ZONE_STORY_TRACKER_FRAGMENT)