Back to Home

ESO Lua File v101050

pregameandingame/addons/modbrowserdata.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
-----------------------------------------
--- Mod Browser Listing Search Data ---
-----------------------------------------
ZO_ModBrowserListingSearchData = ZO_InitializingObject:Subclass()
function ZO_ModBrowserListingSearchData:Initialize(listingIndex)
    self.listingIndex = listingIndex
end
function ZO_ModBrowserListingSearchData:GetListingIndex()
    return self.listingIndex
end
function ZO_ModBrowserListingSearchData:GetTitle()
    return GetModListingTitle(self.listingIndex)
end
function ZO_ModBrowserListingSearchData:GetAuthor()
    return GetModListingAuthor(self.listingIndex)
end
function ZO_ModBrowserListingSearchData:GetOverview()
    return GetModListingOverview(self.listingIndex)
end
function ZO_ModBrowserListingSearchData:GetDescription()
    return GetModListingDescription(self.listingIndex)
end
function ZO_ModBrowserListingSearchData:GetNumUsers()
    return GetModListingNumUsers(self.listingIndex)
end
function ZO_ModBrowserListingSearchData:GetInstallState()
    return GetModListingInstallState(self.listingIndex)
end
function ZO_ModBrowserListingSearchData:GetInstallStateText()
    return GetString("SI_MODINSTALLSTATE", self:GetInstallState())
end
function ZO_ModBrowserListingSearchData:GetFormattedLastUpdatedTime()
    local lastUpdatedTime = GetModListingLastUpdatedTime(self.listingIndex)
    local year, month, day = GetDateElementsFromTimestamp(lastUpdatedTime)
    return ZO_FormatGregorianDate(year, month, day)
end
function ZO_ModBrowserListingSearchData:GetLatestVersion()
    return GetModListingLatestVersion(self.listingIndex)
end
function ZO_ModBrowserListingSearchData:GetNumReleases()
    return GetNumReleasesForModListing(self.listingIndex)
end
function ZO_ModBrowserListingSearchData:GetReleaseVersion(releaseIndex)
    return GetModListingReleaseVersion(self.listingIndex, releaseIndex)
end
function ZO_ModBrowserListingSearchData:GetFormattedReleaseCreationTime(releaseIndex)
    local creationTime = GetModListingReleaseCreationTime(self.listingIndex, releaseIndex)
    local year, month, day = GetDateElementsFromTimestamp(creationTime)
    return ZO_FormatGregorianDate(year, month, day)
end
function ZO_ModBrowserListingSearchData:IsReleaseNoteReady(releaseIndex)
    return IsModListingReleaseNoteReady(self.listingIndex, releaseIndex)
end
function ZO_ModBrowserListingSearchData:RequestLoadReleaseNote(releaseIndex)
    if not self:IsReleaseNoteReady(releaseIndex) then
        RequestLoadModListingReleaseNote(self.listingIndex, releaseIndex)
    end
end
function ZO_ModBrowserListingSearchData:GetReleaseNote(releaseIndex)
    return GetModListingReleaseNote(self.listingIndex, releaseIndex)
end
function ZO_ModBrowserListingSearchData:GetCategory()
    return GetModListingCategory(self.listingIndex)
