Back to Home

ESO Lua File v100027

ingame/retrait/keyboard/zo_retraitstation_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
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
local KEYBOARD_RETRAIT_ROOT_SCENE_NAME = "retrait_keyboard_root"
ZO_RetraitStation_Keyboard = ZO_RetraitStation_Base:Subclass()
function ZO_RetraitStation_Keyboard:New(...)
    return ZO_RetraitStation_Base.New(self, ...)
end
function ZO_RetraitStation_Keyboard:Initialize(control)
    ZO_RetraitStation_Base.Initialize(self, control, KEYBOARD_RETRAIT_ROOT_SCENE_NAME)
    self.retraitPanel = ZO_RetraitStation_Retrait_Keyboard:New(self.control:GetNamedChild("RetraitPanel"), self)
    KEYBOARD_RETRAIT_ROOT_SCENE = self.interactScene
    local fragment = ZO_FadeSceneFragment:New(control)
    self.interactScene:AddFragment(fragment)
    SYSTEMS:RegisterKeyboardRootScene("retrait", self.interactScene)
    SYSTEMS:RegisterKeyboardObject("retrait", self)
end
function ZO_RetraitStation_Keyboard:OnInteractSceneShowing()
    KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor)
end
function ZO_RetraitStation_Keyboard:OnInteractSceneHiding()
    KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
    CRAFTING_RESULTS:SetCraftingTooltip(nil)
end
function ZO_RetraitStation_Keyboard:OnInteractSceneHidden()
    -- this needs to be called on hidden or else the inventory will
    -- attempt a full refresh instead of flagging itself as dirty
    self.retraitPanel:RemoveItemFromRetrait()
end
function ZO_RetraitStation_Keyboard:InitializeKeybindStripDescriptors()
    self.keybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_CENTER,
        -- Clear selections
        {
            name = GetString(SI_CRAFTING_CLEAR_SELECTIONS),
            keybind = "UI_SHORTCUT_NEGATIVE",
            callback = function()
                if self.mode == ZO_RETRAIT_MODE_RETRAIT then
                    self.retraitPanel:SetRetraitSlotItem()
                end
            end,
            visible = function()
                if not ZO_CraftingUtils_IsPerformingCraftProcess() then
                    if self.mode == ZO_RETRAIT_MODE_RETRAIT then
                        return self.retraitPanel:HasItemSlotted()
                    end
                end
                return false
            end,
        },
        -- Perform craft
        {
            name = function()
                if self.mode == ZO_RETRAIT_MODE_RETRAIT then
                    return GetString(SI_RETRAIT_STATION_PERFORM_RETRAIT)
                end
            end,
            keybind = "UI_SHORTCUT_SECONDARY",
            callback = function()
                if self.mode == ZO_RETRAIT_MODE_RETRAIT then
                    self.retraitPanel:PerformRetrait()
                end
            end,
            enabled = function()
                if not ZO_CraftingUtils_IsPerformingCraftProcess() then
                    if self.mode == ZO_RETRAIT_MODE_RETRAIT then
                        return self.retraitPanel:HasValidSelections()
                    end
                end
                return false
            end,
            visible = function()
                if not ZO_CraftingUtils_IsPerformingCraftProcess() then
                    if self.mode == ZO_RETRAIT_MODE_RETRAIT then
                        return self.retraitPanel:HasItemSlotted()
                    end
                end
                return false
            end,
        },
    }
end
function ZO_RetraitStation_Keyboard:InitializeModeBar()
    self.modeBar = self.control:GetNamedChild("ModeMenuBar")
    self.modeBarLabel = self.modeBar:GetNamedChild("Label")
    local function CreateModeData(name, mode, normal, pressed, highlight, disabled)
        return {
            categoryName = name,
            descriptor = mode,
            normal = normal,
            pressed = pressed,
            highlight = highlight,
            disabled = disabled,
            callback = function(tabData)
                self.modeBarLabel:SetText(GetString(name))
                self:SetMode(mode)
            end,
        }
    end
    self.retraitTab = CreateModeData(SI_RETRAIT_STATION_RETRAIT_MODE, ZO_RETRAIT_MODE_RETRAIT, "EsoUI/Art/Crafting/retrait_tabIcon_up.dds", "EsoUI/Art/Crafting/retrait_tabIcon_down.dds", "EsoUI/Art/Crafting/retrait_tabIcon_over.dds", "EsoUI/Art/Crafting/retrait_tabIcon_disabled.dds")
    ZO_MenuBar_AddButton(self.modeBar, self.retraitTab)
    ZO_MenuBar_SelectDescriptor(self.modeBar, ZO_RETRAIT_MODE_RETRAIT)
end
function ZO_RetraitStation_Keyboard:UpdateKeybinds()
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
end
function ZO_RetraitStation_Keyboard:OnItemReceiveDrag(slotControl, bagId, slotIndex)
    if self.mode == ZO_RETRAIT_MODE_RETRAIT then
        self.retraitPanel:OnItemReceiveDrag(slotControl, bagId, slotIndex)
    end
end
function ZO_RetraitStation_Keyboard:SetMode(mode)
    if self.mode ~= mode then
        self.mode = mode
        CRAFTING_RESULTS:SetCraftingTooltip(nil)
        self:UpdateKeybinds()
        self.retraitPanel:SetHidden(mode ~= ZO_RETRAIT_MODE_RETRAIT)
    end
end
function ZO_RetraitStation_Keyboard:IsItemAlreadySlottedToCraft(bag, slot)
    if self.mode == ZO_RETRAIT_MODE_RETRAIT then
        return self.retraitPanel:IsItemAlreadySlottedToCraft(bag, slot)
    end
    return false
end
function ZO_RetraitStation_Keyboard:CanItemBeAddedToCraft(bag, slot)
    if self.mode == ZO_RETRAIT_MODE_RETRAIT then
        return self.retraitPanel:CanItemBeAddedToCraft(bag, slot)
    end
    return false
end
function ZO_RetraitStation_Keyboard:AddItemToCraft(bag, slot)
    if self.mode == ZO_RETRAIT_MODE_RETRAIT then
        self.retraitPanel:AddItemToCraft(bag, slot)
    end
end
function ZO_RetraitStation_Keyboard:RemoveItemFromCraft(bag, slot)
    if self.mode == ZO_RETRAIT_MODE_RETRAIT then
        self.retraitPanel:RemoveItemFromCraft(bag, slot)
    end
end
function ZO_RetraitStation_Keyboard:OnItemReceiveDrag(inventorySlot, bagId, slotIndex)
     if self.mode == ZO_RETRAIT_MODE_RETRAIT then
        self.retraitPanel:OnItemReceiveDrag(inventorySlot, bagId, slotIndex)
    end
end
function ZO_RetraitStation_Keyboard:OnRetraitResult(result)
    if self.mode == ZO_RETRAIT_MODE_RETRAIT then
        self.retraitPanel:OnRetraitResult(result)
    end
end
function ZO_RetraitStation_Keyboard:HandleDirtyEvent()
    self.retraitPanel:HandleDirtyEvent()
end
function ZO_RetraitStation_Keyboard:GetRetraitObject()
    return self.retraitPanel
end
-- Global XML functions
    ZO_RETRAIT_STATION_KEYBOARD = ZO_RetraitStation_Keyboard:New(control)
end