ESO Lua File v100012

ingame/group/gamepad/zo_groupdata_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 ZO_GroupDataManager_Gamepad = GroupMembersManager_Shared:Subclass()
function ZO_GroupDataManager_Gamepad:New(control)
    local manager = ZO_Object.New(self)
    manager:Initialize(control)
    return manager
end
function ZO_GroupDataManager_Gamepad:Initialize(control)
    GAMEPAD_GROUP_DATA_FRAGMENT = ZO_FadeSceneFragment:New(ZO_GroupData_Gamepad)
    GAMEPAD_GROUP_DATA_FRAGMENT:RegisterCallback("StateChange",
        function(oldState, newState)
             if newState == SCENE_FRAGMENT_SHOWING then
                self:RefreshQueuedStatus(IsCurrentlySearchingForGroup())
             end
        end
    )
    local function OnRaidLifeUpdate(event, currentCounter)
        if not IsRaidInProgress() and not HasRaidEnded() then
            currentCounter = nil
        else
            currentCounter = currentCounter or GetRaidReviveCounterInfo()
        end
        self:UpdateRaidLife(currentCounter)
    end
    local function OnGroupingToolsStatusUpdate(isSearching)
        if self:IsShowing() then
            self:RefreshQueuedStatus(isSearching)
        end
    end
    control:RegisterForEvent(EVENT_RAID_REVIVE_COUNTER_UPDATE, OnRaidLifeUpdate)
    control:RegisterForEvent(EVENT_PLAYER_ACTIVATED, OnRaidLifeUpdate)
    control:RegisterForEvent(EVENT_RAID_TIMER_STATE_UPDATE, OnRaidLifeUpdate)
    control:RegisterForEvent(EVENT_GROUPING_TOOLS_STATUS_UPDATE, function(event, ...) OnGroupingToolsStatusUpdate(...) end)
    local function OnGroupChanged()
        self:Update(GetGroupSize())
    end
    control:RegisterForEvent(EVENT_GROUP_MEMBER_LEFT, OnGroupChanged)
    control:RegisterForEvent(EVENT_GROUP_MEMBER_JOINED, OnGroupChanged)
    control:RegisterForEvent(EVENT_GROUP_UPDATE, OnGroupChanged)
    self:InitializeData()
end
function ZO_GroupDataManager_Gamepad:InitializeData()
    self.headerData = {
        titleText = GetString(SI_MAIN_MENU_GROUP),
    }
    self.footerData = {
        data1HeaderText = GetString(SI_GAMEPAD_GROUP_LIST_PANEL_GROUP_MEMBERS_LABEL),
        -- data2HeaderText is the Soul Reservoir (which is hidden until required)
        data3HeaderText = GetString(SI_LFG_QUEUE_STATUS),
    }
end
function ZO_GroupDataManager_Gamepad:UpdateRaidLife(currentCounter)
    if currentCounter then
        self.footerData.data2HeaderText = GetString(SI_GAMEPAD_GROUP_LIST_PANEL_SOUL_RESERVOIR_LABEL)
        self.footerData.data2Text = zo_strformat(SI_GAMEPAD_GROUP_LIST_PANEL_SOUL_RESERVOIR_COUNT, currentCounter)
    else
        self.footerData.data2HeaderText = nil
        self.footerData.data2Text = nil
    end
    if self:IsShowing() then
        CALLBACK_MANAGER:FireCallbacks("OnGroupStatusChange")
    end
end
function ZO_GroupDataManager_Gamepad:RefreshQueuedStatus(isSearching)
    self.footerData.data3Text = isSearching and GetString(SI_LFG_QUEUE_STATUS_QUEUED) or GetString(SI_LFG_QUEUE_STATUS_NOT_QUEUED)
    self.footerData.showLoading = isSearching
    if self:IsShowing() then
        CALLBACK_MANAGER:FireCallbacks("OnGroupStatusChange")
    end
end
function ZO_GroupDataManager_Gamepad:IsShowing()
    return GAMEPAD_GROUP_DATA_FRAGMENT:IsShowing()
end
function ZO_GroupDataManager_Gamepad:GetHeaderData()
    return self.headerData
end
function ZO_GroupDataManager_Gamepad:GetFooterData()
    return self.footerData
end
function ZO_GroupDataManager_Gamepad:Update(groupSize)
    local maxGroupSize = (groupSize > SMALL_GROUP_SIZE_THRESHOLD) and GROUP_SIZE_MAX or SMALL_GROUP_SIZE_THRESHOLD
    self.footerData.data1Text = zo_strformat(SI_GROUP_LIST_PANEL_GROUP_MEMBERS_COUNT, groupSize, maxGroupSize)
    if self:IsShowing() then
        CALLBACK_MANAGER:FireCallbacks("OnGroupStatusChange")
    end
end
    GAMEPAD_GROUP_DATA = ZO_GroupDataManager_Gamepad:New(self)
end