Back to Home

ESO Lua File v100031

ingame/fence/gamepad/fence_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
--[[
---- Lifecycle
--]]
ZO_Fence_Gamepad = ZO_Fence_Base:Subclass()
function ZO_Fence_Gamepad:New(...)
    return ZO_Fence_Base.New(self, ...)
end
function ZO_Fence_Gamepad:Initialize(control)
    self.sceneName = GAMEPAD_STORE_SCENE_NAME
    -- Call base initialize
    ZO_Fence_Base.Initialize(self, control)
    SYSTEMS:RegisterGamepadObject("fence", self)
    local function StateChanged(oldState, newState)
        local mode = STORE_WINDOW_GAMEPAD:GetCurrentMode()
        if newState == SCENE_SHOWN and (mode == ZO_MODE_STORE_LAUNDER or mode == ZO_MODE_STORE_SELL_STOLEN) then
            TriggerTutorial(TUTORIAL_TRIGGER_FENCE_OPENED)
        end
    end
    local storeScene = SCENE_MANAGER:GetScene(GAMEPAD_STORE_SCENE_NAME, SCENE_MANAGER)
    storeScene:RegisterCallback("StateChange", StateChanged)
end
--[[
---- Callbacks
--]]
function ZO_Fence_Gamepad:OnOpened(enableSell, enableLaunder)
    if IsInGamepadPreferredMode() then
        local componentTable = {}
        if enableSell then
            table.insert(componentTable, ZO_MODE_STORE_SELL_STOLEN)
        end
        if enableLaunder then
            table.insert(componentTable, ZO_MODE_STORE_LAUNDER)
        end
        STORE_WINDOW_GAMEPAD:SetActiveComponents(componentTable)
        SCENE_MANAGER:Show(self.sceneName)
    end
end
function ZO_Fence_Gamepad:OnSellSuccess()
    FENCE_SELL_GAMEPAD:OnSuccess()
end
function ZO_Fence_Gamepad:OnLaunderSuccess()
    FENCE_LAUNDER_GAMEPAD:OnSuccess()
end
function ZO_Fence_Gamepad:IsLaundering()
    local currentMode = STORE_WINDOW_GAMEPAD:GetCurrentMode()
    return currentMode == ZO_MODE_STORE_LAUNDER
end
function ZO_Fence_Gamepad:IsSellingStolenItems()
    local currentMode = STORE_WINDOW_GAMEPAD:GetCurrentMode()
    return currentMode == ZO_MODE_STORE_SELL_STOLEN
end
--[[
---- Global
--]]
    FENCE_GAMEPAD = ZO_Fence_Gamepad:New(control)
end