Back to Home

ESO Lua File v100028

ingame/lfg/gamepad/zo_activityqueuedata_gamepad.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
local ActivityQueueData_Gamepad = ZO_Object:Subclass()
function ActivityQueueData_Gamepad:New(...)
    local manager = ZO_Object.New(self)
    manager:Initialize(...)
    return manager
end
function ActivityQueueData_Gamepad:Initialize(control)
    GAMEPAD_ACTIVITY_QUEUE_DATA_FRAGMENT = ZO_FadeSceneFragment:New(control)
    GAMEPAD_ACTIVITY_QUEUE_DATA_FRAGMENT:RegisterCallback("StateChange",
        function(oldState, newState)
            if newState == SCENE_FRAGMENT_SHOWING then
                self:RefreshQueuedStatus(GetActivityFinderStatus())
            end
        end
    )
    local function OnActivityFinderStatusUpdate(status)
        if self:IsShowing() then
            self:RefreshQueuedStatus(status)
        end
    end
    local lastUpdateS = 0
    local function OnUpdate(control, currentFrameTimeSeconds)
        if currentFrameTimeSeconds - lastUpdateS > 1 then
            self:Update()
            lastUpdateS = currentFrameTimeSeconds
        end
    end
    ZO_ACTIVITY_FINDER_ROOT_MANAGER:RegisterCallback("OnActivityFinderStatusUpdate", OnActivityFinderStatusUpdate)
    control:SetHandler("OnUpdate", OnUpdate)
    self.footerData = { }
end
do
    local STATUS_HEADER_TEXT = GetString(SI_LFG_QUEUE_STATUS)
    local ESTIMATED_HEADER_TEXT = GetString(SI_GAMEPAD_LFG_QUEUE_ESTIMATED)
    local ACTUAL_HEADER_TEXT = GetString(SI_GAMEPAD_LFG_QUEUE_ACTUAL)
    function ActivityQueueData_Gamepad:RefreshQueuedStatus(status)
        self.activityFinderStatus = status
        self.statusText = GetString("SI_ACTIVITYFINDERSTATUS", status)
        self.isSearching = status == ACTIVITY_FINDER_STATUS_QUEUED
        local footerData = self.footerData
        if self.isSearching then
            footerData.data1HeaderText = ACTUAL_HEADER_TEXT
            self:Update()
        else
            footerData.data1HeaderText = STATUS_HEADER_TEXT
            footerData.data1Text = self.statusText
            footerData.data2HeaderText = nil
            footerData.data2Text = nil
            footerData.data3HeaderText = nil
            footerData.data3Text = nil
            if self:IsShowing() then
                GAMEPAD_GENERIC_FOOTER:Refresh(GAMEPAD_ACTIVITY_QUEUE_DATA:GetFooterData())
            end
        end
        if self:IsShowing() then
            CALLBACK_MANAGER:FireCallbacks("OnGroupStatusChange")
        end
    end
    function ActivityQueueData_Gamepad:Update()
        if self.isSearching then
            local footerData = self.footerData
            local searchStartTimeMs, searchEstimatedCompletionTimeMs = GetLFGSearchTimes()
            local timeSinceSearchStartMs = GetFrameTimeMilliseconds() - searchStartTimeMs
            local textStartTime = ZO_FormatTimeMilliseconds(timeSinceSearchStartMs, TIME_FORMAT_STYLE_COLONS, TIME_FORMAT_PRECISION_TWELVE_HOUR)
            footerData.data1Text = textStartTime
            if searchEstimatedCompletionTimeMs > 0 then
                local textEstimatedTime = ZO_GetSimplifiedTimeEstimateText(searchEstimatedCompletionTimeMs)
                footerData.data2HeaderText = ESTIMATED_HEADER_TEXT
                footerData.data2Text = textEstimatedTime
                footerData.data3HeaderText = STATUS_HEADER_TEXT
                footerData.data3Text = self.statusText
            else
                footerData.data2HeaderText = STATUS_HEADER_TEXT
                footerData.data2Text = self.statusText
                footerData.data3HeaderText = nil
                footerData.data3Text = nil
            end
            GAMEPAD_GENERIC_FOOTER:Refresh(GAMEPAD_ACTIVITY_QUEUE_DATA:GetFooterData())
        end
    end
end
function ActivityQueueData_Gamepad:IsShowing()
    return GAMEPAD_ACTIVITY_QUEUE_DATA_FRAGMENT:IsShowing()
end
function ActivityQueueData_Gamepad:GetFooterData()
    return self.footerData
end
    GAMEPAD_ACTIVITY_QUEUE_DATA = ActivityQueueData_Gamepad:New(self)
end