Back to Home

ESO Lua File v101043

common/console/zo_playerconsolerequestsutils.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
--[[Gamercard Utils]]--
local function OnGamerCardInfoRequestReady(wasFound, displayName, consoleId)
    if wasFound then
        local undecoratedName = UndecorateDisplayName(displayName)
        ShowGamerCard(undecoratedName, consoleId)
    else
        ZO_Dialogs_ShowGamepadDialog("GAMERCARD_UNAVAILABLE")
    end
end
function ZO_ShowGamerCardFromCharacterName(characterName)
    PLAYER_CONSOLE_INFO_REQUEST_MANAGER:RequestIdFromCharacterName(characterName, ZO_PLAYER_CONSOLE_INFO_REQUEST_DONT_BLOCK, OnGamerCardInfoRequestReady)
end
function ZO_ShowGamerCardFromDisplayName(displayName)
    PLAYER_CONSOLE_INFO_REQUEST_MANAGER:RequestIdFromDisplayName(displayName, ZO_PLAYER_CONSOLE_INFO_REQUEST_DONT_BLOCK, OnGamerCardInfoRequestReady)
end
function ZO_ShowGamerCardFromDisplayNameOrFallback(displayName, idRequestType, ...)
    PLAYER_CONSOLE_INFO_REQUEST_MANAGER:RequestIdFromDisplayNameOrFallbackType(displayName, ZO_PLAYER_CONSOLE_INFO_REQUEST_DONT_BLOCK, idRequestType, OnGamerCardInfoRequestReady, ...)
end
--[[Friend Request Utils]]--
local function OnConsoleFriendRequestReady(wasInfoFound, displayName, consoleId)
    if wasInfoFound then
        ShowConsoleAddFriendDialog(displayName, consoleId)
    end
end
function ZO_ShowConsoleAddFriendDialog(characterName)
    PLAYER_CONSOLE_INFO_REQUEST_MANAGER:RequestIdFromCharacterName(characterName, ZO_PLAYER_CONSOLE_INFO_REQUEST_DONT_BLOCK, OnConsoleFriendRequestReady)
end
    PLAYER_CONSOLE_INFO_REQUEST_MANAGER:RequestIdFromDisplayName(displayName, ZO_PLAYER_CONSOLE_INFO_REQUEST_DONT_BLOCK, OnConsoleFriendRequestReady)
end
function ZO_ShowConsoleAddFriendDialogFromDisplayNameOrFallback(displayName, idRequestType, ...)
    PLAYER_CONSOLE_INFO_REQUEST_MANAGER:RequestIdFromDisplayNameOrFallbackType(displayName, ZO_PLAYER_CONSOLE_INFO_REQUEST_DONT_BLOCK, idRequestType, OnConsoleFriendRequestReady, ...)
end
--[[Add Ignore Utils]]--
local function OnConsoleIgnoreReady(wasInfoFound, displayName, consoleId)
    if wasInfoFound then
        ShowConsoleIgnoreDialog(displayName, consoleId)
    end
end
function ZO_ShowConsoleIgnoreDialog(displayName)
        PLAYER_CONSOLE_INFO_REQUEST_MANAGER:RequestIdFromDisplayName(displayName, ZO_PLAYER_CONSOLE_INFO_REQUEST_DONT_BLOCK, OnConsoleIgnoreReady)
    end
end
function ZO_ShowConsoleIgnoreDialogFromDisplayNameOrFallback(displayName, idRequestType, ...)
        PLAYER_CONSOLE_INFO_REQUEST_MANAGER:RequestIdFromDisplayNameOrFallbackType(displayName, ZO_PLAYER_CONSOLE_INFO_REQUEST_DONT_BLOCK, idRequestType, OnConsoleIgnoreReady, ...)
    end
end
--[[Add Friend Utils]]--
local function OnUserListDialogIdSelectedForFriendAdd(hasResult, displayName, consoleId)
    if hasResult then
        ShowConsoleAddFriendDialog(displayName, consoleId)
    end
