Back to Home

ESO Lua File v100019

ingame/tradinghouse/gamepad/armorfilter_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
local DATA_CALLBACK_INDEX = 1
local EQUIP_TYPE_INDEX = 2
local GamepadArmorFilter = ZO_Object.MultiSubclass(ZO_CategorySubtypeFilter, ZO_ArmorFilter_Shared)
function GamepadArmorFilter:New()
    return ZO_CategorySubtypeFilter.New(self, "Armor", "armor", ITEMTYPE_GLYPH_ARMOR)
end
function GamepadArmorFilter:Initialize(name, traitType, enchantmentType)
    ZO_CategorySubtypeFilter.Initialize(self, name, nil, traitType, enchantmentType)
end
function GamepadArmorFilter:ApplyToSearch(search)
    self:ApplyCategoryFilterToSearch(search, self.m_FilterSubType)
    ZO_GamepadTradingHouse_Filter.ApplyToSearch(self, search)
end
function GamepadArmorFilter:PopulateSubTypes(comboBox, entryName, entry)
    local categoryComboBoxData = self:GetFilterComboBoxData("Category")
    local subTypeComboBoxData = self:GetFilterComboBoxData("SubType")
    local selectedEntryIndex = comboBox:GetHighlightedIndex()
    --Grab this from the base data that populates the category combo box. It isn't on the combo box entry
    local entryEquipTypeData = categoryComboBoxData:GetData()[selectedEntryIndex][EQUIP_TYPE_INDEX]
    
    local forceRepopulate = true    
    if not entryEquipTypeData and subTypeComboBoxData:IsVisible() then
        subTypeComboBoxData:SetVisible(false)
    elseif entryEquipTypeData and not subTypeComboBoxData:IsVisible() then
        subTypeComboBoxData:SetVisible(true)
    else
        forceRepopulate = false
    end
    if forceRepopulate then
        -- reset list to remove or add sub category combo box as needed
        local selectionChanged = categoryComboBoxData:UpdateSelectedEntryMemory(entryName, selectedEntryIndex)
        subTypeComboBoxData:ClearSelectedEntryMemory()
        self:SetCategoryTypeAndSubData(entry)
        ZO_GamepadTradingHouse_Filter.SetComboBoxes(self, self:GetComboBoxData())
        ZO_TradingHouse_SearchCriteriaChanged(selectionChanged)
    else
        ZO_CategorySubtypeFilter.PopulateSubTypes(self, comboBox, entryName, entry)
    end
    self:UpdateFilterData()
end
function GamepadArmorFilter:SetGenericArmorSearch(mode, traitType, enchantmentType, armorType)
    self.m_mode = mode
    self:SetTraitType(traitType)
    self:SetEnchantmentType(enchantmentType)
    self.m_armorType = armorType
end
function GamepadArmorFilter:UpdateFilterData()
    local categoryComboBoxData = self:GetFilterComboBoxData("Category")
    local currentSelectedData =  categoryComboBoxData:GetSelectedEntryDataFromMemory()
    currentSelectedData[DATA_CALLBACK_INDEX]() -- Invoke callback in data container which will in turn call SetGenericArmorSearch
end
function GamepadArmorFilter:SetHidden(hidden)
    if not hidden then
        self:UpdateFilterData()
    end
    ZO_CategorySubtypeFilter.SetHidden(self, hidden)
end
TRADING_HOUSE_GAMEPAD:RegisterSearchFilter(GamepadArmorFilter, SI_TRADING_HOUSE_BROWSE_ITEM_TYPE_APPAREL)