Back to Home

ESO Lua File v100022

ingame/collections/keyboard/dlcbook_keyboard.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
------------------
--Initialization--
------------------
local DLCBook_Keyboard = ZO_SpecializedCollectionsBook_Keyboard:Subclass()
function DLCBook_Keyboard:New(...)
    return ZO_SpecializedCollectionsBook_Keyboard.New(self, ...)
end
function DLCBook_Keyboard:InitializeControls()
    ZO_SpecializedCollectionsBook_Keyboard.InitializeControls(self)
    local contents = self.control:GetNamedChild("Contents")
    local scrollSection = contents:GetNamedChild("ScrollContainer"):GetNamedChild("ScrollChild")
    self.unlockStatusControl = scrollSection:GetNamedChild("UnlockStatusLabel")
    self.questStatusControl = scrollSection:GetNamedChild("QuestStatusLabel")
    self.questAvailableControl = scrollSection:GetNamedChild("QuestAvailable")
    self.questDescriptionControl = scrollSection:GetNamedChild("QuestDescription")
    local buttons = contents:GetNamedChild("DLCInteractButtons")
    self.questAcceptButton = buttons:GetNamedChild("QuestAccept")
    self.unlockPermanentlyButton = buttons:GetNamedChild("UnlockPermanently")
    self.chapterUpgrade = buttons:GetNamedChild("ChapterUpgrade")
    self.subscribeButton = contents:GetNamedChild("SubscribeButton")
end
---------------
--Interaction--
---------------
do
    local function StorySort(entry1, entry2)
        local category1Data = entry1:GetCategoryData()
        local category2Data = entry2:GetCategoryData()
        if category1Data ~= category2Data then
            local categoryIndex1, subcategoryIndex1 = category1Data:GetCategoryIndicies()
            local categoryIndex2, subcategoryIndex2 = category2Data:GetCategoryIndicies()
            if categoryIndex1 ~= categoryIndex2 then
                return categoryIndex1 < categoryIndex2
            else
                return subcategoryIndex1 < subcategoryIndex2
            end
        elseif entry1:GetSortOrder() ~= entry2:GetSortOrder() then
            return entry1:GetSortOrder() < entry2:GetSortOrder()
        else
            return entry1:GetName() < entry2:GetName()
        end
    end
    function DLCBook_Keyboard:SortCollectibleData(collectibleData)
        table.sort(collectibleData, StorySort)
    end
end
function DLCBook_Keyboard:GetCategorizedLists()
    local collectiblesData = self:GetRelevantCollectibles()
    local categoryMapping = {}
    local lists = {}
    local currentCategoryData
    local currentList
    --We presorted by category above to make this part easier
    for _, data in ipairs(collectiblesData) do
        -- Everything should be put into a subcategory, since we don't handle categories and subcategories elegantly in this scene
        local categoryData = data:GetCategoryData()
        if currentCategoryData ~= categoryData then
            currentCategoryData = categoryData
            currentList = {}
            table.insert(lists, 
            { 
                name = categoryData:GetName(),
                collectibles = currentList,
            })
        end
        table.insert(currentList, data)
    end
    return lists
