ESO Lua File v100010

ingame/tradinghouse/gemfilter.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
local GemFilter = ZO_TradingHouseMultiFilter:Subclass()
function GemFilter:New(...)
    return ZO_TradingHouseMultiFilter.New(self, ...)
end
function GemFilter:Initialize(parentControl)
    local control = CreateControlFromVirtual("$(parent)GemContainer", parentControl, "TradingHouseSingleComboFilter")
    ZO_TradingHouseMultiFilter.Initialize(self, control)
    local function SelectGem(_, _, entry, selectionChanged)
          TRADING_HOUSE:HandleSearchCriteriaChanged(selectionChanged)
        self.m_data = entry.minValue
          local enchantmentType = nil
          if(ZO_TradingHouseFilter_Shared_GetGemHasEnchantments(entry.minValue)) then
               enchantmentType = entry.minValue
          end
         local enchantments = TRADING_HOUSE:GetEnchantmentFilters()
          enchantments:SetHidden(enchantmentType == nil)
          enchantments:SetEnchantmentType(enchantmentType)
    end
    ZO_TradingHouse_InitializeRangeComboBox(control:GetNamedChild("Category"), ZO_TRADING_HOUSE_FILTER_GEM_TYPE_DATA, SelectGem)
end
function GemFilter:ApplyToSearch(search)
    search:SetFilter(TRADING_HOUSE_FILTER_TYPE_ITEM, self.m_data)
     TRADING_HOUSE:GetEnchantmentFilters():ApplyToSearch(search)
end
function GemFilter:SetHidden(hidden)
    ZO_TradingHouseMultiFilter.SetHidden(self, hidden)
    local enchantments = TRADING_HOUSE:GetEnchantmentFilters()
    enchantments:SetHidden(hidden)
    if(not hidden) then
        enchantments:SetAnchor(TOPLEFT, self.m_control:GetNamedChild("Category"), BOTTOMLEFT, 0, 10)
    end
     -- Select the first item to ensure that the enchantments combobox is refreshed/shown/hidden (see SelectGem() above).
     local gemComboBox = ZO_ComboBox_ObjectFromContainer(self.m_control:GetNamedChild("Category"))
     gemComboBox:SelectFirstItem()
end
TRADING_HOUSE:RegisterSearchFilter(GemFilter, SI_TRADING_HOUSE_BROWSE_ITEM_TYPE_GLYPHS_AND_GEMS)