Back to Home

ESO Lua File v100032

ingame/retrait/gamepad/zo_retraitstation_gamepad.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
------
-- ZO_RetraitStation_Gamepad
------
local GAMEPAD_RETRAIT_ROOT_SCENE_NAME = "retrait_gamepad_root"
local GAMEPAD_RETRAIT_SCENE_NAME = "retrait_gamepad"
local MODE_TO_SCENE_NAME =
{
    [ZO_RETRAIT_MODE_ROOT] = GAMEPAD_RETRAIT_ROOT_SCENE_NAME,
    [ZO_RETRAIT_MODE_RETRAIT] = GAMEPAD_RETRAIT_SCENE_NAME,
}
ZO_RetraitStation_Gamepad = ZO_RetraitStation_Base:Subclass()
function ZO_RetraitStation_Gamepad:New(...)
    return ZO_RetraitStation_Base.New(self, ...)
end
function ZO_RetraitStation_Gamepad:Initialize(control)
    ZO_RetraitStation_Base.Initialize(self, control, GAMEPAD_RETRAIT_ROOT_SCENE_NAME)
    ZO_GamepadCraftingUtils_InitializeGenericHeader(self, ZO_GAMEPAD_HEADER_TABBAR_DONT_CREATE)
    GAMEPAD_RETRAIT_ROOT_SCENE = self.interactScene
    local fragment = ZO_FadeSceneFragment:New(control)
    self.interactScene:AddFragment(fragment)
    SYSTEMS:RegisterGamepadRootScene("retrait", self.interactScene)
    SYSTEMS:RegisterGamepadObject("retrait", self)
    GAMEPAD_RETRAIT_SCENE = ZO_InteractScene:New(GAMEPAD_RETRAIT_SCENE_NAME, SCENE_MANAGER, self.retraitStationInteraction)
    GAMEPAD_RETRAIT_SCENE:SetInputPreferredMode(INPUT_PREFERRED_MODE_ALWAYS_GAMEPAD)
    local gamepadRetraitModeTopLevel = CreateControlFromVirtual("ZO_RetraitStation_RetraitMode_Gamepad", GuiRoot, "ZO_RetraitStation_Retrait_GamepadTopLevel")
    ZO_RETRAIT_STATION_RETRAIT_GAMEPAD = ZO_RetraitStation_Retrait_Gamepad:New(gamepadRetraitModeTopLevel, GAMEPAD_RETRAIT_SCENE)
    ZO_RETRAIT_STATION_MANAGER:RegisterRetraitScene(GAMEPAD_RETRAIT_SCENE_NAME)
end
function ZO_RetraitStation_Gamepad:OnInteractSceneShowing()
     KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor)
    self.modeList:Activate()
    ZO_GamepadCraftingUtils_SetupGenericHeader(self, GetString(SI_RETRAIT_STATION_HEADER))
    self:ResetMode()
end
function ZO_RetraitStation_Gamepad:OnInteractSceneHiding()
    KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
    self.modeList:Deactivate()
end
function ZO_RetraitStation_Gamepad:InitializeKeybindStripDescriptors()
    self.keybindStripDescriptor =
    {
        -- Select mode.
        {
            keybind = "UI_SHORTCUT_PRIMARY",
            alignment = KEYBIND_STRIP_ALIGN_LEFT,
            name = function()
                return GetString(SI_GAMEPAD_SELECT_OPTION)
            end,
            callback = function()
                local targetData = self.modeList:GetTargetData()
                self:SetMode(targetData.mode)
            end,
        },
    }
    ZO_Gamepad_AddBackNavigationKeybindDescriptors(self.keybindStripDescriptor, GAME_NAVIGATION_TYPE_BUTTON)
    ZO_Gamepad_AddListTriggerKeybindDescriptors(self.keybindStripDescriptor, self.modeList)
end
function ZO_RetraitStation_Gamepad:CreateModeEntry(name, mode, icon)
    local data = ZO_GamepadEntryData:New(GetString(name), icon)
    data.mode = mode
    return data
end
function ZO_RetraitStation_Gamepad:InitializeModeList()
    self.modeList = ZO_GamepadVerticalItemParametricScrollList:New(self.control:GetNamedChild("MaskContainerList"))
    self.modeList:SetAlignToScreenCenter(true)
    local retraitModeEntry = self:CreateModeEntry(SI_RETRAIT_STATION_RETRAIT_MODE, ZO_RETRAIT_MODE_RETRAIT, "EsoUI/Art/Crafting/Gamepad/gp_retrait_tabIcon.dds")
    self.modeList:AddEntry("ZO_GamepadItemEntryTemplate", retraitModeEntry)
    self.modeList:Commit()
end
function ZO_RetraitStation_Gamepad:ResetMode()
    self.mode = ZO_RETRAIT_MODE_ROOT
end
function ZO_RetraitStation_Gamepad:SetMode(mode)
    if self.mode ~= mode then
        self.mode = mode
        SCENE_MANAGER:Push(MODE_TO_SCENE_NAME[mode])
        KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
    end
end
function ZO_RetraitStation_Gamepad:IsItemAlreadySlottedToCraft(bag, slot)
    if self.mode == ZO_RETRAIT_MODE_RETRAIT then
        return ZO_RETRAIT_STATION_RETRAIT_GAMEPAD:IsItemAlreadySlottedToCraft(bag, slot)
    end
    return false
end
function ZO_RetraitStation_Gamepad:CanItemBeAddedToCraft(bag, slot)
    if self.mode == ZO_RETRAIT_MODE_RETRAIT then
        return ZO_RETRAIT_STATION_RETRAIT_GAMEPAD:CanItemBeAddedToCraft(bag, slot)
    end
    return false
end
function ZO_RetraitStation_Gamepad:AddItemToCraft(bag, slot)
    if self.mode == ZO_RETRAIT_MODE_RETRAIT then
        ZO_RETRAIT_STATION_RETRAIT_GAMEPAD:AddItemToCraft(bag, slot)
    end
end
function ZO_RetraitStation_Gamepad:RemoveItemFromCraft(bag, slot)
    if self.mode == ZO_RETRAIT_MODE_RETRAIT then
        ZO_RETRAIT_STATION_RETRAIT_GAMEPAD:RemoveItemFromCraft(bag, slot)
    end
end
function ZO_RetraitStation_Gamepad:OnRetraitResult(result)
    if self.mode == ZO_RETRAIT_MODE_RETRAIT then
        ZO_RETRAIT_STATION_RETRAIT_GAMEPAD:OnRetraitResult(result)
    end
end
function ZO_RetraitStation_Gamepad:HandleDirtyEvent()
    ZO_RETRAIT_STATION_RETRAIT_GAMEPAD:HandleDirtyEvent()
end
-- Global XML functions
    ZO_RETRAIT_STATION_GAMEPAD = ZO_RetraitStation_Gamepad:New(control)
end