ESO Lua File v100013

ingame/group/searchingforgroup.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
local SearchingForGroupManager = ZO_Object:Subclass()
function SearchingForGroupManager:New(...)
    local manager = ZO_Object.New(self)
    manager:Initialize(...)
    return manager
end
function SearchingForGroupManager:Initialize(control)
    self.control = control
    self.spinner = control:GetNamedChild("Spinner")
    self.estimatedTimeControl = control:GetNamedChild("EstimatedTime")
    self.estimatedTimeValueControl = self.estimatedTimeControl:GetNamedChild("Value")
    self.actualTimeControl = control:GetNamedChild("ActualTime")
    self.actualTimeValueControl = self.actualTimeControl:GetNamedChild("Value")
    self.searching = IsCurrentlySearchingForGroup()
    self:Update()
    local function OnGroupingToolsStatusUpdate(searching)
        if self.searching ~= searching then
            self.searching = searching
            self:Update()
            if searching then
                PlaySound(SOUNDS.LFG_SEARCH_STARTED)
            else
                PlaySound(SOUNDS.LFG_SEARCH_FINISHED)
            end
        end
    end
    local function OnPlayerActivated()
    end
    local lastUpdateS = 0
    local function OnUpdate(control, currentFrameTimeSeconds)
        if currentFrameTimeSeconds - lastUpdateS > 1 then
            self:Update()
            lastUpdateS = currentFrameTimeSeconds
        end
    end
    control:RegisterForEvent(EVENT_GROUPING_TOOLS_STATUS_UPDATE, function(event, ...) OnGroupingToolsStatusUpdate(...) end)
    control:RegisterForEvent(EVENT_PLAYER_ACTIVATED, function(event, ...) OnPlayerActivated(...) end)
    control:SetHandler("OnUpdate", OnUpdate)
end
function SearchingForGroupManager:Update()
    if self.searching then
        self.spinner:Show()
        self.estimatedTimeControl:SetHidden(false)
        self.actualTimeControl:SetHidden(false)
        local searchStartTimeMs, searchEstimatedCompletionTimeMs = GetLFGSearchTimes()
        local textEstimatedTime = ZO_GetSimplifiedTimeEstimateText(searchEstimatedCompletionTimeMs)
        self.estimatedTimeValueControl:SetText(textEstimatedTime)
        local timeSinceSearchStartMs = GetFrameTimeMilliseconds() - searchStartTimeMs
        local textStartTime = ZO_FormatTimeMilliseconds(timeSinceSearchStartMs, TIME_FORMAT_STYLE_COLONS, TIME_FORMAT_PRECISION_TWELVE_HOUR)
        self.actualTimeValueControl:SetText(textStartTime)
    else
        self.spinner:Hide()
        self.estimatedTimeControl:SetHidden(true)
        self.actualTimeControl:SetHidden(true)
    end
end
    SEARCHING_FOR_GROUP = SearchingForGroupManager:New(self)
end