end
    local DONT_INCLUDE_ONLINE_FRIENDS = false
    local DONT_INCLUDE_OFFLINE_FRIENDS = false
    PLAYER_CONSOLE_INFO_REQUEST_MANAGER:RequestIdFromUserListDialog(OnUserListDialogIdSelectedForFriendAdd, GetString(SI_GAMEPAD_CONSOLE_SELECT_FOR_FRIEND_ADD), DONT_INCLUDE_ONLINE_FRIENDS, DONT_INCLUDE_OFFLINE_FRIENDS)
end
    return ZO_IsPlaystationPlatform()
end
--[[Invite to Group Utils]]--
local function OnUserListDialogIdSelectedForGroupInvite(hasResult, displayName, consoleId)
    if hasResult then
        local NOT_SENT_FROM_CHAT = false
        local DISPLAY_INVITED_MESSAGE = true
        TryGroupInviteByName(ZO_FormatManualNameEntry(displayName), NOT_SENT_FROM_CHAT, DISPLAY_INVITED_MESSAGE)
    end
end
    local INCLUDE_ONLINE_FRIENDS = true
    local DONT_INCLUDE_OFFLINE_FRIENDS = false
    PLAYER_CONSOLE_INFO_REQUEST_MANAGER:RequestIdFromUserListDialog(OnUserListDialogIdSelectedForGroupInvite, GetString(SI_GAMEPAD_CONSOLE_SELECT_FOR_INVITE), INCLUDE_ONLINE_FRIENDS, DONT_INCLUDE_OFFLINE_FRIENDS)
end
--[[Invite to Guild Utils]]--
    local function OnUserListDialogIdSelectedForGuildInvite(hasResult, displayName, consoleId)
        if hasResult then
            ZO_TryGuildInvite(guildId, ZO_FormatManualNameEntry(displayName))
        end
    end
    local INCLUDE_ONLINE_FRIENDS = true
    local INCLUDE_OFFLINE_FRIENDS = true
    PLAYER_CONSOLE_INFO_REQUEST_MANAGER:RequestIdFromUserListDialog(OnUserListDialogIdSelectedForGuildInvite, GetString(SI_GAMEPAD_CONSOLE_SELECT_FOR_INVITE), INCLUDE_ONLINE_FRIENDS, INCLUDE_OFFLINE_FRIENDS)
end
--[[Communication Utils]]--
ZO_CONSOLE_CAN_COMMUNICATE_RESULT_SUCCESS = 0
ZO_CONSOLE_CAN_COMMUNICATE_RESULT_NO_SUCH_PLAYER = 1
ZO_CONSOLE_CAN_COMMUNICATE_RESULT_NOT_ALLOWED = 2
ZO_CONSOLE_CAN_COMMUNICATE_RESULT_GLOBALLY_RESTRICTED = 3
ZO_CONSOLE_CAN_COMMUNICATE_ERROR_DIALOG = 1
ZO_CONSOLE_CAN_COMMUNICATE_ERROR_ALERT = 2
local function ReportCommunicationError(errorText, errorType)
    if errorType == ZO_CONSOLE_CAN_COMMUNICATE_ERROR_DIALOG then
        ZO_Dialogs_ShowGamepadDialog("CONSOLE_COMMUNICATION_PERMISSION_ERROR", nil,  { mainTextParams = { errorText } })
    elseif errorType == ZO_CONSOLE_CAN_COMMUNICATE_ERROR_ALERT then
        ZO_Alert(UI_ALERT_CATEGORY_ALERT, nil, errorText)
    end
end
function ZO_ConsoleAttemptInteractOrError(callback, displayName, block, errorType, idRequestType, ...)
    if IsIgnored(DecorateDisplayName(displayName)) then
        ReportCommunicationError(GetString(SI_CONSOLE_COMMUNICATION_PERMISSION_ERROR_NOT_ALLOWED), errorType)
        callback(false)
    else
        callback(true)
    end
end
function ZO_ConsoleAttemptCommunicateOrError(callback, displayName, block, errorType, idRequestType, ...)
        ReportCommunicationError(GetString(SI_CONSOLE_COMMUNICATION_PERMISSION_ERROR_GLOBALLY_RESTRICTED), errorType)
        callback(false)
        return
    end
    ZO_ConsoleAttemptInteractOrError(callback, displayName, block, errorType, idRequestType, ...)
end