Back to Home

ESO Lua File v101042

ingame/battleground/battlegroundscoreboardingame.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
--------------------------------------------
--Battleground Scoreboard In Game Scene
--------------------------------------------
ZO_Battleground_Scoreboard_In_Game = ZO_Object:Subclass()
function ZO_Battleground_Scoreboard_In_Game:New(...)
    local scoreboard = ZO_Object.New(self)
    scoreboard:Initialize(...)
    return scoreboard
end
function ZO_Battleground_Scoreboard_In_Game:Initialize(control)
    self.inGameTimer = control
    self.inGameTimerLabel = control:GetNamedChild("Timer")
    BATTLEGROUND_SCOREBOARD_IN_GAME_TIMER_FRAGMENT = ZO_SimpleSceneFragment:New(self.inGameTimer)
    BATTLEGROUND_SCOREBOARD_IN_GAME_SCENE = ZO_Scene:New("battleground_scoreboard_in_game", SCENE_MANAGER)
    BATTLEGROUND_SCOREBOARD_IN_GAME_SCENE:RegisterCallback("StateChange", function(oldState, newState)
        if newState == SCENE_SHOWING then
            self:OnShowing()
        elseif newState == SCENE_HIDDEN then
            self:OnHidden()
        end
    end)
    BATTLEGROUND_SCOREBOARD_IN_GAME_SCENE:SetSceneRestoreHUDSceneToggleUIMode(true)
    BATTLEGROUND_SCOREBOARD_IN_GAME_SCENE:SetSceneRestoreHUDSceneToggleGameMenu(true)
    BATTLEGROUND_SCOREBOARD_IN_GAME_UI_SCENE = ZO_Scene:New("battleground_scoreboard_in_game_ui", SCENE_MANAGER)
    SYSTEMS:RegisterKeyboardRootScene("battleground_scoreboard_in_game", BATTLEGROUND_SCOREBOARD_IN_GAME_SCENE)
    SYSTEMS:RegisterGamepadRootScene("battleground_scoreboard_in_game", BATTLEGROUND_SCOREBOARD_IN_GAME_SCENE)
    local function OnGamepadModeChanged(eventId, isGamepadPreferred)
        self:CloseScoreboard()
    end
    EVENT_MANAGER:RegisterForEvent("BattlegroundScoreboardInGame", EVENT_GAMEPAD_PREFERRED_MODE_CHANGED, OnGamepadModeChanged)
    
end
function ZO_Battleground_Scoreboard_In_Game:InitializeKeybindStrip()
    self.keybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_RIGHT,
        -- Close
        {
            name = GetString(SI_BATTLEGROUND_SCOREBOARD_CLOSE),
            keybind = "HIDE_BATTLEGROUND_SCOREBOARD",
        
            callback = function()
                self:CloseScoreboard()
            end,
        },
        -- Leave Battleground
        {
            name = GetString(SI_BATTLEGROUND_SCOREBOARD_LEAVE_BATTLEGROUND),
            keybind = "LEAVE_BATTLEGROUND",
        
            callback = function()
                self:OnLeaveBattlegroundPressed()
            end,
        },
    }
    self.listNavigationKeybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_CENTER,
        --Player Options
        {
            name = GetString(SI_BATTLEGROUND_SCOREBOARD_PLAYER_OPTIONS_KEYBIND),
            keybind = "BATTLEGROUND_SCOREBOARD_PLAYER_OPTIONS",
            visible = function()
                return IsInGamepadPreferredMode()
            end,
            callback = function()
                BATTLEGROUND_SCOREBOARD_FRAGMENT:ShowGamepadPlayerMenu()
            end,
        },
        -- Previous Entry Select
        {
            name = GetString(SI_BATTLEGROUND_SCOREBOARD_PREVIOUS_PLAYER_KEYBIND),
            keybind = "BATTLEGROUND_SCOREBOARD_PREVIOUS",
            callback = function()
                BATTLEGROUND_SCOREBOARD_FRAGMENT:SelectPreviousPlayerData()
            end,
        },
        -- Next Entry Select
        {
            name = GetString(SI_BATTLEGROUND_SCOREBOARD_NEXT_PLAYER_KEYBIND),
            keybind = "BATTLEGROUND_SCOREBOARD_NEXT",
            callback = function()
                BATTLEGROUND_SCOREBOARD_FRAGMENT:SelectNextPlayerData()
            end,
        },
    }
end
function ZO_Battleground_Scoreboard_In_Game:InitializePlatformStyle()
    self.platformStyle = ZO_PlatformStyle:New(function(style) self:ApplyPlatformStyle(style) end)
