ESO Lua File v100010

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
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_callbacksRegistered = false
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
function ZO_CharacterSelect_GetFormattedLevel(characterData)
    if characterData.veteranRank and characterData.veteranRank > 0 then
        return zo_strformat(SI_CHARACTER_SELECT_VETERAN_RANK_VALUE, characterData.veteranRank)
    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.veteranRank and characterData.veteranRank > 0 then
        return zo_strformat(SI_CHARACTER_SELECT_VETERAN_RANK_CLASS, characterData.veteranRank, className)
    else
        return zo_strformat(SI_CHARACTER_SELECT_LEVEL_CLASS, characterData.level, className)
    end
end
    if characterData.veteranRank and characterData.veteranRank > 0 then
        return zo_strformat(SI_CHARACTER_SELECT_VETERAN_RANK_CLASS, characterData.veteranRank, '')
    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
    g_playerSelectedCharacterId = id
end
do
    local g_bestSelectionPriority = 0
    local g_mostRecentCharId
    local function AddCharacter(i)
        local name, gender, level, veteranRank, class, race, alliance, id, locationId, needsRename = GetCharacterInfo(i)
        -- 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, veteranRank = veteranRank, 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_bestSelectionData = nil
        g_characterDataList = {}
    
        if(numCharacters > 0) then
            for i = 1, numCharacters do
                AddCharacter(i)
            end
        end
    end
end
    defVersionInfo = ""
end
local function OnPregameCharacterListReceived(characterCount, previousCharacterCount)
    if(characterCount > 0) then
        PregameStateManager_SetState("CharacterSelect")
    end
end
    if not g_callbacksRegistered then
        CALLBACK_MANAGER:RegisterCallback("PregameCharacterListReceived", OnPregameCharacterListReceived)
        g_callbacksRegistered = true
    end
end