vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | if not SimpleCombatLog then return end |
2 | |||
3 | local dewdrop = AceLibrary("Dewdrop-2.0") |
||
4 | |||
5 | local L = SimpleCombatLog.loc.filter |
||
6 | |||
7 | local sourceOrVictimArray = { 'source', 'victim' } |
||
8 | local isSourceArray = { true, false } |
||
9 | |||
10 | -- Available type filters. |
||
11 | SimpleCombatLog.typeFilters = { |
||
12 | 'hit', 'heal', 'miss', 'cast', 'gain', 'drain', 'leech', 'dispel', |
||
13 | 'buff', 'debuff', 'fade', 'interrupt', 'death', 'environment', 'extraattack', 'enchant', |
||
14 | } |
||
15 | |||
16 | -- Available name filters. |
||
17 | SimpleCombatLog.nameFilters = { |
||
18 | 'player', 'pet', 'party', 'raid', 'target', 'targettarget', 'other', |
||
19 | } |
||
20 | |||
21 | function SimpleCombatLog:SetFilter(id, filterType, nameFilter, isSource, value) |
||
22 | if value == false then value = nil end |
||
23 | |||
24 | if not self.settings[id] then |
||
25 | self.settings[id] = {} |
||
26 | self.settingDB[id] = self.settings[id] |
||
27 | else |
||
28 | if self.settings[id].theme then |
||
29 | self.settings[id] = SimpleCombatLog.CopyTable({}, self.settings[id]) |
||
30 | self.settings[id].theme = nil |
||
31 | self.settingDB[id] = self.settings[id] |
||
32 | end |
||
33 | end |
||
34 | |||
35 | |||
36 | if not self.settings[id].filters then |
||
37 | self.settings[id].filters = {} |
||
38 | end |
||
39 | |||
40 | if not self.settings[id].filters[filterType] then |
||
41 | self.settings[id].filters[filterType] = {} |
||
42 | end |
||
43 | |||
44 | local source |
||
45 | if isSource then source = 1 else source = 2 end |
||
46 | local flag = self.filterFlags[source][nameFilter] |
||
47 | |||
48 | self.settings[id].filters[filterType][flag] = value |
||
49 | end |
||
50 | |||
51 | |||
52 | function SimpleCombatLog:SetAllTypeFilters(id, nameFilter, isSource, value) |
||
53 | for i, type in pairs(self.typeFilters) do |
||
54 | self:SetFilter(id, type, nameFilter, isSource, value) |
||
55 | end |
||
56 | end |
||
57 | |||
58 | function SimpleCombatLog:IsAllTypeFiltersChecked(id, nameFilter, isSource) |
||
59 | |||
60 | for i, typeFilter in pairs(self.typeFilters) do |
||
61 | if not self:GetFilter(id, typeFilter, nameFilter, isSource) then |
||
62 | return false |
||
63 | end |
||
64 | end |
||
65 | return true |
||
66 | |||
67 | end |
||
68 | |||
69 | local function UpdateFilterTable(self, id, level, value) |
||
70 | if level == 1 then |
||
71 | dewdrop:AddLine( |
||
72 | 'text', L["Filters"], |
||
73 | 'hasArrow', true, |
||
74 | 'value', 'filter', |
||
75 | 'notCheckable', true |
||
76 | ) |
||
77 | elseif level == 2 and value == 'filter' then |
||
78 | |||
79 | self.currMenuType = 'filter' |
||
80 | |||
81 | dewdrop:AddLine( |
||
82 | 'text', L["Type Filters"], |
||
83 | 'isTitle', true, |
||
84 | 'notCheckable', true |
||
85 | ) |
||
86 | |||
87 | dewdrop:AddLine( |
||
88 | 'text', L["AllFilter"], |
||
89 | 'hasArrow', true, |
||
90 | 'value', 'AllFilter', |
||
91 | 'tooltipTitle', L["AllFilter"], |
||
92 | 'tooltipText', L.typeTooltip["AllFilter"], |
||
93 | 'notCheckable', true |
||
94 | ) |
||
95 | |||
96 | for i, v in pairs(self.typeFilters) do |
||
97 | dewdrop:AddLine( |
||
98 | 'text', L[v], |
||
99 | 'hasArrow', true, |
||
100 | 'tooltipTitle', L[v], |
||
101 | 'tooltipText', L.typeTooltip[v], |
||
102 | 'value', v, |
||
103 | 'notCheckable', true |
||
104 | ) |
||
105 | end |
||
106 | elseif level == 3 and self.currMenuType == 'filter' then |
||
107 | |||
108 | if value == 'AllFilter' then |
||
109 | dewdrop:AddLine( |
||
110 | 'text', string.format(L["Name Menu Title"], L["AllFilter"]), |
||
111 | 'isTitle', true, |
||
112 | 'notCheckable', true |
||
113 | ) |
||
114 | for i, isSource in pairs(isSourceArray) do |
||
115 | local isSource = isSource |
||
116 | local sourceOrVictim = sourceOrVictimArray[i] |
||
117 | dewdrop:AddLine( |
||
118 | 'text', L[sourceOrVictim], |
||
119 | 'isTitle', true |
||
120 | ) |
||
121 | for i, nameFilter in pairs(self.nameFilters) do |
||
122 | local nameFilter = nameFilter |
||
123 | local state = nil -- 0: none, 1: partial, 2: all |
||
124 | for j, type in pairs(self.typeFilters) do |
||
125 | local checked = self:GetFilter(id, type, nameFilter, isSource) |
||
126 | if not state then |
||
127 | if checked then |
||
128 | state = 2 |
||
129 | else |
||
130 | state = 0 |
||
131 | end |
||
132 | elseif state == 0 and checked then |
||
133 | state = 1 |
||
134 | elseif state == 2 and not checked then |
||
135 | state = 1 |
||
136 | end |
||
137 | end |
||
138 | local checked, checkIcon, func |
||
139 | if state == 0 then |
||
140 | checked = false |
||
141 | checkIcon = nil |
||
142 | func = function() self:SetAllTypeFilters(id, nameFilter, isSource, true) end |
||
143 | elseif state == 1 then |
||
144 | checked = true |
||
145 | checkIcon = "Interface\\Buttons\\UI-CheckBox-Check-Disabled" |
||
146 | func = function() self:SetAllTypeFilters(id, nameFilter, isSource, true) end |
||
147 | else |
||
148 | checked = true |
||
149 | checkIcon = nil |
||
150 | func = function() self:SetAllTypeFilters(id, nameFilter, isSource, nil) end |
||
151 | end |
||
152 | dewdrop:AddLine( |
||
153 | 'text', L[nameFilter], |
||
154 | 'checked', checked, |
||
155 | 'checkIcon', checkIcon, |
||
156 | 'func', func |
||
157 | ) |
||
158 | end |
||
159 | end |
||
160 | else |
||
161 | |||
162 | local typeFilter = value |
||
163 | dewdrop:AddLine( |
||
164 | 'text', string.format(L["Name Menu Title"], L[typeFilter]), |
||
165 | 'isTitle', true, |
||
166 | 'notCheckable', true |
||
167 | ) |
||
168 | |||
169 | for i, isSource in pairs(isSourceArray) do |
||
170 | local isSource = isSource |
||
171 | local sourceOrVictim = sourceOrVictimArray[i] |
||
172 | dewdrop:AddLine( |
||
173 | 'text', L[sourceOrVictim], |
||
174 | 'isTitle', true |
||
175 | ) |
||
176 | for i, nameFilter in pairs(self.nameFilters) do |
||
177 | local nameFilter = nameFilter |
||
178 | dewdrop:AddLine( |
||
179 | 'text', L[nameFilter], |
||
180 | 'func', function() self:SetFilter(id, typeFilter, nameFilter, isSource, not self:GetFilter(id, typeFilter, nameFilter, isSource) )end, |
||
181 | 'checked', self:GetFilter(id, typeFilter, nameFilter, isSource) |
||
182 | ) |
||
183 | end |
||
184 | end |
||
185 | |||
186 | end |
||
187 | end |
||
188 | end |
||
189 | |||
190 | |||
191 | if SimpleCombatLog.menuFunc then |
||
192 | SimpleCombatLog.menuFunc[1] = UpdateFilterTable |
||
193 | end |
||
194 |