Back to Home

ESO Lua File v100018

pregame/characterselect/zo_characterselect_common.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
local PRIORITY_DEFAULT = 1
local PRIORITY_MOST_RECENT_CHARACTER = 2
local PRIORITY_PLAYER_CHOSEN = 3
local g_characterDataList = {}
local g_bestSelectionData = nil
local g_bestSelectionIndex = nil
local g_accountChampionPoints = 0
local g_playerSelectedCharacterId
    return g_characterDataList
end
    for _, dataEntry in ipairs(g_characterDataList) do
        if(AreId64sEqual(dataEntry.id, charId)) then
            return dataEntry
        end
    end
end
do
    local iconString = IsInGamepadPreferredMode() and "EsoUI/Art/Champion/Gamepad/gp_champion_icon.dds" or "EsoUI/Art/Champion/champion_icon.dds"
    local CHAMPION_FORMATTED_ICON = zo_iconFormat(iconString, "100%", "100%")
    function ZO_CharacterSelect_GetFormattedLevel(characterData)
        if characterData.championPoints and characterData.championPoints > 0 then
            return zo_strformat(SI_CHARACTER_SELECT_LEVEL_CHAMPION, characterData.level, CHAMPION_FORMATTED_ICON)
        else
            return zo_strformat(SI_CHARACTER_SELECT_LEVEL_VALUE, characterData.level)
        end
    end
        local className = characterData.class and GetClassName(characterData.gender, characterData.class) or GetString(SI_UNKNOWN_CLASS)
        if characterData.championPoints and characterData.championPoints > 0 then
            return zo_strformat(SI_CHARACTER_SELECT_LEVEL_CHAMPION_CLASS, characterData.level, CHAMPION_FORMATTED_ICON, className)
        else
            return zo_strformat(SI_CHARACTER_SELECT_LEVEL_CLASS, characterData.level, className)
        end
    end
end
    return zo_strformat(SI_CHARACTER_SELECT_NAME, characterData.name)
end
    if characterData.championPoints and characterData.championPoints > 0 then
        return zo_strformat(SI_CHARACTER_SELECT_CHAMPION_CLASS, characterData.championPoints, '')
    else
        return zo_strformat(SI_CHARACTER_SELECT_LEVEL_CLASS, characterData.level, '')
    end
end
    local raceName = characterData.race and GetRaceName(characterData.gender, characterData.race) or GetString(SI_UNKNOWN_RACE)
    local className = characterData.class and GetClassName(characterData.gender, characterData.class) or GetString(SI_UNKNOWN_CLASS)
    local locationName = characterData.location ~= 0 and GetLocationName(characterData.location) or GetString(SI_UNKNOWN_LOCATION)
    return zo_strformat(SI_CHARACTER_SELECT_RACE_CLASS_LOCATION, raceName, className, locationName)
end
    return g_bestSelectionData
end
    return g_bestSelectionIndex
end
    return g_accountChampionPoints
end
    g_playerSelectedCharacterId = id
end
do
    local g_bestSelectionPriority = 0
    local g_mostRecentCharId
    local function AddCharacter(i)
        local name, gender, level, championPoints, class, race, alliance, id, locationId, needsRename = GetCharacterInfo(i)
        -- if one character has champion points, than the account has champion points
        -- also make sure that the account never loses champion points between characters
        if championPoints > 0  and g_accountChampionPoints < championPoints then
            g_accountChampionPoints = championPoints
        end
        -- Because of the way the messaging works, ensure this character doesn't already exist in the table.
        local characterData = ZO_CharacterSelect_GetDataForCharacterId(id)
        if(characterData == nil) then
            characterData = { name = name, gender = gender, level = level, championPoints = championPoints, class = class, race = race, alliance = alliance, id = id, location = locationId, needsRename = needsRename, index = #g_characterDataList + 1 }
            table.insert(g_characterDataList, characterData)
            if(g_bestSelectionPriority < PRIORITY_DEFAULT) then
                g_bestSelectionPriority = PRIORITY_DEFAULT
                g_bestSelectionData = characterData
                g_bestSelectionIndex = i
            end
            if(AreId64sEqual(g_playerSelectedCharacterId, id)) then
                g_bestSelectionPriority = PRIORITY_PLAYER_CHOSEN
                g_bestSelectionData = characterData
                g_bestSelectionIndex = i
            end
            if(AreId64sEqual(g_mostRecentCharId, id)) then
                if(g_bestSelectionPriority < PRIORITY_MOST_RECENT_CHARACTER) then
                    g_bestSelectionPriority = PRIORITY_MOST_RECENT_CHARACTER
                    g_bestSelectionData = characterData
                    g_bestSelectionIndex = i
                end
            end
        end
    end
    function ZO_CharacterSelect_OnCharacterListReceivedCommon(eventCode, numCharacters, maxCharacters, mostRecentlyPlayedCharacterId, numCharacterDeletesRemaining, maxCharacterDeletes)
        g_mostRecentCharId = mostRecentlyPlayedCharacterId
        g_bestSelectionPriority = 0
        g_accountChampionPoints = 0
        g_bestSelectionData = nil
        g_characterDataList = {}
    
        if(numCharacters > 0) then
            for i = 1, numCharacters do
                AddCharacter(i)
            end
        end
    end
end
    defVersionInfo = ""
end
    local currentUsedSlots = GetNumCharacters()
    local ownedCharacterSlots = GetNumOwnedCharacterSlots()
    return ownedCharacterSlots <= currentUsedSlots and ZO_CharacterSelect_GetAdditionalSlotsRemaining() > 0
end
    local ownedCharacterSlots = GetNumOwnedCharacterSlots()
    local maxSlotsAvailable = GetNumMaxCharacterSlotsAvailable()
    return maxSlotsAvailable - ownedCharacterSlots
end
function ZO_CharacterSelect_OnCharacterRenamedCommon(eventCode, characterId, result, requestedName, successCallback, errorCallback)
    ZO_Dialogs_ReleaseAllDialogsOfName("CHARACTER_SELECT_CHARACTER_RENAMING")
    if result == NAME_RULE_NO_ERROR then
        ZO_Dialogs_ShowPlatformDialog("CHARACTER_SELECT_RENAME_CHARACTER_SUCCESS", { callback = successCallback }, { mainTextParams = {requestedName}})
    else
        local titleText
        local errorMessageText
        if result == NAME_RULE_DUPLICATE_NAME then
            titleText = SI_RENAME_CHARACTER_NAME_IN_USE_ERROR_HEADER
            errorMessageText = zo_strformat(SI_RENAME_CHARACTER_NAME_IN_USE_ERROR_BODY, requestedName)
        else
            titleText = SI_RENAME_CHARACTER_GENERIC_ERROR_HEADER
            errorMessageText = GetString("SI_NAMINGERROR", result)
        end
        local dialogParams = {
            titleParams = { GetString(titleText) },
            mainTextParams = { errorMessageText },
        }
        ZO_Dialogs_ShowPlatformDialog("CHARACTER_SELECT_RENAME_CHARACTER_ERROR", { callback = errorCallback }, dialogParams)
    end
end
    if ZO_RZCHROMA_EFFECTS then
        local characterData = g_characterDataList[index]
        ZO_RZCHROMA_EFFECTS:SetAlliance(characterData.alliance)
    end
end