Back to Home

ESO Lua File v100036

ingame/map/keyboard/worldmapfilters_keyboard.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
156
157
158
159
160
161
--Filter Panel
local WorldMapFilterPanel = ZO_WorldMapFilterPanel_Shared:Subclass()
function WorldMapFilterPanel:New(...)
    local object = ZO_WorldMapFilterPanel_Shared.New(self, ...)
    return object
end
function WorldMapFilterPanel:Initialize(control, mapFilterType, savedVars)
    ZO_WorldMapFilterPanel_Shared.Initialize(self, control, mapFilterType, savedVars)
    self:BuildControls()
end
function WorldMapFilterPanel:SetMapMode(mapMode)
    if(mapMode ~= self.mapMode) then
        self.mapMode = mapMode
        self.modeVars = self.savedVars[mapMode]
        self:LoadInitialState()
    end
end
function WorldMapFilterPanel:RefreshDependentComboBox(checkBox)
    if(checkBox.dependentComboBox) then
        local enabled = ZO_CheckButton_IsChecked(checkBox)
        local dependentComboBox = self:FindComboBox(checkBox.dependentComboBox)
        dependentComboBox:SetEnabled(enabled)
    end
end
function WorldMapFilterPanel:AddPinFilterCheckBox(mapPinGroup, refreshFunction, header)
    if(not self.checkBoxPool) then
        self.checkBoxPool = ZO_ControlPool:New("ZO_CheckButton", self.control, "CheckBox")
    end
    
    local checkBox = self.checkBoxPool:AcquireObject()
    ZO_CheckButton_SetLabelText(checkBox, GetString("SI_MAPFILTER", mapPinGroup))
    ZO_CheckButton_SetToggleFunction(checkBox, function(button, checked)
        self:SetPinFilter(mapPinGroup, checked)
        self:RefreshDependentComboBox(checkBox)
        if(refreshFunction) then
            refreshFunction()
        end
    end)
    checkBox.mapPinGroup = mapPinGroup
    checkBox.refreshFunction = refreshFunction
    table.insert(self.pinFilterCheckBoxes, checkBox)
    self:AnchorControl(checkBox)    
end
function WorldMapFilterPanel:AddPinFilterComboBox(optionsPinGroup, refreshFunction, header, optionsEnumStringName, ...)
    if(not self.comboBoxPool) then
        self.comboBoxPool = ZO_ControlPool:New("ZO_WorldMapFilterComboBox", self.control, "ComboBox")
    end
    
    local comboBoxControl = self.comboBoxPool:AcquireObject()
    local comboBox = ZO_ComboBox_ObjectFromContainer(comboBoxControl)
    comboBox.mapPinGroup = optionsPinGroup
    local function OnOptionChanged(_, entryText, entry)
        self:SetPinFilter(optionsPinGroup, entry.optionValue)
        if(refreshFunction) then
            refreshFunction()
        end
    end
    for i = 1, select("#", ...) do
        local optionValue = select(i, ...)
        local entryText = GetString(optionsEnumStringName, optionValue)
        local entry = comboBox:CreateItemEntry(entryText, OnOptionChanged)
        entry.optionValue = optionValue
        comboBox:AddItem(entry)
    end
    self:AnchorControl(comboBoxControl, 21)
    table.insert(self.pinFilterOptionComboBoxes, comboBox)
end
function WorldMapFilterPanel:LoadInitialState()
    local filterTable = self.modeVars.filters[self.mapFilterType]
    for i = 1, #self.pinFilterCheckBoxes do
        local checkBox = self.pinFilterCheckBoxes[i]
        ZO_CheckButton_SetCheckState(checkBox, self:GetPinFilter(checkBox.mapPinGroup) ~= false)
        self:RefreshDependentComboBox(checkBox)
    end
    for i = 1, #self.pinFilterOptionComboBoxes do
        local comboBox = self.pinFilterOptionComboBoxes[i]
        local value = self:GetPinFilter(comboBox.mapPinGroup)
        for _, entry in ipairs(comboBox:GetItems()) do
            if(entry.optionValue == value) then
                comboBox:SetSelectedItemText(entry.name)
                break
            end
        end
    end
end
--PvE Filter Panel
local PvEWorldMapFilterPanel = ZO_Object.MultiSubclass(ZO_PvEWorldMapFilterPanel_Shared, WorldMapFilterPanel)
function PvEWorldMapFilterPanel:New(...)
    return WorldMapFilterPanel.New(self, ...)
end
--PvP Filter Panel
local PvPWorldMapFilterPanel = ZO_Object.MultiSubclass(ZO_PvPWorldMapFilterPanel_Shared, WorldMapFilterPanel)
function PvPWorldMapFilterPanel:New(...)
    return WorldMapFilterPanel.New(self, ...)
end
--Imperial PvP Filter Panel
local ImperialPvPWorldMapFilterPanel = ZO_Object.MultiSubclass(ZO_ImperialPvPWorldMapFilterPanel_Shared, WorldMapFilterPanel)
function ImperialPvPWorldMapFilterPanel:New(...)
    return WorldMapFilterPanel.New(self, ...)
end
--Battleground Filter Panel
local BattlegroundWorldMapFilterPanel = ZO_Object.MultiSubclass(ZO_BattlegroundWorldMapFilterPanel_Shared, WorldMapFilterPanel)
function BattlegroundWorldMapFilterPanel:New(...)
    return WorldMapFilterPanel.New(self, ...)
end
--Filters
local WorldMapFilters = ZO_WorldMapFilters_Shared:Subclass()
function WorldMapFilters:New(...)
    local object = ZO_WorldMapFilters_Shared.New(self, ...)
    return object
end
function WorldMapFilters:Initialize(control)
    ZO_WorldMapFilters_Shared.Initialize(self, control)
    WORLD_MAP_KEY_FILTERS_FRAGMENT = ZO_FadeSceneFragment:New(control)
    WORLD_MAP_KEY_FILTERS_FRAGMENT:RegisterCallback("StateChange",  function(oldState, newState)
        if(newState == SCENE_SHOWING) then
            self.currentPanel:LoadInitialState()
        end
    end)
    CALLBACK_MANAGER:RegisterCallback("OnWorldMapSavedVarsReady", function(savedVars)
        self.pvePanel = PvEWorldMapFilterPanel:New(self.control:GetNamedChild("PvE"), MAP_FILTER_TYPE_STANDARD, savedVars)
        self.pvpPanel = PvPWorldMapFilterPanel:New(self.control:GetNamedChild("PvP"), MAP_FILTER_TYPE_AVA_CYRODIIL, savedVars)
        self.imperialPvPPanel = ImperialPvPWorldMapFilterPanel:New(self.control:GetNamedChild("ImperialPvP"), MAP_FILTER_TYPE_AVA_IMPERIAL, savedVars)
        self.battlegroundPanel = BattlegroundWorldMapFilterPanel:New(self.control:GetNamedChild("Battleground"), MAP_FILTER_TYPE_BATTLEGROUND, savedVars)
    end)
end
--Global XML
    WORLD_MAP_FILTERS = WorldMapFilters:New(self)
end