end
function ZO_Battleground_Scoreboard_In_Game:ApplyPlatformStyle(style)
    ApplyTemplateToControl(self.inGameTimerLabel, ZO_GetPlatformTemplate("ZO_BattlegroundScoreboard_Timer"))
end
function ZO_Battleground_Scoreboard_In_Game:CloseScoreboard()
    if SCENE_MANAGER:IsShowing("battleground_scoreboard_in_game") or SCENE_MANAGER:IsShowing("battleground_scoreboard_in_game_ui") then
        BATTLEGROUND_SCOREBOARD_FRAGMENT:HideInGameScoreboard()
    end
end
function ZO_Battleground_Scoreboard_In_Game:OnLeaveBattlegroundPressed()
    ZO_Dialogs_ShowPlatformDialog("CONFIRM_LEAVE_BATTLEGROUND")
end
function ZO_Battleground_Scoreboard_In_Game:UpdateTimer()
    self.inGameTimerLabel:SetText(BATTLEGROUND_HUD_FRAGMENT:GetStateText())
end
function ZO_Battleground_Scoreboard_In_Game:OnShowing()
    KEYBIND_STRIP:RemoveDefaultExit()
    KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor)
    KEYBIND_STRIP:AddKeybindButtonGroup(self.listNavigationKeybindStripDescriptor)
    self:UpdateTimer()
    self.inGameTimer:SetHandler("OnUpdate", function() self:UpdateTimer() end)
end
function ZO_Battleground_Scoreboard_In_Game:OnHidden()
    KEYBIND_STRIP:RemoveKeybindButtonGroup(self.listNavigationKeybindStripDescriptor)
    KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
    KEYBIND_STRIP:RestoreDefaultExit()
    self.inGameTimer:SetHandler("OnUpdate", function() self:UpdateTimer() end)
end
function ZO_Battleground_Scoreboard_In_Game:SetupKeybindStripDescriptorAlignment()
    if IsInGamepadPreferredMode() then
        self.keybindStripDescriptor.alignment = KEYBIND_STRIP_ALIGN_LEFT
        self.listNavigationKeybindStripDescriptor.alignment = KEYBIND_STRIP_ALIGN_LEFT
    else
        self.keybindStripDescriptor.alignment = KEYBIND_STRIP_ALIGN_RIGHT
        self.listNavigationKeybindStripDescriptor.alignment = KEYBIND_STRIP_ALIGN_CENTER
    end
end
function ZO_Battleground_Scoreboard_In_Game:SetupPreferredKeybindFragments()
    if IsInGamepadPreferredMode() then
        BATTLEGROUND_SCOREBOARD_IN_GAME_SCENE:AddFragmentGroup(FRAGMENT_GROUP.GAMEPAD_KEYBIND_STRIP_GROUP)
        BATTLEGROUND_SCOREBOARD_IN_GAME_SCENE:RemoveFragmentGroup(FRAGMENT_GROUP.KEYBOARD_KEYBIND_STRIP_GROUP)
    else
        BATTLEGROUND_SCOREBOARD_IN_GAME_SCENE:AddFragmentGroup(FRAGMENT_GROUP.KEYBOARD_KEYBIND_STRIP_GROUP)
        BATTLEGROUND_SCOREBOARD_IN_GAME_SCENE:RemoveFragmentGroup(FRAGMENT_GROUP.GAMEPAD_KEYBIND_STRIP_GROUP)
    end
end
function ZO_Battleground_Scoreboard_In_Game:RefreshMatchInfoFragments()
    local groupToAdd, groupToRemove
    if IsInGamepadPreferredMode() then
        groupToAdd = FRAGMENT_GROUP.BATTLEGROUND_MATCH_INFO_GAMEPAD_GROUP
        groupToRemove = FRAGMENT_GROUP.BATTLEGROUND_MATCH_INFO_KEYBOARD_GROUP
    else
        groupToAdd = FRAGMENT_GROUP.BATTLEGROUND_MATCH_INFO_KEYBOARD_GROUP
        groupToRemove = FRAGMENT_GROUP.BATTLEGROUND_MATCH_INFO_GAMEPAD_GROUP
    end
    BATTLEGROUND_SCOREBOARD_IN_GAME_SCENE:RemoveFragmentGroup(groupToRemove)
    BATTLEGROUND_SCOREBOARD_IN_GAME_UI_SCENE:RemoveFragmentGroup(groupToRemove)
    BATTLEGROUND_SCOREBOARD_IN_GAME_SCENE:AddFragmentGroup(groupToAdd)
    BATTLEGROUND_SCOREBOARD_IN_GAME_UI_SCENE:AddFragmentGroup(groupToAdd)
end
------------------
-- XML Functions
------------------
    ZO_BATTLEGROUND_SCOREBOARD_IN_GAME = ZO_Battleground_Scoreboard_In_Game:New(control)
end