Back to Home

ESO Lua File v100034

ingame/retrait/retraitstation_reconstruct_dialogs.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
-- Keyboard Dialogs
    local function SetupCostLineItem(control, icon, name, quantity)
        local nameLabel = control:GetNamedChild("NameLabel")
        nameLabel:SetText(name)
        local iconTexture = control:GetNamedChild("IconTexture")
        iconTexture:SetTexture(icon)
        local quantityLabel = iconTexture:GetNamedChild("QuantityLabel")
        quantityLabel:SetText(quantity)
        control:SetHidden(false)
    end
    local function SetupDialog(dialog, itemSetPieceData)
        local currencyOptions, materialCosts = itemSetPieceData:GetCostInfo()
        -- Item description
        local itemTexture = dialog:GetNamedChild("ItemTexture")
        itemTexture:SetTexture(itemSetPieceData:GetIcon())
        local itemLabel = dialog:GetNamedChild("ItemLabel")
        itemLabel:SetText(itemSetPieceData:GetItemLink())
        -- Currency cost
        local currencyOption = currencyOptions[1]
        local costContainer = dialog:GetNamedChild("CostContainer")
        local lineItemContainer = costContainer:GetNamedChild("LineItemContainer")
        local currencyCostLineItem = lineItemContainer:GetNamedChild("CurrencyCostLineItem")
        SetupCostLineItem(currencyCostLineItem, currencyOption.currencyIcon, currencyOption.currencyName, currencyOption.currencyRequired)
        -- Material cost
        for upgradeIndex = 1, GetNumSmithingImprovementItems() do
            local costLineItem = lineItemContainer:GetNamedChild(string.format("CostLineItem%d", upgradeIndex))
            local materialCost = materialCosts[upgradeIndex]
            if materialCost then
                SetupCostLineItem(costLineItem, materialCost.reagentIcon, materialCost.reagentItemLink, materialCost.reagentsRequired)
                costLineItem:SetHidden(false)
            else
                costLineItem:SetHidden(true)
            end
        end
    end
    -- Dialog registration
    ZO_Dialogs_RegisterCustomDialog("CONFIRM_ITEM_RECONSTRUCTION",
    {
        customControl = control,
        setup = SetupDialog,
        title =
        {
            text = SI_RETRAIT_STATION_CONFIRM_ITEM_RECONSTRUCTION_TITLE,
        },
        buttons =
        {
            -- Confirm Button
            {
                control = control:GetNamedChild("Confirm"),
                keybind = "DIALOG_PRIMARY",
                text = GetString(SI_RETRAIT_STATION_RECONSTRUCT_ACTION),
                callback = function(dialog)
                    ZO_RECONSTRUCT_KEYBOARD:RequestReconstruction()
                end,
            },
            -- Cancel Button
            {
                control = control:GetNamedChild("Cancel"),
                keybind = "DIALOG_NEGATIVE",
                text = GetString(SI_DIALOG_CANCEL),
            },
        },
    })
end
-- Gamepad Dialogs
    local container = control:GetNamedChild("ContainerScrollChild")
    local summaryDescriptionLabel = container:GetNamedChild("SummaryDescriptionLabel")
    local itemName = control:GetNamedChild("ItemLabel")
    local itemIcon = control:GetNamedChild("ItemIcon")
    local costLinePool = ZO_ControlPool:New("ZO_GamepadDisplayEntryTemplateLowercase34", container)
    local function SetupCostLineControl(costLineControl)
        costLineControl.nameLabel = costLineControl:GetNamedChild("Label")
        -- Order matters:
        costLineControl.iconTexture = costLineControl:GetNamedChild("Icon")
        costLineControl.stackCountLabel = costLineControl.iconTexture:GetNamedChild("StackCount")
    end
    ZO_Dialogs_RegisterCustomDialog("GAMEPAD_CONFIRM_ITEM_RECONSTRUCTION",
    {
        canQueue = true,
        customControl = control,
        setup = function(dialog)
            local data = dialog.data
            local itemSetPieceData = data.itemSetPieceData
            itemName:SetText(itemSetPieceData:GetItemLink())
            itemIcon:SetTexture(itemSetPieceData:GetIcon())
            costLinePool:ReleaseAllObjects()
            local previousControl
            local currencyCosts, materialCosts = itemSetPieceData:GetCostInfo()
            local currencyCost = currencyCosts[1]
            if currencyCost then
                local costLine = costLinePool:AcquireObject()
                costLine.stackCountLabel:SetText(currencyCost.currencyRequired)
                costLine.iconTexture:SetTexture(currencyCost.currencyIcon)
                costLine.nameLabel:SetText(currencyCost.currencyName)
                costLine:ClearAnchors()
                costLine:SetAnchor(TOPLEFT, summaryDescriptionLabel, BOTTOMLEFT, 0, 20)
                previousControl = costLine
            end
            for index, materialCost in ipairs(materialCosts) do
                local costLine = costLinePool:AcquireObject()
                costLine.stackCountLabel:SetText(materialCost.reagentsRequired)
                costLine.iconTexture:SetTexture(materialCost.reagentIcon)
                costLine.nameLabel:SetText(materialCost.reagentItemLink)
                costLine:ClearAnchors()
                if previousControl then
                    costLine:SetAnchor(TOPLEFT, previousControl, BOTTOMLEFT)
                else
                    costLine:SetAnchor(TOPLEFT, summaryDescriptionLabel, BOTTOMLEFT, 0, 20)
                end
                previousControl = costLine
            end
            local NO_ENTRY_LIMIT = nil
            dialog:setupFunc(NO_ENTRY_LIMIT, data)
        end,
        gamepadInfo =
        {
            dialogType = GAMEPAD_DIALOGS.CUSTOM,
        },
        title =
        {
            text = SI_RETRAIT_STATION_CONFIRM_ITEM_RECONSTRUCTION_HEADER,
        },
        mainText = 
        {
            text = "",
        },
        buttons =
        {
            -- Reconstruct Button
            {
                keybind = "DIALOG_PRIMARY",
                text = SI_RETRAIT_STATION_RECONSTRUCT_ACTION,
                callback = function(dialog)
                    ZO_RETRAIT_STATION_RECONSTRUCT_GAMEPAD:RequestReconstruction()
                end,
            },
            -- Back
            {
                keybind = "DIALOG_NEGATIVE",
                text = SI_DIALOG_CANCEL,
            },
        },
    })
end