forked from tectronics/KarniCrap
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinitialize.lua
More file actions
281 lines (230 loc) · 11.6 KB
/
Copy pathinitialize.lua
File metadata and controls
281 lines (230 loc) · 11.6 KB
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
--[[ Karni's Crap Filter ]]--
---------------------------------------------------------------------------------
--
-- Karni's Crap Filter - A World of Warcraft addon
--
-- Copyright (C) 2008-2014 Karnifex
--
-- This file is part of Karni's Crap Filter.
--
-- Karni's Crap Filter is free software: you can redistribute it and/or
-- modify it under the terms of the GNU General Public License as
-- published by the Free Software Foundation, either version 3 of the
-- License, or (at your option) any later version.
--
-- Karni's Crap Filter is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-------------------------------------------------------------------------------
-- initialize (some of) the UI
local echo = KarniCrap_Echo
--[[
function initializeCloth()
local previousCB
local cloth_list = {
{ ["name"] = "Linen Cloth",
["type"] = "Linen",
["always"] = KarniCrapConfig.Cloth_Linen,
["never"] = KarniCrapConfig.Cloth_Linen_Never },
{ ["name"] = "Wool Cloth",
["type"] = "Wool",
["always"] = KarniCrapConfig.Cloth_Wool,
["never"] = KarniCrapConfig.Cloth_Wool_Never },
{ ["name"] = "Silk Cloth", ["type"] = "Silk" },
{ ["name"] = "Mageweave Cloth", ["type"] = "Mageweave" },
{ ["name"] = "Runecloth", ["type"] = "Runecloth" },
{ ["name"] = "Netherweave Cloth", ["type"] = "Netherweave" },
{ ["name"] = "Frostweave Cloth", ["type"] = "Frostweave" }
}
for k,cloth in ipairs(cloth_list) do
local cb_always = CreateFrame("CheckButton", "KarniCrap_Cloth_CB"..cloth["type"], KarniCrap_Cloth, "MyCheckButton")
local cb_never = CreateFrame("CheckButton", "KarniCrap_Cloth_CB"..cloth["type"].."_Never", KarniCrap_Cloth, "MyCheckButton")
local fs = cb_always:CreateFontString("$parent_Text")
-- if "always" box is checked
cb_always:SetScript("OnClick", function(self)
if (self:GetChecked()) then
cloth["always"] = true;
cloth["never"] = false;
_G["KarniCrap_Cloth_CB"..cloth["type"].."_Never"]:SetChecked(false);
--echo("1"..tostring(cloth["always"]))
--echo("2"..tostring(KarniCrapConfig.Cloth_Linen))
echo("value for always is "..tostring(KarniCrapConfig.Cloth_Linen))
echo("value for never is "..tostring(KarniCrapConfig.Cloth_Linen_Never))
--echo(cloth["type"].."(never) is "..tostring(cloth["never"]))
else
cloth["always"] = false;
--echo(cloth["type"].."(always) is "..tostring(cloth["always"]))
end
end )
-- if "never" box is checked
cb_never:SetScript("OnClick", function(self)
if (self:GetChecked()) then
cloth["always"] = false;
cloth["never"] = true;
_G["KarniCrap_Cloth_CB"..cloth["type"] ]:SetChecked(false);
echo(cloth["type"].."(always) is "..tostring(cloth["always"]))
echo(cloth["type"].."(never) is "..tostring(cloth["never"]))
else
cloth["never"] = false;
echo(cloth["type"].."(never) is "..tostring(cloth["never"]))
end
end )
-- label postioning
fs:SetPoint("LEFT", -165, 1)
fs:SetFontObject("GameFontNormalSmall")
fs:SetText("|cFFFFFFFF["..cloth["name"].."]")
-- positioning for checkboxes
if k == 1 then
cb_always:SetPoint("TOPLEFT", "KarniCrap_Cloth", "TOPLEFT", 175, -30)
cb_never:SetPoint("TOPLEFT", cb_always, "TOPRIGHT")
previousCB = cb_always
else
cb_always:SetPoint("TOPLEFT", previousCB, "BOTTOMLEFT", 0, 5)
cb_never:SetPoint("TOPLEFT", cb_always, "TOPRIGHT")
cb_always:SetText(cloth)
previousCB = cb_always
end
_G["KarniCrap_Cloth_CB"..cloth["type"] ]:SetChecked(cloth["always"])
_G["KarniCrap_Cloth_CB"..cloth["type"].."_Never"]:SetChecked(cloth["never"])
end
]]--
--------------------------------------------------------------------------------
--<< Initialize UI >>--
--------------------------------------------------------------------------------
-- Set the state of the UI when the player enters the world
function KarniCrap_InitializeUI()
KarniCrap_Version:SetText("Version "..KarniCrapConfig.Version);
-- addon disabled
if KarniCrapConfig.Enabled == false then
KarniCrap_Disable()
else
KarniCrap_Off:Hide()
KarniCrap_CBEnabled:SetChecked(KarniCrapConfig.Enabled)
end
-- poor item thresholds
KarniCrap_CBPoor:SetChecked(KarniCrapConfig.Poor)
KarniCrap_Poor_GoldInputBox:SetNumber(KarniCrapConfig.PoorThreshold_Gold)
KarniCrap_Poor_SilverInputBox:SetNumber(KarniCrapConfig.PoorThreshold_Silver)
KarniCrap_Poor_CopperInputBox:SetNumber(KarniCrapConfig.PoorThreshold_Copper)
KarniCrap_CheckButtonPoor()
-- common item thresholds
KarniCrap_Tab1_CBCommon:SetChecked(KarniCrapConfig.Common);
KarniCrap_Tab1_CBCommonDesc_GoldInputBox:SetNumber(KarniCrapConfig.CommonThreshold_Gold)
KarniCrap_Tab1_CBCommonDesc_SilverInputBox:SetNumber(KarniCrapConfig.CommonThreshold_Silver)
KarniCrap_Tab1_CBCommonDesc_CopperInputBox:SetNumber(KarniCrapConfig.CommonThreshold_Copper)
KarniCrap_CheckButtonCommon()
-- misc settings
KarniCrap_Tab1_CBUseStackValue:SetChecked(KarniCrapConfig.UseStackValue)
KarniCrap_Tab1_CBEcho:SetChecked(KarniCrapConfig.Echo)
-- corpse settings
KarniCrap_Corpses_CBSkinnable:SetChecked(KarniCrapConfig.Skinnable)
KarniCrap_Corpses_CBGatherable:SetChecked(KarniCrapConfig.Gatherable)
KarniCrap_Corpses_CBMinable:SetChecked(KarniCrapConfig.Minable)
KarniCrap_Corpses_CBEngineerable:SetChecked(KarniCrapConfig.Engineerable)
KarniCrap_Corpses_CBSkilledEnough:SetChecked(KarniCrapConfig.SkilledEnough)
-- tradeskills
KarniCrap_Tradeskills_CBCooking:SetChecked(KarniCrapConfig.Cooking)
KarniCrap_Tradeskills_CBFishing:SetChecked(KarniCrapConfig.Fishing)
-- pickpocket (disabled unless player is a rogue)
KarniCrap_Tradeskills_CBPickpocketing:SetChecked(KarniCrapConfig.Pickpocketing)
KarniCrap_Tradeskills_CBPickpocketing:Disable()
KarniCrap_Tradeskills_CBPickpocketing:SetAlpha(0.3)
local localizedClass, englishClass = UnitClass("player")
if englishClass == "ROGUE" then
KarniCrap_Tradeskills_CBPickpocketing:Enable()
KarniCrap_Tradeskills_CBPickpocketing:SetAlpha(1)
end
-- cloth always
KarniCrap_Cloth_CBLinen:SetChecked(KarniCrapConfig.Cloth_Linen)
KarniCrap_Cloth_CBWool:SetChecked(KarniCrapConfig.Cloth_Wool)
KarniCrap_Cloth_CBSilk:SetChecked(KarniCrapConfig.Cloth_Silk)
KarniCrap_Cloth_CBMageweave:SetChecked(KarniCrapConfig.Cloth_Mageweave)
KarniCrap_Cloth_CBRunecloth:SetChecked(KarniCrapConfig.Cloth_Runecloth)
KarniCrap_Cloth_CBNetherweave:SetChecked(KarniCrapConfig.Cloth_Netherweave)
KarniCrap_Cloth_CBFrostweave:SetChecked(KarniCrapConfig.Cloth_Frostweave)
KarniCrap_Cloth_CBEmbersilk:SetChecked(KarniCrapConfig.Cloth_Embersilk)
KarniCrap_Cloth_CBWindwool:SetChecked(KarniCrapConfig.Cloth_Windwool)
KarniCrap_Cloth_CBSumptuousFur:SetChecked(KarniCrapConfig.Cloth_SumptuousFur)
KarniCrap_Cloth_CBShaldoreiSilk:SetChecked(KarniCrapConfig.Cloth_ShaldoreiSilk)
KarniCrap_Cloth_CBTidesprayLinen:SetChecked(KarniCrapConfig.Cloth_TidesprayLinen)
KarniCrap_Cloth_CBShroudedCloth:SetChecked(KarniCrapConfig.Cloth_ShroudedCloth)
-- cloth never
KarniCrap_Cloth_CBLinen_Never:SetChecked(KarniCrapConfig.Cloth_Linen_Never)
KarniCrap_Cloth_CBWool_Never:SetChecked(KarniCrapConfig.Cloth_Wool_Never)
KarniCrap_Cloth_CBSilk_Never:SetChecked(KarniCrapConfig.Cloth_Silk_Never)
KarniCrap_Cloth_CBMageweave_Never:SetChecked(KarniCrapConfig.Cloth_Mageweave_Never)
KarniCrap_Cloth_CBRunecloth_Never:SetChecked(KarniCrapConfig.Cloth_Runecloth_Never)
KarniCrap_Cloth_CBNetherweave_Never:SetChecked(KarniCrapConfig.Cloth_Netherweave_Never)
KarniCrap_Cloth_CBFrostweave_Never:SetChecked(KarniCrapConfig.Cloth_Frostweave_Never)
KarniCrap_Cloth_CBEmbersilk_Never:SetChecked(KarniCrapConfig.Cloth_Embersilk_Never)
KarniCrap_Cloth_CBWindwool_Never:SetChecked(KarniCrapConfig.Cloth_Windwool_Never)
KarniCrap_Cloth_CBSumptuousFur_Never:SetChecked(KarniCrapConfig.Cloth_SumptuousFur_Never)
KarniCrap_Cloth_CBShaldoreiSilk_Never:SetChecked(KarniCrapConfig.Cloth_ShaldoreiSilk_Never)
KarniCrap_Cloth_CBTidesprayLinen_Never:SetChecked(KarniCrapConfig.Cloth_TidesprayLinen_Never)
KarniCrap_Cloth_CBShroudedCloth_Never:SetChecked(KarniCrapConfig.Cloth_ShroudedCloth_Never)
-- scrolls
KarniCrap_Scrolls_CBMaxScrolls:SetChecked(KarniCrapConfig.ScrollMax)
KarniCrap_Scrolls_CBScrollAgility:SetChecked(KarniCrapConfig.Scroll_Agility)
KarniCrap_Scrolls_CBScrollIntellect:SetChecked(KarniCrapConfig.Scroll_Intellect)
KarniCrap_Scrolls_CBScrollProtection:SetChecked(KarniCrapConfig.Scroll_Protection)
KarniCrap_Scrolls_CBScrollSpirit:SetChecked(KarniCrapConfig.Scroll_Spirit)
KarniCrap_Scrolls_CBScrollStamina:SetChecked(KarniCrapConfig.Scroll_Stamina)
KarniCrap_Scrolls_CBScrollStrength:SetChecked(KarniCrapConfig.Scroll_Strength)
KarniCrap_CBMaxScrolls()
-- food & water
KarniCrap_Consumables_RBFood1:SetChecked(KarniCrapConfig.NeverFood)
KarniCrap_Consumables_RBFood2:SetChecked(KarniCrapConfig.AlwaysFood)
KarniCrap_Consumables_CBFoodMax:SetChecked(KarniCrapConfig.FoodMax)
KarniCrap_Consumables_RBWater1:SetChecked(KarniCrapConfig.NeverWater)
KarniCrap_Consumables_RBWater2:SetChecked(KarniCrapConfig.AlwaysWater)
KarniCrap_Consumables_CBWaterMax:SetChecked(KarniCrapConfig.WaterMax)
KarniCrap_RBFood()
KarniCrap_RBWater()
-- potions
KarniCrap_Potions_RBHealth1:SetChecked(KarniCrapConfig.NeverHealth)
KarniCrap_Potions_RBHealth2:SetChecked(KarniCrapConfig.AlwaysHealth)
KarniCrap_Potions_CBHealthMax:SetChecked(KarniCrapConfig.HealthMax)
KarniCrap_Potions_RBMana1:SetChecked(KarniCrapConfig.NeverMana)
KarniCrap_Potions_RBMana2:SetChecked(KarniCrapConfig.AlwaysMana)
KarniCrap_Potions_CBManaMax:SetChecked(KarniCrapConfig.ManaMax)
KarniCrap_RBHealth()
KarniCrap_RBMana()
-- quality filtering
KarniCrap_Quality_CBQualityPoor:SetChecked(KarniCrapConfig.Quality_Poor)
KarniCrap_Quality_CBQualityCommon:SetChecked(KarniCrapConfig.Quality_Common)
KarniCrap_Quality_CBQualityUncommon:SetChecked(KarniCrapConfig.Quality_Uncommon)
KarniCrap_Quality_CBQualityRare:SetChecked(KarniCrapConfig.Quality_Rare)
KarniCrap_Quality_CBQualityEpic:SetChecked(KarniCrapConfig.Quality_Epic)
KarniCrap_Quality_CBQualityGrouped:SetChecked(KarniCrapConfig.Quality_Grouped)
-- auto-destroy
KarniCrap_CBDestroy:SetChecked(KarniCrapConfig.Destroy)
KarniCrap_CBDestroySlots:SetChecked(KarniCrapConfig.DestroySlots)
KarniCrap_EBDestroySlotsNum:SetNumber(KarniCrapConfig.DestroySlotsNum)
KarniCrap_CBDestroyGroup:SetChecked(KarniCrapConfig.DestroyGroup)
KarniCrap_CBDestroyRaid:SetChecked(KarniCrapConfig.DestroyRaid)
KarniCrap_CBNoDestroyTradeskill:SetChecked(KarniCrapConfig.NoDestroyTradeskill)
KarniCrap_DestroyUI()
-- inventory
KarniCrap_Inventory_CBHideQuestItems:SetChecked(KarniCrapConfig.HideQuestItems)
KarniCrap_CBOpenAtMerchant:SetChecked(KarniCrapConfig.OpenAtMerchant)
-- sorting
if KarniCrapConfig.InvSort == "Stack Value" then
KarniCrap_ValueHeader:SetText("Stack Value")
elseif KarniCrapConfig.InvSort == "Item Value" then
KarniCrap_ValueHeader:SetText("Item Value")
else
KarniCrap_ValueHeader:SetText("Current Value")
end
-- blacklist/whitelist
KarniCrap_BtnDestroyItem:Disable();
KarniCrap_InitializeBlacklist()
KarniCrap_InitializeWhitelist()
-- categories
KarniCrap_InitializeCategories()
KarniCrap_SelectCategory(1)
end