Back to Home

ESO Lua File v100030

ingame/crafting/keyboard/craftingutils_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
do
    local KEYBOARD_SMITHING_FILTER_TO_ITEM_SLOT_TEXTURE =
    {
       [SMITHING_FILTER_TYPE_RAW_MATERIALS] = "EsoUI/Art/Crafting/smithing_refine_emptySlot.dds",
       [SMITHING_FILTER_TYPE_WEAPONS] = "EsoUI/Art/Crafting/smithing_weaponSlot.dds",
       [SMITHING_FILTER_TYPE_ARMOR] = "EsoUI/Art/Crafting/smithing_armorSlot.dds",
       [SMITHING_FILTER_TYPE_JEWELRY] = "EsoUI/Art/Crafting/smithing_jewelrySlot.dds",
    }
        return internalassert(KEYBOARD_SMITHING_FILTER_TO_ITEM_SLOT_TEXTURE[smithingFilter], "No slot texture for smithing filter")
    end
    local KEYBOARD_SMITHING_DECONSTRUCTION_TYPE_TO_MULTIPLE_ITEMS_TEXTURE =
    {
       [SMITHING_DECONSTRUCTION_TYPE_RAW_MATERIALS] = "EsoUI/Art/Crafting/smithing_refine_multiple_emptySlot.dds",
       [SMITHING_DECONSTRUCTION_TYPE_WEAPONS_AND_ARMOR] = "EsoUI/Art/Crafting/smithing_multiple_armorWeaponSlot.dds",
       [SMITHING_DECONSTRUCTION_TYPE_ARMOR] = "EsoUI/Art/Crafting/smithing_multiple_armorSlot.dds",
       [SMITHING_DECONSTRUCTION_TYPE_JEWELRY] = "EsoUI/Art/Crafting/smithing_multiple_jewelrySlot.dds",
    }
        return internalassert(KEYBOARD_SMITHING_DECONSTRUCTION_TYPE_TO_MULTIPLE_ITEMS_TEXTURE[deconstructionType], "No multiple items texture for smithing deconstruction type")
    end
end
--[[ Multicraft Spinner ]]--
ZO_MultiCraftSpinner = ZO_Spinner:Subclass()
function ZO_MultiCraftSpinner:New(...)
    return ZO_Spinner.New(self, ...)
end
function ZO_MultiCraftSpinner:Initialize(control)
    -- init will require minMaxButton to be defined so we can safely call UpdateButtons()
    self.minMaxButton = control:GetNamedChild("MinMax")
    ZO_Spinner.Initialize(self, control, 1, 1)
    self.isMax = true
    self.minMaxButton:SetHandler("OnClicked", function()
        if self.isMax then
            self:SetValue(self:GetMax())
        else
            self:SetValue(self:GetMin())
        end
    end)
end
function ZO_MultiCraftSpinner:UpdateButtons()
    ZO_Spinner.UpdateButtons(self)
    local value = self:GetValue()
    if value < self:GetMax() or self:GetMin() >= self:GetMax() then
        self.isMax = true
        self.minMaxButton:SetText(GetString(SI_CRAFTING_QUANTITY_MAX))
    else
        self.isMax = false
        self.minMaxButton:SetText(GetString(SI_CRAFTING_QUANTITY_MIN))
    end
    self.minMaxButton:SetHidden(self.hideButtons)
    self.minMaxButton:SetEnabled(self.enabled and self:GetMin() < self:GetMax())
end
ESO_Dialogs["CRAFTING_CREATE_MULTIPLE_KEYBOARD"] =
{
    canQueue = true,
    title =
    {
        text = SI_CRAFTING_CONFIRM_CREATE_TITLE,
    },
    mainText =
    {
        text = SI_CRAFTING_CONFIRM_CREATE_MULTIPLE_DESCRIPTION,
    },
    buttons =
    {
        [1] =
        {
            text = SI_DIALOG_ACCEPT,
            callback = function(dialog)
                local craftingObject = dialog.data.craftingObject
                local numIterations = dialog.data.numIterations
                craftingObject:Create(numIterations)
            end,
        },
        [2] =
        {
            text = SI_DIALOG_CANCEL,
        },
    },
}
function ZO_KeyboardCraftingUtils_RequestCraftingCreate(craftingObject, numIterations)
    if numIterations <= 1 then
        craftingObject:Create(numIterations)
        return
    end
    local resultItemLink = craftingObject:GetResultItemLink()
    local nameColor = GetItemQualityColor(GetItemLinkQuality(resultItemLink))
    local colorizedItemName = nameColor:Colorize(GetItemLinkName(resultItemLink))
    local itemQuantity = craftingObject:GetMultiCraftNumResults(numIterations)
    ZO_Dialogs_ShowDialog("CRAFTING_CREATE_MULTIPLE_KEYBOARD", { craftingObject = craftingObject, numIterations = numIterations }, { mainTextParams = { colorizedItemName, itemQuantity } })
end