ESO Lua File v100012

ingame/voicechat/console/zo_voicechat_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
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
--------------------------------------------
-- VoiceChat Gamepad
--------------------------------------------
ZO_VoiceChat_Gamepad = ZO_SocialOptionsDialogGamepad:Subclass()
function ZO_VoiceChat_Gamepad:New(...)
     local voiceChatGamepad = ZO_Object.New(self)
     voiceChatGamepad:Initialize(...)
     return voiceChatGamepad
end
function ZO_VoiceChat_Gamepad:Initialize(control)
    self.control = control
     GAMEPAD_VOICECHAT_SCENE = ZO_Scene:New("gamepad_voice_chat", SCENE_MANAGER)
    GAMEPAD_VOICECHAT_PARTICIPANT_OPTIONS_SCENE = ZO_Scene:New("gamepad_voice_chat_participant_options", SCENE_MANAGER)
    VOICE_CHAT_CHANNELS_GAMEPAD = ZO_VoiceChatChannelsGamepad:New(self.control:GetNamedChild("Channels"))
    VOICE_CHAT_PARTICIPANT_OPTIONS_GAMEPAD = ZO_VoiceChatParticipantOptionsGamepad:New(self.control:GetNamedChild("ParticipantOptions"))
end
function ZO_VoiceChat_Gamepad:InitializeEvents()
    local function OnVoiceTransmitChannelChanged(channelName)
        --Special case: Area is rejoined when zoning, and we don't want to play the alert for this situation
        local channelData = ZO_VoiceChat_GetChannelDataFromName(channelName)
        if not VOICE_CHAT_MANAGER:DoesChannelExist(channelData) then
            return
        end
        local channelType = channelData.channelType
        if channelType == VOICE_CHANNEL_AREA and self.desiredAreaBecameUnavailable then
            self.desiredAreaBecameUnavailable = nil
            return
        end
        --Display an alert if not on a Voice Chat menu
        if VOICE_CHAT_CHANNELS_GAMEPAD:IsHidden() and VOICE_CHAT_PARTICIPANT_OPTIONS_GAMEPAD:IsHidden() then
            local channel = VOICE_CHAT_MANAGER:GetChannel(channelData)
            local soundId = SOUNDS.VOICE_CHAT_ALERT_CHANNEL_MADE_ACTIVE
            local text = zo_strformat(SI_GAMEPAD_VOICECHAT_ALERT_CHANNEL_ACTIVE, channel.name)
            ZO_Alert(UI_ALERT_CATEGORY_ALERT, soundId, text)
        end
        self.desiredAreaBecameUnavailable = nil
    end
    local function OnVoiceChannelUnavailable(channelName)
        local channelData = ZO_VoiceChat_GetChannelDataFromName(channelName)
        --Special case: Area is rejoined when zoning, and we don't want to play the alert for this situation
        if channelData.channelType == VOICE_CHANNEL_AREA and VOICE_CHAT_MANAGER:GetDesiredActiveChannelType() == VOICE_CHANNEL_AREA then
            self.desiredAreaBecameUnavailable = true
        end
    end
    self.control:RegisterForEvent(EVENT_VOICE_TRANSMIT_CHANNEL_CHANGED, function(eventCode, ...) OnVoiceTransmitChannelChanged(...) end)
    self.control:RegisterForEvent(EVENT_VOICE_CHANNEL_UNAVAILABLE, function(eventCode, ...) OnVoiceChannelUnavailable(...) end)
end
function ZO_VoiceChat_Gamepad:BuildInviteToGuildOption(guildId)
    if not DoesPlayerHaveGuildPermission(guildId, GUILD_PERMISSION_INVITE) then
        return
    end
    local callback = function()
        ZO_TryGuildInvite(guildId, self.socialData.displayName)
    end
    local guildName = GetGuildName(guildId)
    local entry = self:BuildOptionEntry(nil, nil, callback)
    entry.templateData.text = zo_strformat(SI_SOCIAL_MENU_GUILD_INVITE, guildName)
    return entry
end
-- ZO_SocialOptionsDialogGamepad Overrides
function ZO_VoiceChat_Gamepad:SetupOptions(data)
    local channelType = data.channel.channelType
    self.playerAlliance = GetUnitAlliance("player")
    
    local displayName = data.speakerData.displayName
    local alliance = nil
    if channelType == VOICE_CHANNEL_GUILD then
        local guildId = data.channel.guildId
        local memberIndex = GetGuildMemberIndexFromDisplayName(guildId, displayName)
        if memberIndex then
            alliance = select(5, GetGuildMemberCharacterInfo(guildId, memberIndex))
        end
    else
        --Channel is Area or Group, so the alliance for this character must be the same
        alliance = self.playerAlliance
    end
    self.socialData = {
        displayName = displayName,
        alliance = alliance,
        voiceChannelType = channelType,
    }
end
function ZO_VoiceChat_Gamepad:BuildOptionsList(list)
    local channelType = self.socialData.voiceChannelType
    if channelType ~= VOICE_CHANNEL_GROUP then
    end
    if channelType == VOICE_CHANNEL_GUILD then
    elseif channelType == VOICE_CHANNEL_GROUP then
    end
    for i = 1, GetNumGuilds() do
        local guildId = GetGuildId(i)
        self:AddOption(list, self:BuildInviteToGuildOption(guildId))
    end
    local displayName = self.socialData.displayName
    if not IsFriend(displayName) then
    end
end
function ZO_VoiceChat_Gamepad:BuildGamerCardOption()
    local socialData = self.socialData
    local displayName = socialData.displayName
    local callback = function()
        ZO_ShowGamerCardFromDisplayName(displayName)
    end
end
-- XML Calls
     VOICE_CHAT_GAMEPAD = ZO_VoiceChat_Gamepad:New(control)
end