Back to Home

ESO Lua File v100032

ingame/inventory/keyboard/itemtransferdialog_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
local ItemTransferDialog_Keyboard = ZO_ItemTransferDialog_Base:Subclass()
function ItemTransferDialog_Keyboard:New(...)
    return ZO_ItemTransferDialog_Base.New(self, ...)
end
function ItemTransferDialog_Keyboard:Initialize(control)
    ZO_ItemTransferDialog_Base.Initialize(self)
    self.dialogControl = control
    local spinnerControl = control:GetNamedChild("Spinner")
    self.spinner = ZO_Spinner:New(spinnerControl, 1, function() return self:GetTransferMaximum() end)
    self.slotControl = control:GetNamedChild("Slot")
    self.iconControl = control:GetNamedChild("SlotIcon")
    self.quantityControl = control:GetNamedChild("SlotStackCount")
    local setupFunc = function(dialog, data)
                          self:Refresh()
                      end
    local callbackFunc = function(dialog)
                            local quantity = self:GetSpinnerValue()
                            self:Transfer(quantity)
                        end
    ZO_Dialogs_RegisterCustomDialog("ITEM_TRANSFER_ADD_TO_CRAFT_BAG_KEYBOARD",
    {
        canQueue = true,
        customControl = control,
        setup = setupFunc,
        title =
        {
            text = SI_PROMPT_TITLE_ADD_ITEMS_TO_CRAFT_BAG,
        },
        buttons =
        {
            {
                control = control:GetNamedChild("Transfer"),
                text =  SI_ITEM_ACTION_ADD_ITEMS_TO_CRAFT_BAG,
                callback = callbackFunc,
            },
            {
                control =   control:GetNamedChild("Cancel"),
                text =      SI_DIALOG_CANCEL,
            }
        }
    })
    ZO_Dialogs_RegisterCustomDialog("ITEM_TRANSFER_REMOVE_FROM_CRAFT_BAG_KEYBOARD",
    {
        customControl = control,
        setup = setupFunc,
        title =
        {
            text = SI_PROMPT_TITLE_REMOVE_ITEMS_FROM_CRAFT_BAG 
        },
        buttons =
        {
            {
                control = control:GetNamedChild("Transfer"),
                text =  SI_ITEM_ACTION_REMOVE_ITEMS_FROM_CRAFT_BAG,
                callback = callbackFunc,
            },
            {
                control =   control:GetNamedChild("Cancel"),
                text =      SI_DIALOG_CANCEL,
            }
        }
    })
end
function ItemTransferDialog_Keyboard:ShowDialog()
    local maxStack = self:GetTransferMaximum()
    self.spinner:SetValue(maxStack, true)
    if self.targetBag == BAG_VIRTUAL then
        ZO_Dialogs_ShowDialog("ITEM_TRANSFER_ADD_TO_CRAFT_BAG_KEYBOARD")
    else
        ZO_Dialogs_ShowDialog("ITEM_TRANSFER_REMOVE_FROM_CRAFT_BAG_KEYBOARD")
    end
    
end
function ItemTransferDialog_Keyboard:Refresh()
    local icon, stackCount, sellPrice, meetsUsageRequirement, locked = GetItemInfo(self.bag, self.slotIndex)
    ZO_Inventory_BindSlot(self.slotControl, SLOT_TYPE_STACK_SPLIT, self.slotIndex, self.bag)
    self.iconControl:SetTexture(icon)
    local USE_LOWERCASE_NUMBER_SUFFIXES = false
    self.quantityControl:SetText(zo_strformat(SI_NUMBER_FORMAT, ZO_AbbreviateNumber(stackCount, NUMBER_ABBREVIATION_PRECISION_TENTHS, USE_LOWERCASE_NUMBER_SUFFIXES)))
    self.quantityControl:SetHidden(stackCount <= 1)
    ZO_ItemSlot_SetupUsableAndLockedColor(self.slotControl, meetsUsageRequirement, locked)
end
function ItemTransferDialog_Keyboard:GetSpinnerValue()
    return self.spinner:GetValue()
end
-------------------
-- Global functions
-------------------
function ZO_ItemTransferDialog_OpenTransferDialog(bag, slotIndex, targetBag)
    ITEM_TRANSFER_DIALOG:Show(bag, slotIndex, targetBag)
end
    local dialog = ItemTransferDialog_Keyboard:New(control)
    SYSTEMS:RegisterKeyboardObject("ItemTransferDialog", dialog)
end