end
do
    internalassert(MOD_BROWSER_CATEGORY_TYPE_MAX_VALUE == 25, "A new mod browser category type has been added. It will need to be added to the CATEGORY_TO_ICON table.")
    local CATEGORY_TO_ICON =
    {
        [MOD_BROWSER_CATEGORY_TYPE_LIBRARIES] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_libraries.dds",
        [MOD_BROWSER_CATEGORY_TYPE_MAIL] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_mail.dds",
        [MOD_BROWSER_CATEGORY_TYPE_COMBAT] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_combat.dds",
        [MOD_BROWSER_CATEGORY_TYPE_CHAT] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_chat.dds",
        [MOD_BROWSER_CATEGORY_TYPE_MISC] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_misc.dds",
        [MOD_BROWSER_CATEGORY_TYPE_ABILITY_BAR] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_abilityBar.dds",
        [MOD_BROWSER_CATEGORY_TYPE_GUILD_TRADERS_AND_VENDORS] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_guildTradersAndVendors.dds",
        [MOD_BROWSER_CATEGORY_TYPE_BANK_AND_INVENTORY] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_bankAndInventory.dds",
        [MOD_BROWSER_CATEGORY_TYPE_BUFFS_AND_DEBUFFS] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_buffsAndDebuffs.dds",
        [MOD_BROWSER_CATEGORY_TYPE_CAST_BARS_AND_COOLDOWNS] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_castBarsAndCooldowns.dds",
        [MOD_BROWSER_CATEGORY_TYPE_CHARACTER_PROGRESSION] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_characterProgression.dds",
        [MOD_BROWSER_CATEGORY_TYPE_CRAFTING] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_crafting.dds",
        [MOD_BROWSER_CATEGORY_TYPE_DATA] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_data.dds",
        [MOD_BROWSER_CATEGORY_TYPE_UI_GRAPHICS] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_uiGraphics.dds",
        [MOD_BROWSER_CATEGORY_TYPE_SOCIAL] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_social.dds",
        [MOD_BROWSER_CATEGORY_TYPE_HOUSING] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_housing.dds",
        [MOD_BROWSER_CATEGORY_TYPE_INFO_AND_PLUGIN_BARS] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_infoAndPluginBars.dds",
        [MOD_BROWSER_CATEGORY_TYPE_MAP_AND_COMPASS] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_mapAndCompass.dds",
        [MOD_BROWSER_CATEGORY_TYPE_PVP] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_pvp.dds",
        [MOD_BROWSER_CATEGORY_TYPE_ROLEPLAY] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_roleplay.dds",
        [MOD_BROWSER_CATEGORY_TYPE_TOOLTIP] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_tooltip.dds",
        [MOD_BROWSER_CATEGORY_TYPE_TRIALS] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_trials.dds",
        [MOD_BROWSER_CATEGORY_TYPE_UNIT_FRAMES] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_unitFrames.dds",
        [MOD_BROWSER_CATEGORY_TYPE_UTILITY] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_utility.dds",
        [MOD_BROWSER_CATEGORY_TYPE_BETA] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_beta.dds",
        [MOD_BROWSER_CATEGORY_TYPE_PLUGINS_AND_PATCHES] = "EsoUI/Art/Addons/Gamepad/gp_mod_listing_category_pluginsAndPatches.dds",
    }
    function ZO_ModBrowserListingSearchData:GetCategoryIcon()
        local category = self:GetCategory()
        return CATEGORY_TO_ICON[category]
    end
end
function ZO_ModBrowserListingSearchData:GetNumImages()
    return GetModListingNumImages(self.listingIndex)
end
function ZO_ModBrowserListingSearchData:IsImageReady(imageIndex)
    return IsModListingImageReady(self.listingIndex, imageIndex)
end
do
    local DEFAULT_MOD_BROWSER_IMAGE_DESIRED_WIDTH = 400
    local DEFAULT_MOD_BROWSER_IMAGE_DESIRED_HEIGHT = 400
    function ZO_ModBrowserListingSearchData:RequestLoadImage(imageIndex, desiredWidth, desiredHeight)
        if not self:IsImageReady(imageIndex) then
            local width = desiredWidth or DEFAULT_MOD_BROWSER_IMAGE_DESIRED_WIDTH
            local height = desiredHeight or DEFAULT_MOD_BROWSER_IMAGE_DESIRED_HEIGHT
            RequestLoadModListingImage(self.listingIndex, imageIndex, width, height)
        end
    end
end
function ZO_ModBrowserListingSearchData:GetImage(imageIndex)
    return GetModListingImage(self.listingIndex, imageIndex)
end
function ZO_ModBrowserListingSearchData:GetNumDependencies()
    return GetModListingNumDependencies(self.listingIndex)
