ESO Lua File v100010

ingame/stable/gamepad/sellmount_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
ZO_SellMount = ZO_Object:Subclass()
function ZO_SellMount:New(...)
    local sellMount = ZO_Object.New(self)
    sellMount:Initialize(...)
    return sellMount
end
function ZO_SellMount:Initialize(control)
    self.control = control
    control.owner = self
     SELL_MOUNT_GAMEPAD_FRAGMENT = ZO_FadeSceneFragment:New(self.control)
    SELL_MOUNT_GAMEPAD_FRAGMENT.alwaysAnimate = true
     SELL_MOUNT_GAMEPAD_FRAGMENT:RegisterCallback("StateChange", function(oldState, newState)
        if newState == SCENE_SHOWING then
            STABLE_HEADER.tooltip:ClearLines()
            STABLE_HEADER.tooltipContainer:SetHidden(true)
        end
          ZO_Stables_BuySellStateChangeCallback_Gamepad(self, oldState, newState)
     end)
end
function ZO_SellMount:InitializeKeybindStripDescriptors()
    self.keybindStripDescriptor = {}
     local function ConfirmSell()
          local selectedData = self.itemList:GetSelectedData()
          ZO_Dialogs_ShowDialog("CONFIRM_SELL_MOUNT", { stableIndex = selectedData.stableIndex}, {mainTextParams = { GetStableSlotInfo(selectedData.stableIndex) }} )
     end
     ZO_Gamepad_AddForwardNavigationKeybindDescriptors(self.keybindStripDescriptor, 
                                                                      GAME_NAVIGATION_TYPE_BUTTON,
                                                                      ConfirmSell,
                                                                      GetString(SI_GAMEPAD_STABLE_SELL_MOUNT),
                                                                      function() return self.canSell end
                                                                 )
     ZO_Gamepad_AddBackNavigationKeybindDescriptors(self.keybindStripDescriptor, GAME_NAVIGATION_TYPE_BUTTON)
end
function ZO_SellMount:InitializeEvents()
    local function RefreshAll()
        if not self.control:IsControlHidden() then
            self:RefreshAll()
        end
    end
    self.control:RegisterForEvent(EVENT_MONEY_UPDATE, RefreshAll)
    self.control:RegisterForEvent(EVENT_MOUNT_UPDATE, RefreshAll)
    self.control:RegisterForEvent(EVENT_MOUNTS_FULL_UPDATE, RefreshAll)
end
function ZO_SellMount:RefreshAll()
     self:UpdateList()
end
function ZO_SellMount:UpdateList()
     self.itemList:Clear()
     local isNextEntryAHeader = false
    local hasMount = false
     for i = ACTIVE_MOUNT_INDEX, GetNumStableSlots() + ACTIVE_MOUNT_INDEX do
          if not IsStableSlotEmpty(i) then
               local name, icon, _, breed, _, price = GetStableSlotInfo(i)
               local level, inventoryBonus, maxInventoryBonus, staminaBonus, maxStaminaBonus, speedBonus, maxSpeedBonus = GetStableSlotMountStats(i)
               local entryData = { stableIndex = i, name = name, icon = icon, breed = breed, price = price, level = level, 
                                                       speedBonus = speedBonus, maxSpeedBonus = maxSpeedBonus,
                                                       staminaBonus = staminaBonus, maxStaminaBonus = maxStaminaBonus,
                                                       inventoryBonus = inventoryBonus, maxInventoryBonus = maxInventoryBonus
                                                     }
               self.itemList:AddEntry("ZO_StableSlotBuyOrSellRow", entryData, nil, nil, MOUNT_BUYSELL_PRE_SELECTED_PADDING, MOUNT_BUYSELL_POST_SELECTED_PADDING)
            hasMount = true
          end
     end
    self.canSell = hasMount
    if not hasMount then
        self.itemList:AddEntry("ZO_StableSlotBuyOrSellRowEmpty", {}, nil, nil, MOUNT_BUYSELL_PRE_SELECTED_PADDING, MOUNT_BUYSELL_POST_SELECTED_PADDING)
    end
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
     self.itemList:Commit()
end
    SELL_MOUNT_GAMEPAD = ZO_SellMount:New(control)
end