end
function DLCBook_Keyboard:RefreshDetails()
    ZO_SpecializedCollectionsBook_Keyboard.RefreshDetails(self)
    local collectibleData = self.navigationTree:GetSelectedData()
    if collectibleData then
        self.unlockStatusControl:SetText(GetString("SI_COLLECTIBLEUNLOCKSTATE", collectibleData:GetUnlockState()))
        local isLocked = collectibleData:IsLocked()
        local isActive = collectibleData:IsActive()
        local isNotOwned = not collectibleData:IsOwned()
        local questAcceptLabelStringId = isActive and SI_DLC_BOOK_QUEST_STATUS_ACCEPTED or SI_DLC_BOOK_QUEST_STATUS_NOT_ACCEPTED
        local questName = collectibleData:GetQuestName()
        self.questStatusControl:SetText(zo_strformat(SI_DLC_BOOK_QUEST_STATUS, questName, GetString(questAcceptLabelStringId)))
        local showsQuest = not (isActive or isLocked)
        local questAvailableControl = self.questAvailableControl
        local questDescriptionControl = self.questDescriptionControl
        local canUnlockOnStore = isNotOwned and collectibleData:IsPurchasable()
        local canUnlockWithSubscription = not IsESOPlusSubscriber() and collectibleData:IsUnlockedViaSubscription()
        local canUpgrade = isNotOwned and collectibleData:RequiresEntitlement()
        if showsQuest then
            questAvailableControl:SetText(GetString(SI_COLLECTIONS_QUEST_AVAILABLE))
            questAvailableControl:SetHidden(false)
            
            questDescriptionControl:SetText(collectibleData:GetQuestDescription())
            questDescriptionControl:SetHidden(false)
        elseif isLocked then
            if canUnlockOnStore or canUnlockWithSubscription or canUpgrade then
                local acquireText = canUpgrade and GetString(SI_COLLECTIONS_QUEST_AVAILABLE_WITH_UPGRADE) or GetString(SI_COLLECTIONS_QUEST_AVAILABLE_WITH_UNLOCK)
                questAvailableControl:SetText(acquireText)
                questAvailableControl:SetHidden(false)
            else
                questAvailableControl:SetHidden(true)
            end
            questDescriptionControl:SetHidden(true)
        else
            questAvailableControl:SetHidden(true)
            questDescriptionControl:SetHidden(true)
        end
        local questAcceptButtonStringId = isActive and SI_DLC_BOOK_ACTION_QUEST_ACCEPTED or SI_DLC_BOOK_ACTION_ACCEPT_QUEST
        self.questAcceptButton:SetText(GetString(questAcceptButtonStringId))
        self.questAcceptButton:SetEnabled(not (isLocked or isActive))
        self.unlockPermanentlyButton:SetHidden(not canUnlockOnStore)
        self.subscribeButton:SetHidden(not canUnlockWithSubscription)
        self.chapterUpgrade:SetHidden(not canUpgrade)
    end
end
function DLCBook_Keyboard:UseSelectedDLC()
    local collectibleData = self.navigationTree:GetSelectedData()
    UseCollectible(collectibleData:GetId())
end
function DLCBook_Keyboard:SearchSelectedDLCInStore()
    local collectibleData = self.navigationTree:GetSelectedData()
    local searchTerm = zo_strformat(SI_CROWN_STORE_SEARCH_FORMAT_STRING, collectibleData:GetName())
    ShowMarketAndSearch(searchTerm, MARKET_OPEN_OPERATION_COLLECTIONS_DLC)
end
function DLCBook_Keyboard:OnSceneShown()
    ZO_SpecializedCollectionsBook_Keyboard.OnSceneShown(self)
    if IsESOPlusSubscriber() then
        TriggerTutorial(TUTORIAL_TRIGGER_COLLECTIONS_DLC_OPENED_AS_SUBSCRIBER)
    end
end
----------
--Events--
----------
    DLC_BOOK_KEYBOARD:UseSelectedDLC()
end
    DLC_BOOK_KEYBOARD:SearchSelectedDLCInStore()
end
    ZO_Dialogs_ShowDialog("CONFIRM_OPEN_URL_BY_TYPE", { urlType = APPROVED_URL_ESO_ACCOUNT_SUBSCRIPTION }, { mainTextParams = { GetString(SI_ESO_PLUS_SUBSCRIPTION_LINK_TEXT), GetString(SI_URL_APPLICATION_WEB) } })
end
end
    DLC_BOOK_KEYBOARD = DLCBook_Keyboard:New(control, "dlcBook", COLLECTIBLE_CATEGORY_TYPE_CHAPTER, COLLECTIBLE_CATEGORY_TYPE_DLC)
end