end
function ZO_ModBrowserListingSearchData:AreDependenciesReady()
    return AreModListingDependenciesReady(self.listingIndex)
end
function ZO_ModBrowserListingSearchData:RequestLoadDependencies()
    if not self:AreDependenciesReady() then
        RequestLoadModListingDependencies(self.listingIndex)
    end
end
function ZO_ModBrowserListingSearchData:GetDependencyTitle(dependencyIndex)
    return GetModListingDependencyTitle(self.listingIndex, dependencyIndex)
end
function ZO_ModBrowserListingSearchData:GetDependencyInstallState(dependencyIndex)
    return GetModListingDependencyInstallState(self.listingIndex, dependencyIndex)
end
function ZO_ModBrowserListingSearchData:GetFormattedDependencyText()
    local formattedText = ""
    local numDependencies = self:GetNumDependencies()
    if self:AreDependenciesReady() and numDependencies > 0 then
        for dependencyIndex = 1, numDependencies do
            local dependencyName = self:GetDependencyTitle(dependencyIndex)
            local dependencyInstallState = self:GetDependencyInstallState(dependencyIndex)
            local dependencyLine = zo_strformat(SI_GAMEPAD_MOD_BROWSER_DEPENDENCY_FORMATTER, dependencyName, GetString("SI_MODINSTALLSTATE", dependencyInstallState))
            if dependencyInstallState == MOD_INSTALL_STATE_NOT_INSTALLED or dependencyInstallState == MOD_INSTALL_STATE_UNINSTALLING then
                dependencyLine = ZO_ERROR_COLOR:Colorize(dependencyLine)
            elseif dependencyInstallState == MOD_INSTALL_STATE_UPDATE_AVAILABLE then
                dependencyLine = ZO_SUCCEEDED_TEXT:Colorize(dependencyLine)
            end
            if formattedText == "" then
                formattedText = string.format("%s %s", GetString(SI_BULLET), dependencyLine)
            else
                formattedText = string.format("%s\n%s %s", formattedText, GetString(SI_BULLET), dependencyLine)
            end
        end
    end
    return formattedText
end
function ZO_ModBrowserListingSearchData:IsInstalled()
    return self:GetInstallState() == MOD_INSTALL_STATE_INSTALLED or self:GetInstallState() == MOD_INSTALL_STATE_UPDATE_AVAILABLE
end
function ZO_ModBrowserListingSearchData:Install()
    if self:GetInstallState() == MOD_INSTALL_STATE_NOT_INSTALLED or self:GetInstallState() == MOD_INSTALL_STATE_UPDATE_AVAILABLE then
        InstallModListing(self.listingIndex)
    end
end
function ZO_ModBrowserListingSearchData:Uninstall(deleteSavedVariables)
    if self:IsInstalled() then
        UninstallModListing(self.listingIndex, deleteSavedVariables)
    end
end
function ZO_ModBrowserListingSearchData:Reinstall()
    if self:IsInstalled() then
        ReinstallModListing(self.listingIndex)
    end
end
function ZO_ModBrowserListingSearchData:DeleteSavedVariables()
    if self:IsInstalled() then
        DeleteSavedVariablesForModListing(self.listingIndex)
    end
end
function ZO_ModBrowserListingSearchData:GetSavedVariablesDiskUsageMB()
    if self:IsInstalled() then
        return GetSavedVariablesDiskUsageMBForModListing(self.listingIndex)
    else
        return 0
    end
end
function ZO_ModBrowserListingSearchData:SetIgnoreUpdates(ignoreUpdates)
    if self:IsInstalled() then
        SetModListingIgnoresUpdates(self.listingIndex, ignoreUpdates)
    end
end
function ZO_ModBrowserListingSearchData:GetIgnoreUpdates()
    if self:IsInstalled() then
        return GetModListingIgnoresUpdates(self.listingIndex)
    end
    return false
end
function ZO_ModBrowserListingSearchData:Report(reportSource, reportReason, comment)
    return ReportModListing(self.listingIndex, reportSource, reportReason, comment)
end