· 6 years ago · Mar 19, 2019, 01:28 AM
1--[[
2
3License: All Rights Reserved, (c) 2006-2018
4
5$Revision: 2319 $
6$Date: 2019-03-03 22:42:48 +1100 (Sun, 03 Mar 2019) $
7
8]]--
9
10local _G = _G
11local select = _G.select
12local pairs = _G.pairs
13local ipairs = _G.ipairs
14local string = _G.string
15local type = _G.type
16local error = _G.error
17local table = _G.table
18
19
20ArkInventory.Localise = LibStub( "AceLocale-3.0" ):GetLocale( "ArkInventory" )
21
22ArkInventory.Const.Bindings = {
23 All = { ITEM_BIND_ON_USE, ITEM_BIND_ON_EQUIP, ITEM_BIND_ON_PICKUP, ITEM_SOULBOUND, ITEM_ACCOUNTBOUND, ITEM_BIND_TO_ACCOUNT, ITEM_BIND_TO_BNETACCOUNT, ITEM_BNETACCOUNTBOUND },
24 Use = { ArkInventory.Localise["WOW_TOOLTIP_ITEM_BIND_ON_USE"] },
25 Equip = { ArkInventory.Localise["WOW_TOOLTIP_ITEM_BIND_ON_EQUIP"] },
26 Pickup = { ArkInventory.Localise["WOW_TOOLTIP_ITEM_BIND_ON_PICKUP"], ArkInventory.Localise["WOW_TOOLTIP_ITEM_SOULBOUND"] },
27 Account = { ArkInventory.Localise["WOW_TOOLTIP_ITEM_ACCOUNTBOUND"], ArkInventory.Localise["WOW_TOOLTIP_ITEM_BIND_TO_ACCOUNT"], ArkInventory.Localise["WOW_TOOLTIP_ITEM_BIND_TO_BNETACCOUNT"], ArkInventory.Localise["WOW_TOOLTIP_ITEM_BNETACCOUNTBOUND"] },
28}
29
30ArkInventory.Const.Category = {
31
32 Min = 1000,
33 Max = 8999,
34
35 Type = {
36 System = 1,
37 Custom = 2,
38 Rule = 3,
39 },
40
41 Code = {
42 System = { -- do NOT change the indicies - if you have to then see the DatabaseUpgradePostLoad( ) function to remap it
43 [401] = {
44 ["id"] = "SYSTEM_DEFAULT",
45 ["text"] = ArkInventory.Localise["DEFAULT"],
46 },
47 [402] = {
48 ["id"] = "SYSTEM_TRASH",
49 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_MISC_JUNK"],
50 },
51 [403] = {
52 ["id"] = "SYSTEM_SOULBOUND",
53 ["text"] = ArkInventory.Localise["CATEGORY_SYSTEM_SOULBOUND"],
54 },
55 [405] = {
56 ["id"] = "SYSTEM_CONTAINER",
57 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER"],
58 },
59 --[406] = { keys },
60 [407] = {
61 ["id"] = "SYSTEM_MISC",
62 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_MISC"],
63 },
64 [408] = {
65 ["id"] = "SYSTEM_REAGENT",
66 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_MISC_REAGENT"],
67 },
68 [409] = {
69 ["id"] = "SYSTEM_RECIPE",
70 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE"],
71 },
72 [411] = {
73 ["id"] = "SYSTEM_QUEST",
74 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_QUEST"],
75 },
76 [414] = {
77 ["id"] = "SYSTEM_EQUIPMENT",
78 ["text"] = ArkInventory.Localise["CATEGORY_SYSTEM_EQUIPMENT"],
79 },
80 [415] = {
81 ["id"] = "SYSTEM_MOUNT",
82 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_MISC_MOUNT"],
83 },
84 [416] = {
85 ["id"] = "SYSTEM_EQUIPMENT_SOULBOUND",
86 ["text"] = ArkInventory.Localise["CATEGORY_SYSTEM_EQUIPMENT_SOULBOUND"],
87 },
88 --[421] = { SYSTEM_PROJECTILE_ARROW }
89 --[422] = { SYSTEM_PROJECTILE_BULLET }
90 [444] = {
91 ["id"] = "SYSTEM_EQUIPMENT_ACCOUNTBOUND",
92 ["text"] = ArkInventory.Localise["CATEGORY_SYSTEM_EQUIPMENT_ACCOUNTBOUND"],
93 },
94 [423] = {
95 ["id"] = "SYSTEM_PET_COMPANION_BOUND",
96 ["text"] = ArkInventory.Localise["PET_COMPANION_BOUND"],
97 },
98 [443] = {
99 ["id"] = "SYSTEM_PET_COMPANION_TRADE",
100 ["text"] = ArkInventory.Localise["PET"],
101 },
102 [441] = {
103 ["id"] = "SYSTEM_PET_BATTLE_TRADE",
104 ["text"] = ArkInventory.Localise["BATTLEPET"],
105 },
106 [442] = {
107 ["id"] = "SYSTEM_PET_BATTLE_BOUND",
108 ["text"] = ArkInventory.Localise["PET_BATTLE_BOUND"],
109 },
110 [428] = {
111 ["id"] = "SYSTEM_REPUTATION",
112 ["text"] = ArkInventory.Localise["REPUTATION"],
113 },
114 [429] = {
115 ["id"] = "SYSTEM_UNKNOWN",
116 ["text"] = ArkInventory.Localise["UNKNOWN"],
117 },
118 [434] = {
119 ["id"] = "SYSTEM_GEM",
120 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_GEM"],
121 },
122 [438] = {
123 ["id"] = "SYSTEM_CURRENCY",
124 ["text"] = ArkInventory.Localise["CURRENCY"],
125 },
126 [439] = {
127 ["id"] = "SYSTEM_GLYPH",
128 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_GLYPH"],
129 },
130 [445] = {
131 ["id"] = "SYSTEM_TOY",
132 ["text"] = ArkInventory.Localise["TOY"],
133 },
134 [446] = {
135 ["id"] = "SYSTEM_NEW",
136 ["text"] = ArkInventory.Localise["CONFIG_DESIGN_ITEM_NEW"],
137 },
138 [447] = {
139 ["id"] = "SYSTEM_HEIRLOOM",
140 ["text"] = ArkInventory.Localise["HEIRLOOM"],
141 },
142 [448] = {
143 ["id"] = "SYSTEM_ARTIFACT_RELIC",
144 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_GEM_ARTIFACT_RELIC"],
145 },
146 --[510] = TRADEGOODS_ENCHANTMENT
147 --[440] = CONSUMABLE_ITEM_ENHANCEMENT
148 [440] = {
149 ["id"] = "SYSTEM_ITEM_ENHANCEMENT",
150 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_ITEM_ENHANCEMENT"],
151 },
152 [451] = {
153 ["id"] = "SYSTEM_MYTHIC_KEYSTONE",
154 ["text"] = ArkInventory.Localise["CATEGORY_SYSTEM_MYTHIC_KEYSTONE"],
155 },
156 [452] = {
157 ["id"] = "SYSTEM_CRAFTING_REAGENT",
158 ["text"] = ArkInventory.Localise["CRAFTING_REAGENT"],
159 },
160 },
161 Consumable = {
162 [404] = {
163 ["id"] = "CONSUMABLE_OTHER",
164 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONSUMABLE_OTHER"],
165 },
166 [417] = {
167 ["id"] = "CONSUMABLE_FOOD",
168 ["text"] = ArkInventory.Localise["CATEGORY_CONSUMABLE_FOOD"],
169 },
170 [418] = {
171 ["id"] = "CONSUMABLE_DRINK",
172 ["text"] = ArkInventory.Localise["CATEGORY_CONSUMABLE_DRINK"],
173 },
174 [419] = {
175 ["id"] = "CONSUMABLE_POTION_MANA",
176 ["text"] = ArkInventory.Localise["CATEGORY_CONSUMABLE_POTION_MANA"],
177 },
178 [420] = {
179 ["id"] = "CONSUMABLE_POTION_HEAL",
180 ["text"] = ArkInventory.Localise["CATEGORY_CONSUMABLE_POTION_HEAL"],
181 },
182 [424] = {
183 ["id"] = "CONSUMABLE_POTION",
184 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONSUMABLE_POTION"],
185 },
186 [430] = {
187 ["id"] = "CONSUMABLE_ELIXIR",
188 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONSUMABLE_ELIXIR"],
189 },
190 [431] = {
191 ["id"] = "CONSUMABLE_FLASK",
192 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONSUMABLE_FLASK"],
193 },
194 [432] = {
195 ["id"] = "CONSUMABLE_BANDAGE",
196 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONSUMABLE_BANDAGE"],
197 },
198 --[433] = CONSUMABLE_SCROLL
199 [435] = {
200 ["id"] = "CONSUMABLE_ELIXIR_BATTLE",
201 ["text"] = ArkInventory.Localise["CATEGORY_CONSUMABLE_ELIXIR_BATTLE"],
202 },
203 [436] = {
204 ["id"] = "CONSUMABLE_ELIXIR_GUARDIAN",
205 ["text"] = ArkInventory.Localise["CATEGORY_CONSUMABLE_ELIXIR_GUARDIAN"],
206 },
207 [437] = {
208 ["id"] = "CONSUMABLE_FOOD_AND_DRINK",
209 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONSUMABLE_FOOD_AND_DRINK"],
210 },
211 --[425] = TRADEGOODS_DEVICES
212 --[426] = TRADEGOODS_EXPLOSIVES
213 [426] = {
214 ["id"] = "CONSUMABLE_EXPLOSIVES_AND_DEVICES",
215 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONSUMABLE_EXPLOSIVES_AND_DEVICES"],
216 },
217 [449] = {
218 ["id"] = "CONSUMABLE_VANTUSRUNE",
219 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONSUMABLE_VANTUSRUNE"],
220 },
221 [450] = {
222 ["id"] = "CONSUMABLE_ARTIFACT_POWER",
223 ["text"] = ArkInventory.Localise["ARTIFACT_POWER"],
224 },
225 },
226 Trade = {
227 [412] = {
228 ["id"] = "TRADEGOODS_OTHER",
229 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_TRADEGOODS_OTHER"],
230 },
231 [427] = {
232 ["id"] = "TRADEGOODS_PARTS",
233 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_TRADEGOODS_PARTS"],
234 },
235 [501] = {
236 ["id"] = "TRADEGOODS_HERB",
237 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_TRADEGOODS_HERB"],
238 },
239 [502] = {
240 ["id"] = "TRADEGOODS_CLOTH",
241 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_TRADEGOODS_CLOTH"],
242 },
243 [503] = {
244 ["id"] = "TRADEGOODS_ELEMENTAL",
245 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_TRADEGOODS_ELEMENTAL"],
246 },
247 [504] = {
248 ["id"] = "TRADEGOODS_LEATHER",
249 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_TRADEGOODS_LEATHER"],
250 },
251 [505] = {
252 ["id"] = "TRADEGOODS_COOKING",
253 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_TRADEGOODS_COOKING"],
254 },
255 [506] = {
256 ["id"] = "TRADEGOODS_METAL_AND_STONE",
257 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_TRADEGOODS_METAL_AND_STONE"],
258 },
259 --[507] = TRADEGOODS_MATERIALS
260 [512] = {
261 ["id"] = "TRADEGOODS_ENCHANTING",
262 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_TRADEGOODS_ENCHANTING"],
263 },
264 [513] = {
265 ["id"] = "TRADEGOODS_JEWELCRAFTING",
266 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_TRADEGOODS_JEWELCRAFTING"],
267 },
268 },
269 Skill = { -- do NOT change the indicies
270 [101] = {
271 ["id"] = "SKILL_ALCHEMY",
272 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_ALCHEMY"],
273 },
274 [102] = {
275 ["id"] = "SKILL_BLACKSMITHING",
276 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_BLACKSMITHING"],
277 },
278 [103] = {
279 ["id"] = "SKILL_COOKING",
280 ["text"] = ArkInventory.Localise["WOW_SKILL_COOKING"],
281 },
282 [104] = {
283 ["id"] = "SKILL_ENGINEERING",
284 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_ENGINEERING"],
285 },
286 [105] = {
287 ["id"] = "SKILL_ENCHANTING",
288 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_TRADEGOODS_ENCHANTING"],
289 },
290 [106] = {
291 ["id"] = "SKILL_FIRST_AID",
292 ["text"] = ArkInventory.Localise["WOW_SKILL_FIRSTAID"],
293 },
294 [107] = {
295 ["id"] = "SKILL_FISHING",
296 ["text"] = ArkInventory.Localise["WOW_SKILL_FISHING"],
297 },
298 [108] = {
299 ["id"] = "SKILL_HERBALISM",
300 ["text"] = ArkInventory.Localise["WOW_SKILL_HERBALISM"],
301 },
302 [109] = {
303 ["id"] = "SKILL_JEWELCRAFTING",
304 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_TRADEGOODS_JEWELCRAFTING"],
305 },
306 [110] = {
307 ["id"] = "SKILL_LEATHERWORKING",
308 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_LEATHERWORKING"],
309 },
310 [111] = {
311 ["id"] = "SKILL_MINING",
312 ["text"] = ArkInventory.Localise["WOW_SKILL_MINING"],
313 },
314 [112] = {
315 ["id"] = "SKILL_SKINNING",
316 ["text"] = ArkInventory.Localise["WOW_SKILL_SKINNING"],
317 },
318 [113] = {
319 ["id"] = "SKILL_TAILORING",
320 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_TAILORING"],
321 },
322 [115] = {
323 ["id"] = "SKILL_INSCRIPTION",
324 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_INSCRIPTION"],
325 },
326 [116] = {
327 ["id"] = "SKILL_ARCHAEOLOGY",
328 ["text"] = ArkInventory.Localise["WOW_SKILL_ARCHAEOLOGY"],
329 },
330 },
331 Class = {
332 [201] = {
333 ["id"] = "CLASS_DRUID",
334 ["text"] = ArkInventory.Localise["WOW_CLASS_DRUID"],
335 },
336 [202] = {
337 ["id"] = "CLASS_HUNTER",
338 ["text"] = ArkInventory.Localise["WOW_CLASS_HUNTER"],
339 },
340 [203] = {
341 ["id"] = "CLASS_MAGE",
342 ["text"] = ArkInventory.Localise["WOW_CLASS_MAGE"],
343 },
344 [204] = {
345 ["id"] = "CLASS_PALADIN",
346 ["text"] = ArkInventory.Localise["WOW_CLASS_PALADIN"],
347 },
348 [205] = {
349 ["id"] = "CLASS_PRIEST",
350 ["text"] = ArkInventory.Localise["WOW_CLASS_PRIEST"],
351 },
352 [206] = {
353 ["id"] = "CLASS_ROGUE",
354 ["text"] = ArkInventory.Localise["WOW_CLASS_ROGUE"],
355 },
356 [207] = {
357 ["id"] = "CLASS_SHAMAN",
358 ["text"] = ArkInventory.Localise["WOW_CLASS_SHAMAN"],
359 },
360 [208] = {
361 ["id"] = "CLASS_WARLOCK",
362 ["text"] = ArkInventory.Localise["WOW_CLASS_WARLOCK"],
363 },
364 [209] = {
365 ["id"] = "CLASS_WARRIOR",
366 ["text"] = ArkInventory.Localise["WOW_CLASS_WARRIOR"],
367 },
368 [210] = {
369 ["id"] = "CLASS_DEATHKNIGHT",
370 ["text"] = ArkInventory.Localise["WOW_CLASS_DEATHKNIGHT"],
371 },
372 [211] = {
373 ["id"] = "CLASS_MONK",
374 ["text"] = ArkInventory.Localise["WOW_CLASS_MONK"],
375 },
376 [212] = {
377 ["id"] = "CLASS_DEMONHUNTER",
378 ["text"] = ArkInventory.Localise["WOW_CLASS_DEMONHUNTER"],
379 },
380 },
381 Empty = {
382 [300] = {
383 ["id"] = "EMPTY_UNKNOWN",
384 ["text"] = ArkInventory.Localise["UNKNOWN"],
385 },
386 [301] = {
387 ["id"] = "EMPTY",
388 ["text"] = ArkInventory.Localise["CATEGORY_EMPTY"],
389 },
390 [302] = {
391 ["id"] = "EMPTY_BAG",
392 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_BAG"],
393 },
394 --[303] = { empty key },
395 [305] = {
396 ["id"] = "EMPTY_HERB",
397 ["text"] = ArkInventory.Localise["WOW_SKILL_HERBALISM"],
398 },
399 [306] = {
400 ["id"] = "EMPTY_ENCHANTING",
401 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_TRADEGOODS_ENCHANTING"],
402 },
403 [307] = {
404 ["id"] = "EMPTY_ENGINEERING",
405 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_ENGINEERING"],
406 },
407 [308] = {
408 ["id"] = "EMPTY_GEM",
409 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_GEM"],
410 },
411 [309] = {
412 ["id"] = "EMPTY_MINING",
413 ["text"] = ArkInventory.Localise["WOW_SKILL_MINING"],
414 },
415 [312] = {
416 ["id"] = "EMPTY_LEATHERWORKING",
417 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_LEATHERWORKING"],
418 },
419 [313] = {
420 ["id"] = "EMPTY_INSCRIPTION",
421 ["text"] = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_INSCRIPTION"],
422 },
423 [314] = {
424 ["id"] = "EMPTY_TACKLE",
425 ["text"] = ArkInventory.Localise["WOW_SKILL_FISHING"],
426 },
427 --[315] = { empty void storage },
428 [316] = {
429 ["id"] = "EMPTY_COOKING",
430 ["text"] = ArkInventory.Localise["WOW_SKILL_COOKING"],
431 },
432 [317] = {
433 ["id"] = "EMPTY_REAGENTBANK",
434 ["text"] = ArkInventory.Localise["REAGENTBANK"],
435 },
436 },
437 Other = { -- do NOT change the indicies - if you have to then see the DatabaseUpgradePostLoad( ) function to remap it
438 [901] = {
439 ["id"] = "SYSTEM_CORE_MATS",
440 ["text"] = ArkInventory.Localise["CATEGORY_SYSTEM_CORE_MATS"],
441 },
442 [902] = {
443 ["id"] = "CONSUMABLE_FOOD_PET",
444 ["text"] = ArkInventory.Localise["CATEGORY_CONSUMABLE_FOOD_PET"],
445 },
446 },
447 },
448
449}
450
451ArkInventory.Const.Actions = {
452 [ArkInventory.Const.ActionID.MainMenu] = {
453 Texture = nil,
454 Name = ArkInventory.Localise["MENU"],
455 Scripts = {
456 OnClick = function( self, button )
457 if not self then return end
458 ArkInventory.MenuMainOpen( self )
459 end,
460 OnEnter = function( self )
461 ArkInventory.GameTooltipSetText( self, ArkInventory.Localise["MENU"] )
462 end,
463 },
464 },
465 [ArkInventory.Const.ActionID.Close] = {
466 Texture = [[Interface\RAIDFRAME\ReadyCheck-NotReady]],
467 Name = ArkInventory.Localise["CLOSE"],
468 Scripts = {
469 OnClick = function( self, button )
470 if not self then return end
471 local loc_id = self:GetParent( ):GetParent( ):GetID( )
472 ArkInventory.Frame_Main_Hide( loc_id )
473 end,
474 OnEnter = function( self )
475 ArkInventory.GameTooltipSetText( self, ArkInventory.Localise["CLOSE"] )
476 end,
477 },
478 },
479 [ArkInventory.Const.ActionID.EditMode] = {
480 Texture = [[Interface\Icons\Trade_Engineering]],
481 Name = ArkInventory.Localise["MENU_ACTION_EDITMODE"],
482 Scripts = {
483 OnClick = function( self, button )
484 if not self then return end
485 ArkInventory.Frame_Main_Level( self:GetParent( ):GetParent( ) )
486 ArkInventory.ToggleEditMode( )
487 end,
488 OnEnter = function( self )
489 ArkInventory.GameTooltipSetText( self, ArkInventory.Localise["MENU_ACTION_EDITMODE"] )
490 end,
491 },
492 },
493 [ArkInventory.Const.ActionID.Rules] = {
494 --Texture = [[Interface\Icons\INV_Misc_Note_05]],
495 --Texture = [[Interface\Icons\Interface\Icons\INV_Gizmo_02]],
496 Texture = [[Interface\Icons\INV_Misc_Book_10]],
497 Name = ArkInventory.Localise["CONFIG_RULE_PLURAL"],
498 LDB = true,
499 Scripts = {
500 OnClick = function( self, button )
501 if not self then return end
502 ArkInventory.Frame_Main_Level( self:GetParent( ):GetParent( ) )
503 ArkInventory.Frame_Rules_Toggle( )
504 end,
505 OnEnter = function( self )
506 ArkInventory.GameTooltipSetText( self, ArkInventory.Localise["CONFIG_RULE_PLURAL"] )
507 end,
508 },
509 },
510 [ArkInventory.Const.ActionID.Search] = {
511 --Texture = [[Interface\Icons\INV_Misc_EngGizmos_20]],
512 Texture = [[Interface\Minimap\Tracking\None]],
513 Name = ArkInventory.Localise["SEARCH"],
514 LDB = true,
515 Scripts = {
516 OnClick = function( self, button )
517 if not self then return end
518 if button == "RightButton" then
519 ArkInventory.Frame_Main_Level( self:GetParent( ):GetParent( ) )
520 local loc_id = self:GetParent( ):GetParent( ):GetID( )
521 if ArkInventory.Global.Location[loc_id].canSearch then
522 ArkInventory.Global.Location[loc_id].filter = ""
523 local me = ArkInventory.GetPlayerCodex( loc_id )
524 me.style.search.hide = not me.style.search.hide
525 ArkInventory.Frame_Main_Generate( nil, ArkInventory.Const.Window.Draw.Refresh )
526 end
527 else
528 ArkInventory.Search.Frame_Toggle( )
529 end
530 end,
531 OnEnter = function( self )
532 ArkInventory.GameTooltipSetText( self, ArkInventory.Localise["SEARCH"] )
533 end,
534 },
535 },
536 [ArkInventory.Const.ActionID.SwitchCharacter] = {
537 Texture = [[Interface\Icons\INV_Misc_GroupLooking]],
538 Name = ArkInventory.Localise["MENU_CHARACTER_SWITCH"],
539 Scripts = {
540 OnClick = function( self, button )
541 if not self then return end
542 ArkInventory.Frame_Main_Level( self:GetParent( ):GetParent( ) )
543 ArkInventory.MenuSwitchCharacterOpen( self )
544 end,
545 OnEnter = function( self )
546 ArkInventory.GameTooltipSetText( self, ArkInventory.Localise["MENU_CHARACTER_SWITCH"] )
547 end,
548 },
549 },
550 [ArkInventory.Const.ActionID.SwitchLocation] = {
551 Texture = [[Interface\Icons\INV_Helmet_47]],
552 Name = ArkInventory.Localise["MENU_LOCATION_SWITCH"],
553 Scripts = {
554 OnClick = function( self, button )
555 if not self then return end
556 ArkInventory.Frame_Main_Level( self:GetParent( ):GetParent( ) )
557 ArkInventory.MenuSwitchLocationOpen( self )
558 end,
559 OnEnter = function( self )
560 ArkInventory.GameTooltipSetText( self, ArkInventory.Localise["MENU_LOCATION_SWITCH"] )
561 end,
562 },
563 },
564 [ArkInventory.Const.ActionID.Restack] = {
565 Texture = [[Interface\Icons\Spell_Shadow_DestructiveSoul]], -- find texture used by bags-button-autosort-up
566 Name = ArkInventory.Localise["RESTACK"],
567 Scripts = {
568 OnClick = function( self, button )
569 if not self then return end
570 if button == "RightButton" then
571 ArkInventory.MenuRestackOpen( self )
572 else
573 local loc_id = self:GetParent( ):GetParent( ):GetID( )
574 ArkInventory.Restack( loc_id )
575 end
576 end,
577 OnEnter = function( self )
578 ArkInventory.GameTooltipSetText( self, ArkInventory.Localise["RESTACK"] )
579 end,
580 },
581 },
582 [ArkInventory.Const.ActionID.Changer] = {
583 Texture = [[Interface\Icons\INV_Misc_EngGizmos_17]],
584 Name = ArkInventory.Localise["MENU_ACTION_BAGCHANGER"],
585 Scripts = {
586 OnClick = function( self, button )
587 if not self then return end
588 ArkInventory.Frame_Main_Level( self:GetParent( ):GetParent( ) )
589 ArkInventory.ToggleChanger( self:GetParent( ):GetParent( ):GetID( ) )
590 end,
591 OnEnter = function( self )
592 ArkInventory.GameTooltipSetText( self, ArkInventory.Localise["MENU_ACTION_BAGCHANGER"] )
593 end,
594 },
595 },
596 [ArkInventory.Const.ActionID.Refresh] = {
597 Texture = [[Interface\Icons\Spell_Frost_Stun]],
598 Name = ArkInventory.Localise["REFRESH"],
599 Scripts = {
600 OnClick = function( self, button )
601 if not self then return end
602 ArkInventory.Frame_Main_Level( self:GetParent( ):GetParent( ) )
603 if button == "RightButton" then
604 ArkInventory.MenuRefreshOpen( self )
605 else
606 local loc_id = self:GetParent( ):GetParent( ):GetID( )
607 --ArkInventory.OutputWarning( "refresh action - .Recalculate" )
608 ArkInventory.Frame_Main_Generate( loc_id, ArkInventory.Const.Window.Draw.Recalculate )
609 end
610 end,
611 OnEnter = function( self )
612 ArkInventory.GameTooltipSetText( self, ArkInventory.Localise["REFRESH"] )
613 end,
614 },
615 },
616}
617
618ArkInventory.Const.Skills = {
619 Primary = 2,
620 Secondary = 4,
621 Data = {
622 -- primary crafting
623 [171] = {
624 id = "SKILL_ALCHEMY",
625 pt = "TradeskillResultMats.Reverse.Alchemy,Tradeskill.Tool.Alchemy",
626 text = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_ALCHEMY"],
627 },
628 [164] = {
629 id = "SKILL_BLACKSMITHING",
630 pt = "TradeskillResultMats.Reverse.Blacksmithing,Tradeskill.Tool.Blacksmithing",
631 text = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_BLACKSMITHING"],
632 },
633 [333] = {
634 id = "SKILL_ENCHANTING",
635 pt = "TradeskillResultMats.Reverse.Enchanting,Tradeskill.Tool.Enchanting",
636 text = ArkInventory.Localise["WOW_ITEM_CLASS_TRADEGOODS_ENCHANTING"],
637 },
638 [202] = {
639 id = "SKILL_ENGINEERING",
640 pt = "TradeskillResultMats.Reverse.Engineering,Tradeskill.Tool.Engineering",
641 text = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_ENGINEERING"],
642 },
643 [773] = {
644 id = "SKILL_INSCRIPTION",
645 pt = "TradeskillResultMats.Reverse.Inscription,Tradeskill.Tool.Inscription",
646 text = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_INSCRIPTION"],
647 },
648 [755] = {
649 id = "SKILL_JEWELCRAFTING",
650 pt = "TradeskillResultMats.Reverse.Jewelcrafting,Tradeskill.Tool.Jewelcrafting",
651 text = ArkInventory.Localise["WOW_ITEM_CLASS_TRADEGOODS_JEWELCRAFTING"],
652 },
653 [165] = {
654 id = "SKILL_LEATHERWORKING",
655 pt = "TradeskillResultMats.Reverse.Leatherworking,Tradeskill.Tool.Leatherworking",
656 text = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_LEATHERWORKING"],
657 },
658 [197] = {
659 id = "SKILL_TAILORING",
660 pt = "TradeskillResultMats.Reverse.Tailoring,Tradeskill.Tool.Tailoring",
661 text = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_TAILORING"],
662 },
663 -- primary collecting
664 [182] = {
665 id = "SKILL_HERBALISM",
666 pt = "Tradeskill.Mat.ByType.Herb",
667 text = ArkInventory.Localise["WOW_SKILL_HERBALISM"],
668 },
669 [186] = {
670 id = "SKILL_MINING",
671 pt = "Tradeskill.Tool.Mining,TradeskillResultMats.Forward.Smelting,TradeskillResultMats.Reverse.Smelting",
672 text = ArkInventory.Localise["WOW_SKILL_MINING"],
673 },
674 [393] = {
675 id = "SKILL_SKINNING",
676 pt = "Tradeskill.Tool.Skinning,Tradeskill.Mat.ByType.Leather",
677 text = ArkInventory.Localise["WOW_SKILL_SKINNING"],
678 },
679 -- secondary
680 [794] = {
681 id = "SKILL_ARCHAEOLOGY",
682 pt = "Tradeskill.Mat.ByType.Keystone",
683 text = ArkInventory.Localise["WOW_SKILL_ARCHAEOLOGY"],
684 },
685 [185] = {
686 id = "SKILL_COOKING",
687 pr = "TradeskillResultMats.Reverse.Cooking",
688 text = ArkInventory.Localise["WOW_SKILL_COOKING"],
689 },
690 [129] = {
691 id = "FIRST_AID",
692 pt = "TradeskillResultMats.Forward.First Aid",
693 text = ArkInventory.Localise["WOW_SKILL_FIRSTAID"],
694 },
695 [356] = {
696 id = "SKILL_FISHING",
697 pt = "Tradeskill.Tool.Fishing",
698 text = ArkInventory.Localise["WOW_SKILL_FISHING"],
699 },
700 },
701}
702
703ArkInventory.Const.Slot.Data = {
704 [ArkInventory.Const.Slot.Type.Unknown] = {
705 ["name"] = ArkInventory.Localise["UNKNOWN"],
706 ["long"] = ArkInventory.Localise["UNKNOWN"],
707 ["type"] = ArkInventory.Localise["UNKNOWN"],
708 },
709 [ArkInventory.Const.Slot.Type.Bag] = {
710 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_BAG"],
711 ["long"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_BAG"],
712 ["type"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_BAG"],
713 },
714 [ArkInventory.Const.Slot.Type.Herb] = {
715 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_HERB"],
716 ["long"] = ArkInventory.Localise["WOW_SKILL_HERBALISM"],
717 ["type"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_HERB"],
718 },
719 [ArkInventory.Const.Slot.Type.Enchanting] = {
720 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_ENCHANTING"],
721 ["long"] = ArkInventory.Localise["WOW_ITEM_CLASS_TRADEGOODS_ENCHANTING"],
722 ["type"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_ENCHANTING"],
723 },
724 [ArkInventory.Const.Slot.Type.Engineering] = {
725 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_ENGINEERING"],
726 ["long"] = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_ENGINEERING"],
727 ["type"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_ENGINEERING"],
728 },
729 [ArkInventory.Const.Slot.Type.Gem] = {
730 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_GEM"],
731 ["long"] = ArkInventory.Localise["WOW_ITEM_CLASS_GEM"],
732 ["type"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_GEM"],
733 },
734 [ArkInventory.Const.Slot.Type.Mining] = {
735 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_MINING"],
736 ["long"] = ArkInventory.Localise["WOW_SKILL_MINING"],
737 ["type"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_MINING"],
738 },
739 [ArkInventory.Const.Slot.Type.Leatherworking] = {
740 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_LEATHERWORKING"],
741 ["long"] = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_LEATHERWORKING"],
742 ["type"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_LEATHERWORKING"],
743 },
744 [ArkInventory.Const.Slot.Type.Inscription] = {
745 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_INSCRIPTION"],
746 ["long"] = ArkInventory.Localise["WOW_ITEM_CLASS_RECIPE_INSCRIPTION"],
747 ["type"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_INSCRIPTION"],
748 },
749 [ArkInventory.Const.Slot.Type.Wearing] = {
750 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_GEAR"],
751 ["long"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_BAG"],
752 ["type"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_BAG"],
753 ["hide"] = true,
754 },
755 [ArkInventory.Const.Slot.Type.Mail] = {
756 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_MAIL"],
757 ["long"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_BAG"],
758 ["type"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_BAG"],
759 ["hide"] = true,
760 },
761 [ArkInventory.Const.Slot.Type.Critter] = {
762 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_CRITTER"],
763 ["long"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_BAG"],
764 ["type"] = ArkInventory.Localise["PET"],
765 ["hide"] = true,
766 },
767 [ArkInventory.Const.Slot.Type.Mount] = {
768 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_MOUNT"],
769 ["long"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_BAG"],
770 ["type"] = ArkInventory.Localise["WOW_ITEM_CLASS_MISC_MOUNT"],
771 ["hide"] = true,
772 },
773 [ArkInventory.Const.Slot.Type.Toybox] = {
774 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_TOY"],
775 ["long"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_BAG"],
776 ["type"] = ArkInventory.Localise["TOY"],
777 ["hide"] = true,
778 },
779 [ArkInventory.Const.Slot.Type.Heirloom] = {
780 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_HEIRLOOM"],
781 ["long"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_BAG"],
782 ["type"] = ArkInventory.Localise["HEIRLOOM"],
783 ["hide"] = true,
784 },
785 [ArkInventory.Const.Slot.Type.Token] = {
786 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_TOKEN"],
787 ["long"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_BAG"],
788 ["type"] = ArkInventory.Localise["CURRENCY"],
789 ["hide"] = true,
790 },
791 [ArkInventory.Const.Slot.Type.Auction] = {
792 ["name"] = AUCTIONS,
793 ["long"] = AUCTIONS,
794 ["type"] = AUCTIONS,
795 ["hide"] = true,
796 },
797 [ArkInventory.Const.Slot.Type.Tackle] = {
798 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_TACKLE"],
799 ["long"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_FISHING"],
800 ["type"] = ArkInventory.Localise["WOW_ITEM_CLASS_CONTAINER_FISHING"],
801 },
802 [ArkInventory.Const.Slot.Type.Void] = {
803 ["name"] = ArkInventory.Localise["VOIDSTORAGE"],
804 ["long"] = ArkInventory.Localise["VOIDSTORAGE"],
805 ["type"] = ArkInventory.Localise["VOIDSTORAGE"],
806 ["texture"] = [[Interface\AddOns\ArkInventory\Images\VoidStorageSlot.tga]],
807 },
808 [ArkInventory.Const.Slot.Type.Cooking] = {
809 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_COOKING"],
810 ["long"] = ArkInventory.Localise["WOW_SKILL_COOKING"],
811 ["type"] = ArkInventory.Localise["WOW_SKILL_COOKING"],
812 },
813 [ArkInventory.Const.Slot.Type.ReagentBank] = {
814 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_REAGENTBANK"],
815 ["long"] = ArkInventory.Localise["REAGENTBANK"],
816 ["type"] = ArkInventory.Localise["REAGENTBANK"],
817 --["texture"] = [[Interface\Paperdoll\UI-PaperDoll-Slot-Relic]],
818 },
819 [ArkInventory.Const.Slot.Type.Reputation] = {
820 ["name"] = ArkInventory.Localise["STATUS_SHORTNAME_REPUTATION"],
821 ["long"] = ArkInventory.Localise["REPUTATION"],
822 ["type"] = ArkInventory.Localise["REPUTATION"],
823 },
824}
825
826ArkInventory.Const.AnchorText = {
827
828}
829
830ArkInventory.Global = { -- globals
831
832 Enabled = false,
833
834 Version = "", --calculated
835
836 Me = {
837 -- this will always point to the current characters data
838 data = nil,
839 },
840
841 Mode = {
842 Bank = false,
843 Vault = false,
844 Mail = false,
845 Merchant = false,
846 Auction = false,
847 Void = false,
848
849 Edit = false,
850 Combat = false,
851 },
852
853 LeaveCombatRun = { }, -- [loc_id] = true
854
855 Tooltip = {
856 Scan = nil,
857 WOW = {
858 GameTooltip,
859 ShoppingTooltip1,
860 ShoppingTooltip2,
861 ItemRefTooltip,
862 ItemRefShoppingTooltip1,
863 ItemRefShoppingTooltip2,
864 WorldMapCompareTooltip1,
865 WorldMapCompareTooltip2,
866 },
867 },
868
869 Category = { }, -- see CategoryGenerate( ) for how this gets populated
870
871 Location = {
872
873 [ArkInventory.Const.Location.Bag] = {
874 id = ArkInventory.Const.Location.Bag,
875 isActive = true,
876 Internal = "bag",
877 Name = ArkInventory.Localise["BACKPACK"],
878 Texture = [[Interface\Icons\INV_Misc_Bag_07_Green]],
879 bagCount = 1, -- actual value set in OnLoad
880 Bags = { },
881 canRestack = true,
882 hasChanger = true,
883 canSearch = true,
884
885 maxBar = 0,
886 maxSlot = { },
887
888 isOffline = false,
889 canView = true,
890 canOverride = true,
891
892 template = "ARKINV_TemplateButtonItem",
893
894 drawState = ArkInventory.Const.Window.Draw.Init,
895 },
896
897 [ArkInventory.Const.Location.Bank] = {
898 id = ArkInventory.Const.Location.Bank,
899 isActive = true,
900 Internal = "bank",
901 Name = ArkInventory.Localise["BANK"],
902 Texture = [[Interface\Icons\INV_Box_02]],
903 bagCount = 1, -- set in OnLoad
904 Bags = { },
905 canRestack = true,
906 hasChanger = true,
907 canSearch = true,
908
909 maxBar = 0,
910 maxSlot = { },
911
912 isOffline = true,
913 canView = true,
914 canOverride = true,
915 canPurge = true,
916
917 tabReagent = nil, -- set in OnLoad
918
919 template = "ARKINV_TemplateButtonItem",
920
921 drawState = ArkInventory.Const.Window.Draw.Init,
922 },
923
924 [ArkInventory.Const.Location.Vault] = {
925 id = ArkInventory.Const.Location.Vault,
926 isActive = true,
927 Internal = "vault",
928 Name = ArkInventory.Localise["VAULT"],
929 --Texture = [[Interface\Icons\INV_Misc_Coin_02]],
930 --Texture = [[Interface\ICONS\INV_Misc_Gem_Topaz_01]],
931 Texture = [[Interface\ICONS\INV_Trinket_80_Titan02d]],
932 bagCount = 1, -- actual value set in OnLoad
933 Bags = { },
934 canRestack = true,
935 hasChanger = true,
936 canSearch = true,
937 isVault = true,
938
939 maxBar = 0,
940 maxSlot = { },
941
942 isOffline = true,
943 canView = true,
944 canOverride = true,
945 canPurge = true,
946
947 template = "ARKINV_TemplateButtonVaultItem",
948
949 drawState = ArkInventory.Const.Window.Draw.Init,
950
951 view_tab = 1,
952 view_mode = "bank",
953 view_load = true,
954
955 },
956
957 [ArkInventory.Const.Location.Mail] = {
958 id = ArkInventory.Const.Location.Mail,
959 isActive = true,
960 Internal = "mail",
961 Name = ArkInventory.Localise["MAILBOX"],
962 --Texture = [[Interface\Icons\INV_Letter_01]]
963 Texture = [[Interface\Minimap\Tracking\Mailbox]],
964 bagCount = 1,
965 Bags = { },
966 canRestack = nil,
967 hasChanger = nil,
968 canSearch = true,
969
970 maxBar = 0,
971 maxSlot = { },
972
973 isOffline = true,
974 canView = true,
975 canOverride = nil,
976 canPurge = true,
977
978 template = "ARKINV_TemplateButtonMailItem",
979
980 drawState = ArkInventory.Const.Window.Draw.Init,
981 },
982
983 [ArkInventory.Const.Location.Wearing] = {
984 id = ArkInventory.Const.Location.Wearing,
985 isActive = true,
986 Internal = "wearing",
987 Name = ArkInventory.Localise["LOCATION_WEARING"],
988 --Texture = [[Interface\Icons\INV_Boots_05]],
989 Texture = [[Interface\ICONS\INV_OrderHall_ArmamentupgradeBlue]],
990 bagCount = 1,
991 Bags = { },
992 canRestack = nil,
993 hasChanger = nil,
994 canSearch = true,
995
996 maxBar = 0,
997 maxSlot = { },
998
999 isOffline = false,
1000 canView = true,
1001 canOverride = nil,
1002
1003 drawState = ArkInventory.Const.Window.Draw.Init,
1004 },
1005
1006 [ArkInventory.Const.Location.Pet] = {
1007 id = ArkInventory.Const.Location.Pet,
1008 isAccount = true,
1009 isActive = true,
1010 Internal = "pet",
1011 Name = ArkInventory.Localise["PET"],
1012 --Texture = [[Interface\Icons\PetJournalPortrait]],
1013 Texture = [[Interface\ICONS\INV_Misc_FireKitty]],
1014 bagCount = 1,
1015 Bags = { },
1016 canRestack = nil,
1017 hasChanger = nil,
1018 canSearch = true,
1019
1020 maxBar = 0,
1021 maxSlot = { },
1022
1023 isOffline = false,
1024 canView = true,
1025 canOverride = nil,
1026 canPurge = true,
1027
1028 template = "ARKINV_TemplateButtonBattlepetItem",
1029
1030 drawState = ArkInventory.Const.Window.Draw.Init,
1031
1032 },
1033
1034 [ArkInventory.Const.Location.Mount] = {
1035 id = ArkInventory.Const.Location.Mount,
1036 isAccount = true,
1037 isActive = true,
1038 Internal = "mount",
1039 Name = ArkInventory.Localise["MOUNT"],
1040 Texture = [[Interface\Icons\MountJournalPortrait]],
1041 bagCount = 1,
1042 Bags = { },
1043 canRestack = nil,
1044 hasChanger = nil,
1045 canSearch = true,
1046
1047 maxBar = 0,
1048 maxSlot = { },
1049
1050 isOffline = false,
1051 canView = true,
1052 canOverride = nil,
1053 canPurge = true,
1054
1055 template = "ARKINV_TemplateButtonMountItem",
1056
1057 drawState = ArkInventory.Const.Window.Draw.Init,
1058
1059 },
1060
1061 [ArkInventory.Const.Location.Toybox] = {
1062 id = ArkInventory.Const.Location.Toybox,
1063 isAccount = true,
1064 isActive = true,
1065 Internal = "toybox",
1066 Name = ArkInventory.Localise["TOYBOX"],
1067 --Texture = [[Interface\Icons\Trade_Archaeology_ChestofTinyGlassAnimals]],
1068 Texture = [[Interface\ICONS\INV_Misc_Toy_02]],
1069 bagCount = 1,
1070 Bags = { },
1071 canRestack = nil,
1072 hasChanger = nil,
1073 canSearch = true,
1074
1075 maxBar = 0,
1076 maxSlot = { },
1077
1078 isOffline = false,
1079 canView = true,
1080 canOverride = nil,
1081 canPurge = true,
1082
1083 template = "ARKINV_TemplateButtonToyboxItem",
1084
1085 drawState = ArkInventory.Const.Window.Draw.Init,
1086
1087 },
1088
1089 [ArkInventory.Const.Location.Heirloom] = {
1090 id = ArkInventory.Const.Location.Heirloom,
1091 isAccount = true,
1092 isActive = true,
1093 Internal = "heirloom",
1094 Name = ArkInventory.Localise["HEIRLOOM"],
1095 Texture = [[Interface\Icons\inv_misc_enggizmos_19]],
1096 --Texture = [[Interface\ICONS\Spell_Shadow_LastingAfflictions]],
1097 bagCount = 1,
1098 Bags = { },
1099 canRestack = nil,
1100 hasChanger = nil,
1101 canSearch = true,
1102
1103 maxBar = 0,
1104 maxSlot = { },
1105
1106 isOffline = false,
1107 canView = true,
1108 canOverride = nil,
1109
1110 --template = "ARKINV_TemplateButtonHeirloomItem",
1111
1112 drawState = ArkInventory.Const.Window.Draw.Init,
1113
1114 },
1115
1116 [ArkInventory.Const.Location.Token] = {
1117 id = ArkInventory.Const.Location.Token,
1118 isActive = true,
1119 Internal = "token",
1120 Name = ArkInventory.Localise["CURRENCY"],
1121 --Texture = [[Interface\ICONS\Spell_Holy_ChampionsBond]],
1122 --Texture = [[Interface\ICONS\ABILITY_Rogue_RollTheBones05]],
1123 Texture = [[Interface\ICONS\inv_misc_coinbag_special]],
1124 bagCount = 1,
1125 Bags = { },
1126 canRestack = nil,
1127 hasChanger = nil,
1128 canSearch = true,
1129
1130 maxBar = 0,
1131 maxSlot = { },
1132
1133 isOffline = false,
1134 canView = true,
1135 canOverride = nil,
1136
1137 drawState = ArkInventory.Const.Window.Draw.Init,
1138 },
1139
1140 [ArkInventory.Const.Location.Auction] = {
1141 id = ArkInventory.Const.Location.Auction,
1142 isActive = false,
1143 Internal = "auction",
1144 Name = AUCTIONS,
1145 --Texture = [[Interface\Minimap\Tracking\Auctioneer]],
1146 Texture = [[Interface\ICONS\INV_Misc_Coin_04]],
1147 bagCount = 1,
1148 Bags = { },
1149 canRestack = nil,
1150 hasChanger = nil,
1151 canSearch = true,
1152
1153 maxBar = 0,
1154 maxSlot = { },
1155
1156 isOffline = true,
1157 canView = true,
1158 canOverride = nil,
1159 canPurge = true,
1160
1161 drawState = ArkInventory.Const.Window.Draw.Init,
1162 },
1163
1164 [ArkInventory.Const.Location.Void] = {
1165 id = ArkInventory.Const.Location.Void,
1166 isActive = true,
1167 Internal = "void",
1168 Name = ArkInventory.Localise["VOIDSTORAGE"],
1169 Texture = [[Interface\Icons\Spell_Nature_AstralRecalGroup]],
1170 bagCount = 1,
1171 Bags = { },
1172 canRestack = nil,
1173 hasChanger = nil,
1174 canSearch = true,
1175
1176 maxBar = 0,
1177 maxSlot = { },
1178
1179 isOffline = true,
1180 canView = true,
1181 canOverride = nil,
1182 canPurge = true,
1183
1184 drawState = ArkInventory.Const.Window.Draw.Init,
1185 },
1186
1187 [ArkInventory.Const.Location.Reputation] = {
1188 id = ArkInventory.Const.Location.Reputation,
1189 isActive = true,
1190 Internal = "reputation",
1191 Name = ArkInventory.Localise["REPUTATION"],
1192 Texture = [[Interface\ICONS\Raf-Icon]], --Ability_PVP_DefenderoftheWeak
1193 bagCount = 1,
1194 Bags = { },
1195 canRestack = nil,
1196 hasChanger = nil,
1197 canSearch = true,
1198
1199 maxBar = 0,
1200 maxSlot = { },
1201
1202 isOffline = false,
1203 canView = true,
1204 canOverride = nil,
1205 canPurge = true,
1206
1207 drawState = ArkInventory.Const.Window.Draw.Init,
1208
1209 },
1210 },
1211
1212 Cache = {
1213
1214 ItemCountRaw = { }, -- key generated via ObjectIDCount( )
1215 ItemCountTooltip = { }, -- key generated via ObjectIDCount( )
1216 ItemSearchData = { }, -- key generated via ObjectIDCount( )
1217 StackCompress = { }, -- key generated via ObjectIDCount( )
1218
1219 SentMail = { }, -- keeps track of any sent mail to other characters you have
1220
1221 BlizzardBagIdToInternalId = { },
1222
1223 },
1224
1225 Thread = {
1226-- Use = false, -- !!! comment out when done testing
1227 Use = true,
1228 WindowState = { },
1229 data = { },
1230 Format = {
1231 Force = "*",
1232 --Restack = "p1-restack-%s",
1233 Restack = "p1-restack",
1234 Collection = "p2-scan-%s",
1235 Scan = "p3-scan-%s-%s",
1236 Window = "p4-draw-%s",
1237 LDB = "p5-ldb-%s",
1238 Tooltip = "p9-tooltip",
1239 JunkSell = "p9-junksell",
1240 },
1241 },
1242
1243 Options = {
1244
1245 Location = ArkInventory.Const.Location.Bag,
1246 ShowHiddenItems = false,
1247
1248 ConfigSortMethodListSort = 1,
1249 ConfigSortMethodListShow = 1,
1250 ConfigCategoryCustomListSort = 1,
1251 ConfigCategoryCustomListShow = 1,
1252 ConfigCategoryRuleListSort = 1,
1253 ConfigCategoryRuleListShow = 1,
1254 ConfigCategoryRuleListSet = 9999,
1255 ConfigCategorysetListSort = 1,
1256 ConfigCategorysetListShow = 1,
1257 ConfigDesignListSort = 1,
1258 ConfigDesignListShow = 1,
1259 ConfigProfileListSort = 1,
1260 ConfigProfileListShow = 1,
1261
1262 SortKeyBagAssignmentSort = true,
1263 BarMoveSource = nil,
1264 BarMoveDestination = nil,
1265
1266 },
1267
1268 Rules = {
1269 Enabled = false, -- change this to module check
1270 },
1271
1272 NewItemResetTime = nil,
1273
1274 Junk = {
1275 run = false,
1276 sold = 0,
1277 destroyed = 0,
1278 money = 0,
1279 },
1280
1281}
1282
1283ArkInventory.Config = {
1284 Internal = {
1285 type = "group",
1286 childGroups = "tree",
1287 name = ArkInventory.Const.Program.Name,
1288 },
1289 Blizzard = {
1290 type = "group",
1291 childGroups = "tree",
1292 name = ArkInventory.Const.Program.Name,
1293 },
1294}
1295
1296ArkInventory.Collection = { }
1297
1298
1299-- Binding Variables
1300BINDING_HEADER_ARKINV = ArkInventory.Const.Program.Name
1301BINDING_NAME_ARKINV_TOGGLE_BAG = ArkInventory.Localise["BACKPACK"]
1302BINDING_NAME_ARKINV_TOGGLE_BANK = ArkInventory.Localise["BANK"]
1303BINDING_NAME_ARKINV_TOGGLE_VAULT = ArkInventory.Localise["VAULT"]
1304BINDING_NAME_ARKINV_TOGGLE_MAIL = ArkInventory.Localise["MAILBOX"]
1305BINDING_NAME_ARKINV_TOGGLE_WEARING = ArkInventory.Localise["LOCATION_WEARING"]
1306BINDING_NAME_ARKINV_TOGGLE_PET = ArkInventory.Localise["PET"]
1307BINDING_NAME_ARKINV_TOGGLE_MOUNT = ArkInventory.Localise["MOUNT"]
1308BINDING_NAME_ARKINV_TOGGLE_TOYBOX = ArkInventory.Localise["TOYBOX"]
1309BINDING_NAME_ARKINV_TOGGLE_HEIRLOOM = ArkInventory.Localise["HEIRLOOM"]
1310BINDING_NAME_ARKINV_TOGGLE_TOKEN = ArkInventory.Localise["CURRENCY"]
1311BINDING_NAME_ARKINV_TOGGLE_VOID = ArkInventory.Localise["VOIDSTORAGE"]
1312BINDING_NAME_ARKINV_TOGGLE_EDIT = ArkInventory.Localise["MENU_ACTION_EDITMODE"]
1313BINDING_NAME_ARKINV_TOGGLE_RULES = ArkInventory.Localise["CONFIG_RULE_PLURAL"]
1314BINDING_NAME_ARKINV_TOGGLE_SEARCH = ArkInventory.Localise["SEARCH"]
1315BINDING_NAME_ARKINV_REFRESH = ArkInventory.Localise["REFRESH"]
1316BINDING_NAME_ARKINV_RELOAD = ArkInventory.Localise["RELOAD"]
1317BINDING_NAME_ARKINV_RESTACK = ArkInventory.Localise["RESTACK"]
1318BINDING_NAME_ARKINV_MENU = ArkInventory.Localise["MENU"]
1319BINDING_NAME_ARKINV_CONFIG = ArkInventory.Localise["CONFIG_TEXT"]
1320BINDING_NAME_ARKINV_LDB_PETS_SUMMON = ArkInventory.Localise["LDB_PETS_SUMMON"]
1321_G["BINDING_NAME_CLICK ARKINV_MountToggle:LeftButton"] = ArkInventory.Localise["LDB_MOUNTS_SUMMON"]
1322
1323
1324ArkInventory.Const.DatabaseDefaults.global = {
1325 ["option"] = {
1326 ["version"] = 0,
1327 ["auto"] = {
1328 ["open"] = {
1329 ["*"] = true,
1330 },
1331 ["close"] = {
1332 ["*"] = true,
1333 },
1334 ["reposition"] = true,
1335 },
1336 ["design"] = { -- layout and style data
1337 ["data"] = {
1338 ["**"] = {
1339 ["system"] = false,
1340 ["used"] = "N", -- Y(es) | N(o) | D(eleted)
1341 ["name"] = "",
1342
1343 -- ** style **
1344 ["font"] = {
1345 ["custom"] = false,
1346 ["face"] = ArkInventory.Const.Font.Face,
1347 ["height"] = ArkInventory.Const.Font.Height,
1348 },
1349 ["window"] = {
1350 ["scale"] = 1,
1351 ["width"] = 16,
1352 ["height"] = 800,
1353 ["border"] = {
1354 ["style"] = ArkInventory.Const.Texture.BorderDefault,
1355 ["size"] = nil,
1356 ["offset"] = nil,
1357 ["scale"] = 1,
1358 ["colour"] = {
1359 ["r"] = 1,
1360 ["g"] = 1,
1361 ["b"] = 1,
1362 },
1363 },
1364 ["pad"] = 8,
1365 ["background"] = {
1366 ["style"] = ArkInventory.Const.Texture.BackgroundDefault,
1367 ["colour"] = {
1368 ["r"] = 0,
1369 ["g"] = 0,
1370 ["b"] = 0,
1371 ["a"] = 0.75,
1372 },
1373 },
1374 ["strata"] = "MEDIUM",
1375 ["list"] = false,
1376 },
1377 ["bar"] = {
1378 ["per"] = 5,
1379 ["pad"] = {
1380 ["internal"] = 8,
1381 ["external"] = 8,
1382 },
1383 ["border"] = {
1384 ["style"] = ArkInventory.Const.Texture.BorderDefault,
1385 ["size"] = nil,
1386 ["offset"] = nil,
1387 ["scale"] = 1,
1388 ["colour"] = {
1389 ["r"] = 0.3,
1390 ["g"] = 0.3,
1391 ["b"] = 0.3,
1392 },
1393 },
1394 ["background"] = {
1395 ["colour"] = {
1396 ["r"] = 0,
1397 ["g"] = 0,
1398 ["b"] = 0.4,
1399 ["a"] = 0.4,
1400 },
1401 },
1402 ["showempty"] = false,
1403 ["anchor"] = ArkInventory.Const.Anchor.BottomRight,
1404 ["compact"] = false,
1405 ["hide"] = false,
1406 ["name"] = {
1407 ["show"] = false,
1408 ["colour"] = {
1409 ["r"] = 1,
1410 ["b"] = 1,
1411 ["g"] = 1,
1412 },
1413 ["height"] = ArkInventory.Const.Font.Height,
1414 ["justify"] = ArkInventory.Const.Anchor.Left,
1415 ["anchor"] = ArkInventory.Const.Anchor.Default,
1416 },
1417 ["data"] = { -- ** layout **
1418 ["*"] = {
1419 ["sort"] = {
1420 ["method"] = nil,
1421 },
1422 ["border"] = {
1423 ["custom"] = 1, -- 1 = default, 2 = custom
1424 ["colour"] = {
1425 ["r"] = 0.3,
1426 ["g"] = 0.3,
1427 ["b"] = 0.3,
1428 },
1429 },
1430 ["background"] = {
1431 ["custom"] = 1, -- 1 = default, 2 = custom, 3 = border
1432 ["colour"] = {
1433 ["r"] = 0,
1434 ["g"] = 0,
1435 ["b"] = 0.4,
1436 ["a"] = 0.4,
1437 },
1438 },
1439 ["name"] = {
1440 ["text"] = "",
1441 ["custom"] = 1, -- 1 = default, 2 = custom
1442 ["colour"] = {
1443 ["r"] = 1,
1444 ["g"] = 1,
1445 ["b"] = 1,
1446 },
1447 },
1448 ["width"] = {
1449 ["min"] = nil,
1450 ["max"] = nil,
1451 },
1452 },
1453 },
1454 },
1455 ["slot"] = {
1456 ["empty"] = {
1457 ["alpha"] = 1,
1458 ["icon"] = true,
1459 ["border"] = true,
1460 ["first"] = 0,
1461 ["clump"] = false,
1462 ["position"] = true,
1463 },
1464 ["data"] = { -- slot type data
1465 ["**"] = {
1466 ["colour"] = { r = 0.30, g = 0.30, b = 0.30 },
1467 },
1468 [ArkInventory.Const.Slot.Type.Unknown] = {
1469 ["colour"] = { r = 1.00, g = 0.00, b = 0.00 },
1470 },
1471 [ArkInventory.Const.Slot.Type.Herb] = {
1472 ["colour"] = { r = 0.00, g = 1.00, b = 0.00 },
1473 },
1474 [ArkInventory.Const.Slot.Type.Enchanting] = {
1475 ["colour"] = { r = 0.06, g = 0.88, b = 0.93 },
1476 },
1477 [ArkInventory.Const.Slot.Type.Engineering] = {
1478 ["colour"] = { r = 0.61, g = 0.74, b = 0.29 },
1479 },
1480 [ArkInventory.Const.Slot.Type.Gem] = {
1481 ["colour"] = { r = 0.63, g = 0.00, b = 0.56 },
1482 },
1483 [ArkInventory.Const.Slot.Type.Mining] = {
1484 ["colour"] = { r = 0.79, g = 0.79, b = 0.00 },
1485 },
1486 [ArkInventory.Const.Slot.Type.Leatherworking] = {
1487 ["colour"] = { r = 0.63, g = 0.45, b = 0.10 },
1488 },
1489 [ArkInventory.Const.Slot.Type.Inscription] = {
1490 ["colour"] = { r = 0.46, g = 0.67, b = 0.63 },
1491 },
1492 [ArkInventory.Const.Slot.Type.Tackle] = {
1493 ["colour"] = { r = 0.12, g = 0.56, b = 0.42 },
1494 },
1495 [ArkInventory.Const.Slot.Type.ReagentBank] = {
1496 ["colour"] = { r = 0.10, g = 0.30, b = 1.00 },
1497 },
1498 },
1499 ["pad"] = 4,
1500 ["border"] = {
1501 ["style"] = ArkInventory.Const.Texture.BorderDefault,
1502 ["size"] = nil,
1503 ["offset"] = nil,
1504 ["scale"] = 1,
1505 ["rarity"] = true,
1506 ["raritycutoff"] = LE_ITEM_QUALITY_POOR,
1507 },
1508 ["anchor"] = ArkInventory.Const.Anchor.BottomRight,
1509 ["age"] = {
1510 ["show"] = false,
1511 ["colour"] = {
1512 ["r"] = 1,
1513 ["g"] = 1,
1514 ["b"] = 1,
1515 },
1516 ["cutoff"] = 0,
1517 ["font"] = {
1518 ["height"] = ArkInventory.Const.Font.Height,
1519 },
1520 },
1521 ["offline"] = {
1522 ["fade"] = true,
1523 },
1524 ["unusable"] = {
1525 ["tint"] = false,
1526 },
1527 ["cooldown"] = {
1528 ["show"] = true,
1529 ["global"] = false,
1530 ["combat"] = true,
1531 },
1532 ["scale"] = 1,
1533 ["itemlevel"] = {
1534 ["show"] = false,
1535 ["anchor"] = ArkInventory.Const.Anchor.Default,
1536 ["min"] = 1,
1537 ["colour"] = {
1538 ["r"] = 1,
1539 ["g"] = 0.82,
1540 ["b"] = 0,
1541 },
1542 ["font"] = {
1543 ["height"] = ArkInventory.Const.Font.Height,
1544 },
1545 },
1546 ["itemcount"] = {
1547 ["show"] = true,
1548 ["anchor"] = ArkInventory.Const.Anchor.Default,
1549 ["colour"] = {
1550 ["r"] = 1,
1551 ["g"] = 1,
1552 ["b"] = 1,
1553 },
1554 ["font"] = {
1555 ["height"] = ArkInventory.Const.Font.Height,
1556 },
1557 },
1558 ["new"] = {
1559 ["enable"] = false,
1560 ["cutoff"] = 2,
1561 },
1562 ["compress"] = {
1563 ["count"] = 0,
1564 ["identify"] = false,
1565 ["position"] = 1,
1566 },
1567-- ["upgrade"] = true, -- need to remove from saved data
1568 ["upgradeicon"] = {
1569 ["show"] = true,
1570 ["anchor"] = ArkInventory.Const.Anchor.Default,
1571 },
1572 ["junkicon"] = {
1573 ["show"] = false,
1574 ["anchor"] = ArkInventory.Const.Anchor.Default,
1575 ["merchant"] = true,
1576 },
1577 ["transmogicon"] = {
1578 ["show"] = true,
1579 ["anchor"] = ArkInventory.Const.Anchor.Default,
1580 ["alternative"] = true,
1581 },
1582 ["size"] = ArkInventory.Const.SLOT_SIZE,
1583 ["quest"] = {
1584 ["bang"] = true,
1585 ["border"] = true,
1586 },
1587 },
1588 ["title"] = {
1589 ["hide"] = false,
1590 ["size"] = 1,
1591 ["colour"] = {
1592 ["online"] = {
1593 ["r"] = 0,
1594 ["g"] = 1,
1595 ["b"] = 0,
1596 },
1597 ["offline"] = {
1598 ["r"] = 1,
1599 ["g"] = 0,
1600 ["b"] = 0,
1601 },
1602 },
1603 ["font"] = {
1604 ["height"] = 20,
1605 },
1606 },
1607 ["search"] = {
1608 ["hide"] = false,
1609 ["label"] = {
1610 ["colour"] = {
1611 ["r"] = 0,
1612 ["g"] = 1,
1613 ["b"] = 0,
1614 },
1615 },
1616 ["text"] = {
1617 ["colour"] = {
1618 ["r"] = 1,
1619 ["g"] = 1,
1620 ["b"] = 1,
1621 },
1622 },
1623 ["font"] = {
1624 ["height"] = 12,
1625 },
1626 },
1627 ["changer"] = {
1628 ["hide"] = false,
1629 ["highlight"] = {
1630 ["show"] = true,
1631 ["colour"] = {
1632 ["r"] = 0,
1633 ["g"] = 1,
1634 ["b"] = 0,
1635 },
1636 },
1637 ["freespace"] = {
1638 ["show"] = true,
1639 ["colour"] = {
1640 ["r"] = 1,
1641 ["g"] = 1,
1642 ["b"] = 1,
1643 },
1644 },
1645 ["font"] = {
1646 ["height"] = 20,
1647 },
1648 },
1649 ["status"] = {
1650 ["hide"] = false,
1651 ["emptytext"] = { -- slot>empty>display
1652 ["show"] = true,
1653 ["colour"] = false,
1654 ["full"] = true,
1655 ["includetype"] = true,
1656 },
1657 ["font"] = {
1658 ["height"] = 16,
1659 },
1660 },
1661 ["sort"] = {
1662 ["when"] = ArkInventory.Const.SortWhen.Open,
1663 ["method"] = 9999, -- the default sort method for this layout
1664 },
1665
1666 -- ** layout **
1667 ["bag"] = {
1668 ["*"] = { -- [bag_id]
1669 ["bar"] = nil, -- bar number to put all bag slots on
1670 },
1671 },
1672 ["category"] = {
1673 ["*"] = nil, -- [category number] = bar number to put it on
1674 },
1675 },
1676 [9999] = {
1677 ["system"] = true,
1678 ["used"] = "Y",
1679 ["name"] = ArkInventory.Localise["DEFAULT"],
1680 },
1681 [9998] = {
1682 ["system"] = true,
1683 ["used"] = "Y",
1684 ["name"] = ArkInventory.Localise["VAULT"],
1685 ["window"] = {
1686 ["width"] = NUM_SLOTS_PER_GUILDBANK_GROUP,
1687 },
1688 ["sort"] = {
1689 ["method"] = 9995,
1690 },
1691 },
1692 [9997] = {
1693 ["system"] = true,
1694 ["used"] = "Y",
1695 ["name"] = "List",
1696 ["window"] = {
1697 ["list"] = true,
1698 ["width"] = 10,
1699 },
1700 ["bar"] = {
1701 ["per"] = 1,
1702 ["data"] = {
1703 [1] = {
1704 ["width"] = {
1705 ["max"] = 1,
1706 },
1707 },
1708 },
1709 },
1710 ["slot"] = {
1711 ["anchor"] = ArkInventory.Const.Anchor.BottomLeft,
1712 },
1713 ["changer"] = {
1714 ["hide"] = true,
1715 },
1716 ["status"] = {
1717 ["hide"] = true,
1718 },
1719 ["sort"] = {
1720 ["method"] = 9993,
1721 },
1722 },
1723 [1000] = {
1724 ["system"] = false,
1725 ["used"] = "Y",
1726 ["name"] = ArkInventory.Localise["DEFAULT"],
1727 },
1728 },
1729 ["min"] = 1000,
1730 ["next"] = 1000,
1731 ["max"] = 8999,
1732 },
1733 ["category"] = {
1734 ["**"] = {
1735--[[
1736 see ArkInventory.Const.Category.Type
1737 -- System = 1,
1738 -- Custom = 2,
1739 -- Rule = 3,
1740]]--
1741 ["data"] = {
1742 ["**"] = { -- [number] = { data }
1743 ["system"] = false,
1744 ["used"] = "N", -- Y(es) | N(o) | D(eleted)
1745 ["name"] = "",
1746 -- rules
1747 ["order"] = 1000,
1748 ["formula"] = "false",
1749 ["damaged"] = false,
1750 },
1751 },
1752 ["min"] = 1000,
1753 ["next"] = 1000,
1754 ["max"] = 8999,
1755 },
1756 },
1757 ["catset"] = { -- category sets
1758 ["data"] = {
1759 ["**"] = {
1760 ["system"] = false,
1761 ["used"] = "N", -- Y(es) | N(o) | D(eleted)
1762 ["name"] = "",
1763 ["category"] = {
1764 ["assign"] = {
1765 ["*"] = nil, -- item id = category number to assign the item to
1766 },
1767 ["active"] = {
1768 ["*"] = { -- category type
1769 ["*"] = false, -- category id = enabled
1770 },
1771 [ArkInventory.Const.Category.Type.System] = {
1772 ["*"] = true,
1773 },
1774 },
1775 ["junk"] = {
1776 ["*"] = { -- category type
1777 ["*"] = false, -- true = autosell
1778 },
1779 [ArkInventory.Const.Category.Type.System] = {
1780 ["*"] = false,
1781 [402] = true,
1782 },
1783 },
1784 },
1785 },
1786 [9999] = {
1787 ["system"] = true,
1788 ["used"] = "Y",
1789 ["name"] = ArkInventory.Localise["DEFAULT"],
1790 },
1791 [1000] = {
1792 ["system"] = false,
1793 ["used"] = "Y",
1794 ["name"] = ArkInventory.Localise["DEFAULT"],
1795 },
1796 },
1797 ["min"] = 1000,
1798 ["next"] = 1000,
1799 ["max"] = 8999,
1800 },
1801 ["profile"] = {
1802 ["data"] = {
1803 ["**"] = { -- id
1804 ["system"] = false,
1805 ["used"] = "N", -- Y(es) | N(o) | D(eleted)
1806 ["name"] = "",
1807 ["location"] = {
1808 ["**"] = { -- loc_id
1809 ["monitor"] = true,
1810 ["save"] = true,
1811 ["override"] = false,
1812 ["special"] = true,
1813 ["notify"] = false,
1814 ["anchor"] = {
1815 ["point"] = ArkInventory.Const.Anchor.TopRight,
1816 ["locked"] = false,
1817 ["t"] = nil,
1818 ["b"] = nil,
1819 ["l"] = nil,
1820 ["r"] = nil,
1821 },
1822 ["style"] = 1000,
1823 ["layout"] = 1000,
1824 ["catset"] = 1000,
1825 ["container"] = {
1826 ["width"] = 400,
1827 ["height"] = 400,
1828 },
1829 },
1830 [ArkInventory.Const.Location.Bag] = {
1831 ["notify"] = true,
1832 ["override"] = true,
1833 },
1834 [ArkInventory.Const.Location.Bank] = {
1835 ["notify"] = true,
1836 ["override"] = true,
1837 },
1838 [ArkInventory.Const.Location.Vault] = {
1839 ["notify"] = true,
1840 ["override"] = true,
1841 },
1842 },
1843 },
1844 [1000] = {
1845 ["system"] = false,
1846 ["used"] = "Y",
1847 ["name"] = ArkInventory.Localise["DEFAULT"],
1848 },
1849 [9999] = {
1850 ["system"] = true,
1851 ["used"] = "Y",
1852 ["name"] = ArkInventory.Localise["DEFAULT"],
1853 },
1854 },
1855 ["min"] = 1000,
1856 ["next"] = 1000,
1857 ["max"] = 8999,
1858 },
1859 ["sort"] = {
1860 ["method"] = {
1861 ["data"] = {
1862 ["**"] = {
1863 ["system"] = false,
1864 ["used"] = "N", -- Y(es) | N(o) | D(eleted)
1865 ["name"] = "",
1866 ["bagslot"] = true,
1867 ["ascending"] = true,
1868 ["reversed"] = false,
1869 ["active"] = { },
1870 ["order"] = { },
1871 },
1872 [9999] = {
1873 ["system"] = true,
1874 ["used"] = "Y",
1875 ["name"] = ArkInventory.Localise["CONFIG_SORTING_METHOD_BAGSLOT"],
1876 },
1877 [9998] = {
1878 ["system"] = true,
1879 ["used"] = "Y",
1880 ["name"] = "Rarity > Category > Location > Name",
1881 ["bagslot"] = false,
1882 ["active"] = {
1883 ["quality"] = true,
1884 ["category"] = true,
1885 ["location"] = true,
1886 ["name"] = true,
1887 },
1888 ["order"] = {
1889 [1] = "quality",
1890 [2] = "category",
1891 [3] = "location",
1892 [4] = "name",
1893 },
1894 },
1895 [9997] = {
1896 ["system"] = true,
1897 ["used"] = "Y",
1898 ["name"] = "Name (Ascending)",
1899 ["bagslot"] = false,
1900 ["active"] = {
1901 ["name"] = true,
1902 },
1903 ["order"] = {
1904 [1] = "name",
1905 },
1906 },
1907 [9996] = {
1908 ["system"] = true,
1909 ["used"] = "Y",
1910 ["name"] = "Vendor Price",
1911 ["bagslot"] = false,
1912 ["active"] = {
1913 ["vendorprice"] = true,
1914 },
1915 ["order"] = {
1916 [1] = "vendorprice",
1917 },
1918 },
1919 [9995] = {
1920 ["system"] = true,
1921 ["used"] = "Y",
1922 ["name"] = string.format( "%s / %s", ArkInventory.Localise["VAULT"], ArkInventory.Localise["VOIDSTORAGE"] ),
1923 },
1924 [9994] = {
1925 ["system"] = true,
1926 ["used"] = "Y",
1927 ["name"] = "Name (Descending)",
1928 ["bagslot"] = false,
1929 ["ascending"] = false,
1930 ["active"] = {
1931 ["name"] = true,
1932 },
1933 ["order"] = {
1934 [1] = "name",
1935 },
1936 },
1937 [9993] = {
1938 ["system"] = true,
1939 ["used"] = "Y",
1940 ["name"] = string.format( "%s (%s)", ArkInventory.Localise["CONFIG_SORTING_METHOD_BAGSLOT"], "Descending" ),
1941 ["ascending"] = false,
1942 },
1943 },
1944 ["min"] = 1000,
1945 ["next"] = 1000,
1946 ["max"] = 8999,
1947 },
1948 },
1949 ["showdisabled"] = true,
1950 ["restack"] = {
1951 ["blizzard"] = true, -- use blizzard cleanup function
1952 -- cleanup options
1953 ["reverse"] = false,
1954 ["deposit"] = false, -- blizzard - run deposit all items
1955 -- restack options
1956 ["refresh"] = false, -- do a refresh when the restack is finished
1957 ["topup"] = true, -- top up stacks in the bank (and reagent bank) with items from bags
1958 ["bank"] = false, -- fill up empty bank slots from bag
1959 ["priority"] = true, -- true = full reagent bank first, false = fill profession bags first
1960 },
1961 ["bucket"] = {
1962 ["*"] = nil
1963 },
1964 ["bugfix"] = {
1965 ["framelevel"] = {
1966 ["enable"] = true,
1967 ["alert"] = 0,
1968 },
1969 ["zerosizebag"] = {
1970 ["enable"] = true,
1971 ["alert"] = true,
1972 },
1973 },
1974 ["tooltip"] = {
1975 ["show"] = true, -- show tooltips for items
1976 ["scale"] = {
1977 ["enabled"] = false,
1978 ["amount"] = 1,
1979 },
1980 ["me"] = false, -- only show my data
1981 ["highlight"] = "", -- highlight my data
1982 ["faction"] = true, -- only show my faction
1983 ["realm"] = true, -- only show my realm
1984 ["crossrealm"] = false, -- show connected realms
1985 ["add"] = { -- things to add to the tooltip
1986 ["empty"] = false, -- empty line / seperator
1987 ["count"] = true, -- item count
1988 ["vendor"] = false, -- vendor price (deprecated)
1989 ["ilvl"] = false, -- item level (deprecated)
1990 ["vault"] = true,
1991 ["tabs"] = true,
1992 },
1993 ["colour"] = {
1994 ["count"] = {
1995 ["r"] = 1,
1996 ["g"] = 0.5,
1997 ["b"] = 0.15,
1998 },
1999 ["vendor"] = {
2000 ["r"] = 0.5,
2001 ["g"] = 0.5,
2002 ["b"] = 0.5,
2003 },
2004 ["class"] = false,
2005 },
2006 ["battlepet"] = {
2007 ["enable"] = true,
2008 ["source"] = true,
2009 ["description"] = true,
2010 ["mouseover"] = {
2011 ["enable"] = true,
2012 ["detailed"] = true,
2013 },
2014 },
2015 ["reputation"] = { -- need to add this to the config at some point
2016 ["enable"] = true,
2017 ["description"] = true,
2018 ["custom"] = 1, -- 1 = default, 2 = custom
2019 ["style"] = {
2020 ["normal"] = "",
2021 ["count"] = "",
2022 },
2023 },
2024 ["precalc"] = false,
2025 ["refresh"] = true,
2026 },
2027 ["tracking"] = {
2028 ["items"] = { },
2029 ["reputation"] = {
2030 ["custom"] = 1, -- 1 = default, 2 = custom
2031 ["style"] = {
2032 ["ldb"] = "",
2033 ["tooltip"] = "",
2034 },
2035 },
2036 },
2037 ["message"] = {
2038 ["translation"] = {
2039 ["interim"] = true,
2040 ["final"] = true,
2041 },
2042 ["restack"] = {
2043 ["*"] = true,
2044 },
2045 ["battlepet"] = {
2046 ["opponent"] = true,
2047 },
2048 ["mount"] = {
2049 ["warnings"] = true,
2050 },
2051 ["bag"] = {
2052 ["unknown"] = true,
2053 },
2054 ["rules"] = {
2055 ["hooked"] = true,
2056 ["registration"] = true,
2057 },
2058 },
2059 ["mount"] = {
2060 ["correction"] = { }, -- [spell] = mountType
2061 },
2062 ["junk"] = {
2063 ["sell"] = false,
2064 ["limit"] = true,
2065 ["delete"] = false,
2066 ["notify"] = true,
2067 ["raritycutoff"] = LE_ITEM_QUALITY_POOR, -- max quality to sell/destroy
2068 ["list"] = true,
2069 ["test"] = true,
2070 },
2071 ["font"] = {
2072 ["face"] = ArkInventory.Const.Font.Face,
2073 ["height"] = ArkInventory.Const.Font.Height,
2074 },
2075 ["menu"] = {
2076 ["font"] = {
2077 ["face"] = ArkInventory.Const.Font.Face,
2078 ["height"] = ArkInventory.Const.Font.Height,
2079 },
2080 },
2081 ["newitemglow"] = {
2082 ["enable"] = true,
2083 ["colour"] = { r = 0.7, g = 0.7, b = 0.7, a = 0.5 },
2084 ["clearonclose"] = false,
2085 },
2086 ["transmog"] = {
2087 ["enable"] = true,
2088 ["anchor"] = ArkInventory.Const.Anchor.Default,
2089 ["secondary"] = false,
2090 ["icon"] = {
2091 [ArkInventory.Const.Transmog.State.CanLearnMyself] = {
2092 ["style"] = ArkInventory.Const.Transmog.StyleDefault,
2093 ["colour"] = { r = 0.00, g = 1.00, b = 0.00, a = 1 }, -- green
2094 },
2095 [ArkInventory.Const.Transmog.State.CanLearnMyselfSecondary] = {
2096 ["style"] = ArkInventory.Const.Transmog.StyleDefault,
2097 ["colour"] = { r = 0.08, g = 0.76, b = 0.94, a = 1 },
2098 },
2099 [ArkInventory.Const.Transmog.State.CanLearnOther] = {
2100 ["style"] = ArkInventory.Const.Transmog.StyleDefault,
2101 ["colour"] = { r = 1.00, g = 1.00, b = 0.00, a = 1 },
2102 },
2103 [ArkInventory.Const.Transmog.State.CanLearnOtherSecondary] = {
2104 ["style"] = ArkInventory.Const.Transmog.StyleDefault,
2105 ["colour"] = { r = 1.00, g = 0.78, b = 1.00, a = 1 },
2106 },
2107 },
2108 },
2109 ["conflict"] = {
2110 ["tsm"] = {
2111 ["mailbox"] = false,
2112 ["merchant"] = false,
2113 },
2114 },
2115 ["ui"] = {
2116 ["search"] = {
2117 ["scale"] = 1,
2118 ["background"] = {
2119 ["style"] = ArkInventory.Const.Texture.BackgroundDefault,
2120 ["colour"] = {
2121 ["r"] = 0,
2122 ["g"] = 0,
2123 ["b"] = 0,
2124 ["a"] = 0.75,
2125 },
2126 },
2127 ["border"] = {
2128 ["style"] = ArkInventory.Const.Texture.BorderDefault,
2129 ["size"] = nil,
2130 ["offset"] = nil,
2131 ["scale"] = 1,
2132 ["colour"] = {
2133 ["r"] = 1,
2134 ["g"] = 1,
2135 ["b"] = 1,
2136 },
2137 },
2138 ["font"] = {
2139 ["height"] = ArkInventory.Const.Font.Height,
2140 },
2141 ["strata"] = "MEDIUM"
2142 },
2143 ["rules"] = {
2144 ["scale"] = 1,
2145 ["background"] = {
2146 ["style"] = ArkInventory.Const.Texture.BackgroundDefault,
2147 ["colour"] = {
2148 ["r"] = 0,
2149 ["g"] = 0,
2150 ["b"] = 0,
2151 ["a"] = 0.75,
2152 },
2153 },
2154 ["border"] = {
2155 ["style"] = ArkInventory.Const.Texture.BorderDefault,
2156 ["size"] = nil,
2157 ["offset"] = nil,
2158 ["scale"] = 1,
2159 ["colour"] = {
2160 ["r"] = 1,
2161 ["g"] = 1,
2162 ["b"] = 1,
2163 },
2164 },
2165 ["font"] = {
2166 ["height"] = ArkInventory.Const.Font.Height,
2167 },
2168 ["strata"] = "MEDIUM"
2169 },
2170 },
2171 ["thread"] = {
2172 ["debug"] = false,
2173 ["timeout"] = {
2174 ["normal"] = 25,
2175 ["combat"] = 100, -- 200ms appears to be the actual limit
2176 ["tooltip"] = 50, -- tooltip generation queue
2177 ["junksell"] = 75, -- this is a minimum duration timer, not a timeout, must be above 50 (will occasionally fail when that low)
2178 },
2179 },
2180 },
2181 ["player"] = {
2182 ["version"] = 0,
2183 ["data"] = {
2184 ["*"] = { -- player or guild name
2185
2186 ["erasesilent"] = false,
2187
2188 ["ldb"] = {
2189 ["bags"] = {
2190 ["colour"] = false,
2191 ["full"] = true,
2192 ["includetype"] = true,
2193 },
2194 ["pets"] = {
2195 ["randomise"] = true,
2196 ["useall"] = true,
2197 ["selected"] = {
2198 ["*"] = nil,
2199 },
2200 },
2201 ["mounts"] = {
2202 ["randomise"] = true,
2203 ["type"] = {
2204 ["l"] = { -- land (ground)
2205 ["useflying"] = false,
2206 ["usesurface"] = false,
2207 ["useall"] = true,
2208 ["selected"] = {
2209 ["*"] = nil,
2210 },
2211 },
2212 ["a"] = { -- air (flying)
2213 ["dismount"] = false,
2214 ["useall"] = true,
2215 ["selected"] = {
2216 ["*"] = nil,
2217 },
2218 },
2219 ["u"] = { -- underwater
2220 ["useall"] = true,
2221 ["selected"] = {
2222 ["*"] = nil,
2223 },
2224 },
2225 ["s"] = { -- surface (water)
2226 ["useall"] = true,
2227 ["selected"] = {
2228 ["*"] = nil,
2229 },
2230 },
2231 ["x"] = { -- unknown
2232 ["useall"] = true,
2233 ["selected"] = {
2234 ["*"] = nil,
2235 },
2236 },
2237 },
2238 },
2239 ["tracking"] = {
2240 ["currency"] = {
2241 ["tracked"] = {
2242 ["*"] = false,
2243 },
2244 },
2245 ["item"] = {
2246 ["tracked"] = {
2247 ["*"] = false,
2248 },
2249 },
2250 ["reputation"] = {
2251 ["tracked"] = {
2252 ["*"] = false,
2253 },
2254 ["watched"] = nil,
2255 },
2256 },
2257 ["travelform"] = false,
2258 },
2259
2260 ["option"] = { -- mostly moved to profile
2261 ["**"] = { -- loc_id
2262 ["bag"] = {
2263 ["*"] = { -- bag_id
2264 ["display"] = true,
2265 ["restack"] = {
2266 ["ignore"] = false,
2267 },
2268 },
2269 },
2270 },
2271 },
2272
2273 ["info"] = {
2274 ["*"] = nil,
2275 ["money"] = 0,
2276
2277 },
2278
2279 ["location"] = {
2280 ["*"] = {
2281 ["slot_count"] = 0,
2282 ["bag"] = {
2283 ["*"] = {
2284 ["status"] = ArkInventory.Const.Bag.Status.Unknown,
2285-- ["texture"] = nil,
2286-- ["h"] = nil,
2287-- ["q"] = nil,
2288 ["type"] = ArkInventory.Const.Slot.Type.Unknown,
2289 ["count"] = 0,
2290 ["empty"] = 0,
2291 ["slot"] = {
2292-- stuff
2293 },
2294 },
2295 },
2296 },
2297 },
2298
2299 ["profile"] = 1000,
2300
2301 },
2302 },
2303 },
2304 ["cache"] = {
2305 ["version"] = 0,
2306 ["default"] = {
2307 ["*"] = nil, -- key generated via ObjectIDCategory( )
2308 },
2309 ["rule"] = {
2310 ["*"] = nil, -- key generated via ObjectIDRule( )
2311 },
2312 },
2313}
2314
2315ArkInventory.Const.DatabaseDefaults.profile = {
2316 ["option"] = {
2317 ["version"] = 0,
2318 },
2319}
2320
2321
2322function ArkInventory.TOCVersionFail( quiet )
2323
2324 if true then return false end
2325
2326 --ArkInventory.Output( ArkInventory.Const.TOC, " / ", ArkInventory.Const.TOC_Min, " / ", ArkInventory.Const.TOC_Name )
2327 if ArkInventory.Const.TOC < ArkInventory.Const.TOC_Min then
2328 if not quiet then
2329 ArkInventory.Output( ArkInventory.Global.Version, ArkInventory.Localise["DISABLED"] )
2330 ArkInventory.OutputError( ArkInventory.Const.TOC_Name, " (Alpha/Beta) Server required. Do not run this version on the Live servers.")
2331 ArkInventory:Disable( )
2332 end
2333 return true
2334 end
2335end
2336
2337function ArkInventory.OnLoad( )
2338
2339 -- called via hidden frame in xml
2340
2341 ArkInventory.Const.Program.Version = 0 + GetAddOnMetadata( ArkInventory.Const.Program.Name, "Version" )
2342
2343 ArkInventory.Global.Version = string.format( "v%s", string.gsub( ArkInventory.Const.Program.Version, "(%d-)(%d%d)(%d%d)$", "%1.%2.%3" ) )
2344
2345 local releasetype = GetAddOnMetadata( ArkInventory.Const.Program.Name, "X-ReleaseType" )
2346 if releasetype ~= "" then
2347 ArkInventory.Global.Version = string.format( "%s %s(%s)%s", ArkInventory.Global.Version, RED_FONT_COLOR_CODE, releasetype, FONT_COLOR_CODE_CLOSE )
2348 end
2349
2350
2351 local loc_id = 0
2352 local bags
2353
2354
2355 -- bags
2356 loc_id = ArkInventory.Const.Location.Bag
2357 bags = ArkInventory.Global.Location[loc_id].Bags
2358
2359 bags[#bags + 1] = BACKPACK_CONTAINER
2360 for x = 1, NUM_BAG_SLOTS do
2361 bags[#bags + 1] = x
2362 end
2363 ArkInventory.Global.Location[loc_id].bagCount = #bags
2364
2365
2366 -- bank
2367 loc_id = ArkInventory.Const.Location.Bank
2368 bags = ArkInventory.Global.Location[loc_id].Bags
2369
2370 bags[#bags + 1] = BANK_CONTAINER
2371 for x = NUM_BAG_SLOTS + 1, NUM_BAG_SLOTS + NUM_BANKBAGSLOTS do
2372 bags[#bags + 1] = x
2373 end
2374 bags[#bags + 1] = REAGENTBANK_CONTAINER
2375 ArkInventory.Global.Location[loc_id].tabReagent = #bags
2376 ArkInventory.Global.Location[loc_id].bagCount = #bags
2377
2378
2379 -- vault
2380 loc_id = ArkInventory.Const.Location.Vault
2381 bags = ArkInventory.Global.Location[loc_id].Bags
2382
2383 for x = 1, MAX_GUILDBANK_TABS do
2384 bags[#bags + 1] = ArkInventory.Const.Offset.Vault + x
2385 end
2386 ArkInventory.Global.Location[loc_id].bagCount = #bags
2387
2388
2389 -- mail
2390 loc_id = ArkInventory.Const.Location.Mail
2391 bags = ArkInventory.Global.Location[loc_id].Bags
2392 for x = 1, 2 do
2393 bags[#bags + 1] = ArkInventory.Const.Offset.Mail + x
2394 end
2395 ArkInventory.Global.Location[loc_id].bagCount = #bags
2396
2397 -- wearing
2398 table.insert( ArkInventory.Global.Location[ArkInventory.Const.Location.Wearing].Bags, ArkInventory.Const.Offset.Wearing + 1 )
2399
2400 -- pet
2401 table.insert( ArkInventory.Global.Location[ArkInventory.Const.Location.Pet].Bags, ArkInventory.Const.Offset.Pet + 1 )
2402
2403 -- mount
2404 table.insert( ArkInventory.Global.Location[ArkInventory.Const.Location.Mount].Bags, ArkInventory.Const.Offset.Mount + 1 )
2405
2406 -- toybox
2407 table.insert( ArkInventory.Global.Location[ArkInventory.Const.Location.Toybox].Bags, ArkInventory.Const.Offset.Toybox + 1 )
2408
2409 -- heirloom
2410 table.insert( ArkInventory.Global.Location[ArkInventory.Const.Location.Heirloom].Bags, ArkInventory.Const.Offset.Heirloom + 1 )
2411
2412 -- currency
2413 table.insert( ArkInventory.Global.Location[ArkInventory.Const.Location.Token].Bags, ArkInventory.Const.Offset.Token + 1 )
2414 table.insert( ArkInventory.Global.Location[ArkInventory.Const.Location.Token].Bags, -4 )
2415
2416 -- auctions
2417 table.insert( ArkInventory.Global.Location[ArkInventory.Const.Location.Auction].Bags, ArkInventory.Const.Offset.Auction + 1 )
2418
2419 -- void storage
2420 for x = 1, ArkInventory.Const.VOID_STORAGE_PAGES do
2421 table.insert( ArkInventory.Global.Location[ArkInventory.Const.Location.Void].Bags, ArkInventory.Const.Offset.Void + x )
2422 end
2423
2424 -- reputation
2425 table.insert( ArkInventory.Global.Location[ArkInventory.Const.Location.Reputation].Bags, ArkInventory.Const.Offset.Reputation + 1 )
2426
2427 -- setup reverse lookup cache
2428 for loc_id, loc_data in pairs( ArkInventory.Global.Location ) do
2429 for bag_id, v in pairs( loc_data.Bags ) do
2430 ArkInventory.Global.Cache.BlizzardBagIdToInternalId[v] = { loc_id=loc_id, bag_id=bag_id }
2431 end
2432 end
2433
2434end
2435
2436function ArkInventory.OnInitialize( )
2437
2438 -- pre acedb load, the database is just a table
2439 ArkInventory.DatabaseUpgradePreLoad( )
2440
2441 -- load database, use default profile as we dont need them, metatables now active
2442 ArkInventory.acedb = LibStub( "AceDB-3.0" ):New( "ARKINVDB", ArkInventory.Const.DatabaseDefaults, true )
2443 ArkInventory.db = ArkInventory.acedb.global
2444
2445 ArkInventory.StartupChecks( )
2446
2447 -- config menu (internal)
2448 ArkInventory.Lib.Config:RegisterOptionsTable( ArkInventory.Const.Frame.Config.Internal, ArkInventory.Config.Internal )
2449 ArkInventory.Lib.Dialog:SetDefaultSize( ArkInventory.Const.Frame.Config.Internal, 1250, 650 )
2450
2451 -- config menu (blizzard)
2452 ArkInventory.ConfigBlizzard( )
2453 ArkInventory.Lib.Config:RegisterOptionsTable( ArkInventory.Const.Frame.Config.Blizzard, ArkInventory.Config.Blizzard, { "arkinventory", "arkinv", "ai" } )
2454 ArkInventory.Lib.Dialog:AddToBlizOptions( ArkInventory.Const.Frame.Config.Blizzard, ArkInventory.Const.Program.Name )
2455
2456
2457 -- tooltip
2458 ArkInventory.Global.Tooltip.Scan = ArkInventory.TooltipScanInit( "ARKINV_ScanTooltip" )
2459
2460 ArkInventory.PlayerInfoSet( )
2461 ArkInventory.MediaRegister( )
2462
2463 local me = ArkInventory.GetPlayerCodex( )
2464
2465 for loc_id, loc_data in pairs( ArkInventory.Global.Location ) do
2466 if loc_data.canView then
2467 if me.profile.location[loc_id].special then
2468 local frame = ArkInventory.Frame_Main_Get( loc_id )
2469 table.insert( UISpecialFrames, frame:GetName( ) )
2470 end
2471 end
2472 end
2473
2474
2475 if not ARKINV_MountToggle then
2476
2477 -- secure mount button to be able to cancel shapeshift forms
2478 local btn = CreateFrame( "ItemButton", "ARKINV_MountToggle", UIParent, "SecureActionButtonTemplate" )
2479
2480 local macrotext = "/dismount [combat, mounted, noflying]\n" -- dismount if in combat and mounted and not flying
2481 macrotext = macrotext .. "/stopmacro [combat]\n" -- abort if in combat
2482
2483 if ( me.player.data.info.class == "DRUID" ) or ( me.player.data.info.class == "WARLOCK" ) or ( me.player.data.info.class == "SHAMAN" ) then
2484 macrotext = macrotext .. "/cancelform [noform:0]\n" -- cancel any form
2485 end
2486
2487 -- class shapeshifts
2488 if me.player.data.ldb.travelform then
2489 if me.player.data.info.class == "DRUID" then
2490 local cat_form = GetSpellInfo( 768 )
2491 local travel_form = GetSpellInfo( 783 )
2492 macrotext = macrotext .. "/cast [indoors] " .. cat_form .. "; " .. travel_form .. "\n"
2493 end
2494 -- shaman ghost wolf?
2495 else
2496 macrotext = macrotext .. "/run ArkInventory.LDB.Mounts:OnClick( )\n"
2497 end
2498
2499 --ArkInventory.Output( macrotext )
2500
2501 btn:SetAttribute( "type", "macro" )
2502 btn:SetAttribute( "macrotext", macrotext )
2503
2504 btn:SetPoint( "CENTER" )
2505 btn:Hide( )
2506
2507 end
2508
2509end
2510
2511function ArkInventory.OnEnable( )
2512
2513 -- Called when the addon is enabled
2514
2515 --ArkInventory.Output( "OnEnable" )
2516
2517 if ArkInventory.TOCVersionFail( ) then return end
2518
2519 ArkInventory.PlayerInfoSet( )
2520
2521 ArkInventory.BlizzardAPIHook( )
2522
2523 ArkInventory.DatabaseUpgradePostLoad( )
2524
2525 ArkInventory.CategoryGenerate( )
2526
2527 -- tag all locations as changed
2528 ArkInventory.LocationSetValue( nil, "changed", true )
2529
2530 -- tag all locations to be rebuilt from scratch
2531 --ArkInventory.OutputWarning( "OnEnable - .restart window draw" )
2532 ArkInventory.Frame_Main_DrawStatus( nil, ArkInventory.Const.Window.Draw.Restart )
2533
2534 -- init location player id
2535 ArkInventory.LocationSetValue( nil, "player_id", ArkInventory.PlayerIDSelf( ) )
2536
2537 -- fix companion data
2538 ArkInventory.CompanionDataUpdate( )
2539
2540 -- register events
2541 --ArkInventory:RegisterMessage( "EVENT_ARKINV_STORAGE" )
2542
2543 ArkInventory:RegisterEvent( "PLAYER_ENTERING_WORLD", "EVENT_ARKINV_PLAYER_ENTER" ) -- not really needed but seems to fix a bug where ace doesnt seem to init again
2544 ArkInventory:RegisterEvent( "PLAYER_LEAVING_WORLD", "EVENT_ARKINV_PLAYER_LEAVE" ) -- when the player logs out or the UI is reloaded.
2545
2546 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_PLAYER_MONEY_BUCKET", 1 )
2547 ArkInventory:RegisterEvent( "PLAYER_MONEY", "EVENT_ARKINV_PLAYER_MONEY" )
2548
2549 ArkInventory:RegisterEvent( "SKILL_LINES_CHANGED", "EVENT_ARKINV_PLAYER_SKILLS" ) -- triggered when you gain or lose a skill, skillup, collapse/expand a skill header
2550
2551 ArkInventory:RegisterEvent( "PLAYER_REGEN_DISABLED", "EVENT_ARKINV_COMBAT_ENTER" ) -- player entered combat
2552 ArkInventory:RegisterEvent( "PLAYER_REGEN_ENABLED", "EVENT_ARKINV_COMBAT_LEAVE" ) -- player left combat
2553
2554 local bucket1 = ArkInventory.db.option.bucket[ArkInventory.Const.Location.Bag] or 0.5
2555
2556 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_TOOLTIP_REBUILD_QUEUE_UPDATE_BUCKET", bucket1 )
2557 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_BAG_RESCAN_BUCKET", 5 )
2558 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_BAG_UPDATE_BUCKET", bucket1 )
2559 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_LOCATION_SCANNED_BUCKET", bucket1 * 2 )
2560 ArkInventory:RegisterEvent( "BAG_UPDATE", "EVENT_ARKINV_BAG_UPDATE" )
2561 ArkInventory:RegisterEvent( "ITEM_LOCK_CHANGED", "EVENT_ARKINV_BAG_LOCK" )
2562-- ArkInventory:RegisterEvent( "BAG_NEW_ITEMS_UPDATED", "EVENT_ARKINV_BAG_UPDATE" ) -- fix me : do something with it?
2563-- ArkInventory:RegisterEvent( "BAG_SLOT_FLAGS_UPDATED", "EVENT_ARKINV_BAG_UPDATE" ) -- fix me : do something with it?
2564
2565 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_BAG_UPDATE_COOLDOWN_BUCKET", bucket1 )
2566 ArkInventory:RegisterEvent( "BAG_UPDATE_COOLDOWN", "EVENT_ARKINV_BAG_UPDATE_COOLDOWN" )
2567
2568 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_CHANGER_UPDATE_BUCKET", 1 )
2569
2570 ArkInventory:RegisterEvent( "ACTIVE_TALENT_GROUP_CHANGED", "EVENT_ARKINV_TALENT_CHANGED" )
2571
2572 ArkInventory:RegisterEvent( "BANKFRAME_OPENED", "EVENT_ARKINV_BANK_ENTER" )
2573 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_BANK_LEAVE_BUCKET", 0.3 )
2574 ArkInventory:RegisterEvent( "BANKFRAME_CLOSED", "EVENT_ARKINV_BANK_LEAVE" )
2575 ArkInventory:RegisterEvent( "PLAYERBANKSLOTS_CHANGED", "EVENT_ARKINV_BANK_UPDATE" ) -- a bag_update event for the bank (-1)
2576 ArkInventory:RegisterEvent( "PLAYERBANKBAGSLOTS_CHANGED", "EVENT_ARKINV_BANK_SLOT" ) -- triggered when you purchase a new bank bag slot
2577 --ArkInventory:RegisterEvent( "BANK_BAG_SLOT_FLAGS_UPDATED", "EVENT_ARKINV_BANK_UPDATE" )
2578
2579 ArkInventory:RegisterEvent( "REAGENTBANK_PURCHASED", "EVENT_ARKINV_BANK_TAB" ) -- triggered when you purchase a bank tab (reagent bank)
2580 ArkInventory:RegisterEvent( "PLAYERREAGENTBANKSLOTS_CHANGED", "EVENT_ARKINV_REAGENTBANK_UPDATE" ) -- a bag_update event for the reagent bank (-3)
2581 ArkInventory:RegisterEvent( "REAGENTBANK_UPDATE", "EVENT_ARKINV_REAGENTBANK_UPDATE" )
2582
2583 ArkInventory:RegisterEvent( "GUILDBANKFRAME_OPENED", "EVENT_ARKINV_VAULT_ENTER" )
2584 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_VAULT_LEAVE_BUCKET", 0.3 )
2585 ArkInventory:RegisterEvent( "GUILDBANKFRAME_CLOSED", "EVENT_ARKINV_VAULT_LEAVE" )
2586 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_VAULT_UPDATE_BUCKET", ArkInventory.db.option.bucket[ArkInventory.Const.Location.Vault] or 1.5 )
2587 ArkInventory:RegisterEvent( "GUILDBANKBAGSLOTS_CHANGED", "EVENT_ARKINV_VAULT_UPDATE" )
2588 ArkInventory:RegisterEvent( "GUILDBANK_ITEM_LOCK_CHANGED", "EVENT_ARKINV_VAULT_LOCK" )
2589 ArkInventory:RegisterEvent( "GUILDBANK_UPDATE_MONEY", "EVENT_ARKINV_VAULT_MONEY" )
2590 ArkInventory:RegisterEvent( "GUILDBANK_UPDATE_TABS", "EVENT_ARKINV_VAULT_TABS" )
2591 ArkInventory:RegisterEvent( "GUILDBANKLOG_UPDATE", "EVENT_ARKINV_VAULT_LOG" )
2592 ArkInventory:RegisterEvent( "GUILDBANK_UPDATE_TEXT", "EVENT_ARKINV_VAULT_INFO" )
2593
2594 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_VOID_UPDATE_BUCKET", 0.5 )
2595 ArkInventory:RegisterEvent( "VOID_STORAGE_UPDATE", "EVENT_ARKINV_VOID_UPDATE" )
2596 --ArkInventory:RegisterEvent( "VOID_TRANSFER_DONE", "EVENT_ARKINV_VOID_UPDATE" )
2597 --ArkInventory:RegisterEvent( "VOID_STORAGE_DEPOSIT_UPDATE", "EVENT_ARKINV_VOID_UPDATE" )
2598 ArkInventory:RegisterEvent( "VOID_STORAGE_CONTENTS_UPDATE", "EVENT_ARKINV_VOID_UPDATE" )
2599 --ArkInventory:RegisterEvent( "VOID_DEPOSIT_WARNING", "EVENT_ARKINV_VOID_UPDATE" )
2600
2601 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_INVENTORY_CHANGE_BUCKET", bucket1 )
2602 ArkInventory:RegisterEvent( "UNIT_INVENTORY_CHANGED", "EVENT_ARKINV_INVENTORY_CHANGE" )
2603
2604 ArkInventory:RegisterEvent( "MAIL_SHOW", "EVENT_ARKINV_MAIL_ENTER" )
2605 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_MAIL_LEAVE_BUCKET", 0.3 )
2606 ArkInventory:RegisterEvent( "MAIL_CLOSED", "EVENT_ARKINV_MAIL_LEAVE" )
2607 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_MAIL_UPDATE_BUCKET", ArkInventory.db.option.bucket[ArkInventory.Const.Location.Mail] or 2 )
2608 ArkInventory:RegisterEvent( "MAIL_INBOX_UPDATE", "EVENT_ARKINV_MAIL_UPDATE" )
2609 ArkInventory:RegisterEvent( "MAIL_SEND_SUCCESS", "EVENT_ARKINV_MAIL_SEND_SUCCESS" )
2610
2611 ArkInventory:RegisterEvent( "TRADE_SHOW", "EVENT_ARKINV_TRADE_ENTER" )
2612 ArkInventory:RegisterEvent( "TRADE_CLOSED", "EVENT_ARKINV_TRADE_LEAVE" )
2613
2614 ArkInventory:RegisterEvent( "AUCTION_HOUSE_SHOW", "EVENT_ARKINV_AUCTION_ENTER" )
2615 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_AUCTION_LEAVE_BUCKET", 0.3 )
2616 ArkInventory:RegisterEvent( "AUCTION_HOUSE_CLOSED", "EVENT_ARKINV_AUCTION_LEAVE" )
2617 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_AUCTION_UPDATE_MASSIVE_BUCKET", 60 )
2618 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_AUCTION_UPDATE_BUCKET", 2 )
2619 ArkInventory:RegisterEvent( "AUCTION_OWNED_LIST_UPDATE", "EVENT_ARKINV_AUCTION_UPDATE" )
2620
2621 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_MERCHANT_LEAVE_BUCKET", 0.3 )
2622 ArkInventory:RegisterEvent( "MERCHANT_SHOW", "EVENT_ARKINV_MERCHANT_ENTER" )
2623 ArkInventory:RegisterEvent( "MERCHANT_CLOSED", "EVENT_ARKINV_MERCHANT_LEAVE" )
2624 ArkInventory:RegisterEvent( "TRANSMOGRIFY_OPEN", "EVENT_ARKINV_TRANSMOG_ENTER" )
2625 ArkInventory:RegisterEvent( "TRANSMOGRIFY_CLOSE", "EVENT_ARKINV_MERCHANT_LEAVE" )
2626
2627 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_COLLECTION_MOUNT_UPDATE_BUCKET", 1 )
2628-- ArkInventory:RegisterEvent( "COMPANION_UPDATE", "EVENT_ARKINV_COLLECTION_COMPANION_UPDATE" ) -- do i really need this? it triggers when other people mount/dismount as well
2629 ArkInventory:RegisterEvent( "COMPANION_LEARNED", "EVENT_ARKINV_COLLECTION_COMPANION_UPDATE" )
2630 ArkInventory:RegisterEvent( "COMPANION_UNLEARNED", "EVENT_ARKINV_COLLECTION_COMPANION_UPDATE" )
2631
2632 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_COLLECTION_PET_UPDATE_BUCKET", 1 )
2633 ArkInventory:RegisterEvent( "NEW_PET_ADDED", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2634 ArkInventory:RegisterEvent( "PET_JOURNAL_LIST_UPDATE", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2635 ArkInventory:RegisterEvent( "PET_JOURNAL_PET_DELETED", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2636 ArkInventory:RegisterEvent( "PET_JOURNAL_PET_RESTORED", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2637 ArkInventory:RegisterEvent( "PET_JOURNAL_PET_REVOKED", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2638 ArkInventory:RegisterEvent( "PET_JOURNAL_PETS_HEALED", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2639 ArkInventory:RegisterEvent( "BATTLE_PET_CURSOR_CLEAR", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2640 ArkInventory:RegisterEvent( "PET_BATTLE_LEVEL_CHANGED", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2641 ArkInventory:RegisterEvent( "PET_BATTLE_QUEUE_STATUS", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2642 ArkInventory:RegisterEvent( "PET_BATTLE_CLOSE", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2643 ArkInventory:RegisterEvent( "PET_BATTLE_OPENING_DONE", "EVENT_ARKINV_BATTLEPET_OPENING_DONE" )
2644 --ArkInventory:RegisterEvent( "CHAT_MSG_PET_BATTLE_COMBAT_LOG", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2645 --ArkInventory:RegisterEvent( "CHAT_MSG_PET_INFO", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2646 --ArkInventory:RegisterEvent( "CHAT_MSG_PET_BATTLE_INFO", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2647 --ArkInventory:RegisterEvent( "PET_BATTLE_PET_CHANGED", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2648 --ArkInventory:RegisterEvent( "PET_BATTLE_PET_ROUND_RESULTS", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2649 --ArkInventory:RegisterEvent( "PET_BATTLE_XP_CHANGED", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2650 --ArkInventory:RegisterEvent( "PET_BATTLE_OVER", "EVENT_ARKINV_COLLECTION_PET_UPDATE" )
2651
2652 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_COLLECTION_TOYBOX_UPDATE_BUCKET", 1 )
2653 ArkInventory:RegisterEvent( "TOYS_UPDATED", "EVENT_ARKINV_COLLECTION_TOYBOX_UPDATE" )
2654
2655 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_COLLECTION_HEIRLOOM_UPDATE_BUCKET", 1 )
2656 ArkInventory:RegisterEvent( "HEIRLOOMS_UPDATED", "EVENT_ARKINV_COLLECTION_HEIRLOOM_UPDATE" )
2657
2658 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_COLLECTION_REPUTATION_UPDATE_BUCKET", 1 )
2659 ArkInventory:RegisterEvent( "UPDATE_FACTION", "EVENT_ARKINV_COLLECTION_REPUTATION_UPDATE" )
2660 ArkInventory:RegisterEvent( "LFG_BONUS_FACTION_ID_UPDATED", "EVENT_ARKINV_COLLECTION_REPUTATION_UPDATE" )
2661 --ArkInventory:RegisterEvent( "QUEST_LOG_UPDATE", "" ) -- triggers too often to be usable
2662
2663 ArkInventory:RegisterEvent( "EQUIPMENT_SETS_CHANGED", "EVENT_ARKINV_EQUIPMENT_SETS_CHANGED" )
2664
2665 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_COLLECTION_CURRENCY_UPDATE_BUCKET", 1 )
2666 ArkInventory:RegisterEvent( "CURRENCY_DISPLAY_UPDATE", "EVENT_ARKINV_COLLECTION_CURRENCY_UPDATE" )
2667
2668 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_QUEST_UPDATE_BUCKET", 3 ) -- update quest item glows. not super urgent just get them there eventually
2669 ArkInventory:RegisterEvent( "QUEST_ACCEPTED", "EVENT_ARKINV_QUEST_UPDATE" )
2670-- ArkInventory:RegisterEvent( "QUEST_ITEM_UPDATED", "EVENT_ARKINV_QUEST_UPDATE" ) -- no longer valid in BFA
2671 ArkInventory:RegisterEvent( "QUEST_FINISHED", "EVENT_ARKINV_QUEST_UPDATE" )
2672 ArkInventory:RegisterEvent( "UNIT_QUEST_LOG_CHANGED", "EVENT_ARKINV_QUEST_UPDATE" )
2673
2674 ArkInventory:RegisterEvent( "CVAR_UPDATE", "EVENT_ARKINV_CVAR_UPDATE" )
2675
2676-- ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_ZONE_CHANGED_BUCKET", 5 )
2677-- ArkInventory:RegisterEvent( "ZONE_CHANGED", "EVENT_ARKINV_ZONE_CHANGED" )
2678-- ArkInventory:RegisterEvent( "ZONE_CHANGED_INDOORS", "EVENT_ARKINV_ZONE_CHANGED" )
2679-- ArkInventory:RegisterEvent( "ZONE_CHANGED_NEW_AREA", "EVENT_ARKINV_ZONE_CHANGED" )
2680
2681 -- ldb mount/pet updates
2682 ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_ACTIONBAR_UPDATE_USABLE_BUCKET", 1 )
2683 ArkInventory:RegisterEvent( "ACTIONBAR_UPDATE_USABLE", "EVENT_ARKINV_ACTIONBAR_UPDATE_USABLE" )
2684
2685 --soul shards
2686 --ArkInventory:RegisterBucketMessage( "EVENT_ARKINV_UNIT_POWER_BUCKET", 1 )
2687 --ArkInventory:RegisterEvent( "UNIT_POWER", "EVENT_ARKINV_UNIT_POWER" )
2688
2689 -- scrapping
2690 ArkInventory:RegisterEvent( "SCRAPPING_MACHINE_SHOW", "EVENT_ARKINV_SCRAP_ENTER" )
2691 ArkInventory:RegisterEvent( "SCRAPPING_MACHINE_CLOSE", "EVENT_ARKINV_SCRAP_LEAVE" )
2692
2693
2694 for loc_id, loc_data in pairs( ArkInventory.Global.Location ) do
2695 -- initialise codex for each location
2696 ArkInventory.GetLocationCodex( loc_id )
2697 end
2698
2699 ArkInventory.ScanProfessions( )
2700 ArkInventory.ScanLocation( )
2701
2702 ArkInventory.LDB.Money:Update( )
2703 ArkInventory.LDB.Bags:Update( )
2704 ArkInventory.LDB.Tracking_Currency:Update( )
2705 ArkInventory.LDB.Tracking_Item:Update( )
2706 ArkInventory.LDB.Tracking_Reputation:Update( )
2707
2708 ArkInventory.ScanAuctionExpire( )
2709
2710 ArkInventory.Output( ArkInventory.Global.Version, " ", ArkInventory.Localise["ENABLED"] )
2711
2712 ArkInventory.MediaMenuFontSet( ArkInventory.db.option.font.face, ArkInventory.db.option.menu.font.height )
2713
2714 if not ArkInventory.Global.Thread.Use then
2715 -- should be set to true by default so if its not then i forgot to put it back
2716 ArkInventory.OutputWarning( "Thread.Use is disabled (this may be deliberate if this is an Alpha/Beta version)" )
2717 end
2718
2719
2720 SetSortBagsRightToLeft( ArkInventory.db.option.restack.reverse )
2721
2722end
2723
2724function ArkInventory.OnDisable( )
2725
2726 --ArkInventory.Frame_Main_Hide( )
2727
2728 if ArkInventory.TOCVersionFail( true ) then return end
2729
2730 ArkInventory.BlizzardAPIHook( true )
2731
2732 ArkInventory.Output( ArkInventory.Global.Version, " ", ArkInventory.Localise["DISABLED"] )
2733
2734end
2735
2736function ArkInventory.ItemSortKeyClear( loc_id )
2737
2738 -- clear sort keys
2739
2740 local codex = ArkInventory.GetLocationCodex( loc_id )
2741
2742 if not codex.workpad.bar then return end
2743
2744 for _, bar in pairs( codex.workpad.bar ) do
2745 for _, item in pairs( bar.item ) do
2746 item.sortkey = nil
2747 end
2748 end
2749
2750end
2751
2752function ArkInventory.ItemSortKeyGenerate( i, bar_id, codex )
2753
2754 if not i then return nil end
2755
2756 local codex = codex or ArkInventory.GetLocationCodex( i.loc_id )
2757
2758 local sid = codex.style.sort.method
2759
2760 if bar_id then
2761 sid = codex.layout.bar.data[bar_id].sort.method or sid
2762 end
2763
2764 local sorting = ArkInventory.ConfigInternalSortMethodGet( sid )
2765
2766 local s = { }
2767 local sx = ""
2768
2769 if sid == 9995 then
2770 -- vault layout / void storage layout
2771 s["!bagslot"] = string.format( "%04i %04i", i.bag_id or 0, i.did or i.slot_id or 0 )
2772 else
2773 -- all other bag/slot
2774 s["!bagslot"] = string.format( "%04i %04i", i.bag_id or 0, i.slot_id or 0 )
2775 end
2776
2777 if sorting.used and not sorting.bagslot then
2778
2779 local t
2780 local info = ArkInventory.ObjectInfoArray( i.h, i )
2781
2782 -- slot type
2783 t = 0
2784 if sorting.active.slottype then
2785 t = info.osd.slottype
2786 end
2787 s["!slottype"] = string.format( "%04i", t or 0 )
2788
2789
2790 -- item count (system)
2791 t = i.count
2792 s["!count"] = string.format( "%010i", t or 1 )
2793
2794
2795 -- item name
2796 t = "!"
2797 if sorting.active.name then
2798
2799 if i.h then
2800
2801 t = info.name
2802 if t and type( i.cn ) == "string" and i.cn ~= "" then
2803 t = string.format( "%s %s", t, i.cn )
2804 end
2805 t = t or "!"
2806
2807 if sorting.reversed then
2808 t = ArkInventory.ReverseName( t )
2809 end
2810
2811 else
2812
2813 if codex.style.slot.empty.position then
2814 -- first alphabetically (default)
2815 t = "!"
2816 else
2817 -- last alphabetically
2818 t = "_"
2819 end
2820
2821 end
2822
2823 end
2824 s["name"] = t or "!"
2825
2826
2827 -- item quality
2828 t = 0
2829 if i.q and sorting.active.quality then
2830 t = i.q
2831 end
2832 s["quality"] = string.format( "%02i", t or 0 )
2833
2834
2835 -- equip location
2836 t = "!"
2837 if i.h and info.class == "item" and sorting.active.location then
2838 if type( info.equiploc ) == "string" and info.equiploc ~= "" and _G[info.equiploc] then
2839 t = _G[info.equiploc]
2840 end
2841 end
2842 s["location"] = string.format( "%s", t or "!" )
2843
2844
2845 -- item type / subtype
2846 local item_type = 0
2847 local item_subtype = 0
2848
2849 if sorting.active.itemtype then
2850 item_type = info.itemtypeid
2851 item_subtype = info.itemsubtypeid
2852 end
2853 s["itemtype"] = string.format( "%04i %04i", item_type or 0, item_subtype or 0 )
2854
2855
2856 -- item (use) level
2857 t = 0
2858 if i.h and sorting.active.itemuselevel then
2859 t = info.uselevel
2860 end
2861 s["itemuselevel"] = string.format( "%04i", t or 0 )
2862
2863
2864 -- item (stat) level
2865 t = 0
2866 if i.h and sorting.active.itemstatlevel then
2867 t = info.ilvl
2868 end
2869 s["itemstatlevel"] = string.format( "%04i", t or 0 )
2870
2871
2872 -- item age
2873 t = 0
2874 if i.h and sorting.active.itemage then
2875 t = i.age
2876 end
2877 s["itemage"] = string.format( "%010i", t or 0 )
2878
2879
2880 -- vendor price
2881 t = 0
2882 if i.h and sorting.active.vendorprice then
2883 t = ( info.vendorprice or 0 ) * ( i.count or 1 )
2884 end
2885 s["vendorprice"] = string.format( "%010i", t or 0 )
2886
2887
2888 -- expansion
2889 t = 0
2890 if i.h and sorting.active.expansion then
2891 t = ( info.expansion or 0 )
2892 end
2893 s["expansion"] = string.format( "%03i", t or 0 )
2894
2895
2896 -- category
2897 local cat_type = 0
2898 local cat_code = 0
2899 local cat_order = 0
2900
2901 if i.h and sorting.active.category then
2902
2903 local cat_id = ArkInventory.ItemCategoryGet( i )
2904
2905 cat_type, cat_code = ArkInventory.CategoryCodeSplit( cat_id )
2906
2907 if cat_type == ArkInventory.Const.Category.Type.Rule then
2908 local cat = ArkInventory.db.option.category[cat_type].data[cat_code]
2909 if cat.used then
2910 cat_order = cat.order
2911 end
2912 end
2913
2914 end
2915 s["category"] = string.format( "%02i %04i %04i", cat_type or 0, cat_order or 0, cat_code or 0 )
2916
2917
2918 -- id
2919 local t = 0
2920 if i.h and sorting.active.id then
2921 t = info.id
2922 end
2923 s["id"] = string.format( "%s:%010i:%02i", info.class or "error", t or 0, info.sb or ArkInventory.Const.Bind.Never )
2924
2925
2926 -- build key
2927 for k, v in ipairs( sorting.order ) do
2928 if type( s[v] ) == "string" then
2929 sx = string.format( "%s %s", sx, s[v] )
2930 end
2931 end
2932
2933 sx = string.format( "%s%s", sx, s["!count"] )
2934 sx = string.format( "%s%s", sx, s["!bagslot"] )
2935
2936 else
2937
2938 sx = s["!bagslot"]
2939
2940 end
2941
2942 return sx
2943
2944end
2945
2946
2947function ArkInventory.LocationSetValue( l, k, v )
2948 for loc_id, loc_data in pairs( ArkInventory.Global.Location ) do
2949 if l == nil or l == loc_id then
2950 loc_data[k] = v
2951 end
2952 end
2953end
2954
2955function ArkInventory.CategoryLocationSet( loc_id, cat_id, bar_id )
2956
2957 assert( cat_id ~= nil , "category is nil" )
2958
2959 local cat_def = ArkInventory.CategoryGetSystemID( "SYSTEM_DEFAULT" )
2960
2961 if ( cat_id ~= cat_def ) or ( bar_id ~= nil ) then
2962 local codex = ArkInventory.GetLocationCodex( loc_id )
2963 codex.layout.category[cat_id] = bar_id
2964 end
2965
2966end
2967
2968function ArkInventory.CategoryLocationGet( loc_id, cat_id )
2969
2970 -- return 1: which bar a category is located on
2971 -- return 2: is it the default bar
2972
2973 local cat_id = cat_id or ArkInventory.CategoryGetSystemID( "SYSTEM_UNKNOWN" )
2974
2975 local codex = ArkInventory.GetLocationCodex( loc_id )
2976 local bar_id = codex.layout.category[cat_id]
2977 --ArkInventory.Output( "loc=[", loc_id, "], cat=[", cat_id, "], bar=[", bar, "]" )
2978
2979 local cat_def = ArkInventory.CategoryGetSystemID( "SYSTEM_DEFAULT" )
2980 local bar_def = codex.layout.category[cat_def] or 1
2981
2982 if not bar_id then
2983 -- if this category hasn't been assigned to a bar then return the bar that DEFAULT is using
2984 return bar_def, true
2985 else
2986 return bar_id, false
2987 end
2988
2989end
2990
2991function ArkInventory.CategoryHiddenCheck( loc_id, cat_id )
2992
2993 -- hidden categories have a negative bar number
2994
2995 local bar_id = ArkInventory.CategoryLocationGet( loc_id, cat_id )
2996
2997 if bar_id < 0 then
2998 return true
2999 else
3000 return false
3001 end
3002
3003end
3004
3005function ArkInventory.CategoryHiddenToggle( loc_id, cat_id )
3006 ArkInventory.CategoryLocationSet( loc_id, cat_id, 0 - ArkInventory.CategoryLocationGet( loc_id, cat_id ) )
3007end
3008
3009function ArkInventory.CategoryGenerate( )
3010
3011 local categories = {
3012 ["SYSTEM"] = ArkInventory.Const.Category.Code.System, -- CATEGORY_SYSTEM
3013 ["CONSUMABLE"] = ArkInventory.Const.Category.Code.Consumable, -- CATEGORY_CONSUMABLE
3014 ["TRADEGOODS"] = ArkInventory.Const.Category.Code.Trade, -- CATEGORY_TRADEGOODS
3015 ["SKILL"] = ArkInventory.Const.Category.Code.Skill, -- CATEGORY_SKILL
3016 ["CLASS"] = ArkInventory.Const.Category.Code.Class, -- CATEGORY_CLASS
3017 ["EMPTY"] = ArkInventory.Const.Category.Code.Empty, -- CATEGORY_EMPTY
3018 ["RULE"] = ArkInventory.db.option.category[ArkInventory.Const.Category.Type.Rule].data, -- CATEGORY_RULE
3019 ["CUSTOM"] = ArkInventory.db.option.category[ArkInventory.Const.Category.Type.Custom].data, -- CATEGORY_CUSTOM
3020 }
3021
3022 table.wipe( ArkInventory.Global.Category )
3023
3024 for tn, d in pairs( categories ) do
3025
3026 for k, v in pairs( d ) do
3027
3028 --ArkInventory.Output( k, " - ", v )
3029
3030 local system, order, sort_order, name, cat_id, cat_type, cat_code
3031
3032 if tn == "RULE" then
3033
3034 if v.used == "Y" then
3035
3036 cat_type = ArkInventory.Const.Category.Type.Rule
3037 cat_code = k
3038
3039 system = nil
3040 name = string.format( "[%04i] %s", k, v.name )
3041 order = ( v.order or 99999 ) + ( k / 10000 )
3042 sort_order = string.lower( v.name )
3043
3044 end
3045
3046 elseif tn == "CUSTOM" then
3047
3048 if v.used == "Y" then
3049
3050 cat_type = ArkInventory.Const.Category.Type.Custom
3051 cat_code = k
3052
3053 system = nil
3054 name = string.format( "[%04i] %s", k, v.name )
3055 order = k
3056 sort_order = string.lower( v.name )
3057
3058 end
3059
3060 else
3061
3062 cat_type = ArkInventory.Const.Category.Type.System
3063 cat_code = k
3064
3065 system = string.upper( v.id )
3066
3067 name = v.text
3068 if type( name ) == "function" then
3069 name = name( )
3070 end
3071 sort_order = string.lower( name )
3072 name = string.format( "[%04i] %s", k, name or system )
3073
3074 end
3075
3076 if name then
3077
3078 cat_id = ArkInventory.CategoryCodeJoin( cat_type, cat_code )
3079
3080 assert( not ArkInventory.Global.Category[cat_id], string.format( "duplicate category: %s [%s] ", tn, cat_id ) )
3081
3082 ArkInventory.Global.Category[cat_id] = {
3083 ["id"] = cat_id,
3084 ["system"] = system,
3085 ["name"] = name or string.format( "%s %04i %s", tn, k, "<no name>" ),
3086 ["fullname"] = string.format( "%s > %s", ArkInventory.Localise[string.format( "CATEGORY_%s", tn )], name ),
3087 ["order"] = order or 0,
3088 ["sort_order"] = string.lower( sort_order ) or "!",
3089 ["type_code"] = tn,
3090 ["type"] = ArkInventory.Localise[string.format( "CATEGORY_%s", tn )],
3091 }
3092
3093 end
3094
3095 end
3096
3097 end
3098
3099end
3100
3101function ArkInventory.CategoryCodeSplit( id )
3102 local cat_type, cat_code = string.match( id, "(%d+)!(%d+)" )
3103 return tonumber( cat_type ), tonumber( cat_code )
3104end
3105
3106function ArkInventory.CategoryCodeJoin( cat_type, cat_code )
3107 return string.format( "%i!%i", cat_type, cat_code )
3108end
3109
3110function ArkInventory.CategoryGetNext( v )
3111
3112 if not v.next then
3113 v.next = v.min
3114 else
3115 if v.next < v.min then
3116 v.next = v.min
3117 end
3118 end
3119
3120 local c = 0
3121
3122 while true do
3123
3124 v.next = v.next + 1
3125
3126 if v.next > v.max then
3127 c = c + 1
3128 v.next = v.min
3129 end
3130
3131 if c > 1 then
3132 return -1
3133 end
3134
3135 if not v.data[v.next] then
3136 return -2
3137 end
3138
3139 if v.data[v.next].used == "N" then
3140 return v.next, v.data[v.next]
3141 end
3142
3143 end
3144
3145end
3146
3147function ArkInventory.CategoryBarHasEntries( loc_id, bar_id, cat_type )
3148
3149 for _, cat in ArkInventory.spairs( ArkInventory.Global.Category ) do
3150
3151 local t = cat.type_code
3152 local cat_bar, def_bar = ArkInventory.CategoryLocationGet( loc_id, cat.id )
3153
3154 if abs( cat_bar ) == bar_id and not def_bar then
3155 if cat_type == t then
3156 return true
3157 end
3158 end
3159
3160 end
3161
3162end
3163
3164
3165function ArkInventory.CategoryGetSystemID( cat_name )
3166
3167 -- internal system category names only, if it doesnt exist you'll get the default instead
3168
3169 --ArkInventory.Output( "search=[", cat_name, "]" )
3170
3171 local cat_name = string.upper( cat_name )
3172 local cat_def
3173
3174 for _, v in pairs( ArkInventory.Global.Category ) do
3175
3176 --ArkInventory.Output( "checking=[", v.system, "]" )
3177
3178 if cat_name == v.system then
3179 --ArkInventory.Output( "found=[", cat_name, " = ", v.name, "] = [", v.id, "]" )
3180 return v.id
3181
3182 elseif v.system == "SYSTEM_DEFAULT" then
3183 --ArkInventory.Output( "default found=[", v.name, "] = [", v.id, "]" )
3184 cat_def = v.id
3185 end
3186
3187 end
3188
3189 --ArkInventory.Output( "not found=[", cat_name, "] = using default[", cat_def, "]" )
3190 return cat_def
3191
3192end
3193
3194
3195function ArkInventory.ItemCategoryGetDefaultActual( i )
3196
3197 -- local debuginfo = { ["m"]=gcinfo( ), ["t"]=GetTime( ) }
3198
3199 -- pet journal pets
3200 if i.loc_id == ArkInventory.Const.Location.Pet then
3201
3202 if i.bp then
3203 if i.sb == ArkInventory.Const.Bind.Pickup or i.sb == ArkInventory.Const.Bind.Account then
3204 return ArkInventory.CategoryGetSystemID( "SYSTEM_PET_BATTLE_BOUND" )
3205 else
3206 return ArkInventory.CategoryGetSystemID( "SYSTEM_PET_BATTLE_TRADE" )
3207 end
3208 else
3209 if i.sb == ArkInventory.Const.Bind.Pickup or i.sb == ArkInventory.Const.Bind.Account then
3210 return ArkInventory.CategoryGetSystemID( "SYSTEM_PET_COMPANION_BOUND" )
3211 else
3212 return ArkInventory.CategoryGetSystemID( "SYSTEM_PET_COMPANION_TRADE" )
3213 end
3214 end
3215
3216 end
3217
3218 -- mounts
3219 if i.loc_id == ArkInventory.Const.Location.Mount then
3220 return ArkInventory.CategoryGetSystemID( "SYSTEM_MOUNT" )
3221 end
3222
3223 -- currencies
3224 if i.loc_id == ArkInventory.Const.Location.Token then
3225 return ArkInventory.CategoryGetSystemID( "SYSTEM_CURRENCY" )
3226 end
3227
3228 -- toybox
3229 if i.loc_id == ArkInventory.Const.Location.Toybox then
3230 return ArkInventory.CategoryGetSystemID( "SYSTEM_TOY" )
3231 end
3232
3233 -- heirloom
3234 if i.loc_id == ArkInventory.Const.Location.Heirloom then
3235 return ArkInventory.CategoryGetSystemID( "SYSTEM_HEIRLOOM" )
3236 end
3237
3238 -- reputation
3239 if i.loc_id == ArkInventory.Const.Location.Reputation then
3240 return ArkInventory.CategoryGetSystemID( "SYSTEM_REPUTATION" )
3241 end
3242
3243
3244 -- everything else
3245 local info = ArkInventory.ObjectInfoArray( i.h, i )
3246
3247
3248 -- mythic keystone
3249 if info.class == "keystone" then
3250 return ArkInventory.CategoryGetSystemID( "SYSTEM_MYTHIC_KEYSTONE" )
3251 end
3252
3253 -- caged battle pets
3254 if info.class == "battlepet" then
3255 if i.sb == ArkInventory.Const.Bind.Pickup or i.sb == ArkInventory.Const.Bind.Account then
3256 return ArkInventory.CategoryGetSystemID( "SYSTEM_PET_BATTLE_BOUND" )
3257 else
3258 return ArkInventory.CategoryGetSystemID( "SYSTEM_PET_BATTLE_TRADE" )
3259 end
3260 end
3261
3262
3263 -- items only from here on
3264 if info.class ~= "item" then return end
3265
3266
3267 if info.q == LE_ITEM_QUALITY_HEIRLOOM then
3268 return ArkInventory.CategoryGetSystemID( "SYSTEM_HEIRLOOM" )
3269 end
3270
3271 --ArkInventory.Output( "bag[", i.bag_id, "], slot[", i.slot_id, "] = ", itemType )
3272
3273 -- no item info
3274 if info.name == nil then
3275 return ArkInventory.CategoryGetSystemID( "SYSTEM_UNKNOWN" )
3276 end
3277
3278 -- unknown items
3279 if info.itemtypeid == ArkInventory.Const.ItemClass.UNKNOWN then
3280 return ArkInventory.CategoryGetSystemID( "SYSTEM_UNKNOWN" )
3281 end
3282
3283 -- starlight rose dust
3284 if info.id == 129158 then
3285 return ArkInventory.CategoryGetSystemID( "SYSTEM_QUEST" )
3286 end
3287
3288 -- trash
3289 if info.q == LE_ITEM_QUALITY_POOR then
3290 return ArkInventory.CategoryGetSystemID( "SYSTEM_TRASH" )
3291 end
3292
3293 -- quest items
3294 if info.itemtypeid == ArkInventory.Const.ItemClass.QUEST then
3295 return ArkInventory.CategoryGetSystemID( "SYSTEM_QUEST" )
3296 end
3297
3298 -- bags / containers
3299 if info.itemtypeid == ArkInventory.Const.ItemClass.CONTAINER then
3300 return ArkInventory.CategoryGetSystemID( "SYSTEM_CONTAINER" )
3301 end
3302
3303 -- gems
3304 if info.itemtypeid == ArkInventory.Const.ItemClass.GEM then
3305 if info.itemsubtypeid == ArkInventory.Const.ItemClass.GEM_ARTIFACT_RELIC then
3306 return ArkInventory.CategoryGetSystemID( "SYSTEM_ARTIFACT_RELIC" )
3307 else
3308 return ArkInventory.CategoryGetSystemID( "SYSTEM_GEM" )
3309 end
3310 end
3311
3312 -- glyphs
3313 if info.itemtypeid == ArkInventory.Const.ItemClass.GLYPH then
3314 return ArkInventory.CategoryGetSystemID( "SYSTEM_GLYPH" )
3315 end
3316
3317 -- battle pet as an item
3318 if info.itemtypeid == ArkInventory.Const.ItemClass.BATTLEPET then
3319 if i.sb == ArkInventory.Const.Bind.Pickup or i.sb == ArkInventory.Const.Bind.Account then
3320 return ArkInventory.CategoryGetSystemID( "SYSTEM_PET_BATTLE_BOUND" )
3321 else
3322 return ArkInventory.CategoryGetSystemID( "SYSTEM_PET_BATTLE_TRADE" )
3323 end
3324 end
3325
3326 -- misc
3327 if info.itemtypeid == ArkInventory.Const.ItemClass.MISC then
3328
3329 if info.itemsubtypeid == ArkInventory.Const.ItemClass.MISC_PET or ArkInventory.PT_ItemInSets( i.h, ArkInventory.Localise["PT_CATEGORY_PET"] ) then
3330 if i.sb == ArkInventory.Const.Bind.Pickup or i.sb == ArkInventory.Const.Bind.Account then
3331 return ArkInventory.CategoryGetSystemID( "SYSTEM_PET_COMPANION_BOUND" )
3332 else
3333 return ArkInventory.CategoryGetSystemID( "SYSTEM_PET_COMPANION_TRADE" )
3334 end
3335 end
3336
3337 if info.itemsubtypeid == ArkInventory.Const.ItemClass.MISC_MOUNT or ArkInventory.PT_ItemInSets( i.h, ArkInventory.Localise["PT_CATEGORY_MOUNT"] ) then
3338 return ArkInventory.CategoryGetSystemID( "SYSTEM_MOUNT" )
3339 end
3340
3341 end
3342
3343 -- item enhancements
3344 if info.itemtypeid == ArkInventory.Const.ItemClass.ITEM_ENHANCEMENT then
3345 return ArkInventory.CategoryGetSystemID( "SYSTEM_ITEM_ENHANCEMENT" )
3346 end
3347
3348 -- artifact power. tooltip check is lower down
3349 if IsArtifactPowerItem( info.id ) or ArkInventory.PT_ItemInSets( i.h, ArkInventory.Localise["PT_CATEGORY_ARTIFACT_POWER"] ) then
3350 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_ARTIFACT_POWER" )
3351 end
3352
3353
3354
3355 -- setup tooltip for scanning
3356 if ArkInventory.Global.Location[i.loc_id].isOffline then
3357 ArkInventory.TooltipSetHyperlink( ArkInventory.Global.Tooltip.Scan, i.h )
3358 else
3359 local blizzard_id = ArkInventory.InternalIdToBlizzardBagId( i.loc_id, i.bag_id )
3360 ArkInventory.TooltipSetItem( ArkInventory.Global.Tooltip.Scan, blizzard_id, i.slot_id )
3361 end
3362
3363 -- tooltip not ready, set to unknown so it will try again next time
3364 if not ArkInventory.TooltipIsReady( ArkInventory.Global.Tooltip.Scan ) then
3365 ArkInventory.OutputError( i.h, " not ready" )
3366 return ArkInventory.CategoryGetSystemID( "SYSTEM_UNKNOWN" )
3367 end
3368
3369
3370 -- unusable soulbound items are also trash (if enabled)
3371 if i.loc_id == ArkInventory.Const.Location.Bag then
3372 if false then -- add config option first
3373 if i.sb == ArkInventory.Const.Bind.Pickup then
3374 local usable = ArkInventory.TooltipCanUse( ArkInventory.Global.Tooltip.Scan )
3375 if not usable then
3376 return ArkInventory.CategoryGetSystemID( "SYSTEM_TRASH" )
3377 end
3378 end
3379 end
3380 end
3381
3382
3383 -- equipable items
3384 if info.equiploc ~= "" or info.itemtypeid == ArkInventory.Const.ItemClass.WEAPON or info.itemtypeid == ArkInventory.Const.ItemClass.ARMOR then
3385
3386-- if not ( info.itemtypeid == ArkInventory.Const.ItemClass.WEAPON or info.itemtypeid == ArkInventory.Const.ItemClass.ARMOR ) then
3387-- ArkInventory.Output( i.h, " / ", info.equiploc )
3388-- end
3389
3390 if i.sb == ArkInventory.Const.Bind.Account then
3391 return ArkInventory.CategoryGetSystemID( "SYSTEM_EQUIPMENT_ACCOUNTBOUND" )
3392 elseif i.sb == ArkInventory.Const.Bind.Pickup then
3393 return ArkInventory.CategoryGetSystemID( "SYSTEM_EQUIPMENT_SOULBOUND" )
3394 else
3395 return ArkInventory.CategoryGetSystemID( "SYSTEM_EQUIPMENT" )
3396 end
3397
3398 end
3399
3400
3401 -- recipe
3402 if info.itemtypeid == ArkInventory.Const.ItemClass.RECIPE then
3403 return ArkInventory.CategoryGetSystemID( "SYSTEM_RECIPE" )
3404 end
3405
3406 -- toys
3407 if ArkInventory.TooltipContains( ArkInventory.Global.Tooltip.Scan, ITEM_TOY_ONUSE, false, true, true, true ) then
3408 if ( i.sb == ArkInventory.Const.Bind.Pickup or i.sb == ArkInventory.Const.Bind.Account ) and ArkInventory.TooltipContains( ArkInventory.Global.Tooltip.Scan, ArkInventory.Localise["ALREADY_KNOWN"], false, true, true, true ) then
3409 return ArkInventory.CategoryGetSystemID( "SYSTEM_TRASH" )
3410 else
3411 return ArkInventory.CategoryGetSystemID( "SYSTEM_TOY" )
3412 end
3413 end
3414
3415
3416 local codex = ArkInventory.GetLocationCodex( i.loc_id )
3417
3418 -- only check these if its the player (not the account)
3419 if codex.player.data.info.isplayer then
3420
3421 -- class requirement (via tooltip)
3422 local _, _, req = ArkInventory.TooltipFind( ArkInventory.Global.Tooltip.Scan, ArkInventory.Localise["WOW_TOOLTIP_REQUIRES_CLASS"], false, true, true, 0, true )
3423 if req and string.find( req, codex.player.data.info.class_local ) then
3424 return ArkInventory.CategoryGetSystemID( string.format( "CLASS_%s", codex.player.data.info.class ) )
3425 end
3426
3427 -- class requirement (via PT)
3428 local key = string.format( "PT_CLASS_%s", codex.player.data.info.class )
3429 if ArkInventory.PT_ItemInSets( i.h, ArkInventory.Localise[key] ) then
3430 return ArkInventory.CategoryGetSystemID( string.format( "CLASS_%s", codex.player.data.info.class ) )
3431 end
3432
3433 end
3434
3435
3436 -- artifact power (tooltip)
3437 if ArkInventory.TooltipFind( ArkInventory.Global.Tooltip.Scan, ArkInventory.Localise["WOW_TOOLTIP_ARTIFACT_POWER"], false, true, false, 0, true ) then
3438 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_ARTIFACT_POWER" )
3439 end
3440
3441 -- ancient mana (tooltip)
3442 if ArkInventory.TooltipFind( ArkInventory.Global.Tooltip.Scan, ArkInventory.Localise["WOW_TOOLTIP_ANCIENT_MANA"], false, true, false, 0, true ) then
3443 return ArkInventory.CategoryGetSystemID( "SYSTEM_CURRENCY" )
3444 end
3445
3446
3447 if info.itemtypeid == ArkInventory.Const.ItemClass.TRADEGOODS then
3448
3449 local t = { "ELEMENTAL", "CLOTH", "LEATHER", "METAL_AND_STONE", "COOKING", "HERB", "ENCHANTING", "JEWELCRAFTING", "ENCHANTMENT" }
3450
3451 for _, w in pairs( t ) do
3452 if info.itemsubtypeid == ArkInventory.Const.ItemClass[string.format( "TRADEGOODS_%s", w )] then
3453 return ArkInventory.CategoryGetSystemID( string.format( "TRADEGOODS_%s", w ) )
3454 end
3455 end
3456
3457 end
3458
3459 if info.itemtypeid == ArkInventory.Const.ItemClass.CONSUMABLE then
3460
3461 if info.itemsubtypeid == ArkInventory.Const.ItemClass.CONSUMABLE_FOOD_AND_DRINK then
3462
3463 if ArkInventory.TooltipContains( ArkInventory.Global.Tooltip.Scan, ArkInventory.Localise["WOW_ITEM_TOOLTIP_FOOD"] ) then
3464 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_FOOD" )
3465 end
3466
3467 if ArkInventory.TooltipContains( ArkInventory.Global.Tooltip.Scan, ArkInventory.Localise["WOW_ITEM_TOOLTIP_DRINK"] ) then
3468 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_DRINK" )
3469 end
3470
3471 if ArkInventory.PT_ItemInSets( i.h, ArkInventory.Localise["PT_CATEGORY_CONSUMABLE_FOOD"] ) then
3472 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_FOOD" )
3473 end
3474
3475 if ArkInventory.PT_ItemInSets( i.h, ArkInventory.Localise["PT_CATEGORY_CONSUMABLE_DRINK"] ) then
3476 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_DRINK" )
3477 end
3478
3479 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_FOOD_AND_DRINK" )
3480
3481 end
3482
3483 if info.itemsubtypeid == ArkInventory.Const.ItemClass.CONSUMABLE_POTION then
3484
3485 if ArkInventory.TooltipContains( ArkInventory.Global.Tooltip.Scan, ArkInventory.Localise["WOW_ITEM_TOOLTIP_POTION_HEAL"] ) or ArkInventory.PT_ItemInSets( i.h, ArkInventory.Localise["PT_CATEGORY_POTION_HEAL"] ) then
3486 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_POTION_HEAL" )
3487 end
3488
3489 if ArkInventory.TooltipContains( ArkInventory.Global.Tooltip.Scan, ArkInventory.Localise["WOW_ITEM_TOOLTIP_POTION_MANA"] ) or ArkInventory.PT_ItemInSets( i.h, ArkInventory.Localise["PT_CATEGORY_POTION_MANA"] ) then
3490 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_POTION_MANA" )
3491 end
3492
3493 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_POTION" )
3494
3495 end
3496
3497 if info.itemsubtypeid == ArkInventory.Const.ItemClass.CONSUMABLE_ELIXIR then
3498
3499 if ArkInventory.TooltipContains( ArkInventory.Global.Tooltip.Scan, ArkInventory.Localise["WOW_ITEM_TOOLTIP_ELIXIR_BATTLE"] ) then
3500 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_ELIXIR_BATTLE" )
3501 end
3502
3503 if ArkInventory.TooltipContains( ArkInventory.Global.Tooltip.Scan, ArkInventory.Localise["WOW_ITEM_TOOLTIP_ELIXIR_GUARDIAN"] ) then
3504 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_ELIXIR_GUARDIAN" )
3505 end
3506
3507 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_ELIXIR" )
3508
3509 end
3510
3511 if info.itemsubtypeid == ArkInventory.Const.ItemClass.CONSUMABLE_FLASK then
3512 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_FLASK" )
3513 end
3514
3515 if info.itemsubtypeid == ArkInventory.Const.ItemClass.CONSUMABLE_BANDAGE then
3516 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_BANDAGE" )
3517 end
3518
3519 if info.itemsubtypeid == ArkInventory.Const.ItemClass.CONSUMABLE_EXPLOSIVES_AND_DEVICES then
3520 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_EXPLOSIVES_AND_DEVICES" )
3521 end
3522
3523 if info.itemsubtypeid == ArkInventory.Const.ItemClass.CONSUMABLE_OTHER then
3524
3525 if ArkInventory.TooltipContains( ArkInventory.Global.Tooltip.Scan, ArkInventory.Localise["BATTLEPET"] ) then
3526 if i.sb == ArkInventory.Const.Bind.Pickup or i.sb == ArkInventory.Const.Bind.Account then
3527 return ArkInventory.CategoryGetSystemID( "SYSTEM_PET_COMPANION_BOUND" )
3528 else
3529 return ArkInventory.CategoryGetSystemID( "SYSTEM_PET_COMPANION_TRADE" )
3530 end
3531 end
3532
3533 end
3534
3535 end
3536
3537
3538 -- primary professions
3539 if codex.player.data.info.skills then
3540
3541 local _, _, req = ArkInventory.TooltipFind( ArkInventory.Global.Tooltip.Scan, ArkInventory.Localise["WOW_TOOLTIP_REQUIRES_SKILL"], false, true, true, 0, true )
3542
3543 for x = 1, ArkInventory.Const.Skills.Primary do
3544
3545 if codex.player.data.info.skills[x] then
3546
3547 local skill = ArkInventory.Const.Skills.Data[codex.player.data.info.skills[x]]
3548
3549 if skill then
3550
3551 if ArkInventory.PT_ItemInSets( i.h, skill.pt ) then
3552 return ArkInventory.CategoryGetSystemID( skill.id )
3553 end
3554
3555 if req and string.find( req, skill.text ) then
3556 return ArkInventory.CategoryGetSystemID( skill.id )
3557 end
3558
3559 end
3560
3561 end
3562
3563 end
3564
3565 end
3566
3567
3568 -- crafting reagents
3569 if info.craft then
3570 return ArkInventory.CategoryGetSystemID( "SYSTEM_CRAFTING_REAGENT" )
3571 --return ArkInventory.CategoryGetSystemID( "SYSTEM_REAGENT" )
3572 end
3573
3574
3575 -- misc
3576 if info.itemtypeid == ArkInventory.Const.ItemClass.MISC then
3577
3578 if info.itemsubtypeid == ArkInventory.Const.ItemClass.MISC_REAGENT then
3579 return ArkInventory.CategoryGetSystemID( "SYSTEM_REAGENT" )
3580 end
3581
3582 if info.itemsubtypeid == ArkInventory.Const.ItemClass.MISC_OTHER then
3583
3584 if ArkInventory.TooltipContains( ArkInventory.Global.Tooltip.Scan, ArkInventory.Localise["BATTLEPET"] ) then
3585 if i.sb == ArkInventory.Const.Bind.Pickup or i.sb == ArkInventory.Const.Bind.Account then
3586 return ArkInventory.CategoryGetSystemID( "SYSTEM_PET_COMPANION_BOUND" )
3587 else
3588 return ArkInventory.CategoryGetSystemID( "SYSTEM_PET_COMPANION_TRADE" )
3589 end
3590 end
3591
3592 end
3593
3594 end
3595
3596 if info.itemtypeid == ArkInventory.Const.ItemClass.TRADEGOODS then
3597
3598 if info.itemsubtypeid == ArkInventory.Const.ItemClass.TRADEGOODS_PARTS then
3599 return ArkInventory.CategoryGetSystemID( "TRADEGOODS_PARTS" )
3600 end
3601
3602 end
3603
3604 -- archeology
3605 if ArkInventory.PT_ItemInSets( i.h, ArkInventory.Const.Skills.Data[794].pt ) then
3606 return ArkInventory.CategoryGetSystemID( ArkInventory.Const.Skills.Data[794].id )
3607 end
3608
3609 -- quest items (via tooltip)
3610 if ArkInventory.TooltipContains( ArkInventory.Global.Tooltip.Scan, ITEM_BIND_QUEST, false, true, true ) then
3611 return ArkInventory.CategoryGetSystemID( "SYSTEM_QUEST" )
3612 end
3613
3614 -- quest items (via PT)
3615 if ArkInventory.PT_ItemInSets( i.h, ArkInventory.Localise["PT_CATEGORY_QUEST"] ) then
3616 return ArkInventory.CategoryGetSystemID( "SYSTEM_QUEST" )
3617 end
3618
3619 -- reputation (via PT)
3620 if ArkInventory.PT_ItemInSets( i.h, ArkInventory.Localise["PT_CATEGORY_REPUTATION"] ) then
3621 return ArkInventory.CategoryGetSystemID( "SYSTEM_REPUTATION" )
3622 end
3623
3624
3625
3626 -- left overs
3627
3628 if i.sb == ArkInventory.Const.Bind.Pickup or i.sb == ArkInventory.Const.Bind.Account then
3629 return ArkInventory.CategoryGetSystemID( "SYSTEM_SOULBOUND" )
3630 end
3631
3632 if info.itemtypeid == ArkInventory.Const.ItemClass.TRADEGOODS then
3633 return ArkInventory.CategoryGetSystemID( "TRADEGOODS_OTHER" )
3634 end
3635
3636 if info.itemtypeid == ArkInventory.Const.ItemClass.CONSUMABLE then
3637 return ArkInventory.CategoryGetSystemID( "CONSUMABLE_OTHER" )
3638 end
3639
3640 if info.itemtypeid == ArkInventory.Const.ItemClass.MISC then
3641 return ArkInventory.CategoryGetSystemID( "SYSTEM_MISC" )
3642 end
3643
3644 if info.itemtypeid == ArkInventory.Const.ItemClass.REAGENT then
3645 return ArkInventory.CategoryGetSystemID( "SYSTEM_REAGENT" )
3646 end
3647
3648
3649 return ArkInventory.CategoryGetSystemID( "SYSTEM_DEFAULT" )
3650
3651end
3652
3653function ArkInventory.ItemCategoryGetDefaultEmpty( loc_id, bag_id )
3654
3655 local codex = ArkInventory.GetLocationCodex( loc_id )
3656 local clump = codex.style.slot.empty.clump
3657
3658 local blizzard_id = ArkInventory.InternalIdToBlizzardBagId( loc_id, bag_id )
3659 local bt = ArkInventory.BagType( blizzard_id )
3660
3661 --ArkInventory.Output( "loc[", loc_id, "] bag[", bag_id, " / ", blizzard_id, "] type[", bt, "]" )
3662
3663 if bt == ArkInventory.Const.Slot.Type.Bag then
3664 if clump then
3665 return ArkInventory.CategoryGetSystemID( "EMPTY" )
3666 else
3667 return ArkInventory.CategoryGetSystemID( "EMPTY_BAG" )
3668 end
3669 end
3670
3671 if bt == ArkInventory.Const.Slot.Type.Enchanting then
3672 if clump then
3673 return ArkInventory.CategoryGetSystemID( "SKILL_ENCHANTING" )
3674 else
3675 return ArkInventory.CategoryGetSystemID( "EMPTY_ENCHANTING" )
3676 end
3677 end
3678
3679 if bt == ArkInventory.Const.Slot.Type.Engineering then
3680 if clump then
3681 return ArkInventory.CategoryGetSystemID( "SKILL_ENGINEERING" )
3682 else
3683 return ArkInventory.CategoryGetSystemID( "EMPTY_ENGINEERING" )
3684 end
3685 end
3686
3687 if bt == ArkInventory.Const.Slot.Type.Gem then
3688 if clump then
3689 return ArkInventory.CategoryGetSystemID( "SKILL_JEWELCRAFTING" )
3690 else
3691 return ArkInventory.CategoryGetSystemID( "EMPTY_GEM" )
3692 end
3693 end
3694
3695 if bt == ArkInventory.Const.Slot.Type.Herb then
3696 if clump then
3697 return ArkInventory.CategoryGetSystemID( "SKILL_HERBALISM" )
3698 else
3699 return ArkInventory.CategoryGetSystemID( "EMPTY_HERB" )
3700 end
3701 end
3702
3703 if bt == ArkInventory.Const.Slot.Type.Inscription then
3704 if clump then
3705 return ArkInventory.CategoryGetSystemID( "SKILL_INSCRIPTION" )
3706 else
3707 return ArkInventory.CategoryGetSystemID( "EMPTY_INSCRIPTION" )
3708 end
3709 end
3710
3711 if bt == ArkInventory.Const.Slot.Type.Leatherworking then
3712 if clump then
3713 return ArkInventory.CategoryGetSystemID( "SKILL_LEATHERWORKING" )
3714 else
3715 return ArkInventory.CategoryGetSystemID( "EMPTY_LEATHERWORKING" )
3716 end
3717 end
3718
3719 if bt == ArkInventory.Const.Slot.Type.Mining then
3720 if clump then
3721 return ArkInventory.CategoryGetSystemID( "SKILL_MINING" )
3722 else
3723 return ArkInventory.CategoryGetSystemID( "EMPTY_MINING" )
3724 end
3725 end
3726
3727 if bt == ArkInventory.Const.Slot.Type.Tackle then
3728 if clump then
3729 return ArkInventory.CategoryGetSystemID( "SKILL_FISHING" )
3730 else
3731 return ArkInventory.CategoryGetSystemID( "EMPTY_TACKLE" )
3732 end
3733 end
3734
3735 if bt == ArkInventory.Const.Slot.Type.Cooking then
3736 if clump then
3737 return ArkInventory.CategoryGetSystemID( "SKILL_COOKING" )
3738 else
3739 return ArkInventory.CategoryGetSystemID( "EMPTY_COOKING" )
3740 end
3741 end
3742
3743 if bt == ArkInventory.Const.Slot.Type.ReagentBank then
3744 if clump then
3745 return ArkInventory.CategoryGetSystemID( "EMPTY" )
3746 else
3747 return ArkInventory.CategoryGetSystemID( "EMPTY_REAGENTBANK" )
3748 end
3749 end
3750
3751 if clump then
3752 return ArkInventory.CategoryGetSystemID( "EMPTY" )
3753 else
3754 return ArkInventory.CategoryGetSystemID( "EMPTY_UNKNOWN" )
3755 end
3756
3757 ArkInventory.Output( "code failure, should never get here" )
3758
3759end
3760
3761function ArkInventory.ItemCategoryGetDefault( i )
3762
3763 -- items cache id
3764 local cid = ArkInventory.ObjectIDCategory( i )
3765
3766 if ArkInventory.TranslationsLoaded then
3767
3768 if ArkInventory.db.cache.default[cid] then
3769
3770 -- if the value has been cached then use it
3771 return ArkInventory.db.cache.default[cid]
3772
3773 else
3774
3775 local cat
3776
3777 if i.h then
3778
3779 cat = ArkInventory.ItemCategoryGetDefaultActual( i )
3780
3781 if cat ~= ArkInventory.CategoryGetSystemID( "SYSTEM_UNKNOWN" ) then
3782 ArkInventory.db.cache.default[cid] = cat
3783 end
3784
3785 else
3786
3787 cat = ArkInventory.ItemCategoryGetDefaultEmpty( i.loc_id, i.bag_id )
3788
3789 if cat ~= ArkInventory.CategoryGetSystemID( "EMPTY_UNKNOWN" ) then
3790 ArkInventory.db.cache.default[cid] = cat
3791 end
3792
3793 end
3794
3795 return cat
3796
3797 end
3798
3799 else
3800
3801 return ArkInventory.CategoryGetSystemID( "SYSTEM_UNKNOWN" )
3802
3803 end
3804
3805end
3806
3807
3808function ArkInventory.ItemCategoryGetRule( i )
3809
3810 -- local debuginfo = { ["m"]=gcinfo( ), ["t"]=GetTime( ) }
3811
3812 if not ArkInventory.Global.Rules.Enabled then
3813 return false
3814 end
3815
3816 return ArkInventoryRules.AppliesToItem( i )
3817
3818 -- ArkInventory.Output( "ItemCategoryGetRule( ) end", debuginfo )
3819
3820end
3821
3822function ArkInventory.ItemCategoryGetPrimary( i )
3823
3824 if i.h then -- only items can have a category, empty slots can only be used by rules
3825
3826 -- items category cache id
3827 local cid, id, codex = ArkInventory.ObjectIDCategory( i )
3828
3829 local cat_id = codex.catset.category.assign[id]
3830 if cat_id then
3831 -- manually assigned item to a category?
3832 local cat_type, cat_code = ArkInventory.CategoryCodeSplit( cat_id )
3833 if cat_type == 1 then
3834 return cat_id
3835 elseif codex.catset.category.active[cat_type][cat_code] then -- category is active in this categoryset?
3836 if ArkInventory.db.option.category[cat_type].data[cat_code].used == "Y" then -- category is enabled?
3837 return cat_id
3838 end
3839 end
3840 end
3841
3842 end
3843
3844 if ArkInventory.Global.Rules.Enabled then
3845
3846 if ArkInventory.Global.Rules.Broken then
3847 error( "crap" )
3848 end
3849
3850
3851
3852 -- items rule cache id
3853 local cid = ArkInventory.ObjectIDRule( i )
3854
3855 -- if the value has already been cached then use it
3856 if ArkInventory.db.cache.rule[cid] == nil then
3857 -- check for any rule that applies to the item, cache the result, use false for no match (default)
3858 ArkInventory.db.cache.rule[cid] = ArkInventory.ItemCategoryGetRule( i )
3859 end
3860
3861 return ArkInventory.db.cache.rule[cid]
3862
3863 end
3864
3865 return false
3866
3867end
3868
3869function ArkInventory.ItemCategorySet( i, cat_id )
3870
3871 -- set cat_id to nil to reset back to default
3872
3873 local cid, id, codex = ArkInventory.ObjectIDCategory( i )
3874 --ArkInventory.Output( cid, " / ", id, " / ", cat_id, " / ", codex.player.data.info.name )
3875 codex.catset.category.assign[id] = cat_id
3876
3877end
3878
3879function ArkInventory.ItemCategoryGet( i )
3880
3881 local unknown = ArkInventory.CategoryGetSystemID( "SYSTEM_UNKNOWN" )
3882
3883 local default = ArkInventory.CategoryGetSystemID( "SYSTEM_DEFAULT" )
3884 default = ( i and ArkInventory.ItemCategoryGetDefault( i ) ) or default
3885
3886 local cat = ArkInventory.ItemCategoryGetPrimary( i )
3887
3888 return cat or default or unknown, cat, default or unknown
3889
3890end
3891
3892function ArkInventory.ReverseName( n )
3893
3894 if n and type( n ) == "string" then
3895
3896 local s = { }
3897
3898 for w in string.gmatch( n, "%S+" ) do
3899 table.insert( s, 1, w )
3900 end
3901
3902 return table.concat( s, " " )
3903
3904 end
3905
3906end
3907
3908function ArkInventory.ItemCacheClear( h )
3909
3910 --ArkInventory.Output( "ItemCacheClear( )" )
3911
3912 if not h then
3913
3914 --ArkInventory.Output( "clearing cache - all" )
3915
3916 ArkInventory.Table.Clean( ArkInventory.db.cache.rule )
3917 ArkInventory.Table.Clean( ArkInventory.db.cache.default )
3918
3919 else
3920
3921 local cid
3922 local i = { h = h }
3923
3924 --ArkInventory.Output( "clearing cache - ", h )
3925
3926 for loc_id, loc_data in pairs( ArkInventory.Global.Location ) do
3927 i.loc_id = loc_id
3928 for bag_id in pairs( ArkInventory.Global.Location[loc_id].Bags ) do
3929 i.bag_id = bag_id
3930 for k, v in ipairs( ArkInventory.Const.Bind ) do
3931
3932 i.sb = v
3933
3934 cid = ArkInventory.ObjectIDRule( i )
3935 ArkInventory.db.cache.rule[cid] = nil
3936
3937 cid = ArkInventory.ObjectIDCategory( i )
3938 ArkInventory.db.cache.default[cid] = nil
3939
3940 end
3941 end
3942 end
3943
3944 end
3945
3946 ArkInventory.CategoryGenerate( )
3947 --ArkInventory.OutputWarning( "ItemCacheClear - .Recalculate" )
3948 ArkInventory.Frame_Main_DrawStatus( nil, ArkInventory.Const.Window.Draw.Recalculate )
3949
3950end
3951
3952function ArkInventory.Frame_Main_DrawStatus( loc_id, level )
3953
3954 local level = level or ArkInventory.Const.Window.Draw.None
3955
3956 if ArkInventory.Global.Location[loc_id] and ArkInventory.Global.Location[loc_id].canView then
3957 if level < ArkInventory.Global.Location[loc_id].drawState then
3958 ArkInventory.Global.Location[loc_id].drawState = level
3959 end
3960 end
3961
3962end
3963
3964function ArkInventory.Frame_Main_Generate( location, drawstatus )
3965
3966-- if drawstatus and drawstatus < 4 then
3967-- ArkInventory.OutputWarning( "Frame_Main_Generate( ", location, ", ", drawstatus, " )" )
3968-- end
3969
3970 for loc_id, loc_data in pairs( ArkInventory.Global.Location ) do
3971 if loc_data.canView and ( not location or loc_id == location ) then
3972 ArkInventory.Frame_Main_DrawStatus( loc_id, drawstatus )
3973 ArkInventory.Frame_Main_DrawLocation( loc_id )
3974 end
3975 end
3976
3977end
3978
3979function ArkInventory.Frame_Main_DrawLocation( loc_id )
3980 local frame = ArkInventory.Frame_Main_Get( loc_id )
3981 ArkInventory.Frame_Main_Draw( frame )
3982end
3983
3984function ArkInventory.PutItemInBank( )
3985
3986 -- item dropped on bank "bag"
3987
3988 if CursorHasItem( ) then
3989
3990 for x = 1, GetContainerNumSlots( BANK_CONTAINER ) do
3991 h = GetContainerItemLink( BANK_CONTAINER, x )
3992 if not h then
3993 if not PickupContainerItem( BANK_CONTAINER, x ) then
3994 ClearCursor( )
3995 end
3996 return
3997 end
3998 end
3999
4000 UIErrorsFrame:AddMessage( ERR_BAG_FULL, 1.0, 0.1, 0.1, 1.0 )
4001 ClearCursor( )
4002
4003 end
4004
4005end
4006
4007function ArkInventory.PutItemInReagentBank( )
4008
4009 -- item dropped on reagentbank "bag"
4010
4011 if CursorHasItem( ) then
4012
4013 for x = 1, GetContainerNumSlots( REAGENTBANK_CONTAINER ) do
4014 h = GetContainerItemLink( REAGENTBANK_CONTAINER, x )
4015 if not h then
4016 if not PickupContainerItem( REAGENTBANK_CONTAINER, x ) then
4017 ClearCursor( )
4018 end
4019 return
4020 end
4021 end
4022
4023 UIErrorsFrame:AddMessage( ERR_BAG_FULL, 1.0, 0.1, 0.1, 1.0 )
4024 ClearCursor( )
4025
4026 end
4027
4028end
4029
4030function ArkInventory.PutItemInGuildBank( tab_id )
4031
4032 local ctab = GetCurrentGuildBankTab( )
4033 local tab_id = tab_id or ctab
4034
4035 if CursorHasItem( ) then
4036
4037 local loc_id = ArkInventory.Const.Location.Vault
4038 local _, _, _, canDeposit = GetGuildBankTabInfo( tab_id )
4039
4040 if canDeposit then
4041
4042 --ArkInventory.Output( "PutItemInGuildBank( ", tab_id, " )" )
4043
4044 if tab_id ~= ctab then
4045 SetCurrentGuildBankTab( tab_id )
4046 ArkInventory.QueryVault( tab_id )
4047 end
4048
4049 for x = 1, MAX_GUILDBANK_SLOTS_PER_TAB do
4050 h = GetGuildBankItemLink( tab_id, x )
4051 if not h then
4052 if not PickupGuildBankItem( tab_id, x ) then --AutoStoreGuildBankItem
4053 ClearCursor( )
4054 end
4055 return
4056 end
4057 end
4058
4059 UIErrorsFrame:AddMessage( ERR_BAG_FULL, 1.0, 0.1, 0.1, 1.0 )
4060 ClearCursor( )
4061
4062 end
4063
4064 end
4065
4066end
4067
4068function ArkInventory.SetItemButtonStock( frame, count, status )
4069
4070 -- used to show the number of empty slots on bags in the changer window
4071
4072 if not frame then
4073 return
4074 end
4075
4076 local obj = _G[string.format( "%s%s", frame:GetName( ), "Stock" )]
4077 if not obj then
4078 return
4079 end
4080
4081 local count = count or 0
4082
4083 local loc_id = frame.ARK_Data.loc_id
4084
4085 local codex = ArkInventory.GetLocationCodex( loc_id )
4086
4087 if codex.style.changer.freespace.show then
4088
4089 if status then
4090
4091 if status == ArkInventory.Const.Bag.Status.Purchase then
4092 obj:SetText( ArkInventory.Localise["STATUS_PURCHASE"] )
4093 elseif status == ArkInventory.Const.Bag.Status.Unknown then
4094 obj:SetText( ArkInventory.Localise["STATUS_NO_DATA"] )
4095 elseif status == ArkInventory.Const.Bag.Status.NoAccess then
4096 obj:SetText( ArkInventory.Localise["VAULT_TAB_ACCESS_NONE"] )
4097 else
4098 obj:SetText( "" )
4099 end
4100
4101 else
4102
4103 if count > 0 then
4104 obj:SetText( count )
4105 obj.numInStock = count
4106 else
4107 obj:SetText( ArkInventory.Localise["FULL"] )
4108 obj.numInStock = 0
4109 end
4110
4111 end
4112
4113 local colour = codex.style.changer.freespace.colour
4114 obj:SetTextColor( colour.r, colour.g, colour.b )
4115
4116 obj:Show( )
4117
4118 else
4119
4120 obj:SetText( "" )
4121 obj.numInStock = 0
4122 obj:Hide( )
4123
4124 end
4125
4126end
4127
4128function ArkInventory.ValidFrame( frame, visible, db )
4129
4130 if frame and frame.ARK_Data and frame.ARK_Data.loc_id then
4131 return true
4132 end
4133
4134--[[
4135 if frame and frame.ARK_Data and frame.ARK_Data.loc_id then
4136
4137 local r1 = true
4138 if db then
4139 local i = ArkInventory.Frame_Item_GetDB( frame )
4140 if i == nil then
4141 r1 = false
4142 end
4143 end
4144
4145 local r2 = true
4146 if visible and not frame:IsVisible( ) then
4147 r2 = false
4148 end
4149
4150 return r1 and r2
4151
4152 end
4153
4154 return false
4155]]--
4156
4157end
4158
4159function ArkInventory.Frame_Main_Get( loc_id )
4160
4161 local framename = string.format( "%s%s", ArkInventory.Const.Frame.Main.Name, loc_id )
4162 local frame = _G[framename]
4163 assert( frame, string.format( "xml element '%s' could not be found", framename ) )
4164
4165 return frame
4166
4167end
4168
4169function ArkInventory.Frame_Main_Scale( loc_id )
4170
4171 local frame = ArkInventory.Frame_Main_Get( loc_id )
4172
4173 if not ArkInventory.ValidFrame( frame ) then return end
4174
4175 local loc_id = frame.ARK_Data.loc_id
4176
4177 local codex = ArkInventory.GetLocationCodex( loc_id )
4178
4179 local old_scale = frame:GetScale( )
4180 local new_scale = codex.style.window.scale
4181
4182 if old_scale ~= new_scale then
4183 frame:SetScale( new_scale )
4184 end
4185
4186 if ArkInventory.Global.Location[loc_id].drawState <= ArkInventory.Const.Window.Draw.Init then
4187
4188 old_scale = nil
4189
4190 if ArkInventory.db.option.auto.reposition then
4191 ArkInventory.Frame_Main_Reposition( loc_id )
4192 end
4193
4194 end
4195
4196 ArkInventory.Frame_Main_Anchor_Set( loc_id, old_scale )
4197
4198end
4199
4200function ArkInventory.Frame_Main_Scale_All( )
4201 for loc_id, loc_data in pairs( ArkInventory.Global.Location ) do
4202 if loc_data.canView then
4203 ArkInventory.Frame_Main_Scale( loc_id )
4204 end
4205 end
4206end
4207
4208function ArkInventory.Frame_Main_Reposition( loc_id )
4209
4210 local frame = ArkInventory.Frame_Main_Get( loc_id )
4211
4212 if not ArkInventory.ValidFrame( frame ) then return end
4213
4214 if not frame.ARK_Data.loaded then
4215 --ArkInventory.Output( "cant reposition ", frame:GetName( ), " until its been built, the frame has no size" )
4216 --return
4217 end
4218
4219 local codex = ArkInventory.GetLocationCodex( loc_id )
4220 local f_scale = frame:GetScale( )
4221 local a, x
4222
4223 a = codex.profile.location[loc_id].anchor.t
4224 x = UIParent:GetTop( ) / f_scale
4225 if not a or a > x then
4226 --ArkInventory.Output( loc_id, " top = ", a, " / ", x )
4227 codex.profile.location[loc_id].anchor.t = x
4228 codex.profile.location[loc_id].anchor.b = x - frame:GetHeight( )
4229 end
4230
4231 a = codex.profile.location[loc_id].anchor.b
4232 x = UIParent:GetBottom( ) / f_scale
4233 if not a or a < x then
4234 --ArkInventory.Output( loc_id, " bottom = ", a, " / ", x )
4235 codex.profile.location[loc_id].anchor.b = x
4236 codex.profile.location[loc_id].anchor.t = x + frame:GetHeight( )
4237 end
4238
4239 a = codex.profile.location[loc_id].anchor.r
4240 x = UIParent:GetRight( ) / f_scale
4241 if not a or a > x then
4242 --ArkInventory.Output( loc_id, " right = ", a, " / ", x )
4243 codex.profile.location[loc_id].anchor.r = x
4244 codex.profile.location[loc_id].anchor.l = x - frame:GetWidth( )
4245 end
4246
4247 a = codex.profile.location[loc_id].anchor.l
4248 x = UIParent:GetLeft( ) / f_scale
4249 if not a or a < x then
4250 --ArkInventory.Output( loc_id, " left = ", a, " / ", x )
4251 codex.profile.location[loc_id].anchor.l = x
4252 codex.profile.location[loc_id].anchor.r = x + frame:GetWidth( )
4253 end
4254
4255 ArkInventory.Frame_Main_Anchor_Set( loc_id )
4256
4257end
4258
4259function ArkInventory.Frame_Main_Reposition_All( )
4260 for loc_id, loc_data in pairs( ArkInventory.Global.Location ) do
4261 if loc_data.canView then
4262 ArkInventory.Frame_Main_Reposition( loc_id )
4263 end
4264 end
4265end
4266
4267
4268function ArkInventory.Frame_Main_Offline( frame )
4269
4270 local loc_id = frame.ARK_Data.loc_id
4271 local me = ArkInventory.GetPlayerCodex( )
4272 local codex = ArkInventory.GetLocationCodex( loc_id )
4273
4274 --ArkInventory.Output( "loc_playerid=[", ArkInventory.Global.Location[loc_id].player_id, "] player_id=[", codex.player.data.info.player_id, "] guild_id=[", codex.player.data.info.guild_id, "]" )
4275
4276 if codex.player.current == me.player.data.info.player_id or codex.player.current == me.player.data.info.guild_id or ArkInventory.Global.Location[loc_id].isAccount then
4277
4278 ArkInventory.Global.Location[loc_id].isOffline = false
4279
4280 if loc_id == ArkInventory.Const.Location.Bank and ArkInventory.Global.Mode.Bank == false then
4281 ArkInventory.Global.Location[loc_id].isOffline = true
4282 end
4283
4284 if loc_id == ArkInventory.Const.Location.Vault and ArkInventory.Global.Mode.Vault == false then
4285 ArkInventory.Global.Location[loc_id].isOffline = true
4286 end
4287
4288 if loc_id == ArkInventory.Const.Location.Mail and ArkInventory.Global.Mode.Mail == false then
4289 ArkInventory.Global.Location[loc_id].isOffline = true
4290 end
4291
4292 if loc_id == ArkInventory.Const.Location.Void and ArkInventory.Global.Mode.Void == false then
4293 ArkInventory.Global.Location[loc_id].isOffline = true
4294 end
4295
4296 else
4297
4298 ArkInventory.Global.Location[loc_id].isOffline = true
4299
4300 end
4301
4302end
4303
4304function ArkInventory.Frame_Main_Anchor_Save( frame )
4305
4306 if not ArkInventory.ValidFrame( frame, true ) then return end
4307
4308 local loc_id = frame.ARK_Data.loc_id
4309 local codex = ArkInventory.GetLocationCodex( loc_id )
4310
4311 codex.profile.location[loc_id].anchor.t = frame:GetTop( )
4312 codex.profile.location[loc_id].anchor.b = frame:GetBottom( )
4313 codex.profile.location[loc_id].anchor.l = frame:GetLeft( )
4314 codex.profile.location[loc_id].anchor.r = frame:GetRight( )
4315
4316end
4317
4318function ArkInventory.Frame_Main_Anchor_Set( loc_id, old_scale )
4319
4320 local frame = ArkInventory.Frame_Main_Get( loc_id )
4321 local codex = ArkInventory.GetLocationCodex( loc_id )
4322 local anchor = codex.profile.location[loc_id].anchor.point
4323
4324 local f_scale = frame:GetScale( )
4325 local p_scale = UIParent:GetScale( )
4326
4327 local t = codex.profile.location[loc_id].anchor.t
4328 if not t then
4329 t = UIParent:GetTop( ) / f_scale
4330 elseif old_scale then
4331 t = t / f_scale * old_scale
4332 end
4333
4334 local b = codex.profile.location[loc_id].anchor.b
4335 if not b then
4336 b = UIParent:GetBottom( ) / f_scale
4337 elseif old_scale then
4338 b = b / f_scale * old_scale
4339 end
4340
4341 local l = codex.profile.location[loc_id].anchor.l
4342 if not l then
4343 l = UIParent:GetLeft( ) / f_scale
4344 elseif old_scale then
4345 l = l / f_scale * old_scale
4346 end
4347
4348 local r = codex.profile.location[loc_id].anchor.r
4349 if not r then
4350 r = UIParent:GetRight( ) / f_scale
4351 elseif old_scale then
4352 r = r / f_scale * old_scale
4353 end
4354
4355 local h = l + ( ( r - l ) / 2 )
4356 local v = b + ( ( t - b ) / 2 )
4357
4358 frame:ClearAllPoints( )
4359 if anchor == ArkInventory.Const.Anchor.BottomRight then
4360 frame:SetPoint( "BOTTOMRIGHT", nil, "BOTTOMLEFT", r, b )
4361 elseif anchor == ArkInventory.Const.Anchor.BottomLeft then
4362 frame:SetPoint( "BOTTOMLEFT", nil, "BOTTOMLEFT", l, b )
4363 elseif anchor == ArkInventory.Const.Anchor.TopLeft then
4364 frame:SetPoint( "TOPLEFT", nil, "BOTTOMLEFT", l, t )
4365 elseif anchor == ArkInventory.Const.Anchor.Top then
4366 frame:SetPoint( "TOP", nil, "BOTTOMLEFT", h, t )
4367 elseif anchor == ArkInventory.Const.Anchor.Bottom then
4368 frame:SetPoint( "BOTTOM", nil, "BOTTOMLEFT", h, b )
4369 elseif anchor == ArkInventory.Const.Anchor.Left then
4370 frame:SetPoint( "LEFT", nil, "BOTTOMLEFT", l, v )
4371 elseif anchor == ArkInventory.Const.Anchor.Right then
4372 frame:SetPoint( "RIGHT", nil, "BOTTOMLEFT", r, v )
4373 else
4374 frame:SetPoint( "TOPRIGHT", nil, "BOTTOMLEFT", r, t )
4375 end
4376
4377 if codex.profile.location[loc_id].anchor.locked then
4378 frame:RegisterForDrag( )
4379 else
4380 frame:RegisterForDrag( "LeftButton" )
4381 end
4382
4383 ArkInventory.Frame_Main_Anchor_Save( frame )
4384
4385end
4386
4387function ArkInventory.Frame_Main_Paint( frame )
4388
4389 if not ArkInventory.ValidFrame( frame ) then return end
4390
4391 local loc_id = frame.ARK_Data.loc_id
4392 local codex = ArkInventory.GetLocationCodex( loc_id )
4393
4394 for _, z in pairs( { frame:GetChildren( ) } ) do
4395
4396 local framename = z:GetName( )
4397 if framename then -- only process objects with a name (other addons can add frames without names, we don't want to deal with them)
4398
4399 -- background
4400 local obj = _G[string.format( "%s%s", framename, "Background" )]
4401 if obj then
4402 local background = codex.style.window.background.style or ArkInventory.Const.Texture.BackgroundDefault
4403 if background == ArkInventory.Const.Texture.BackgroundDefault then
4404 local colour = codex.style.window.background.colour
4405 ArkInventory.SetTexture( obj, true, colour.r, colour.g, colour.b, colour.a )
4406 else
4407 local file = ArkInventory.Lib.SharedMedia:Fetch( ArkInventory.Lib.SharedMedia.MediaType.BACKGROUND, background )
4408 ArkInventory.SetTexture( obj, file )
4409 end
4410 end
4411
4412 -- border
4413 --local obj = _G[string.format( "%s%s", framename, "ArkBorder" )]
4414 local obj = z.ArkBorder
4415 if obj then
4416
4417 if codex.style.window.border.style == ArkInventory.Const.Texture.BorderNone then
4418
4419 obj:Hide( )
4420
4421 else
4422
4423 local border = codex.style.window.border.style or ArkInventory.Const.Texture.BorderDefault
4424 local file = ArkInventory.Lib.SharedMedia:Fetch( ArkInventory.Lib.SharedMedia.MediaType.BORDER, border )
4425 local size = codex.style.window.border.size or ArkInventory.Const.Texture.Border[ArkInventory.Const.Texture.BorderDefault].size
4426 local offset = codex.style.window.border.offset or ArkInventory.Const.Texture.Border[ArkInventory.Const.Texture.BorderDefault].offsetdefault.window
4427 local scale = codex.style.window.border.scale or 1
4428 local colour = codex.style.window.border.colour
4429 ArkInventory.Frame_Border_Paint( obj, file, size, offset, scale, colour.r, colour.g, colour.b, 1 )
4430
4431 obj:Show( )
4432
4433 end
4434
4435 end
4436
4437 end
4438
4439 end
4440
4441end
4442
4443function ArkInventory.Frame_Main_Paint_All( )
4444
4445 for loc_id, loc_data in pairs( ArkInventory.Global.Location ) do
4446 if loc_data.canView then
4447 local frame = ArkInventory.Frame_Main_Get( loc_id )
4448 ArkInventory.Frame_Main_Paint( frame )
4449 end
4450 end
4451
4452end
4453
4454function ArkInventory.Frame_Border_Paint( obj, file, size, offset, scale, r, g, b, a )
4455
4456 if not obj then return end
4457
4458 local edgeSize = ( size or 1 ) * ( scale or 1 )
4459 local info = obj:GetBackdrop( )
4460 if not info or info.edgeFile ~= file then
4461 obj:SetBackdrop( { edgeFile = file, edgeSize = edgeSize } )
4462 end
4463 obj:SetBackdropBorderColor( r or 0, g or 0, b or 0, a or 1 )
4464
4465 local parent = obj:GetParent( )
4466 local offset = ( offset or 0 ) * ( scale or 1 )
4467
4468 obj:ClearAllPoints( )
4469 obj:SetPoint( "TOPLEFT", parent, 0 - offset, offset )
4470 obj:SetPoint( "BOTTOMRIGHT", parent, offset, 0 - offset )
4471
4472end
4473
4474function ArkInventory.Frame_Main_Resize( frame )
4475
4476 --ArkInventory.Output( "Frame_Main_Resize" )
4477
4478 if not ArkInventory.ValidFrame( frame, true ) then return end
4479
4480 local loc_id = frame.ARK_Data.loc_id
4481 local codex = ArkInventory.GetLocationCodex( loc_id )
4482
4483 local width = codex.profile.location[loc_id].container.width
4484 local height = codex.profile.location[loc_id].container.height
4485
4486 local f1 = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Title.Name )]
4487 if not codex.style.title.hide then
4488 height = height + f1:GetHeight( )
4489 end
4490
4491 local f2 = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Search.Name )]
4492 if not codex.style.search.hide then
4493 height = height + f2:GetHeight( )
4494 end
4495
4496 local f5 = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Status.Name )]
4497 if not codex.style.status.hide then
4498 height = height + f5:GetHeight( )
4499 end
4500
4501 local f4 = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Changer.Name )]
4502 if not codex.style.changer.hide then
4503 height = height + f4:GetHeight( )
4504 end
4505
4506-- local f3 = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Scroll.Name )]
4507
4508
4509 -- set the size of the window
4510 frame:SetWidth( width )
4511 frame:SetHeight( height )
4512
4513 --ArkInventory.Output( string.format( "set window %i size %i x %i", loc_id, width, height ) )
4514
4515 ArkInventory.Frame_Main_Scale( loc_id )
4516
4517end
4518
4519function ArkInventory.Frame_Main_Draw( frame )
4520
4521 local loc_id = frame.ARK_Data.loc_id
4522 local thread_id = string.format( ArkInventory.Global.Thread.Format.Window, loc_id )
4523
4524 if not frame:IsVisible( ) then
4525 ArkInventory.OutputThread( thread_id, " aborting, not visible" )
4526 return
4527 end
4528
4529 if not ArkInventory.Global.Thread.Use then
4530 local tz = debugprofilestop( )
4531 ArkInventory.OutputThread( thread_id, " starting" )
4532 ArkInventory.Frame_Main_Draw_Threaded( frame )
4533 tz = debugprofilestop( ) - tz
4534 ArkInventory.OutputThread( string.format( "%s dead after %0.0fms", thread_id, tz ) )
4535 return
4536 end
4537
4538 if ArkInventory.ThreadRunning( thread_id ) then
4539
4540 -- already in progress, find highest drawstate and start again
4541
4542 --ArkInventory.Output( "draw", " [", loc_id, "] existing thread, old=", ArkInventory.Global.Thread.WindowState[loc_id], ", new=", ArkInventory.Global.Location[loc_id].drawState )
4543
4544 if ArkInventory.Global.Thread.WindowState[loc_id] >= ArkInventory.Global.Location[loc_id].drawState then
4545 ArkInventory.Global.Thread.WindowState[loc_id] = ArkInventory.Global.Location[loc_id].drawState
4546 end
4547
4548 else
4549
4550 -- nothing in progress so just kick it off
4551
4552 --ArkInventory.Output( "draw [", loc_id, "] new thread, state=", ArkInventory.Global.Location[loc_id].drawState )
4553
4554 ArkInventory.Global.Thread.WindowState[loc_id] = ArkInventory.Global.Location[loc_id].drawState
4555
4556 end
4557
4558 -- load the co-routine, overwite existing, the garbage collector will sort it out
4559 local tf = function ( )
4560 ArkInventory.Frame_Main_Draw_Threaded( frame )
4561 end
4562
4563 ArkInventory.ThreadStart( thread_id, tf )
4564
4565 --ArkInventory.Output( "draw location ", loc_id, " complete" )
4566
4567end
4568
4569function ArkInventory.Frame_Main_Draw_Threaded( frame )
4570
4571 local loc_id = frame.ARK_Data.loc_id
4572 --ArkInventory.Output( "Frame_Main_Draw_Threaded( ", frame:GetName( ), " ) drawstate[", ArkInventory.Global.Location[loc_id].drawState, "]" ) --, framelevel[", frame:GetFrameLevel( ), "]" )
4573
4574 if not ArkInventory.Global.Location[loc_id].canView then
4575 -- not a controllable window (for scanning only)
4576 -- shouldnt ever get here, but just in case
4577 frame:Hide( )
4578 return
4579 end
4580
4581 local codex = ArkInventory.GetLocationCodex( loc_id )
4582 --ArkInventory.Output( "draw = ", loc_id, " / ", codex.player.data.info.player_id )
4583
4584 ArkInventory.ThreadYield_Window( loc_id )
4585
4586 -- is the window online or offline?
4587 ArkInventory.Frame_Main_Offline( frame )
4588
4589
4590 if loc_id == ArkInventory.Const.Location.Vault then
4591
4592 -- force vault back to item display when offline
4593 if ArkInventory.Global.Location[loc_id].isOffline then
4594 ArkInventory.Global.Location[loc_id].view_mode = "bank"
4595 end
4596
4597 obj = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Container.Name )]
4598 obj:Hide( )
4599
4600 obj = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Info.Name )]
4601 obj:Hide( )
4602
4603 obj = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Log.Name )]
4604 obj:Hide( )
4605
4606 if ArkInventory.Global.Location[loc_id].view_mode == "log" or ArkInventory.Global.Location[loc_id].view_mode == "moneylog" then
4607 obj = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Log.Name )]
4608 obj:Show( )
4609 elseif ArkInventory.Global.Location[loc_id].view_mode == "tabinfo" then
4610 obj = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Info.Name )]
4611 obj:Show( )
4612 elseif ArkInventory.Global.Location[loc_id].view_mode == "bank" then
4613 obj = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Container.Name )]
4614 obj:Show( )
4615 end
4616
4617 end
4618
4619
4620 -- edit mode
4621 if ArkInventory.Global.Mode.Edit then
4622 ArkInventory.Frame_Main_DrawStatus( loc_id, ArkInventory.Const.Window.Draw.Recalculate )
4623 end
4624
4625
4626 -- do we still need to draw the window?
4627 if ArkInventory.Global.Location[loc_id].drawState < ArkInventory.Const.Window.Draw.None then
4628 obj = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Container.Name )]
4629 ArkInventory.OutputThread( loc_id, " Frame_Container_Draw" )
4630 ArkInventory.Frame_Container_Draw( obj )
4631 ArkInventory.ThreadYield_Window( loc_id )
4632 end
4633
4634 if ArkInventory.Global.Location[loc_id].drawState <= ArkInventory.Const.Window.Draw.Restart then
4635
4636 ArkInventory.OutputThread( loc_id, " MediaFrameDefaultFontSet" )
4637 ArkInventory.MediaFrameDefaultFontSet( frame )
4638 ArkInventory.ThreadYield_Window( loc_id )
4639
4640 ArkInventory.OutputThread( loc_id, " Frame_Main_Paint" )
4641 ArkInventory.Frame_Main_Paint( frame )
4642 ArkInventory.ThreadYield_Window( loc_id )
4643
4644 end
4645
4646 if ArkInventory.Global.Location[loc_id].drawState <= ArkInventory.Const.Window.Draw.Refresh then
4647
4648 -- title frame
4649
4650 -- hide the title window if it's not needed
4651 local subframe1 = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Title.Name )]
4652 local obj = subframe1
4653 if codex.style.title.hide then
4654
4655 -- show mini action buttons
4656 for k, v in pairs( ArkInventory.Const.Actions ) do
4657 local obj = _G[string.format( "%s%s%s%s", frame:GetName( ), ArkInventory.Const.Frame.Scroll.Name, "ActionButton", k )]
4658 if obj then
4659 obj:Show( )
4660 end
4661 end
4662
4663 obj:Hide( )
4664 obj:SetHeight( 1 )
4665
4666 else
4667
4668 -- hide mini action buttons
4669 for k, v in pairs( ArkInventory.Const.Actions ) do
4670 local obj = _G[string.format( "%s%s%s%s", frame:GetName( ), ArkInventory.Const.Frame.Scroll.Name, "ActionButton", k )]
4671 if obj then
4672 obj:Hide( )
4673 end
4674 end
4675
4676 local height = codex.style.title.font.height
4677 ArkInventory.MediaFrameFontSet( obj, nil, height )
4678
4679 -- window title text
4680 local who = _G[string.format( "%s%s%s", frame:GetName( ), ArkInventory.Const.Frame.Title.Name, "Who" )]
4681 local t = ""
4682
4683 if codex.style.title.size == ArkInventory.Const.Window.Title.SizeThin then
4684
4685 -- thin size
4686 t = ArkInventory.DisplayName5( codex.player.data.info )
4687
4688 -- one line of action buttons
4689-- z = _G[string.format( "%s%s", obj:GetName( ), "ActionButton21" )]
4690-- z:ClearAllPoints( )
4691-- z:SetPoint( "RIGHT", _G[string.format( "%s%s", obj:GetName( ), "ActionButton14" )], "LEFT", -3, 0 )
4692
4693 who:SetMaxLines( 1 )
4694
4695 else
4696
4697 -- normal size
4698 t = ArkInventory.DisplayName1( codex.player.data.info )
4699 height = height * 2
4700
4701 -- two lines of action buttons
4702-- z = _G[string.format( "%s%s", obj:GetName( ), "ActionButton21" )]
4703-- z:ClearAllPoints( )
4704-- z:SetPoint( "TOP", _G[string.format( "%s%s", obj:GetName( ), "ActionButton11" )], "BOTTOM", 0, -2 )
4705
4706 who:SetMaxLines( 2 )
4707
4708 end
4709
4710 -- online/offline colouring
4711 if ArkInventory.Global.Location[loc_id].isOffline then
4712 local colour = codex.style.title.colour.offline
4713 who:SetTextColor( colour.r, colour.g, colour.b )
4714 t = string.format( "%s [%s]", t, PLAYER_OFFLINE )
4715 else
4716 local colour = codex.style.title.colour.online
4717 who:SetTextColor( colour.r, colour.g, colour.b )
4718 end
4719
4720 if height < ArkInventory.Const.Frame.Title.MinHeight then
4721 height = ArkInventory.Const.Frame.Title.MinHeight
4722 end
4723
4724 -- set icon to match height
4725 local z = _G[string.format( "%s%s", obj:GetName( ), "ActionButton0" )]
4726 z:SetWidth( height )
4727 z:SetHeight( height )
4728
4729 who:SetHeight( height )
4730 who:SetText( t )
4731
4732 height = height + ArkInventory.Const.Frame.Title.Height
4733 obj:SetHeight( height )
4734
4735 obj:Show( )
4736
4737 ArkInventory.ThreadYield_Window( loc_id )
4738
4739 end
4740
4741 ArkInventory.ThreadYield_Window( loc_id )
4742
4743
4744 -- hide the search window if it's not needed
4745 local subframe2 = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Search.Name )]
4746 local obj = subframe2
4747 if codex.style.search.hide then
4748
4749 obj:Hide( )
4750 obj:SetHeight( 1 )
4751
4752 obj:SetPoint( "TOPLEFT", subframe1, "BOTTOMLEFT", 0, 1 )
4753
4754 obj.filterText:SetText( "" )
4755
4756 else
4757
4758 local height = codex.style.search.font.height
4759 ArkInventory.MediaFrameFontSet( obj, nil, height )
4760
4761 local obj2 = _G[string.format( "%s%s", obj:GetName( ), "FilterLabel" )]
4762 local colour = codex.style.search.label.colour
4763 obj2:SetTextColor( colour.r, colour.g, colour.b )
4764 local width = obj2:GetStringWidth( )
4765
4766 local colour = codex.style.search.text.colour
4767 obj.filterText:SetTextColor( colour.r, colour.g, colour.b )
4768 obj.filterText:SetPoint( "LEFT", obj, "LEFT", width + 20, 0 )
4769
4770 if height < ArkInventory.Const.Frame.Search.MinHeight then
4771 height = ArkInventory.Const.Frame.Search.MinHeight
4772 end
4773
4774 obj:SetHeight( height + ArkInventory.Const.Frame.Search.Height )
4775 obj:Show( )
4776
4777 obj:SetPoint( "TOPLEFT", subframe1, "BOTTOMLEFT" )
4778
4779 end
4780
4781 ArkInventory.ThreadYield_Window( loc_id )
4782
4783
4784 -- hide the changer frame if it can't be used
4785 local subframe5 = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Status.Name )]
4786 local subframe4 = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Changer.Name )]
4787 local obj = subframe4
4788
4789 if codex.style.changer.hide or not ArkInventory.Global.Location[loc_id].hasChanger then
4790 obj:SetHeight( 1 )
4791 obj:Hide( )
4792 obj:SetPoint( "BOTTOMLEFT", subframe5, "TOPLEFT", 0, -1 )
4793 else
4794 ArkInventory.Frame_Changer_Update( loc_id )
4795 ArkInventory.ThreadYield_Window( loc_id )
4796 obj:SetHeight( ArkInventory.Const.Frame.Changer.Height )
4797 obj:Show( )
4798 obj:SetPoint( "BOTTOMLEFT", subframe5, "TOPLEFT" )
4799 end
4800
4801
4802 ArkInventory.Frame_Status_Update( frame )
4803
4804 ArkInventory.Frame_Main_Resize( frame )
4805
4806 ArkInventory.ThreadYield_Window( loc_id )
4807
4808 end
4809
4810 ArkInventory.Global.Location[loc_id].drawState = ArkInventory.Const.Window.Draw.None
4811
4812-- if ArkInventory.Global.Location[loc_id].show then
4813-- ArkInventory.Global.Location[loc_id].show = nil
4814-- frame:Show( )
4815-- end
4816
4817end
4818
4819function ArkInventory.FrameLevelReset( frame, level )
4820
4821 if type( frame ) == "string" then
4822 frame = _G[frame]
4823 end
4824
4825 if frame == nil then
4826 return
4827 end
4828
4829 if frame:GetFrameLevel( ) ~= level then
4830 frame:SetFrameLevel( level )
4831 end
4832
4833 for _, z in pairs( { frame:GetChildren( ) } ) do
4834 ArkInventory.FrameLevelReset( z, level + 1 )
4835 end
4836
4837end
4838
4839local function FrameLevelGetMaxRecurse( frame, level )
4840
4841 if frame:GetFrameLevel( ) > level then
4842 level = frame:GetFrameLevel( )
4843 end
4844
4845 for _, z in pairs( { frame:GetChildren( ) } ) do
4846 level = FrameLevelGetMaxRecurse( z, level )
4847 end
4848
4849 return level
4850
4851end
4852
4853function ArkInventory.FrameLevelGetMax( frame )
4854
4855 local level = frame:GetFrameLevel( )
4856
4857 for loc_id, loc_data in pairs( ArkInventory.Global.Location ) do
4858 if loc_data.canView then
4859
4860 local f2 = ArkInventory.Frame_Main_Get( loc_id )
4861
4862 if f2 and f2:IsVisible( ) and frame ~= f2 then
4863 level = FrameLevelGetMaxRecurse( f2, level )
4864 end
4865
4866 end
4867 end
4868
4869 return level
4870
4871end
4872
4873function ArkInventory.Frame_Main_Level( frame )
4874
4875 local level = ArkInventory.FrameLevelGetMax( frame )
4876 --ArkInventory.Output( frame:GetName( ), " before: ", frame:GetFrameLevel( ), ":", level )
4877
4878 if frame:GetFrameLevel( ) < level then
4879 ArkInventory.FrameLevelReset( frame, level + 10 )
4880
4881 --level = ArkInventory.FrameLevelGetMax( frame )
4882 --ArkInventory.Output( frame:GetName( ), " after: ", frame:GetFrameLevel( ), ":", level )
4883 end
4884
4885end
4886
4887function ArkInventory.Frame_Main_Toggle( loc_id )
4888
4889 local frame = ArkInventory.Frame_Main_Get( loc_id )
4890
4891 if frame then
4892 if frame:IsVisible( ) then
4893 ArkInventory.Frame_Main_Hide( loc_id )
4894 else
4895 ArkInventory.Frame_Main_Show( loc_id )
4896 end
4897 end
4898
4899end
4900
4901function ArkInventory.Frame_Main_Show( loc_id, player_id )
4902
4903 assert( loc_id, "invalid location: nil" )
4904
4905 local frame = ArkInventory.Frame_Main_Get( loc_id )
4906
4907 if loc_id == ArkInventory.Const.Location.Bank or loc_id == ArkInventory.Const.Location.Vault then
4908 if frame:IsVisible( ) then
4909 -- covers shifting from offline to online
4910 ArkInventory.Frame_Main_DrawStatus( loc_id, ArkInventory.Const.Window.Draw.Recalculate )
4911 end
4912 end
4913
4914 --ArkInventory.Output( "show: ", loc_id, ", ", player_id )
4915 local codex = ArkInventory.SetLocationCodex( loc_id, player_id )
4916 --ArkInventory.Output( "player=", codex.player.data.info.player_id )
4917 --ArkInventory.Output( "layout=", codex.layout_id, ", style=", codex.style_id, ", catset=", codex.catset_id )
4918
4919 if codex.style.sort.when == ArkInventory.Const.SortWhen.Open or codex.style.sort.when == ArkInventory.Const.SortWhen.Instant then
4920 --ArkInventory.OutputWarning( "Frame_Main_Show - .Recalculate" )
4921 ArkInventory.Frame_Main_DrawStatus( loc_id, ArkInventory.Const.Window.Draw.Recalculate )
4922 end
4923
4924 frame:Show( )
4925
4926-- ArkInventory.Global.Location[loc_id].show = true
4927
4928 ArkInventory.Frame_Main_Generate( loc_id )
4929
4930end
4931
4932function ArkInventory.Frame_Main_OnShow( frame )
4933
4934-- ArkInventory.Output( "Frame_Main_OnShow" )
4935
4936 local loc_id = frame.ARK_Data.loc_id
4937 local codex = ArkInventory.GetLocationCodex( loc_id )
4938
4939 if ArkInventory.Global.Location[loc_id].drawState <= ArkInventory.Const.Window.Draw.Init then
4940 ArkInventory.Frame_Main_Resize( frame )
4941 end
4942
4943 -- frame strata
4944 if frame:GetFrameStrata( ) ~= codex.style.window.strata then
4945 frame:SetFrameStrata( codex.style.window.strata )
4946 end
4947
4948 ArkInventory.Frame_Main_Level( frame )
4949
4950 if ArkInventory.db.option.auto.reposition then
4951 ArkInventory.Frame_Main_Reposition( loc_id )
4952 end
4953
4954 if loc_id == ArkInventory.Const.Location.Bag then
4955 PlaySound( SOUNDKIT.IG_BACKPACK_OPEN )
4956 elseif loc_id == ArkInventory.Const.Location.Bank then
4957 PlaySound( SOUNDKIT.IG_CHARACTER_INFO_OPEN )
4958 elseif loc_id == ArkInventory.Const.Location.Vault then
4959 PlaySound( SOUNDKIT.GUILD_VAULT_OPEN )
4960 elseif loc_id == ArkInventory.Const.Location.Wearing then
4961 PlaySound( SOUNDKIT.IG_CHARACTER_INFO_OPEN )
4962 elseif loc_id == ArkInventory.Const.Location.Auction then
4963 PlaySound( SOUNDKIT.IG_CHARACTER_INFO_OPEN )
4964 elseif loc_id == ArkInventory.Const.Location.Void then
4965 PlaySound( SOUNDKIT.UI_ETHEREAL_WINDOW_OPEN )
4966 elseif loc_id == ArkInventory.Const.Location.Token then
4967 PlaySound( SOUNDKIT.IG_CHARACTER_INFO_OPEN )
4968 elseif loc_id == ArkInventory.Const.Location.Reputation then
4969 PlaySound( SOUNDKIT.IG_CHARACTER_INFO_OPEN )
4970 else
4971 PlaySound( SOUNDKIT.IG_SPELLBOOK_OPEN )
4972 end
4973
4974end
4975
4976function ArkInventory.Frame_Main_Search( frame )
4977
4978 local loc_id = frame.ARK_Data.loc_id
4979 local filter = _G[string.format( "%s%s", frame:GetName( ), "SearchFilter" )]
4980 if not filter then
4981 ArkInventory.OutputError( "code failure: searchfilter object not found" )
4982 return
4983 end
4984
4985 filter = filter:GetText( )
4986 local cf = ArkInventory.Global.Location[loc_id].filter or ""
4987
4988 if cf ~= filter then
4989 --ArkInventory.Output( "search [", loc_id, "] [", cf, "] [", filter, "]" )
4990 ArkInventory.Global.Location[loc_id].filter = filter
4991 ArkInventory.Frame_Main_Generate( loc_id, ArkInventory.Const.Window.Draw.Refresh )
4992 end
4993
4994end
4995
4996function ArkInventory.Frame_Main_Hide( w )
4997
4998 for loc_id, loc_data in pairs( ArkInventory.Global.Location ) do
4999 if loc_data.canView then
5000 if not w or w == loc_id then
5001 local frame = ArkInventory.Frame_Main_Get( loc_id )
5002 frame:Hide( )
5003 end
5004 end
5005 end
5006
5007end
5008
5009function ArkInventory.Frame_Main_OnHide( frame )
5010
5011 ArkInventory.Lib.Dewdrop:Close( )
5012
5013 local loc_id = frame.ARK_Data.loc_id
5014
5015 if loc_id == ArkInventory.Const.Location.Bag then
5016
5017 PlaySound( SOUNDKIT.IG_BACKPACK_CLOSE )
5018 ArkInventory.Frame_Main_Clear_NewItemGlow( loc_id )
5019
5020 elseif loc_id == ArkInventory.Const.Location.Bank then
5021
5022 PlaySound( SOUNDKIT.IG_CHARACTER_INFO_CLOSE )
5023
5024 if ArkInventory.Global.Mode.Bank and ArkInventory.LocationIsControlled( ArkInventory.Const.Location.Bank ) then
5025 -- close blizzards bank frame if we're hiding blizzard frames, we're at the bank, and the bank window was closed
5026 CloseBankFrame( )
5027 end
5028
5029 elseif loc_id == ArkInventory.Const.Location.Vault then
5030
5031 PlaySound( SOUNDKIT.GUILD_VAULT_CLOSE )
5032
5033 if ArkInventory.Global.Mode.Vault and ArkInventory.LocationIsControlled( ArkInventory.Const.Location.Vault ) then
5034
5035 -- close blizzards vault frame if we're hiding blizzard frames, we're at the vault, and the vault window was closed
5036
5037 GuildBankPopupFrame:Hide( )
5038 StaticPopup_Hide( "GUILDBANK_WITHDRAW" )
5039 StaticPopup_Hide( "GUILDBANK_DEPOSIT" )
5040 StaticPopup_Hide( "CONFIRM_BUY_GUILDBANK_TAB" )
5041
5042 CloseGuildBankFrame( )
5043
5044 end
5045
5046 elseif loc_id == ArkInventory.Const.Location.Wearing then
5047
5048 PlaySound( SOUNDKIT.IG_CHARACTER_INFO_CLOSE )
5049
5050 elseif loc_id == ArkInventory.Const.Location.Auction then
5051
5052 PlaySound( SOUNDKIT.IG_CHARACTER_INFO_CLOSE )
5053
5054 elseif loc_id == ArkInventory.Const.Location.Void then
5055
5056 PlaySound( SOUNDKIT.UI_ETHEREAL_WINDOW_CLOSE )
5057
5058 elseif loc_id == ArkInventory.Const.Location.Token then
5059
5060 PlaySound( SOUNDKIT.IG_CHARACTER_INFO_CLOSE )
5061
5062 elseif loc_id == ArkInventory.Const.Location.Reputation then
5063
5064 PlaySound( SOUNDKIT.IG_CHARACTER_INFO_CLOSE )
5065
5066 else
5067
5068 PlaySound( SOUNDKIT.IG_SPELLBOOK_CLOSE )
5069
5070 end
5071
5072 if ArkInventory.Global.Mode.Edit then
5073 -- if the edit mode is active then disable edit mode and flag for rebuild when next opened
5074 ArkInventory.Global.Mode.Edit = false
5075 --ArkInventory.OutputWarning( "Frame_Main_OnHide - .Recalculate" )
5076 ArkInventory.Frame_Main_Generate( nil, ArkInventory.Const.Window.Draw.Recalculate )
5077 end
5078
5079 ArkInventory.FrameLevelReset( frame, 1 )
5080
5081end
5082
5083function ArkInventory.Frame_Main_OnLoad( frame )
5084
5085 assert( frame, "frame is nil" )
5086
5087 local framename = frame:GetName( )
5088 local loc_id = string.match( framename, "^.-(%d+)" )
5089
5090 assert( loc_id ~= nil, string.format( "xml element '%s' is not an %s frame", framename, ArkInventory.Const.Program.Name ) )
5091
5092 loc_id = tonumber( loc_id )
5093
5094 frame.ARK_Data = {
5095 loc_id = loc_id,
5096 }
5097
5098 local tex
5099
5100 frame:SetDontSavePosition( true )
5101 frame:SetUserPlaced( false )
5102
5103 -- setup title frame action buttons
5104 for k, v in pairs( ArkInventory.Const.Actions ) do
5105
5106 local obj = _G[string.format( "%s%s%s%s", frame:GetName( ), ArkInventory.Const.Frame.Title.Name, "ActionButton", k )]
5107
5108 if obj then
5109
5110 tex = obj:GetNormalTexture( )
5111 ArkInventory.SetTexture( tex, v.Texture or ArkInventory.Global.Location[loc_id].Texture )
5112 tex:SetTexCoord( 0.075, 0.925, 0.075, 0.925 )
5113
5114 tex = obj:GetPushedTexture( )
5115 ArkInventory.SetTexture( tex, v.Texture or ArkInventory.Global.Location[loc_id].Texture )
5116 tex:SetTexCoord( 0.075, 0.925, 0.075, 0.925 )
5117
5118 tex = obj:GetHighlightTexture( )
5119 ArkInventory.SetTexture( tex, v.Texture or ArkInventory.Global.Location[loc_id].Texture )
5120 tex:SetTexCoord( 0.075, 0.925, 0.075, 0.925 )
5121
5122 for s, f in pairs( v.Scripts ) do
5123 obj:SetScript( s, f )
5124 end
5125
5126 end
5127
5128 end
5129
5130 -- setup main frame mini action buttons
5131 for k, v in pairs( ArkInventory.Const.Actions ) do
5132
5133 local obj = _G[string.format( "%s%s%s%s", frame:GetName( ), ArkInventory.Const.Frame.Scroll.Name, "ActionButton", k )]
5134
5135 if obj then
5136
5137 tex = obj:GetNormalTexture( )
5138 ArkInventory.SetTexture( tex, v.Texture or ArkInventory.Global.Location[loc_id].Texture )
5139 tex:SetTexCoord( 0.075, 0.925, 0.075, 0.925 )
5140
5141 tex = obj:GetPushedTexture( )
5142 ArkInventory.SetTexture( tex, v.Texture or ArkInventory.Global.Location[loc_id].Texture )
5143 tex:SetTexCoord( 0.075, 0.925, 0.075, 0.925 )
5144
5145 tex = obj:GetHighlightTexture( )
5146 ArkInventory.SetTexture( tex, v.Texture or ArkInventory.Global.Location[loc_id].Texture )
5147 tex:SetTexCoord( 0.075, 0.925, 0.075, 0.925 )
5148
5149 for s, f in pairs( v.Scripts ) do
5150 obj:SetScript( s, f )
5151 end
5152
5153 end
5154
5155 end
5156
5157end
5158
5159function ArkInventory.Frame_Container_Calculate( frame )
5160
5161 --ArkInventory.Output( "Frame_Container_Calculate( ", frame:GetName( ), " )" )
5162
5163 local loc_id = frame.ARK_Data.loc_id
5164 local codex = ArkInventory.GetLocationCodex( loc_id )
5165
5166 ArkInventory.Table.Clean( codex.workpad, nil, true )
5167-- table.wipe( codex.workpad )
5168
5169 -- break the inventory up into it's respective bars
5170 ArkInventory.Frame_Container_CalculateBars( frame )
5171
5172 -- calculate what the container should look like with those bars
5173 ArkInventory.Frame_Container_CalculateContainer( frame )
5174
5175end
5176
5177function ArkInventory.Frame_Container_CalculateBars( frame )
5178
5179 -- loads the inventory into their respective bars
5180
5181 local loc_id = frame.ARK_Data.loc_id
5182 local codex = ArkInventory.GetLocationCodex( loc_id )
5183
5184 ArkInventory.ThreadYield_Window( loc_id )
5185
5186 local firstempty = codex.style.slot.empty.first or 0
5187-- ArkInventory.Output( "show ", firstempty, " empty slots" )
5188 local firstemptyshown = { }
5189
5190 --ArkInventory.Output( GREEN_FONT_COLOR_CODE, "Frame_Container_CalculateBars( ", frame:GetName( ), " ) for [", codex.player.data.info.name, "] start" )
5191
5192 codex.workpad.bar = codex.workpad.bar or { }
5193 table.wipe( codex.workpad.bar )
5194 codex.workpad.bar_count = 1
5195
5196 local bag
5197 local cat_id
5198 local bar_id
5199 local ignore = false
5200 local hidden = false
5201 local show_all = false
5202 local stack_compress = codex.style.slot.compress.count
5203
5204 if ArkInventory.Global.Mode.Edit or ArkInventory.Global.Options.ShowHiddenItems or codex.style.window.list then
5205 -- show everything if in edit mode or the user wants us to ignore the hidden flag
5206 show_all = true
5207 end
5208
5209 local new_shift = codex.style.slot.new.enable
5210 local new_cutoff = ArkInventory.TimeAsMinutes( ) - codex.style.slot.new.cutoff
5211 local new_reset = ArkInventory.Global.NewItemResetTime or new_cutoff
5212
5213 if stack_compress > 0 then -- stack compression
5214
5215 if not ArkInventory.Global.Cache.StackCompress[loc_id] then
5216 ArkInventory.Global.Cache.StackCompress[loc_id] = { }
5217 else
5218 table.wipe( ArkInventory.Global.Cache.StackCompress[loc_id] )
5219 end
5220
5221 end
5222
5223
5224 -- the basics, just stick the items into their appropriate bars (cpu intensive)
5225 for bag_id in pairs( ArkInventory.Global.Location[loc_id].Bags ) do
5226
5227 bag = codex.player.data.location[loc_id].bag[bag_id]
5228
5229 for slot_id = 1, bag.count do
5230
5231 local i = bag.slot[slot_id]
5232 ignore = false
5233
5234 if loc_id == ArkInventory.Const.Location.Vault and not codex.player.data.option[loc_id].bag[bag_id].display then
5235 ignore = true
5236 end
5237
5238 if i and not ignore then
5239
5240 if codex.style.window.list then
5241
5242 cat_id = ArkInventory.CategoryGetSystemID( "SYSTEM_DEFAULT" )
5243
5244 else
5245
5246 if i.h and new_shift and i.age and i.age > new_reset and i.age > new_cutoff then
5247 cat_id = ArkInventory.CategoryGetSystemID( "SYSTEM_NEW" )
5248 else
5249 cat_id = ArkInventory.ItemCategoryGet( i )
5250 end
5251
5252 end
5253
5254 bar_id = codex.layout.bag[bag_id].bar or ArkInventory.CategoryLocationGet( loc_id, cat_id )
5255 --ArkInventory.Output( "loc=[", loc_id, "], bag=[", bag_id, "], slot=[", slot_id, "], cat=[", cat_id, "], bar_id=[", bar_id, "]" )
5256
5257 if not show_all then
5258
5259 -- no point doing this if show all is enabled
5260
5261 if firstempty > 0 and not i.h and bar_id > 0 then
5262
5263 if not firstemptyshown[bag.type] then
5264 firstemptyshown[bag.type] = 0
5265 end
5266
5267 if firstemptyshown[bag.type] < firstempty then
5268 firstemptyshown[bag.type] = firstemptyshown[bag.type] + 1
5269 else
5270 bar_id = 0 - bar_id
5271 end
5272
5273 end
5274
5275 if stack_compress > 0 and i.h and bar_id > 0 then
5276
5277 local info = ArkInventory.ObjectInfoArray( i.h, i )
5278
5279 if info.stacksize > 1 then
5280
5281 local key = ArkInventory.ObjectIDCount( i.h, i )
5282
5283 if not ArkInventory.Global.Cache.StackCompress[loc_id][key] then
5284 ArkInventory.Global.Cache.StackCompress[loc_id][key] = 0
5285 end
5286
5287 if ArkInventory.Global.Cache.StackCompress[loc_id][key] < stack_compress then
5288 ArkInventory.Global.Cache.StackCompress[loc_id][key] = ArkInventory.Global.Cache.StackCompress[loc_id][key] + 1
5289 else
5290 bar_id = 0 - bar_id
5291 end
5292
5293 end
5294
5295 end
5296
5297 end
5298
5299
5300 hidden = false
5301
5302 if not codex.player.data.option[loc_id].bag[bag_id].display then
5303 -- isoalted bags do not get shown
5304 hidden = true
5305 elseif bar_id < 0 then
5306 -- hidden categories (reside on negative bar numbers) do not get shown
5307 hidden = true
5308 end
5309
5310 if show_all or not hidden then
5311
5312 bar_id = abs( bar_id )
5313
5314 -- create the bar
5315 if not codex.workpad.bar[bar_id] then
5316 codex.workpad.bar[bar_id] = { ["id"] = bar_id, ["item"] = { }, ["count"] = 0, ["width"] = 0, ["height"] = 0, ["ghost"] = false, ["frame"] = 0 }
5317 end
5318
5319 -- add the item to the bar
5320 codex.workpad.bar[bar_id].item[#codex.workpad.bar[bar_id].item + 1] = { ["bag"] = bag_id, ["slot"] = slot_id }
5321
5322 -- increment the bars item count
5323 codex.workpad.bar[bar_id].count = codex.workpad.bar[bar_id].count + 1
5324
5325 -- keep track of the last bar used
5326 if bar_id > codex.workpad.bar_count then
5327 codex.workpad.bar_count = bar_id
5328 end
5329
5330 --ArkInventory.Output( "bag[", bag_id, "], slot[", slot_id, "], cat[", cat_id, "], bar[", bar_id, "], id=[", codex.workpad.bar[bar_id].id, "]" )
5331
5332 end
5333
5334 end
5335
5336 ArkInventory.ThreadYield_Window( loc_id )
5337
5338 end
5339
5340 --ArkInventory.Output( "bag = ", bag_id, ", count = ", bag.count, " / ", ArkInventory.Table.Elements( bag.slot ) )
5341
5342 end
5343
5344
5345 -- get highest used bar
5346 local cats = codex.layout.category
5347 for _, bar_id in pairs( cats ) do
5348 if bar_id > codex.workpad.bar_count then
5349 codex.workpad.bar_count = bar_id
5350 end
5351 end
5352
5353 -- round up to a full number of bars per row
5354 local bpr = codex.style.window.list and 1 or codex.style.bar.per or 1
5355 codex.workpad.bar_count = ceil( codex.workpad.bar_count / bpr ) * bpr
5356
5357 if ArkInventory.Global.Mode.Edit then
5358 -- and add an entire extra row for easy bar/category movement when in edit mode
5359 codex.workpad.bar_count = codex.workpad.bar_count + bpr
5360 end
5361
5362 -- update the maximum number of bar frames used so far
5363 if codex.workpad.bar_count > ArkInventory.Global.Location[loc_id].maxBar then
5364 ArkInventory.Global.Location[loc_id].maxBar = codex.workpad.bar_count
5365 end
5366
5367 -- if we're in edit mode then create all missing bars and add a ghost item to every bar
5368 -- ghost items allow for the bar menu icon
5369 if ArkInventory.Global.Mode.Edit or codex.style.bar.showempty then
5370
5371 --ArkInventory.Output( "edit mode - adding ghost bars" )
5372 for bar_id = 1, codex.workpad.bar_count do
5373
5374 if not codex.workpad.bar[bar_id] then
5375
5376 -- create a ghost bar
5377 codex.workpad.bar[bar_id] = { ["id"] = bar_id, ["item"] = { }, ["count"] = 1, ["width"] = 0, ["height"] = 0, ["ghost"] = true, ["frame"] = 0 }
5378
5379 else
5380
5381 -- add a ghost item to the bar by incrementing the bars item count
5382 codex.workpad.bar[bar_id].count = codex.workpad.bar[bar_id].count + 1
5383
5384 end
5385
5386 end
5387
5388 end
5389
5390 --ArkInventory.Output( GREEN_FONT_COLOR_CODE, "Frame_Container_CalculateBars( ", frame:GetName( ), " ) end" )
5391
5392 ArkInventory.ThreadYield_Window( loc_id )
5393
5394end
5395
5396function ArkInventory.Frame_Container_CalculateContainer( frame )
5397
5398 -- calculate what the bars look like in the conatiner
5399
5400 --ArkInventory.Output( GREEN_FONT_COLOR_CODE, "Frame_Container_Calculate( ", frame:GetName( ), " ) start" )
5401
5402 local loc_id = frame.ARK_Data.loc_id
5403 local codex = ArkInventory.GetLocationCodex( loc_id )
5404
5405 ArkInventory.ThreadYield_Window( loc_id )
5406
5407 codex.workpad.container = { row = { } }
5408
5409 local bpr = codex.style.window.list and 1 or codex.style.bar.per or 1
5410 local rownum = 0
5411 local bf = 1 -- bar frame, allocated to each bar as it's calculated (uses less frames this way)
5412
5413 --ArkInventory.Output( "container ", loc_id, " has ", codex.workpad.bar_count, " bars" )
5414 --ArkInventory.Output( "container ", loc_id, " set for ", bpr, " bars per row" )
5415
5416
5417 if ArkInventory.Global.Mode.Edit == false and codex.style.bar.compact then
5418
5419 --ArkInventory.Output( "compact bars enabled" )
5420
5421 local bc = 0 -- number of bars currently in this row
5422 local vr = { } -- virtual row - holds a list of bars for this row
5423
5424 for j = 1, codex.workpad.bar_count do
5425
5426 --ArkInventory.Output( "bar [", j, "]" )
5427
5428 if codex.workpad.bar[j] then
5429 if codex.workpad.bar[j].count > 0 then
5430 --ArkInventory.Output( "assignment: bar [", j, "] to frame [", bf, "]" )
5431 codex.workpad.bar[j].frame = bf
5432 bf = bf + 1
5433 bc = bc + 1
5434 vr[bc] = j
5435 else
5436 --ArkInventory.Output( "bar [", j, "] has no items" )
5437 end
5438 else
5439 --ArkInventory.Output( "bar [", j, "] has no items (does not exist)" )
5440 end
5441
5442 if bc > 0 and ( bc == bpr or j == codex.workpad.bar_count ) then
5443
5444 rownum = rownum + 1
5445 if not codex.workpad.container.row[rownum] then
5446 codex.workpad.container.row[rownum] = { }
5447 end
5448
5449 --ArkInventory.Output( "row [", rownum, "] allocated [", bc, "] bars" )
5450
5451 codex.workpad.container.row[rownum].bar = vr
5452
5453 --ArkInventory.Output( "row [", rownum, "] created" )
5454
5455 bc = 0
5456 vr = { }
5457
5458 end
5459
5460 end
5461
5462 else
5463
5464 for j = 1, codex.workpad.bar_count, bpr do
5465
5466 local bc = 0 -- number of bars currently in this row
5467 local vr = { } -- virtual row - holds a list of bars for this row
5468
5469 for b = 1, bpr do
5470 if codex.workpad.bar[j + b - 1] then
5471 if codex.workpad.bar[j + b - 1].count > 0 then
5472 --ArkInventory.Output( "assignment: bar [", j + b - 1, "] to frame [", bf, "]" )
5473 codex.workpad.bar[j + b - 1]["frame"] = bf
5474 bf = bf + 1
5475 bc = bc + 1
5476 vr[bc] = j + b -1
5477 else
5478 --ArkInventory.Output( "bar [", j+b-1, "] has no items" )
5479 end
5480 else
5481 --ArkInventory.Output( "bar [", j+b-1, "] has no items (does not exist)" )
5482 end
5483 end
5484
5485 if bc > 0 then
5486
5487 rownum = rownum + 1
5488 if not codex.workpad.container.row[rownum] then
5489 codex.workpad.container.row[rownum] = { }
5490 end
5491
5492 --ArkInventory.Output( "row [", rownum, "] allocated [", bc, "] bars" )
5493
5494 codex.workpad.container.row[rownum].bar = vr
5495
5496 end
5497
5498 end
5499
5500 end
5501
5502 ArkInventory.ThreadYield_Window( loc_id )
5503
5504 -- fit the bars into the row
5505
5506 local rmw = codex.style.window.width -- row max width
5507 local rcw = 0 -- row current width
5508 local rch = 1 -- row current height
5509 local rmh = 0 -- row max height
5510 local igb = ArkInventory.Global.Mode.Edit and not codex.style.bar.showempty -- ignore ghost bars for row width purposes (makes the window get wider in edit mode)
5511 local rmb = 0 -- row max (height) bar - bar id of tallest bar
5512 local mwb = 0 -- number of minimum width bars in the row
5513
5514 local bar = codex.workpad.bar
5515
5516 --ArkInventory.Output( "bars per row=[", bpr, "], max columns=[", rmw, "], columns per bar=[", floor( rmw / bpr ), "]" )
5517
5518 for rownum, row in ipairs( codex.workpad.container.row ) do
5519
5520 rcw = 0
5521 mwb = 0
5522
5523 for k, bar_id in ipairs( row.bar ) do
5524
5525 -- initial setup for each bar
5526 bar[bar_id].minwidth = codex.layout.bar.data[bar_id].width.min
5527 if bar[bar_id].minwidth == 0 then
5528 bar[bar_id].minwidth = nil
5529 end
5530
5531 if codex.style.window.list then
5532 bar[bar_id].maxwidth = 1
5533 else
5534 bar[bar_id].maxwidth = codex.layout.bar.data[bar_id].width.max
5535 end
5536
5537 if bar[bar_id].maxwidth == 0 then
5538 bar[bar_id].maxwidth = nil
5539 end
5540
5541 bar[bar_id].width = bar[bar_id].minwidth or 1
5542 bar[bar_id].height = bar[bar_id].count
5543
5544 if bar[bar_id].minwidth then
5545 bar[bar_id].height = math.ceil( bar[bar_id].count / bar[bar_id].minwidth )
5546 mwb = mwb + 1
5547 end
5548
5549 if bar[bar_id].height > rmh then
5550 rmh = bar[bar_id].height
5551 end
5552
5553
5554 rcw = rcw + ( igb and bar[bar_id].ghost and 0 or bar[bar_id].width )
5555
5556 --ArkInventory.Output( "row=[", rownum, "], index=[", k, "], bar=[", bar_id, "], width=[", bar[bar_id].width, "], height=[", bar[bar_id].height, "], mwb=[", mwb, "]" )
5557
5558 end
5559
5560 if rmh > 1 then
5561
5562 local first = true
5563 if #row.bar == mwb then
5564 -- if all the bars in the row have min width then allow them to be adjusted
5565 if rcw < rmw then
5566 -- but only if the total width is less than the window width
5567 first = false
5568 -- otherwise it will change the width of the tallest bar before passing through which we dont want
5569 end
5570 end
5571
5572
5573 repeat
5574
5575 rmh = 1
5576 rmb = 0
5577
5578 -- find the bar with tallest height (ignore bars at max width, and bars at minwidth on the first pass)
5579 for _, bar_id in ipairs( row.bar ) do
5580 --if ( bar[bar_id].height > rmh ) and not ( bar[bar_id].maxwidth and bar[bar_id].width >= bar[bar_id].maxwidth ) and not ( first and bar[bar_id].minwidth and bar[bar_id].width >= bar[bar_id].minwidth ) then
5581 if ( bar[bar_id].height > rmh ) and not ( bar[bar_id].maxwidth and bar[bar_id].width >= bar[bar_id].maxwidth ) and not ( first and bar[bar_id].minwidth and bar[bar_id].width >= bar[bar_id].minwidth ) then
5582 rmb = bar_id
5583 rmh = bar[bar_id].height
5584 end
5585 end
5586
5587 if rmb > 0 and rmh > 1 then
5588
5589 -- increase the tallest bars width by one
5590 bar[rmb].width = bar[rmb].width + 1
5591
5592 -- recalcualte it's new height
5593 bar[rmb].height = math.ceil( bar[rmb].count / bar[rmb].width )
5594
5595 end
5596
5597 -- check if all fits
5598 rcw = 0
5599 rmh = 0
5600 for _, bar_id in ipairs( row.bar ) do
5601 rcw = rcw + ( igb and bar[bar_id].ghost and 0 or bar[bar_id].width )
5602 if bar[bar_id].height > rmh then
5603 rmh = bar[bar_id].height
5604 end
5605 end
5606
5607 first = false
5608
5609 -- exit if the width fits (or is over), or the max height is 1, no bar heights were changed on the second or higher pass
5610 until rcw >= rmw or rmh == 1 or (rmb == 0 and not first)
5611
5612 end
5613
5614 --ArkInventory.Output( "maximum height for row [", rownum, "] was [", rmh, "]" )
5615
5616 for k, bar_id in ipairs( row.bar ) do
5617
5618 --ArkInventory.Output( "setting max height for row [", rownum, "] bar [", bar_id, "] to [", rmh, "]" )
5619
5620 -- set height of all bars in the row to the maximum height used (looks better)
5621 bar[bar_id].height = rmh
5622
5623 if bar[bar_id].ghost or ArkInventory.Global.Mode.Edit or codex.style.bar.showempty then
5624 -- remove the ghost item from the count (it was only needed to calculate properly)
5625 bar[bar_id].count = bar[bar_id].count - 1
5626 end
5627
5628 end
5629
5630 ArkInventory.ThreadYield_Window( loc_id )
5631
5632 end
5633
5634 --ArkInventory.Output( GREEN_FONT_COLOR_CODE, "Frame_Container_Calculate( ", frame:GetName( ), " ) end" )
5635
5636end
5637
5638function ArkInventory.Frame_Container_Draw( frame )
5639
5640 local loc_id = frame.ARK_Data.loc_id
5641 local codex = ArkInventory.GetLocationCodex( loc_id )
5642
5643 local slotScale = codex.style.slot.scale or 1
5644 local slotSize = ( codex.style.slot.size or ArkInventory.Const.SLOT_SIZE ) * slotScale
5645
5646 --ArkInventory.Output( "draw frame=", frame:GetName( ), ", loc=", loc_id, ", state=", ArkInventory.Global.Location[loc_id].drawState )
5647
5648 if ArkInventory.Global.Location[loc_id].drawState <= ArkInventory.Const.Window.Draw.Recalculate then
5649
5650 -- calculate what the container should look like
5651 ArkInventory.OutputThread( "Frame_Container_Calculate" )
5652 ArkInventory.Frame_Container_Calculate( frame )
5653 ArkInventory.ThreadYield_Window( loc_id )
5654
5655 -- create (if required) the bar frames, and hide any that are no longer required
5656 for bar_id = 1, ArkInventory.Global.Location[loc_id].maxBar do
5657
5658 local barframename = string.format( "%sBar%s", frame:GetName( ), bar_id )
5659 local barframe = _G[barframename]
5660 if not barframe then
5661 barframe = CreateFrame( "Frame", barframename, frame, "ARKINV_TemplateFrameBar" )
5662 end
5663
5664 ArkInventory.Frame_Bar_Paint( barframe )
5665
5666 end
5667
5668 ArkInventory.ThreadYield_Window( loc_id )
5669
5670 -- create (if required) the bags and their item buttons
5671 for bag_id in pairs( ArkInventory.Global.Location[loc_id].Bags ) do
5672
5673 local bagframename = string.format( "%sBag%s", frame:GetName( ), bag_id )
5674 local bagframe = _G[bagframename]
5675 if not bagframe then
5676 bagframe = CreateFrame( "Frame", bagframename, frame, "ARKINV_TemplateFrameBag" )
5677 end
5678
5679
5680 -- remember the maximum number of slots used for each bag
5681 local c = codex.player.data.location[loc_id].bag[bag_id].count
5682
5683 if not ArkInventory.Global.Location[loc_id].maxSlot[bag_id] then
5684 ArkInventory.Global.Location[loc_id].maxSlot[bag_id] = 0
5685 end
5686
5687 if c > ArkInventory.Global.Location[loc_id].maxSlot[bag_id] then
5688 ArkInventory.Global.Location[loc_id].maxSlot[bag_id] = c
5689 end
5690
5691
5692 -- create the item frames for the bag
5693 for slot_id = 1, ArkInventory.Global.Location[loc_id].maxSlot[bag_id] do
5694
5695 local itemframename, itemframe = ArkInventory.ContainerItemNameGet( loc_id, bag_id, slot_id )
5696 local tainteditemframename = itemframename .. "T"
5697 local tainteditemframe = _G[tainteditemframename]
5698
5699 if tainteditemframe and not InCombatLockdown( ) then
5700
5701 -- a tainteditemframe exists and youre no longer in combat so "delete" it. a normal itemframe will get created further down
5702
5703 tainteditemframe:Hide( )
5704 tainteditemframe:SetParent( nil )
5705
5706 _G[tainteditemframename] = nil
5707 tainteditemframe = nil
5708
5709 _G[itemframename] = nil
5710 itemframe = nil
5711
5712 end
5713
5714 if not itemframe then
5715
5716 if InCombatLockdown( ) then
5717
5718 -- in combat, create a tainted frame that is viable
5719
5720 itemframe = CreateFrame( "ItemButton", tainteditemframename, bagframe, "ARKINV_TemplateButtonItemTainted" )
5721
5722 _G[tainteditemframename] = itemframe
5723 _G[itemframename] = itemframe
5724
5725 --ArkInventory.Output( "tainted ", tainteditemframename )
5726
5727 else
5728
5729 itemframe = CreateFrame( "ItemButton", itemframename, bagframe, ArkInventory.Global.Location[loc_id].template or "ARKINV_TemplateButtonViewOnlyItem" )
5730
5731 --ArkInventory.Output( "secure ", itemframename )
5732
5733 end
5734
5735 end
5736
5737 if itemframe.ARK_Data.init then
5738 -- also covers stuff for frames that were created before database load
5739 itemframe.ARK_Data.init = nil
5740 ArkInventory.MediaFrameDefaultFontSet( itemframe )
5741 itemframe:SetScale( slotScale )
5742 end
5743
5744 ArkInventory.ThreadYield_Window( loc_id )
5745
5746 end
5747
5748 end
5749
5750 end
5751
5752
5753 -- position the bar frames
5754 local name = frame:GetName( )
5755
5756 local bpr = codex.style.window.list and 1 or codex.style.bar.per or 1
5757 local padSlot = codex.style.slot.pad * slotScale
5758 local padBarInternal = codex.style.bar.pad.internal * slotScale
5759 local padBarExternal = codex.style.bar.pad.external
5760 local padWindow = codex.style.window.pad
5761 local padLabel = codex.style.bar.name.show and ( not codex.style.window.list ) and ( codex.style.bar.name.height + padSlot ) or 0
5762 local padActionButtons = codex.style.title.hide and ArkInventory.Const.Frame.Main.MiniActionButtonSize or 0
5763 local anchor = codex.style.bar.anchor
5764
5765 local padList = 0
5766 if codex.style.window.list then
5767 padList = ( codex.style.window.width - 1 ) * ( slotSize + padSlot )
5768 end
5769
5770 local barOffsetX, barOffsetY, barWidth, barHeight
5771
5772 for rownum, row in ipairs( codex.workpad.container.row ) do
5773
5774 row.width = padWindow * 2 - padBarExternal
5775
5776 for bar_index, bar_id in ipairs( row.bar ) do
5777
5778 local bar = codex.workpad.bar[bar_id]
5779 local barframename = string.format( "%sBar%s", name, bar.frame )
5780 local obj = _G[barframename]
5781 assert( obj, string.format( "xml element '%s' could not be found", barframename ) )
5782
5783 -- assign the bar number used to the bar frame
5784 obj.ARK_Data.bar_id = bar_id
5785 obj.ARK_Data.displayed = true
5786
5787 if ArkInventory.Global.Location[loc_id].drawState <= ArkInventory.Const.Window.Draw.Recalculate then
5788
5789 obj:ClearAllPoints( )
5790
5791 local obj_width = ( bar.width * slotSize ) + ( ( bar.width - 1 ) * padSlot ) + ( padBarInternal * 2 ) + padList
5792 obj:SetWidth( obj_width )
5793
5794 row.width = row.width + obj_width + padBarExternal
5795
5796 row.height = ( bar.height * slotSize ) + ( ( bar.height - 1 ) * padSlot ) + ( padBarInternal * 2 ) + padLabel
5797 obj:SetHeight( row.height )
5798
5799 if bar_index == 1 then
5800
5801 --ArkInventory.Output( "r[", rownum, "] h[", row.height, "] o[", barHeight, "]" )
5802
5803 -- first bar in a new row, set X offset
5804 barOffsetX = padWindow
5805 barWidth = 0
5806
5807 if bar.frame == 1 then
5808
5809 -- first row, first bar, set Y offset
5810 barOffsetY = padWindow
5811
5812 -- increment Y offset if mini action items are visible, theyre always at the top
5813 if codex.style.title.hide then
5814 if anchor == ArkInventory.Const.Anchor.TopLeft or anchor == ArkInventory.Const.Anchor.TopRight then
5815 barOffsetY = barOffsetY + ArkInventory.Const.Frame.Main.MiniActionButtonSize or 0
5816 end
5817 end
5818
5819 else
5820
5821 -- next row, first bar, increment Y offset
5822 barOffsetY = barOffsetY + ( barHeight or 0 ) + padBarExternal
5823
5824 end
5825
5826 barHeight = row.height
5827
5828 else
5829
5830 -- same row, subsequent bars, increment X offset
5831 barOffsetX = barOffsetX + ( barWidth or 0 ) + padBarExternal
5832
5833 end
5834
5835 barWidth = obj_width
5836
5837 --ArkInventory.Output( "r[", rownum, "] b[", bar_index, "] f[", bar.frame, "] x[", barOffsetX, "] y[", barOffsetY, "]" )
5838
5839 if anchor == ArkInventory.Const.Anchor.BottomLeft then
5840 obj:SetPoint( "BOTTOMLEFT", frame, barOffsetX, barOffsetY )
5841 elseif anchor == ArkInventory.Const.Anchor.TopLeft then
5842 obj:SetPoint( "TOPLEFT", frame, barOffsetX, 0 - barOffsetY )
5843 elseif anchor == ArkInventory.Const.Anchor.TopRight then
5844 obj:SetPoint( "TOPRIGHT", frame, 0 - barOffsetX, 0 - barOffsetY )
5845 else
5846 obj:SetPoint( "BOTTOMRIGHT", frame, 0 - barOffsetX, barOffsetY )
5847 end
5848
5849 end
5850
5851 if ArkInventory.Global.Location[loc_id].drawState <= ArkInventory.Const.Window.Draw.Refresh then
5852
5853 ArkInventory.OutputThread( loc_id, " Frame_Bar_DrawItems")
5854 ArkInventory.Frame_Bar_DrawItems( obj )
5855 ArkInventory.ThreadYield_Window( loc_id )
5856
5857 end
5858
5859 end
5860
5861 end
5862
5863
5864 if ArkInventory.Global.Location[loc_id].drawState <= ArkInventory.Const.Window.Draw.Refresh then
5865
5866 -- display/hide the appropriate items - mostly used for search matching (thus the refresh level)
5867 for bag_id in pairs( ArkInventory.Global.Location[loc_id].Bags ) do
5868
5869 if codex.player.data.option[loc_id].bag[bag_id].display then
5870
5871 -- this bag and its items should be visible
5872 for slot_id = 1, ArkInventory.Global.Location[loc_id].maxSlot[bag_id] do
5873
5874 local itemframename, itemframe = ArkInventory.ContainerItemNameGet( loc_id, bag_id, slot_id )
5875 assert( itemframe, string.format( "xml element '%s' could not be found", itemframename ) )
5876
5877 if itemframe.ARK_Data.displayed then
5878
5879 ArkInventory.Frame_Item_Update_Clickable( itemframe )
5880
5881 if ArkInventory.Global.Location[loc_id].drawState <= ArkInventory.Const.Window.Draw.Restart then
5882
5883 itemframe:SetScale( slotScale )
5884
5885 ArkInventory.Frame_Item_Update_Count_Anchor( itemframe )
5886 ArkInventory.Frame_Item_Update_Stock_Anchor( itemframe )
5887 ArkInventory.Frame_Item_Update_StatusIconUpgrade_Anchor( itemframe )
5888 ArkInventory.Frame_Item_Update_StatusIconJunk_Anchor( itemframe )
5889 ArkInventory.Frame_Item_Update_StatusIconTransmog_Anchor( itemframe )
5890
5891 end
5892
5893 itemframe:Show( )
5894
5895 else
5896
5897 itemframe:Hide( )
5898
5899 end
5900
5901 itemframe.ARK_Data.displayed = nil
5902
5903 end
5904
5905 end
5906
5907 end
5908
5909 -- display/hide the appropriate bags (separated for better reload visual impact)
5910 for bag_id in pairs( ArkInventory.Global.Location[loc_id].Bags ) do
5911
5912 local bagframename = string.format( "%sBag%s", frame:GetName( ), bag_id )
5913 local bagframe = _G[bagframename]
5914 assert( bagframe, string.format( "xml element '%s' could not be found", bagframename ) )
5915
5916 if codex.player.data.option[loc_id].bag[bag_id].display then
5917 bagframe:Show( )
5918 else
5919 bagframe:Hide( )
5920 end
5921
5922 end
5923
5924 -- display/hide the appropriate bars
5925 for bar_id = 1, ArkInventory.Global.Location[loc_id].maxBar do
5926
5927 local barframename = string.format( "%s%s%s", name, "Bar", bar_id )
5928 local barframe = _G[barframename]
5929 assert( barframe, string.format( "xml element '%s' could not be found", barframename ) )
5930
5931 if barframe.ARK_Data.displayed then
5932 barframe:Show( )
5933 else
5934 barframe:Hide( )
5935 end
5936
5937 barframe.ARK_Data.displayed = nil
5938
5939 end
5940
5941 end
5942
5943
5944 if ArkInventory.Global.Location[loc_id].drawState <= ArkInventory.Const.Window.Draw.Recalculate then
5945
5946 -- set container height and width
5947
5948 local c = codex.workpad.container
5949
5950 c.width = ArkInventory.Const.Window.Min.Width
5951
5952 c.height = padWindow * 2 + padActionButtons - padBarExternal
5953
5954 for row_index, row in ipairs( c.row ) do
5955
5956 if row.width > c.width then
5957 c.width = row.width
5958 end
5959
5960 c.height = c.height + row.height + padBarExternal
5961
5962 end
5963
5964 -- set the container frame dimensions
5965 frame:SetWidth( c.width )
5966 frame:SetHeight( c.height )
5967
5968
5969 -- set scrollframe/slider
5970 local h = codex.style.window.height
5971 if c.height < h then
5972 h = c.height
5973 end
5974
5975 local sf = frame:GetParent( )
5976
5977 sf.range = c.height
5978 sf.stepSize = ArkInventory.Const.Frame.Scroll.stepSize
5979
5980 if c.height > h then
5981
5982 sf.scrollBar:SetMinMaxValues( 0, c.height - h )
5983 sf.scrollBar:Show( )
5984
5985 else
5986
5987 sf:SetVerticalScroll( 0 )
5988 sf.scrollBar:Hide( )
5989
5990 end
5991
5992 codex.profile.location[loc_id].container.width = c.width
5993 codex.profile.location[loc_id].container.height = h
5994-- codex.profile.location[loc_id].container.heightmax = c.height
5995
5996 ArkInventory.ThreadYield_Window( loc_id )
5997
5998 end
5999
6000end
6001
6002function ArkInventory.Frame_Container_OnLoad( frame )
6003
6004 -- not in combat yet so theres no taint here
6005
6006 local framename = frame:GetName( )
6007 local loc_id = string.match( framename, "^.-(%d+)ScrollContainer" )
6008
6009 assert( loc_id, string.format( "xml element '%s' is not an %s frame", framename, ArkInventory.Const.Program.Name ) )
6010
6011 loc_id = tonumber( loc_id )
6012
6013 frame.ARK_Data = {
6014 loc_id = loc_id,
6015 }
6016
6017
6018 -- pre-build a set amount of non tainted usable bag slots for the backpack to cater for entering the world when in combat
6019 if loc_id == ArkInventory.Const.Location.Bag then
6020 for bag_id = 1, ( NUM_BAG_SLOTS + 1 ) do
6021 local bagframename = string.format( "%sBag%s", frame:GetName( ), bag_id )
6022 local bagframe = CreateFrame( "Frame", bagframename, frame, "ARKINV_TemplateFrameBag" )
6023 end
6024 end
6025
6026end
6027
6028function ArkInventory.Frame_Scroll_OnLoad( frame )
6029
6030 assert( frame, "frame is nil" )
6031
6032 local framename = frame:GetName( )
6033
6034 local loc_id = string.match( framename, "^.-(%d+)Scroll" )
6035 assert( loc_id, string.format( "xml element '%s' is not an %s frame", framename, ArkInventory.Const.Program.Name ) )
6036 loc_id = loc_id
6037
6038 frame.ARK_Data = {
6039 loc_id = loc_id,
6040 }
6041
6042 frame.stepSize = ArkInventory.Const.Frame.Scroll.stepSize
6043
6044end
6045
6046function ArkInventory.Frame_Bar_OnLoad( frame )
6047
6048 assert( frame, "Frame_Bar_OnLoad( ) passed a nil frame" )
6049
6050 local framename = frame:GetName( )
6051 local loc_id, bar_id = string.match( framename, "^.-(%d+)ScrollContainerBar(%d+)" )
6052
6053 assert( loc_id, string.format( "xml element '%s' is not an %s frame", framename, ArkInventory.Const.Program.Name ) )
6054 assert( bar_id, string.format( "xml element '%s' is not an %s frame", framename, ArkInventory.Const.Program.Name ) )
6055
6056 loc_id = tonumber( loc_id )
6057 bar_id = tonumber( bar_id )
6058
6059 frame.ARK_Data = {
6060 loc_id = loc_id,
6061 bar_id = bar_id,
6062 }
6063
6064 frame:SetID( bar_id )
6065
6066 ArkInventory.MediaFrameDefaultFontSet( frame )
6067
6068 frame:Hide( )
6069
6070end
6071
6072function ArkInventory.Frame_Bar_Paint_All( )
6073
6074 --ArkInventory.Output( "Frame_Bar_Paint_All( )" )
6075
6076 for loc_id, loc_data in pairs( ArkInventory.Global.Location ) do
6077 if loc_data.canView then
6078
6079 c = _G[string.format( "%s%s%s", ArkInventory.Const.Frame.Main.Name, loc_id, ArkInventory.Const.Frame.Container.Name )]
6080
6081 if c then
6082
6083 for bar_id = 1, loc_data.maxBar do
6084
6085 obj = _G[string.format( "%s%s%s", c:GetName( ), "Bar", bar_id )]
6086
6087 if obj then
6088 ArkInventory.Frame_Bar_Paint( obj )
6089 end
6090
6091 end
6092
6093 end
6094
6095 end
6096 end
6097
6098end
6099
6100function ArkInventory.Frame_Bar_Paint( frame )
6101
6102 if not frame then return end
6103
6104 local loc_id = frame.ARK_Data.loc_id
6105 local bar_id = frame.ARK_Data.bar_id
6106 local codex = ArkInventory.GetLocationCodex( loc_id )
6107
6108 -- border
6109 local obj = frame.ArkBorder
6110 if obj then
6111
6112 if codex.style.bar.border.style ~= ArkInventory.Const.Texture.BorderNone then
6113
6114 local border = codex.style.bar.border.style or ArkInventory.Const.Texture.BorderDefault
6115 local file = ArkInventory.Lib.SharedMedia:Fetch( ArkInventory.Lib.SharedMedia.MediaType.BORDER, border )
6116 local size = codex.style.bar.border.size or ArkInventory.Const.Texture.Border[ArkInventory.Const.Texture.BorderDefault].size
6117 local offset = codex.style.bar.border.offset or ArkInventory.Const.Texture.Border[ArkInventory.Const.Texture.BorderDefault].offsetdefault.bar
6118 local scale = codex.style.bar.border.scale or 1
6119
6120 local colour = nil
6121 if codex.layout.bar.data[bar_id].border.custom == 2 then
6122 colour = codex.layout.bar.data[bar_id].border.colour
6123 else
6124 colour = codex.style.bar.border.colour
6125 end
6126
6127 ArkInventory.Frame_Border_Paint( obj, file, size, offset, scale, colour.r, colour.g, colour.b, 1 )
6128
6129 obj:Show( )
6130
6131 else
6132
6133 obj:Hide( )
6134
6135 end
6136
6137 end
6138
6139
6140 -- background colour
6141 local obj = frame.ArkBackground
6142 if obj then
6143
6144 local colour = codex.style.bar.background.colour
6145
6146 if codex.layout.bar.data[bar_id].background.custom == 3 then
6147
6148 -- use border colour
6149 if codex.layout.bar.data[bar_id].border.custom == 2 then
6150 -- use custom border colour
6151 colour = codex.layout.bar.data[bar_id].border.colour
6152 else
6153 -- use default border colour
6154 colour = codex.style.bar.border.colour
6155 end
6156
6157 elseif codex.layout.bar.data[bar_id].background.custom == 2 then
6158
6159 -- use custom background colour
6160 colour = codex.layout.bar.data[bar_id].background.colour
6161
6162 end
6163
6164 --frame:SetBackdropBorderColor( colour.r, colour.g, colour.b, colour.a )
6165 ArkInventory.SetTexture( obj, true, colour.r, colour.g, colour.b, colour.a )
6166
6167 end
6168
6169
6170 -- edit mode bar number
6171 local obj = frame.ArkEdit
6172 if obj then
6173
6174 if ArkInventory.Global.Mode.Edit then
6175
6176 local padSlot = codex.style.slot.pad
6177 local padBarInternal = codex.style.bar.pad.internal
6178 local padLabel = codex.style.bar.name.show and ( codex.style.bar.name.height + padSlot ) or 0
6179 local slotAnchor = codex.style.slot.anchor
6180
6181 obj:ClearAllPoints( )
6182
6183 -- anchor to the opposite corner that items are
6184 if slotAnchor == ArkInventory.Const.Anchor.BottomLeft then
6185 obj:SetPoint( "TOPRIGHT", 0 - padBarInternal, 0 - padBarInternal - padLabel )
6186 elseif slotAnchor == ArkInventory.Const.Anchor.TopLeft then
6187 obj:SetPoint( "BOTTOMRIGHT", 0 - padBarInternal, padBarInternal + padLabel )
6188 elseif slotAnchor == ArkInventory.Const.Anchor.TopRight then
6189 obj:SetPoint( "BOTTOMLEFT", padBarInternal, padBarInternal + padLabel )
6190 else -- slotAnchor == ArkInventory.Const.Anchor.BottomRight then
6191 obj:SetPoint( "TOPLEFT", padBarInternal, 0 - padBarInternal - padLabel )
6192 end
6193
6194 obj:Show( )
6195
6196 else
6197
6198 obj:Hide( )
6199
6200 end
6201
6202 end
6203
6204
6205 -- label
6206 ArkInventory.Frame_Bar_Label( frame )
6207
6208end
6209
6210function ArkInventory.Frame_Bar_Label( frame )
6211
6212 local loc_id = frame.ARK_Data.loc_id
6213 local bar_id = frame.ARK_Data.bar_id
6214 local codex = ArkInventory.GetLocationCodex( loc_id )
6215
6216 local obj = frame.ArkLabel
6217
6218 if obj then
6219
6220 local txt = codex.layout.bar.data[bar_id].name.text
6221
6222 if txt and txt ~= "" and codex.style.bar.name.show and not codex.style.window.list then
6223
6224 local padBarInternal = codex.style.bar.pad.internal
6225 local anchor = codex.style.bar.name.anchor
6226
6227 if anchor == ArkInventory.Const.Anchor.Default then
6228 anchor = codex.style.slot.anchor
6229 if anchor == ArkInventory.Const.Anchor.TopLeft or anchor == ArkInventory.Const.Anchor.TopRight then
6230 anchor = ArkInventory.Const.Anchor.Bottom
6231 else
6232 anchor = ArkInventory.Const.Anchor.Top
6233 end
6234 end
6235
6236 obj:ClearAllPoints( )
6237
6238 if anchor == ArkInventory.Const.Anchor.Top then
6239 obj:SetPoint( "TOPLEFT", frame:GetName( ), padBarInternal, 0 - padBarInternal )
6240 else
6241 obj:SetPoint( "BOTTOMLEFT", frame:GetName( ), padBarInternal, padBarInternal )
6242 end
6243 obj:SetPoint( "RIGHT", frame:GetName( ), 0 - padBarInternal )
6244
6245 obj:SetHeight( codex.style.bar.name.height )
6246 obj:SetText( txt )
6247
6248 local colour = codex.style.bar.name.colour
6249 if codex.layout.bar.data[bar_id].name.custom == 2 then
6250 -- use custom colour
6251 colour = codex.layout.bar.data[bar_id].name.colour
6252 end
6253 obj:SetTextColor( colour.r, colour.g, colour.b )
6254
6255 ArkInventory.MediaObjectFontSet( obj, nil, codex.style.bar.name.height )
6256
6257 obj:Show( )
6258
6259 else
6260
6261 obj:Hide( )
6262
6263 end
6264
6265 end
6266
6267end
6268
6269function ArkInventory.Frame_Bar_DrawItems( frame )
6270
6271 --ArkInventory.Output( "Frame_Bar_DrawItems( ", frame:GetName( ), " )" )
6272
6273 local loc_id = frame.ARK_Data.loc_id
6274
6275 if ArkInventory.Global.Location[loc_id].drawState > ArkInventory.Const.Window.Draw.Refresh then
6276 return
6277 end
6278
6279 ArkInventory.ThreadYield_Window( loc_id )
6280
6281 local codex = ArkInventory.GetLocationCodex( loc_id )
6282
6283 local bar_id = frame.ARK_Data.bar_id
6284 local bar = codex.workpad.bar[bar_id]
6285 assert( bar, string.format( "workpad data for bar %d does not exist", bar_id ) )
6286
6287-- ArkInventory.Output( "drawing ", codex.player.data.info.name, " - bar ", bar_id, ", count = ", bar.count, ", start = ", time( ) )
6288
6289 if bar.count == 0 or bar.ghost then
6290 return
6291 end
6292
6293 if ArkInventory.Global.Location[loc_id].drawState <= ArkInventory.Const.Window.Draw.Resort then
6294
6295 --ArkInventory.Output( "resorting loc[", loc_id, "] state[", ArkInventory.Global.Location[loc_id].drawState, "] bar[", bar_id, "] @ ", time( ) )
6296
6297 -- sort the items in the bar (cpu intensive)
6298 local bag_id
6299 local slot_id
6300 local i
6301
6302 ArkInventory.ThreadYield_Window( loc_id )
6303
6304 for j = 1, bar.count do
6305 bag_id = bar.item[j].bag
6306 slot_id = bar.item[j].slot
6307 i = codex.player.data.location[loc_id].bag[bag_id].slot[slot_id]
6308 bar.item[j].sortkey = ArkInventory.ItemSortKeyGenerate( i, bar_id, codex ) or "!"
6309 ArkInventory.ThreadYield_Window( loc_id )
6310 end
6311
6312
6313 local sid_def = codex.style.sort.method or 9999
6314 local sid = codex.layout.bar.data[bar_id].sort.method or sid_def
6315
6316 if ArkInventory.db.option.sort.method.data[sid].used ~= "Y" then
6317 --ArkInventory.OutputWarning( "bar ", bar_id, " in location ", loc_id, " is using an invalid sort method. resetting it to default" )
6318 codex.layout.bar.data[bar_id].sort.method = nil
6319 sid = sid_def
6320 end
6321
6322 if ArkInventory.db.option.sort.method.data[sid].ascending then
6323 sort( bar.item, function( a, b ) return a.sortkey > b.sortkey end )
6324 else
6325 sort( bar.item, function( a, b ) return a.sortkey < b.sortkey end )
6326 end
6327
6328 ArkInventory.ThreadYield_Window( loc_id )
6329
6330 end
6331
6332
6333
6334 -- DO NOT SCALE THESE VALUES
6335 local slotSize = codex.style.slot.size or ArkInventory.Const.SLOT_SIZE
6336 local slotAnchor = codex.style.slot.anchor
6337
6338 if codex.style.window.list then
6339 if slotAnchor == ArkInventory.Const.Anchor.TopLeft or slotAnchor == ArkInventory.Const.Anchor.BottomLeft then
6340 slotAnchor = ArkInventory.Const.Anchor.TopLeft
6341 else
6342 slotAnchor = ArkInventory.Const.Anchor.TopRight
6343 end
6344 end
6345
6346 local padSlot = codex.style.slot.pad
6347 local padBarInternal = codex.style.bar.pad.internal
6348
6349 local padList = 0
6350 if codex.style.window.list then
6351 padList = ( codex.style.window.width - 1 ) * slotSize + ( codex.style.window.width - 2 ) * padSlot
6352 end
6353
6354 local col = bar.width
6355
6356 -- cycle through the items in the bar
6357
6358 --ArkInventory.Output( "bar = ", bar_id, ", count = ", bar.count, " ,width=", bar.width )
6359
6360 local itemOffsetX, itemOffsetY
6361
6362 for j = 1, bar.count do
6363
6364 --local i = codex.player.data.location[loc_id].bag[bar.item[j].bag].slot[bar.item[j].slot]
6365 local objname, obj = ArkInventory.ContainerItemNameGet( loc_id, bar.item[j].bag, bar.item[j].slot )
6366 assert( obj, string.format( "xml element '%s' is missing", objname ) )
6367
6368 local matches = ArkInventory.Frame_Item_MatchesFilter( obj )
6369
6370 if ( ArkInventory.Global.Location[loc_id].drawState <= ArkInventory.Const.Window.Draw.Resort ) or ( codex.style.window.list and ArkInventory.Global.Location[loc_id].drawState <= ArkInventory.Const.Window.Draw.Refresh ) then
6371
6372 obj:ClearAllPoints( )
6373 obj:SetSize( slotSize, slotSize )
6374
6375 if mod( ( j - 1 ), col ) == 0 then
6376
6377 -- first item in a new row, set X offset
6378 itemOffsetX = padBarInternal
6379
6380 if j == 1 then
6381
6382 -- first row, first item, set Y offset
6383 itemOffsetY = padBarInternal
6384
6385 -- increment Y offset if bar names are enabled
6386 if codex.style.bar.name.show and not codex.style.window.list then
6387
6388 local nameAnchor = codex.style.bar.name.anchor
6389
6390 if nameAnchor ~= ArkInventory.Const.Anchor.Default then
6391
6392 local tempAnchor = ArkInventory.Const.Anchor.Top
6393 if slotAnchor == ArkInventory.Const.Anchor.BottomLeft or slotAnchor == ArkInventory.Const.Anchor.BottomRight then
6394 tempAnchor = ArkInventory.Const.Anchor.Bottom
6395 end
6396
6397 if nameAnchor == tempAnchor then
6398 itemOffsetY = itemOffsetY + codex.style.bar.name.height + padSlot
6399 end
6400
6401 end
6402
6403 end
6404
6405 if codex.style.window.list and not matches then
6406 -- cater for first entry in list view being hidden
6407 itemOffsetY = itemOffsetY - slotSize - padSlot
6408 end
6409
6410 else
6411
6412 -- next row, first item, increment Y offset
6413 if not ( codex.style.window.list and not matches ) then
6414 -- non matching items are hidden
6415 -- in list view that leaves gaps so dont increment the Y offset if this is list view and the item does not match
6416 itemOffsetY = itemOffsetY + slotSize + padSlot
6417 end
6418
6419 end
6420
6421 else
6422
6423 -- same row, subsequent items, increment X offset
6424 -- list view only has a single item per row so wont get here
6425
6426 itemOffsetX = itemOffsetX + slotSize + padSlot
6427
6428 end
6429
6430 --ArkInventory.Output( "item ", j, ", x=", itemOffsetX, ", y=", itemOffsetY )
6431
6432 if slotAnchor == ArkInventory.Const.Anchor.BottomLeft then
6433 obj:SetPoint( "BOTTOMLEFT", frame, itemOffsetX, itemOffsetY )
6434 elseif slotAnchor == ArkInventory.Const.Anchor.TopLeft then
6435 obj:SetPoint( "TOPLEFT", frame, itemOffsetX, 0 - itemOffsetY )
6436 elseif slotAnchor == ArkInventory.Const.Anchor.TopRight then
6437 obj:SetPoint( "TOPRIGHT", frame, 0 - itemOffsetX, 0 - itemOffsetY )
6438 else -- slotAnchor == ArkInventory.Const.Anchor.BottomRight then
6439 obj:SetPoint( "BOTTOMRIGHT", frame, 0 - itemOffsetX, itemOffsetY )
6440 end
6441
6442 local listobj = obj.ArkListEntry
6443 if listobj then
6444
6445 if codex.style.window.list then
6446
6447 listobj:ClearAllPoints( )
6448
6449 listobj:SetPoint( "TOP", obj )
6450 listobj:SetPoint( "BOTTOM", obj )
6451
6452 if slotAnchor == ArkInventory.Const.Anchor.TopLeft then
6453 listobj:SetPoint( "LEFT", obj, "RIGHT", padSlot, 0 )
6454 else
6455 listobj:SetPoint( "RIGHT", obj, "LEFT", 0 - padSlot, 0 )
6456 end
6457
6458 listobj:SetWidth( padList )
6459 listobj:Show( )
6460
6461 else
6462
6463 listobj:Hide( )
6464
6465 end
6466
6467 end
6468
6469 end
6470
6471 if ArkInventory.Global.Location[loc_id].drawState <= ArkInventory.Const.Window.Draw.Refresh then
6472
6473 ArkInventory.Frame_Item_Update( loc_id, bar.item[j].bag, bar.item[j].slot )
6474
6475 if matches then
6476 obj.ARK_Data.displayed = true
6477 --obj:Show( )
6478 else
6479 obj.ARK_Data.displayed = nil
6480 --obj:Hide( )
6481 end
6482
6483 end
6484
6485 ArkInventory.ThreadYield_Window( loc_id )
6486
6487 end
6488
6489 if codex.style.window.list and ArkInventory.Global.Location[loc_id].drawState <= ArkInventory.Const.Window.Draw.Refresh then
6490 frame:GetParent( ):GetParent( ):UpdateScrollChildRect( )
6491 frame:GetParent( ):GetParent( ):SetVerticalScroll( 0 )
6492 end
6493
6494end
6495
6496function ArkInventory.Frame_Bar_Insert( loc_id, bar_id )
6497
6498 local codex = ArkInventory.GetLocationCodex( loc_id )
6499 local t = codex.layout.bar.data
6500 table.insert( t, bar_id, ArkInventory.Table.Copy( t[0] ) )
6501
6502
6503 -- move category data (bar numbers can be negative)
6504 for cat, bar in pairs( codex.layout.category ) do
6505 if abs( bar ) >= bar_id then
6506 if bar > 0 then
6507 ArkInventory.CategoryLocationSet( loc_id, cat, bar + 1 )
6508 else
6509 ArkInventory.CategoryLocationSet( loc_id, cat, bar - 1 )
6510 end
6511 end
6512 end
6513
6514
6515 -- move bag assignment
6516 for bag_id in pairs( ArkInventory.Global.Location[loc_id].Bags ) do
6517 local z = codex.layout.bag[bag_id].bar
6518 if z and z >= bar_id then
6519 codex.layout.bag[bag_id].bar = z + 1
6520 end
6521 end
6522
6523end
6524
6525function ArkInventory.Frame_Bar_Remove( loc_id, bar_id )
6526
6527 local codex = ArkInventory.GetLocationCodex( loc_id )
6528 local t = codex.layout.bar.data
6529 table.remove( t, bar_id )
6530
6531
6532 -- move category data (bar numbers can be negative)
6533 local cat_def = ArkInventory.CategoryGetSystemID( "SYSTEM_DEFAULT" )
6534
6535 for cat, bar in pairs( codex.layout.category ) do
6536 if abs( bar ) > bar_id then
6537 if bar > 0 then
6538 ArkInventory.CategoryLocationSet( loc_id, cat, bar - 1 )
6539 else
6540 ArkInventory.CategoryLocationSet( loc_id, cat, bar + 1 )
6541 end
6542 elseif abs( bar ) == bar_id then
6543 if cat == cat_def then
6544 -- if the DEFAULT category was on the bar then move it to bar 1
6545 ArkInventory.CategoryLocationSet( loc_id, cat, 1 )
6546 else
6547 -- erase the location, setting it back to the same as DEFAULT
6548 ArkInventory.CategoryLocationSet( loc_id, cat, nil )
6549 end
6550 end
6551
6552 end
6553
6554
6555 -- move bag assignment
6556 for bag_id in pairs( ArkInventory.Global.Location[loc_id].Bags ) do
6557 local z = codex.layout.bag[bag_id].bar
6558 if not z then
6559 -- do nothing
6560 elseif z > bar_id then
6561 codex.layout.bag[bag_id].bar = z - 1
6562 elseif z == bar_id then
6563 codex.layout.bag[bag_id].bar = nil
6564 end
6565 end
6566
6567end
6568
6569function ArkInventory.Frame_Bar_Move( loc_id, bar1, bar2 )
6570
6571 --ArkInventory.Output( "loc [", loc_id, "], bar1 [", bar1, "], bar2 [", bar2, "]" )
6572
6573 if not bar1 or not bar2 or bar1 == bar2 or bar1 < 1 or bar2 < 1 then return end
6574
6575 local codex = ArkInventory.GetLocationCodex( loc_id )
6576 local t = codex.layout.bar.data
6577
6578 local step = 1
6579 if bar2 < bar1 then
6580 step = -1
6581 table.insert( t, bar2, ArkInventory.Table.Copy( t[bar1] ) )
6582 table.remove( t, bar1 + 1 )
6583 else
6584 table.insert( t, bar2 + 1, ArkInventory.Table.Copy( t[bar1] ) )
6585 table.remove( t, bar1 )
6586 end
6587
6588
6589 -- move category data (bar numbers can be negative)
6590 for cat, bar in pairs( codex.layout.category ) do
6591 local z = abs( bar )
6592 if z == bar1 then
6593 ArkInventory.CategoryLocationSet( loc_id, cat, bar2 )
6594 elseif ( ( step == 1 ) and ( z > bar1 and z <= bar2 ) ) or ( ( step == -1 ) and ( z >= bar2 and z < bar1 ) ) then
6595 if bar > 0 then
6596 ArkInventory.CategoryLocationSet( loc_id, cat, bar - step )
6597 else
6598 ArkInventory.CategoryLocationSet( loc_id, cat, bar + step )
6599 end
6600 end
6601 end
6602
6603 -- move bag assignment
6604 for bag_id in pairs( ArkInventory.Global.Location[loc_id].Bags ) do
6605 local z = codex.layout.bag[bag_id].bar
6606 if not z then
6607 -- do nothing
6608 elseif z == bar1 then
6609 codex.layout.bag[bag_id].bar = bar2
6610 elseif ( ( step == 1 ) and ( z > bar1 and z <= bar2 ) ) or ( ( step == -1 ) and ( z >= bar2 and z < bar1 ) ) then
6611 codex.layout.bag[bag_id].bar = z - step
6612 end
6613 end
6614
6615end
6616
6617function ArkInventory.Frame_Bar_Clear( loc_id, bar_id )
6618
6619 local codex = ArkInventory.GetLocationCodex( loc_id )
6620
6621 -- clear bar data
6622 codex.layout.bar.data[bar_id] = ArkInventory.Table.Copy( codex.layout.bar.data[0] )
6623
6624 -- clear category
6625 for k, v in pairs( codex.layout.category ) do
6626 if v == bar_id then
6627 local cat_def = ArkInventory.CategoryGetSystemID( "SYSTEM_DEFAULT" )
6628 if k ~= cat_def then
6629 -- erase the location, setting it back to the same as DEFAULT
6630 ArkInventory.CategoryLocationSet( loc_id, k, nil )
6631 end
6632 end
6633 end
6634
6635 -- clear bag assignment
6636 for bag_id in pairs( ArkInventory.Global.Location[loc_id].Bags ) do
6637 if codex.layout.bag[bag_id].bar == bar_id then
6638 codex.layout.bag[bag_id].bar = nil
6639 end
6640 end
6641
6642end
6643
6644
6645function ArkInventory.Frame_Bar_Edit_OnLoad( frame )
6646
6647 assert( frame, "frame is missing" )
6648
6649 local framename = frame:GetName( )
6650 local loc_id, bar_id = string.match( framename, "^.-(%d+)ScrollContainerBar(%d+)" )
6651
6652 assert( loc_id, string.format( "xml element '%s' is not an %s frame", framename, ArkInventory.Const.Program.Name ) )
6653 assert( bar_id, string.format( "xml element '%s' is not an %s frame", framename, ArkInventory.Const.Program.Name ) )
6654
6655 loc_id = tonumber( loc_id )
6656 bar_id = tonumber( bar_id )
6657
6658 frame.ARK_Data = {
6659 loc_id = loc_id,
6660 bar_id = bar_id,
6661 }
6662
6663 frame:SetID( bar_id )
6664
6665 -- <START> because blizzard sometimes forgets to turn things off by default
6666
6667 if frame.NewItemTexture then
6668 frame.NewItemTexture:Hide( )
6669 end
6670
6671 if frame.BattlepayItemTexture then
6672 frame.BattlepayItemTexture:Hide( )
6673 end
6674
6675 -- <END> because blizzard sometimes forgets to turn things off by default
6676
6677 ArkInventory.MediaFrameDefaultFontSet( frame )
6678
6679 ArkInventory.SetItemButtonTexture( frame, [[Interface\Buttons\WHITE8X8]] )
6680 SetItemButtonTextureVertexColor( frame, 0.5, 0.1, 0.1, 0.3 )
6681
6682 frame:RegisterForClicks( "LeftButtonUp", "RightButtonUp" )
6683 frame:RegisterForDrag( "LeftButton" )
6684
6685end
6686
6687function ArkInventory.Frame_Bar_Edit_OnClick( frame, button )
6688
6689 --ArkInventory.Output( "OnClick( ", frame:GetName( ), ", ", button, " )" )
6690
6691 local loc_id = frame.ARK_Data.loc_id
6692 local bar_id = frame.ARK_Data.bar_id
6693
6694 if button then
6695 ArkInventory.MenuBarOpen( frame )
6696 end
6697
6698end
6699
6700function ArkInventory.Frame_Bar_Edit_OnDragStart( frame )
6701
6702 local loc_id = frame.ARK_Data.loc_id
6703 local bar_id = frame.ARK_Data.bar_id
6704
6705 --ArkInventory.Output( "drag start for bar ", loc_id, ".", bar_id )
6706
6707 ArkInventory.Global.Options.BarMoveLocation = loc_id
6708 ArkInventory.Global.Options.BarMoveSource = bar_id
6709
6710end
6711
6712function ArkInventory.Frame_Bar_Edit_OnDragReceive( frame )
6713
6714 local loc_id = frame.ARK_Data.loc_id
6715 local bar_id = frame.ARK_Data.bar_id
6716
6717 --ArkInventory.Output( "drag receive for bar ", loc_id, ".", bar_id )
6718
6719 if ArkInventory.Global.Options.BarMoveLocation and ArkInventory.Global.Options.BarMoveSource then
6720
6721 if ArkInventory.Global.Options.BarMoveLocation == loc_id and ArkInventory.Global.Options.BarMoveSource ~= bar_id then
6722 ArkInventory.Frame_Bar_Move( loc_id, ArkInventory.Global.Options.BarMoveSource, bar_id )
6723 ArkInventory.Global.Options.BarMoveInProgress = false
6724 ArkInventory.Global.Options.BarMoveLocation = nil
6725 ArkInventory.Global.Options.BarMoveSource = nil
6726 --ArkInventory.OutputWarning( "Frame_Bar_Edit_OnDragReceive - .Recalculate" )
6727 ArkInventory.Frame_Main_Generate( nil, ArkInventory.Const.Window.Draw.Recalculate )
6728 else
6729 if ArkInventory.Global.Options.BarMoveLocation == loc_id then
6730 ArkInventory.OutputWarning( ArkInventory.Localise["MENU_BAR_MOVE_FAIL_SAME"] )
6731 else
6732 ArkInventory.OutputWarning( ArkInventory.Localise["MENU_BAR_MOVE_FAIL_OUTSIDE"] )
6733 end
6734 end
6735
6736 end
6737
6738end
6739
6740
6741function ArkInventory.Frame_Bag_OnLoad( frame )
6742
6743 assert( frame, "Frame_Bag_OnLoad( ) passed a nil frame" )
6744
6745 local framename = frame:GetName( )
6746 local loc_id, bag_id = string.match( framename, "^.-(%d+)ScrollContainerBag(%d+)" )
6747
6748 assert( loc_id, string.format( "xml element '%s' is not an %s frame", framename, ArkInventory.Const.Program.Name ) )
6749 assert( bag_id, string.format( "xml element '%s' is not an %s frame", framename, ArkInventory.Const.Program.Name ) )
6750
6751 loc_id = tonumber( loc_id )
6752 bag_id = tonumber( bag_id )
6753
6754 frame.ARK_Data = {
6755 loc_id = loc_id,
6756 bag_id = bag_id,
6757 blizzard_id = ArkInventory.InternalIdToBlizzardBagId( loc_id, bag_id ),
6758 inv_id = ArkInventory.InventoryIDGet( loc_id, bag_id ),
6759 }
6760
6761 frame:SetID( frame.ARK_Data.blizzard_id )
6762
6763 -- pre-build a set amount of non tainted usable item slots for the backpack to cater for entering the world when in combat
6764 if loc_id == ArkInventory.Const.Location.Bag then
6765 ArkInventory.Global.Location[loc_id].maxSlot[bag_id] = MAX_CONTAINER_ITEMS
6766 for slot_id = 1, MAX_CONTAINER_ITEMS do
6767 local itemframename = ArkInventory.ContainerItemNameGet( loc_id, bag_id, slot_id )
6768 local itemframe = CreateFrame( "ItemButton", itemframename, frame, ArkInventory.Global.Location[loc_id].template or "ARKINV_TemplateButtonViewOnlyItem" )
6769 end
6770 end
6771
6772 ArkInventory.MediaFrameDefaultFontSet( frame )
6773
6774 frame:Hide( )
6775
6776end
6777
6778
6779function ArkInventory.SetTexture( obj, texture, r, g, b, a, c )
6780
6781 if not obj then
6782 return
6783 end
6784
6785 if texture then
6786 obj:Show( )
6787 else
6788 obj:Hide( )
6789 return
6790 end
6791
6792 if texture == true then
6793 -- solid colour
6794 obj:SetColorTexture( r or 0, g or 0, b or 0, a or 1 )
6795 else
6796 if c then
6797 SetPortraitToTexture( obj, texture or ArkInventory.Const.Texture.Missing )
6798 else
6799 obj:SetTexture( texture or ArkInventory.Const.Texture.Missing )
6800 if r and g and b then
6801 obj:SetVertexColor( r, g, b )
6802 end
6803 end
6804 end
6805
6806end
6807
6808function ArkInventory.SetItemButtonTexture( frame, texture, r, g, b, a, c )
6809
6810 if not frame then
6811 return
6812 end
6813
6814 local obj = frame.icon
6815
6816 if not obj then
6817 return
6818 end
6819
6820 ArkInventory.SetTexture( obj, texture, r, g, b, a, c )
6821
6822 --obj:SetTexCoord( 0.075, 0.935, 0.075, 0.935 )
6823 obj:SetTexCoord( 0.075, 0.925, 0.075, 0.925 )
6824
6825end
6826
6827function ArkInventory.SetItemButtonDesaturate( frame, desaturate, r, g, b )
6828
6829 if not frame then
6830 return
6831 end
6832
6833 local obj = frame.icon
6834
6835 if not obj then
6836 return
6837 end
6838
6839 local shaderSupported = obj:SetDesaturated( desaturate )
6840
6841 if desaturate then
6842
6843 if shaderSupported then
6844 return
6845 end
6846
6847 if not r or not g or not b then
6848 r = 0.5
6849 g = 0.5
6850 b = 0.5
6851 end
6852
6853 else
6854
6855 if not r or not g or not b then
6856 r = 1.0
6857 g = 1.0
6858 b = 1.0
6859 end
6860
6861 end
6862
6863 obj:SetVertexColor( r, g, b )
6864
6865end
6866
6867
6868function ArkInventory.Frame_Item_GetDB( frame )
6869
6870 assert( frame.ARK_Data, " invalid frame" )
6871
6872 --ArkInventory.Output( "frame=[", frame:GetName( ), "]" )
6873 local loc_id = frame.ARK_Data.loc_id
6874 local bag_id = frame.ARK_Data.bag_id
6875 local slot_id = frame.ARK_Data.slot_id
6876
6877 local codex = ArkInventory.GetLocationCodex( loc_id )
6878
6879 --ArkInventory.Output( codex.player.current, " / ", codex.player.data.info.player_id )
6880 --ArkInventory.Output( "loc=[", loc_id, "], bag=[", bag_id, "], slot=[", slot_id, "]" )
6881
6882 if slot_id == nil then
6883 return codex.player.data.location[loc_id].bag[bag_id]
6884 else
6885 return codex.player.data.location[loc_id].bag[bag_id].slot[slot_id]
6886 end
6887
6888end
6889
6890function ArkInventory.Frame_Item_Update_Texture( frame )
6891
6892 if not ArkInventory.ValidFrame( frame ) then return end
6893
6894 local loc_id = frame.ARK_Data.loc_id
6895 local i = ArkInventory.Frame_Item_GetDB( frame )
6896
6897 if i and i.h then
6898
6899 -- frame has an item
6900 frame.hasItem = 1
6901
6902 -- item is readable?
6903 if loc_id ~= ArkInventory.Const.Location.Vault then
6904 if not ArkInventory.Global.Location[loc_id].isOffline then
6905 frame.readable = i.r
6906 end
6907 else
6908 frame.readable = nil
6909 end
6910
6911 -- item texture
6912 local t = i.texture or ArkInventory.ObjectInfoTexture( i.h )
6913 ArkInventory.SetItemButtonTexture( frame, t )
6914
6915 else
6916
6917 frame.hasItem = nil
6918 frame.readable = nil
6919
6920 ArkInventory.Frame_Item_Update_Empty( frame )
6921
6922 end
6923
6924 ArkInventory.Frame_Item_Update_New( frame )
6925
6926end
6927
6928function ArkInventory.Frame_Item_Update_Quest( frame )
6929
6930 if not ArkInventory.ValidFrame( frame ) then return end
6931
6932 local obj = _G[frame:GetName( ) .. "IconQuestTexture"]
6933 if not obj then return end
6934
6935 local loc_id = frame.ARK_Data.loc_id
6936 if ( loc_id == ArkInventory.Const.Location.Bag or loc_id == ArkInventory.Const.Location.Bank ) and not ArkInventory.Global.Location[loc_id].isOffline then
6937
6938 local i = ArkInventory.Frame_Item_GetDB( frame )
6939
6940 if i and i.h then
6941
6942 local isQuestItem, questId, isActive = GetContainerItemQuestInfo( frame.ARK_Data.blizzard_id, frame.ARK_Data.slot_id )
6943
6944 if questId then
6945
6946 local codex = ArkInventory.GetLocationCodex( loc_id )
6947
6948 if not isActive then
6949 if codex.style.slot.quest.bang then
6950 ArkInventory.SetTexture( obj, TEXTURE_ITEM_QUEST_BANG )
6951 return
6952 end
6953 elseif isQuestItem then
6954 if codex.style.slot.quest.border then
6955 ArkInventory.SetTexture( obj, TEXTURE_ITEM_QUEST_BORDER )
6956 return
6957 end
6958 end
6959
6960 end
6961
6962 end
6963
6964 end
6965
6966 obj:Hide( )
6967
6968end
6969
6970function ArkInventory.Frame_Item_Update_StatusIconUpgrade( frame )
6971
6972 if not ArkInventory.ValidFrame( frame ) then return end
6973
6974 local obj = frame.UpgradeIcon
6975 if not obj then return end
6976
6977 local loc_id = frame.ARK_Data.loc_id
6978 if ( loc_id == ArkInventory.Const.Location.Bag or loc_id == ArkInventory.Const.Location.Bank ) and not ArkInventory.Global.Location[loc_id].isOffline then
6979
6980 local i = ArkInventory.Frame_Item_GetDB( frame )
6981 if i and i.h then
6982
6983 local codex = ArkInventory.GetLocationCodex( loc_id )
6984
6985 if codex.style.slot.upgradeicon.show then
6986
6987 ContainerFrameItemButton_UpdateItemUpgradeIcon( frame )
6988 return
6989
6990 end
6991
6992 end
6993
6994 end
6995
6996 obj:Hide( )
6997
6998end
6999
7000function ArkInventory.Frame_Item_Update_StatusIconUpgrade_Anchor( frame )
7001
7002 if not ArkInventory.ValidFrame( frame ) then return end
7003
7004 local obj = frame.UpgradeIcon
7005 if not obj then return end
7006
7007 local loc_id = frame.ARK_Data.loc_id
7008 local codex = ArkInventory.GetLocationCodex( loc_id )
7009
7010 if not codex.style.slot.upgradeicon.show then return end
7011
7012 local anchor = codex.style.slot.upgradeicon.anchor
7013 local anchorpoint = "BOTTOMLEFT"
7014 local x, y = -3, -3
7015
7016 if anchor == ArkInventory.Const.Anchor.BottomRight then
7017 anchorpoint = "BOTTOMRIGHT"
7018 x, y = 3, -3
7019 elseif anchor == ArkInventory.Const.Anchor.TopLeft then
7020 anchorpoint = "TOPLEFT"
7021 x, y = -3, 3
7022 elseif anchor == ArkInventory.Const.Anchor.TopRight then
7023 anchorpoint = "TOPRIGHT"
7024 x, y = 3, 3
7025 end
7026
7027 obj:ClearAllPoints( )
7028 obj:SetPoint( anchorpoint, frame, x, y )
7029
7030end
7031
7032function ArkInventory.Frame_Item_Update_StatusIconJunk( frame )
7033
7034 if not ArkInventory.ValidFrame( frame ) then return end
7035
7036 local obj = frame.JunkIcon
7037 if not obj then return end
7038
7039 local loc_id = frame.ARK_Data.loc_id
7040 if ( loc_id == ArkInventory.Const.Location.Bag or loc_id == ArkInventory.Const.Location.Bank ) and not ArkInventory.Global.Location[loc_id].isOffline then
7041
7042 local i = ArkInventory.Frame_Item_GetDB( frame )
7043 if i and i.h then
7044
7045 local codex = ArkInventory.GetLocationCodex( loc_id )
7046
7047 if codex.style.slot.junkicon.show then
7048
7049 local isJunk, vendorPrice = ArkInventory.JunkCheck( i, codex )
7050
7051 if isJunk then
7052 obj:Show( )
7053 return
7054 end
7055
7056 end
7057
7058 end
7059
7060 end
7061
7062 obj:Hide( )
7063
7064end
7065
7066function ArkInventory.Frame_Item_Update_StatusIconJunk_Anchor( frame )
7067
7068 if not ArkInventory.ValidFrame( frame ) then return end
7069
7070 local obj = frame.JunkIcon
7071 if not obj then return end
7072
7073 local loc_id = frame.ARK_Data.loc_id
7074 local codex = ArkInventory.GetLocationCodex( loc_id )
7075
7076 if not codex.style.slot.junkicon.show then return end
7077
7078 local anchor = codex.style.slot.junkicon.anchor
7079 local anchorpoint = "TOPRIGHT"
7080 local x, y = 3, 3
7081
7082 if anchor == ArkInventory.Const.Anchor.BottomRight then
7083 anchorpoint = "BOTTOMRIGHT"
7084 x, y = 3, -3
7085 elseif anchor == ArkInventory.Const.Anchor.BottomLeft then
7086 anchorpoint = "BOTTOMLEFT"
7087 x, y = -3, -3
7088 elseif anchor == ArkInventory.Const.Anchor.TopLeft then
7089 anchorpoint = "TOPLEFT"
7090 x, y = -3, 3
7091 end
7092
7093 obj:ClearAllPoints( )
7094 obj:SetPoint( anchorpoint, frame, x, y )
7095
7096end
7097
7098function ArkInventory.ItemTransmogState( h, sb, loc_id, rule )
7099
7100-- if h and sb == ArkInventory.Const.Bind.Pickup and not ArkInventory.Global.Location[loc_id].isOffline then
7101-- return random( 4 )
7102-- end
7103
7104 if h and sb == ArkInventory.Const.Bind.Equip and not ArkInventory.Global.Location[loc_id].isOffline then
7105
7106 local visualID, sourceID = C_TransmogCollection.GetItemInfo( h )
7107 if visualID and sourceID then
7108
7109 --ArkInventory.Output( h, " ", visualID, " / ", sourceID )
7110
7111 -- this item has an appearance
7112
7113-- local codex = ArkInventory.GetLocationCodex( loc_id )
7114-- if codex.style.slot.transmogicon.show or rule then
7115 if ArkInventory.db.option.transmog.enable or rule then
7116
7117 local sourceMe = { } -- sources i can collect
7118 local sourceOther = { } -- sources i cannot collect
7119
7120 local itemInfo = { GetItemInfoInstant( h ) }
7121 local itemSubType = itemInfo[7] or -2
7122 local invType = itemInfo[4] or -2
7123
7124 local source = C_TransmogCollection.GetAllAppearanceSources( visualID )
7125 for _, id in pairs( source ) do
7126
7127 local isInfoReady, canCollect = C_TransmogCollection.PlayerCanCollectSource( id )
7128 if isInfoReady then
7129
7130 local info = C_TransmogCollection.GetSourceInfo( id )
7131
7132 if canCollect then
7133
7134 sourceMe[id] = info
7135
7136 else
7137
7138 local itemInfo = { GetItemInfoInstant( info.itemID ) }
7139
7140 if itemSubType == itemInfo[7] then
7141 -- only add sources that match the sub type of the item
7142 sourceOther[id] = info
7143 end
7144
7145 end
7146
7147 end
7148
7149 end
7150
7151
7152 local collectedMe = false
7153 local collectedMeFromThisItem = false
7154
7155 if sourceMe[sourceID] then
7156
7157 -- this character can collect this appearance
7158 -- check if the appearance hasn't been collected
7159
7160 for id, info in pairs( sourceMe ) do
7161 if info.isCollected then
7162 collectedMe = true
7163 if id == sourceID then
7164 collectedMeFromThisItem = true
7165 end
7166 end
7167 end
7168
7169 if not collectedMe then
7170
7171 --ArkInventory.Output( h, " unknown, learn it" )
7172
7173 -- can be learnt by this character
7174 return ArkInventory.Const.Transmog.State.CanLearnMyself
7175
7176 end
7177
7178 end
7179
7180
7181 local collectedOther = false
7182 local collectedOtherFromThisItem = false
7183
7184 if sourceOther[sourceID] then
7185
7186 -- cant be learnt by this character, another character may be able to collect it
7187
7188 for id, info in pairs( sourceOther ) do
7189 if info.isCollected then
7190 collectedOther = true
7191 if id == sourceID then
7192 collectedOtherFromThisItem = true
7193 end
7194 end
7195 end
7196
7197 if not collectedOther then
7198
7199 --ArkInventory.Output( h, " unknown, send to another character" )
7200
7201 -- can be learnt by another character
7202 return ArkInventory.Const.Transmog.State.CanLearnOther
7203
7204 end
7205
7206 end
7207
7208 --if codex.style.slot.transmogicon.alternative or rule then
7209 if ArkInventory.db.option.transmog.secondary then
7210
7211 if collectedMe and not collectedMeFromThisItem then
7212
7213 --ArkInventory.Output( h, " learnt, from another item" )
7214
7215 -- already known on this character but from another item, learn this one as well?
7216 return ArkInventory.Const.Transmog.State.CanLearnMyselfSecondary
7217
7218 end
7219
7220 if collectedOther and not collectedOtherFromThisItem then
7221
7222 --ArkInventory.Output( h, " learnt, from another item, send to another character" )
7223
7224 -- already known on another character but from another item, learn this one as well?
7225 return ArkInventory.Const.Transmog.State.CanLearnOtherSecondary
7226
7227 end
7228
7229 end
7230
7231 end
7232
7233 end
7234
7235 end
7236
7237 return false
7238
7239end
7240
7241function ArkInventory.Frame_Item_Update_StatusIconTransmog( frame )
7242
7243 if not ArkInventory.ValidFrame( frame ) then return end
7244
7245 local obj = frame.ArkTransmogIcon or _G[frame:GetName( ).."ArkTransmogIcon"]
7246 if not obj then return end
7247
7248 local i = ArkInventory.Frame_Item_GetDB( frame )
7249
7250 if i and i.h then
7251
7252 local state = ArkInventory.ItemTransmogState( i.h, i.sb, i.loc_id )
7253 if state then
7254
7255 local info = ArkInventory.db.option.transmog.icon[state]
7256 local file = ArkInventory.Lib.SharedMedia:Fetch( ArkInventory.Const.Transmog.SharedMediaType, info.style )
7257 ArkInventory.SetTexture( obj, file, info.colour.r, info.colour.g, info.colour.b, info.colour.a )
7258 return
7259
7260 end
7261
7262 end
7263
7264 obj:Hide( )
7265
7266end
7267
7268function ArkInventory.Frame_Item_Update_StatusIconTransmog_Anchor( frame )
7269
7270 if not ArkInventory.ValidFrame( frame ) then return end
7271
7272 local obj = frame.ArkTransmogIcon or _G[frame:GetName( ).."ArkTransmogIcon"]
7273 if not obj then return end
7274
7275 local loc_id = frame.ARK_Data.loc_id
7276 --local codex = ArkInventory.GetLocationCodex( loc_id )
7277
7278 --if not codex.style.slot.transmogicon.show then return end
7279 if not ArkInventory.db.option.transmog.enable then return end
7280
7281 local anchor = ArkInventory.db.option.transmog.anchor
7282 local anchorpoint = "BOTTOMLEFT"
7283 local x, y = 2, 2
7284
7285 if anchor == ArkInventory.Const.Anchor.BottomRight then
7286 anchorpoint = "BOTTOMRIGHT"
7287 x, y = -2, 2
7288 elseif anchor == ArkInventory.Const.Anchor.TopLeft then
7289 anchorpoint = "TOPLEFT"
7290 x, y = 2, -2
7291 elseif anchor == ArkInventory.Const.Anchor.TopRight then
7292 anchorpoint = "TOPRIGHT"
7293 x, y = -2, -2
7294 end
7295
7296 obj:ClearAllPoints( )
7297 obj:SetPoint( anchorpoint, frame, 0, 0 )
7298
7299end
7300
7301function ArkInventory.Frame_Item_Update_Count( frame )
7302
7303 if not ArkInventory.ValidFrame( frame ) then return end
7304
7305 local obj = frame.Count or _G[frame:GetName( ).."Count"]
7306 if not obj then return end
7307
7308 local i = ArkInventory.Frame_Item_GetDB( frame )
7309
7310 frame.count = 0
7311
7312 if i and i.h then
7313
7314 local codex = ArkInventory.GetLocationCodex( i.loc_id )
7315 if codex.style.slot.itemcount.show and not codex.style.window.list then
7316
7317 local osd = ArkInventory.ObjectStringDecode( i.h )
7318 local count = i.count or 0
7319 frame.count = count
7320
7321 if osd.class == "battlepet" then
7322 count = osd.level
7323 end
7324
7325 local more = 0
7326
7327 if codex.style.slot.compress.count > 0 and codex.style.slot.compress.identify and not ArkInventory.Global.Options.ShowHiddenItems then
7328
7329 local info = ArkInventory.ObjectInfoArray( i.h )
7330 if info.stacksize > 1 then
7331
7332 local loc_id = frame.ARK_Data.loc_id
7333 local player = ArkInventory.GetPlayerInfo( )
7334 local search_id = ArkInventory.ObjectIDCount( i.h )
7335
7336 if not ( ArkInventory.Global.Cache.ItemCountRaw[search_id] and ArkInventory.Global.Cache.ItemCountRaw[search_id][player.player_id] ) then
7337 ArkInventory.ObjectCountGetRaw( search_id )
7338 end
7339
7340 if ArkInventory.Global.Cache.ItemCountRaw[search_id] and ArkInventory.Global.Cache.ItemCountRaw[search_id][player.player_id] and ArkInventory.Global.Cache.ItemCountRaw[search_id][player.player_id].location[loc_id] then
7341 more = ArkInventory.Global.Cache.ItemCountRaw[search_id][player.player_id].location[loc_id].s
7342 if more <= codex.style.slot.compress.count then
7343 more = 0
7344 end
7345 end
7346
7347 end
7348
7349 end
7350
7351 if osd.class == "battlepet" or count > 1 or more > 0 or ( frame.isBag and count > 0 ) then
7352
7353 if count > ( frame.maxDisplayCount or 9999 ) then
7354 count = "***"
7355 end
7356
7357 if more > 0 then
7358 if codex.style.slot.compress.position == 1 then
7359 count = "+" .. count
7360 else
7361 count = count .. "+"
7362 end
7363 end
7364
7365 obj:SetText( count )
7366
7367 local colour = codex.style.slot.itemcount.colour
7368 obj:SetTextColor( colour.r, colour.g, colour.b )
7369
7370 ArkInventory.MediaObjectFontSet( obj, nil, codex.style.slot.itemcount.font.height )
7371
7372 obj:Show( )
7373
7374 return
7375
7376 end
7377
7378 end
7379
7380 end
7381
7382 obj:Hide( )
7383
7384end
7385
7386function ArkInventory.Frame_Item_Update_Count_Anchor( frame )
7387
7388 if not ArkInventory.ValidFrame( frame ) then return end
7389
7390 local obj = frame.Count or _G[frame:GetName( ).."Count"]
7391 if not obj then return end
7392
7393 local loc_id = frame.ARK_Data.loc_id
7394 local codex = ArkInventory.GetLocationCodex( loc_id )
7395
7396 if not codex.style.slot.itemcount.show then return end
7397
7398 local anchor = codex.style.slot.itemcount.anchor
7399 local anchorpoint = "BOTTOMRIGHT"
7400
7401 if anchor == ArkInventory.Const.Anchor.BottomLeft then
7402 anchorpoint = "BOTTOMLEFT"
7403 elseif anchor == ArkInventory.Const.Anchor.TopLeft then
7404 anchorpoint = "TOPLEFT"
7405 elseif anchor == ArkInventory.Const.Anchor.TopRight then
7406 anchorpoint = "TOPRIGHT"
7407 end
7408
7409 obj:ClearAllPoints( )
7410 obj:SetPoint( anchorpoint, frame )
7411
7412end
7413
7414function ArkInventory.Frame_Item_Update_Stock( frame )
7415
7416 if not ArkInventory.ValidFrame( frame ) then return end
7417
7418 local obj = frame.Stock or _G[frame:GetName( ).."Stock"]
7419 if not obj then return end
7420
7421 local i = ArkInventory.Frame_Item_GetDB( frame )
7422
7423 if i and i.h then
7424
7425 local stock = 0
7426 local codex = ArkInventory.GetLocationCodex( i.loc_id )
7427
7428 if codex.style.slot.itemlevel.show then
7429
7430 local info = ArkInventory.ObjectInfoArray( i.h, i )
7431
7432 if info.class == "item" then
7433
7434 -- equipable items
7435 if info.equiploc ~= "" and info.equiploc ~= "INVTYPE_BAG" and info.ilvl >= codex.style.slot.itemlevel.min then
7436 stock = info.ilvl
7437 end
7438
7439 -- artifact relics
7440 if info.itemtypeid == ArkInventory.Const.ItemClass.GEM and info.itemsubtypeid == ArkInventory.Const.ItemClass.GEM_ARTIFACT_RELIC then
7441 stock = info.ilvl
7442 end
7443
7444 -- artifact power and ancient mana
7445 if info.itemtypeid == ArkInventory.Const.ItemClass.CONSUMABLE and info.itemsubtypeid == ArkInventory.Const.ItemClass.CONSUMABLE_OTHER then
7446
7447 stock = ArkInventory.TooltipExtractValueArtifactPower( i.h ) or 0
7448
7449 if stock == 0 then
7450 stock = ArkInventory.TooltipExtractValueAncientMana( i.h ) or 0
7451 end
7452
7453 end
7454
7455 elseif info.class == "keystone" then
7456
7457 stock = info.ilvl
7458
7459 end
7460
7461 if stock > 0 then
7462
7463 if stock > ( frame.maxDisplayCount or 9999 ) then
7464
7465 if stock >= 1000000000000 then
7466 stock = string.format( "%.0f%s", stock / 1000000000000, ArkInventory.Localise["WOW_ITEM_TOOLTIP_10P12S"] )
7467 elseif stock >= 1000000000 then
7468 stock = string.format( "%.0f%s", stock / 1000000000, ArkInventory.Localise["WOW_ITEM_TOOLTIP_10P9S"] )
7469 elseif stock >= 1000000 then
7470 stock = string.format( "%.0f%s", stock / 1000000, ArkInventory.Localise["WOW_ITEM_TOOLTIP_10P6S"] )
7471 elseif stock > 9999 then
7472 stock = string.format( "%.0f%s", stock / 1000, ArkInventory.Localise["WOW_ITEM_TOOLTIP_10P3S"] )
7473 else
7474 stock = string.format( "%.0f", stock )
7475 end
7476
7477 else
7478
7479 stock = string.format( "%.0f", stock )
7480
7481 end
7482
7483 obj:SetText( stock )
7484
7485 local colour = codex.style.slot.itemlevel.colour
7486 obj:SetTextColor( colour.r, colour.g, colour.b )
7487
7488 ArkInventory.MediaObjectFontSet( obj, nil, codex.style.slot.itemlevel.font.height )
7489
7490 obj:Show( )
7491
7492 return
7493
7494 end
7495
7496 end
7497
7498 end
7499
7500 obj:Hide( )
7501
7502end
7503
7504function ArkInventory.Frame_Item_Update_Stock_Anchor( frame )
7505
7506 if not ArkInventory.ValidFrame( frame ) then return end
7507
7508 local obj = frame.Stock or _G[frame:GetName( ).."Stock"]
7509 if not obj then return end
7510
7511 local loc_id = frame.ARK_Data.loc_id
7512 local codex = ArkInventory.GetLocationCodex( loc_id )
7513
7514 if not codex.style.slot.itemlevel.show then return end
7515
7516 local anchor = codex.style.slot.itemlevel.anchor
7517 local anchorpoint = "TOPLEFT"
7518
7519 if anchor == ArkInventory.Const.Anchor.BottomRight then
7520 anchorpoint = "BOTTOMRIGHT"
7521 elseif anchor == ArkInventory.Const.Anchor.BottomLeft then
7522 anchorpoint = "BOTTOMLEFT"
7523 elseif anchor == ArkInventory.Const.Anchor.TopRight then
7524 anchorpoint = "TOPRIGHT"
7525 end
7526
7527 obj:ClearAllPoints( )
7528 obj:SetPoint( anchorpoint, frame )
7529
7530end
7531
7532function ArkInventory.Frame_Item_MatchesFilter( frame )
7533
7534 if not ArkInventory.ValidFrame( frame ) then return end
7535
7536 local loc_id = frame.ARK_Data.loc_id
7537 local matches = false
7538
7539 local f = string.trim( string.lower( ArkInventory.Global.Location[loc_id].filter or "" ) )
7540
7541 f = ArkInventory.Search.CleanText( f )
7542
7543 if f == "" then
7544 return true
7545 end
7546
7547 local i = ArkInventory.Frame_Item_GetDB( frame )
7548 if not i or not i.h then
7549 return false
7550 end
7551
7552 local txt = ArkInventory.Search.GetContent( i.h, i )
7553
7554 if string.find( txt, f, nil, true ) then
7555 return true
7556 end
7557
7558end
7559
7560function ArkInventory.Frame_Item_Update_Fade( frame, changer )
7561
7562 if not ArkInventory.ValidFrame( frame ) then return end
7563
7564 local loc_id = frame.ARK_Data.loc_id
7565 local bag_id = frame.ARK_Data.bag_id
7566 local codex = ArkInventory.GetLocationCodex( loc_id )
7567 local alpha = 1
7568
7569 if ArkInventory.Global.Location[loc_id].isOffline then
7570 if codex.style.slot.offline.fade then
7571 alpha = 0.6
7572 end
7573 end
7574
7575 if loc_id == ArkInventory.Const.Location.Vault and changer then
7576 if codex.player.data.option[loc_id].bag[bag_id].display == false then
7577 alpha = 0.4
7578 end
7579 end
7580
7581 frame:SetAlpha( alpha )
7582
7583end
7584
7585function ArkInventory.Frame_Item_Update_Border( frame, changer )
7586
7587 if not ArkInventory.ValidFrame( frame ) then return end
7588
7589 --ArkInventory.Output( frame.ARK_Data.loc_id, ".", frame.ARK_Data.bag_id, ".", frame.ARK_Data.slot_id )
7590
7591 local obj = frame.ArkBorder
7592 if obj then
7593
7594 local loc_id = frame.ARK_Data.loc_id
7595 local codex = ArkInventory.GetLocationCodex( loc_id )
7596
7597 if codex.style.slot.border.style ~= ArkInventory.Const.Texture.BorderNone then
7598
7599 local border = codex.style.slot.border.style or ArkInventory.Const.Texture.BorderDefault
7600 local file = ArkInventory.Lib.SharedMedia:Fetch( ArkInventory.Lib.SharedMedia.MediaType.BORDER, border )
7601 local size = codex.style.slot.border.size or ArkInventory.Const.Texture.Border[ArkInventory.Const.Texture.BorderDefault].size
7602 local offset = codex.style.slot.border.offset or ArkInventory.Const.Texture.Border[ArkInventory.Const.Texture.BorderDefault].offsetdefault.slot
7603 local scale = codex.style.slot.border.scale or 1
7604
7605 -- border colour
7606 local i = ArkInventory.Frame_Item_GetDB( frame )
7607
7608 local r, g, b = ArkInventory.GetItemQualityColor( LE_ITEM_QUALITY_POOR )
7609 local a = 0.6
7610
7611 if i and i.h then
7612
7613 if codex.style.slot.border.rarity then
7614 if ( i.q or LE_ITEM_QUALITY_POOR ) >= ( codex.style.slot.border.raritycutoff or LE_ITEM_QUALITY_POOR ) then
7615 r, g, b = ArkInventory.GetItemQualityColor( i.q or LE_ITEM_QUALITY_POOR )
7616 if not frame.locked then
7617 a = 1
7618 end
7619 end
7620 end
7621
7622 else
7623
7624 if codex.style.slot.empty.border then
7625
7626 if changer then
7627
7628 r, g, b = ArkInventory.GetItemQualityColor( LE_ITEM_QUALITY_ARTIFACT )
7629
7630 else
7631
7632 local bag_id = frame.ARK_Data.bag_id
7633 local bt = codex.player.data.location[loc_id].bag[bag_id].type
7634
7635 local c = codex.style.slot.data[bt].colour
7636 r, g, b = c.r, c.g, c.b
7637
7638 end
7639
7640 end
7641
7642 end
7643
7644 ArkInventory.Frame_Border_Paint( obj, file, size, offset, scale, r, g, b, a )
7645
7646 obj:Show( )
7647
7648 else
7649
7650 obj:Hide( )
7651
7652 end
7653
7654 end
7655
7656end
7657
7658function ArkInventory.Frame_Item_Update_List( frame, show )
7659
7660 if not ArkInventory.ValidFrame( frame ) then return end
7661
7662 local obj = frame.ArkListEntry
7663 if obj then
7664
7665 if show then
7666
7667 ArkInventory.Frame_Item_Update_Border( obj )
7668 ArkInventory.Frame_Item_Update_List_Text( obj )
7669
7670 else
7671
7672 obj:Hide( )
7673
7674 end
7675
7676 end
7677
7678end
7679
7680function ArkInventory.Frame_Item_Update_List_Text( frame )
7681
7682 if not ArkInventory.ValidFrame( frame ) then return end
7683
7684 local i = ArkInventory.Frame_Item_GetDB( frame )
7685
7686 if frame.Text1 and frame.Text2 then
7687
7688 local txt1 = ""
7689 local txt2 = ""
7690 local txt3 = ""
7691
7692 if i then
7693
7694 local loc_id = frame.ARK_Data.loc_id
7695 local osd = ArkInventory.ObjectStringDecode( i.h )
7696
7697 if osd.class == "currency" then
7698
7699 local info = ArkInventory.Collection.Currency.GetCurrency( osd.id )
7700 if not info then
7701
7702 txt1 = string.format( "no currency data found for [%s]", osd.id or "nil" )
7703
7704 else
7705
7706 txt1 = info.name
7707
7708 if info.maximumAmount > 0 then
7709 txt2 = string.format( CURRENCY_TOTAL_CAP, "", FormatLargeNumber( info.currentAmount ), FormatLargeNumber( info.maximumAmount ) )
7710 else
7711 txt2 = string.format( CURRENCY_TOTAL, "", FormatLargeNumber( info.currentAmount ) )
7712 end
7713
7714 if info.weeklyLimit > 0 then
7715 local weekly = string.format( CURRENCY_WEEKLY_CAP, "", FormatLargeNumber( info.currentWeeklyAmount ), FormatLargeNumber( info.weeklyLimit ) )
7716 txt2 = string.format( "%s\n%s", weekly, txt2 )
7717 end
7718
7719 end
7720
7721 elseif osd.class == "reputation" then
7722
7723 local info = ArkInventory.Collection.Reputation.GetReputation( osd.id )
7724 if not info then
7725 txt1 = string.format( "no reputation data found for [%s]", osd.id or "nil" )
7726 else
7727 txt1 = info.name
7728 txt2 = ArkInventory.Collection.Reputation.LevelText( osd.id, ArkInventory.Const.Reputation.Style.TwoLines )
7729 end
7730
7731 else
7732
7733 txt1 = ArkInventory.ObjectInfoName( i.h )
7734
7735 end
7736
7737 end
7738
7739 if txt1 == "" then
7740 frame.Text1:SetText( txt1 )
7741 frame.Text1:Hide( )
7742 else
7743 frame.Text1:SetText( txt1 )
7744 frame.Text1:Show( )
7745 end
7746
7747 if txt2 == "" then
7748 frame.Text2:SetText( txt1 )
7749 frame.Text2:Hide( )
7750 else
7751 frame.Text2:SetText( txt2 )
7752 frame.Text2:SetTextColor( 1, 1, 1 )
7753 frame.Text2:Show( )
7754 end
7755
7756 end
7757
7758end
7759
7760function ArkInventory.Frame_Item_Update_New( frame, clear )
7761
7762 if not ArkInventory.ValidFrame( frame ) then return end
7763
7764 local loc_id = frame.ARK_Data.loc_id
7765 local bag_id = frame.ARK_Data.bag_id
7766 local blizzard_id = frame.ARK_Data.blizzard_id
7767 local slot_id = frame.ARK_Data.slot_id
7768
7769 local codex = ArkInventory.GetLocationCodex( loc_id )
7770 local i = ArkInventory.Frame_Item_GetDB( frame )
7771
7772 local isNewItem = false
7773 local isBattlePayItem = false
7774 if loc_id == ArkInventory.Const.Location.Bag and not ArkInventory.Global.Location[loc_id].isOffline and not clear then
7775 isNewItem = C_NewItems.IsNewItem( blizzard_id, slot_id )
7776 isBattlePayItem = IsBattlePayItem( blizzard_id, slot_id )
7777 end
7778
7779 local battlepayItemTexture = frame.BattlepayItemTexture
7780 local NewItemTexture = frame.NewItemTexture
7781 local flash = frame.flashAnim
7782 local newitemglowAnim = frame.newitemglowAnim
7783 local obj = frame.ArkAgeText
7784
7785 if obj then
7786
7787 if i and i.h then
7788
7789 if codex.style.slot.age.show then
7790
7791 local cutoff = codex.style.slot.age.cutoff
7792 local age, age_text = ArkInventory.ItemAgeGet( i.age )
7793
7794 if age and ( cutoff == 0 or age <= cutoff ) then
7795
7796 obj:ClearAllPoints( )
7797 if codex.style.slot.itemlevel.show then
7798 obj:SetPoint( "CENTER" )
7799 else
7800 obj:SetPoint( "TOPLEFT" )
7801 end
7802
7803 local colour = codex.style.slot.age.colour
7804
7805 obj:SetText( age_text )
7806 obj:SetTextColor( colour.r, colour.g, colour.b )
7807 ArkInventory.MediaObjectFontSet( obj, nil, codex.style.slot.age.font.height )
7808 obj:Show( )
7809
7810 else
7811
7812 obj:Hide( )
7813
7814 if isNewItem then
7815 C_NewItems.RemoveNewItem( blizzard_id, slot_id )
7816 end
7817
7818 end
7819
7820 else
7821
7822 obj:Hide( )
7823
7824 end
7825
7826 else
7827
7828 obj:Hide( )
7829
7830 end
7831
7832 end
7833
7834 if not isNewItem then
7835
7836 if flash:IsPlaying( ) or newitemglowAnim:IsPlaying( ) then
7837 flash:Stop( )
7838 newitemglowAnim:Stop( )
7839 end
7840
7841 battlepayItemTexture:Hide( )
7842 NewItemTexture:Hide( )
7843
7844 else
7845
7846 if isBattlePayItem then
7847
7848 NewItemTexture:Hide( )
7849 battlepayItemTexture:Show( )
7850
7851 else
7852
7853 battlepayItemTexture:Hide( )
7854
7855 if ArkInventory.db.option.newitemglow.enable then
7856 local c = ArkInventory.db.option.newitemglow.colour
7857 ArkInventory.SetTexture( frame.NewItemTexture, true, c.r, c.g, c.b, c.a )
7858 NewItemTexture:Show( )
7859 else
7860 NewItemTexture:Hide( )
7861 end
7862
7863 end
7864
7865 if ArkInventory.db.option.newitemglow.enable and not flash:IsPlaying( ) and not newitemglowAnim:IsPlaying( ) then
7866 flash:Play( )
7867 newitemglowAnim:Play( )
7868 end
7869
7870 end
7871
7872end
7873
7874function ArkInventory.Frame_Main_Clear_NewItemGlow( loc_id )
7875
7876 if ArkInventory.db.option.newitemglow.enable and ArkInventory.db.option.newitemglow.clearonclose and loc_id == ArkInventory.Const.Location.Bag and not ArkInventory.Global.Location[loc_id].isOffline then
7877
7878 --ArkInventory.Output( "Frame_Main_Clear_NewItemGlow( ", loc_id, " )" )
7879
7880 for bag_id in pairs( ArkInventory.Global.Location[loc_id].Bags ) do
7881
7882 local blizzard_id = ArkInventory.InternalIdToBlizzardBagId( loc_id, bag_id )
7883
7884 for slot_id = 1, ArkInventory.Global.Location[loc_id].maxSlot[bag_id] or 0 do
7885
7886 if C_NewItems.IsNewItem( blizzard_id, slot_id ) then
7887
7888 C_NewItems.RemoveNewItem( blizzard_id, slot_id )
7889
7890 local objname, obj = ArkInventory.ContainerItemNameGet( loc_id, bag_id, slot_id )
7891 ArkInventory.Frame_Item_Update_New( obj, true )
7892
7893 end
7894
7895 end
7896
7897 end
7898
7899 end
7900
7901end
7902
7903function ArkInventory.Frame_Item_Update_Empty( frame )
7904
7905 if not ArkInventory.ValidFrame( frame ) then return end
7906
7907 local loc_id = frame.ARK_Data.loc_id
7908 local bag_id = frame.ARK_Data.bag_id
7909
7910 local i = ArkInventory.Frame_Item_GetDB( frame )
7911
7912 if i and not i.h then
7913
7914 local codex = ArkInventory.GetLocationCodex( loc_id )
7915 local bt = codex.player.data.location[loc_id].bag[bag_id].type
7916
7917 -- slot background
7918 if codex.style.slot.empty.icon then
7919
7920 -- icon
7921 local texture = ArkInventory.Const.Texture.Empty.Item
7922
7923 if loc_id == ArkInventory.Const.Location.Wearing then
7924 -- wearing empty slot icons
7925 local a, b = GetInventorySlotInfo( ArkInventory.Const.InventorySlotName[i.slot_id] )
7926 --ArkInventory.Output( "id=[", i.slot_id, "], name=[", ArkInventory.Const.InventorySlotName[i.slot_id], "], texture=[", b, "]" )
7927 texture = b or texture
7928 else
7929 texture = ArkInventory.Const.Slot.Data[bt].texture or texture
7930 end
7931
7932 ArkInventory.SetItemButtonTexture( frame, texture )
7933
7934 else
7935
7936 -- solid colour
7937 local colour = codex.style.slot.data[bt].colour
7938 colour.a = codex.style.slot.empty.alpha
7939 ArkInventory.SetItemButtonTexture( frame, true, colour.r, colour.g, colour.b, colour.a )
7940
7941 end
7942
7943 end
7944
7945end
7946
7947function ArkInventory.Frame_Item_Empty_Paint_All( )
7948
7949 for loc_id, loc_data in pairs( ArkInventory.Global.Location ) do
7950 if loc_data.canView then
7951
7952 for bag_id in pairs( loc_data.Bags ) do
7953
7954 for slot_id = 1, ArkInventory.Global.Location[loc_id].maxSlot[bag_id] or 0 do
7955
7956 local objname, obj = ArkInventory.ContainerItemNameGet( loc_id, bag_id, slot_id )
7957 ArkInventory.Frame_Item_Update_Empty( obj )
7958 ArkInventory.Frame_Item_Update_Border( obj )
7959
7960 end
7961
7962 end
7963
7964 end
7965 end
7966
7967end
7968
7969function ArkInventory.Frame_Item_OnEnter( frame )
7970
7971 if not ArkInventory.db.option.tooltip.show then return end
7972
7973 local loc_id = frame.ARK_Data.loc_id
7974 local bag_id = frame.ARK_Data.bag_id
7975 local blizzard_id = frame.ARK_Data.blizzard_id
7976 local i = ArkInventory.Frame_Item_GetDB( frame )
7977
7978 --ArkInventory.Output( "item=[", i.h, "]" )
7979
7980 local reset = true
7981
7982 if i.h then
7983
7984 if ArkInventory.Global.Location[loc_id].isOffline then
7985
7986 ArkInventory.GameTooltipSetHyperlink( frame, i.h )
7987
7988 elseif blizzard_id == BANK_CONTAINER or blizzard_id == REAGENTBANK_CONTAINER then
7989
7990 BankFrameItemButton_OnEnter( frame )
7991 reset = false
7992
7993 elseif loc_id == ArkInventory.Const.Location.Pet then
7994
7995 ArkInventory.GameTooltipSetPosition( frame )
7996 ArkInventory.TooltipBuildBattlepet( GameTooltip, i.h, i )
7997 CursorUpdate( frame )
7998 return
7999
8000 elseif loc_id == ArkInventory.Const.Location.Toybox then
8001
8002 ArkInventory.GameTooltipSetPosition( frame )
8003 GameTooltip:SetToyByItemID( i.item )
8004
8005 elseif loc_id == ArkInventory.Const.Location.Heirloom then
8006
8007 ArkInventory.GameTooltipSetPosition( frame )
8008 GameTooltip:SetHeirloomByItemID( i.item )
8009
8010 elseif loc_id == ArkInventory.Const.Location.Token then
8011
8012 ArkInventory.GameTooltipSetPosition( frame )
8013 GameTooltip:SetCurrencyByID( i.index )
8014
8015 elseif loc_id == ArkInventory.Const.Location.Bag or loc_id == ArkInventory.Const.Location.Bank then
8016
8017 ContainerFrameItemButton_OnEnter( frame )
8018 reset = false
8019
8020 else
8021
8022 ArkInventory.GameTooltipSetHyperlink( frame, i.h )
8023
8024 end
8025
8026
8027 if IsModifiedClick( "DRESSUP" ) then
8028
8029 ShowInspectCursor( )
8030
8031 elseif IsModifiedClick( "COMPAREITEMS" ) or GetCVarBool( "alwaysCompareItems" ) then
8032
8033 GameTooltip_ShowCompareItem( )
8034 ResetCursor( )
8035
8036 elseif reset then
8037
8038 ResetCursor( )
8039
8040 end
8041
8042 else
8043
8044 GameTooltip:Hide( )
8045 ResetCursor( )
8046
8047 end
8048
8049end
8050
8051function ArkInventory.Frame_Item_OnEnter_Tainted( frame )
8052
8053 if not ArkInventory.ValidFrame( frame ) then return end
8054
8055 if not ArkInventory.db.option.tooltip.show then
8056 return
8057 end
8058
8059 ArkInventory.GameTooltipSetText( frame, ArkInventory.Localise["BUGFIX_TAINTED_ALERT_MOUSEOVER_TEXT"], 1.0, 0.1, 0.1 )
8060
8061end
8062
8063function ArkInventory.Frame_Item_OnMouseUp( frame, button )
8064
8065 if ArkInventory.Global.Mode.Edit then
8066 ArkInventory.MenuItemOpen( frame )
8067 return
8068 end
8069
8070
8071 local loc_id = frame.ARK_Data.loc_id
8072 local i = ArkInventory.Frame_Item_GetDB( frame )
8073
8074 if not i then return end
8075
8076 if ArkInventory.Global.Location[loc_id].isOffline or frame.ARK_Data.tainted then
8077
8078 if HandleModifiedItemClick( i.h ) then return end
8079
8080 -- must be online or untainted to continue
8081 return
8082
8083 end
8084
8085
8086 if loc_id == ArkInventory.Const.Location.Bag then
8087
8088 -- already handled in onclick
8089 return
8090
8091 end
8092
8093
8094 if loc_id == ArkInventory.Const.Location.Bank then
8095
8096 -- already handled in onclick
8097 return
8098
8099 end
8100
8101
8102 if HandleModifiedItemClick( i.h ) then return end
8103
8104
8105 if loc_id == ArkInventory.Const.Location.Vault then
8106
8107 if not ArkInventory.Global.Mode.Vault then
8108 -- must be at the vault to continue
8109 return
8110 end
8111
8112 local tab_id = frame.ARK_Data.bag_id
8113 local slot_id = frame.ARK_Data.slot_id
8114
8115 if IsModifiedClick( "SPLITSTACK" ) then
8116 if i.count > 1 and not frame.locked then
8117 StackSplitFrame:OpenStackSplitFrame( frame.count, frame, "BOTTOMLEFT", "TOPLEFT" )
8118 end
8119 return
8120 end
8121
8122 local infoType, info1, info2 = GetCursorInfo( )
8123 if infoType == "money" then
8124 DepositGuildBankMoney( info1 )
8125 ClearCursor( )
8126 elseif infoType == "guildbankmoney" then
8127 DropCursorMoney( )
8128 ClearCursor( )
8129 else
8130 if button == "RightButton" then
8131 AutoStoreGuildBankItem( tab_id, slot_id )
8132 else
8133 PickupGuildBankItem( tab_id, slot_id )
8134 end
8135 end
8136
8137 return
8138
8139 end
8140
8141
8142 if loc_id == ArkInventory.Const.Location.Mail then
8143
8144 if not ArkInventory.Global.Mode.Mail then
8145 -- must be at the mailbox to continue
8146 return
8147 end
8148
8149 if button == "RightButton" then
8150 if i.msg_id and i.money then
8151 TakeInboxMoney( i.msg_id )
8152 elseif i.msg_id and i.att_id then
8153 TakeInboxItem( i.msg_id, i.att_id )
8154 end
8155 end
8156
8157 return
8158
8159 end
8160
8161
8162 if loc_id == ArkInventory.Const.Location.Wearing then
8163
8164 -- nothing to do
8165 return
8166
8167 end
8168
8169
8170 if loc_id == ArkInventory.Const.Location.Pet then
8171
8172 if i.guid then
8173
8174 if button == "LeftButton" then
8175
8176 ArkInventory.Collection.Pet.Summon( i.guid )
8177
8178 elseif button == "RightButton" then
8179
8180 ArkInventory.MenuItemPetJournal( frame, i.guid )
8181
8182 end
8183
8184 end
8185
8186 ClearCursor( )
8187
8188 return
8189
8190 end
8191
8192
8193 if loc_id == ArkInventory.Const.Location.Mount then
8194
8195 if i.index then
8196 if button == "LeftButton" then
8197
8198 local md = ArkInventory.Collection.Mount.GetMount( i.index )
8199
8200 if md.active then
8201 ArkInventory.Collection.Mount.Dismiss( )
8202 elseif ArkInventory.Collection.Mount.IsUsable( md.index ) then
8203 ArkInventory.Collection.Mount.Summon( i.index )
8204 end
8205
8206 elseif button == "RightButton" then
8207
8208 ArkInventory.MenuItemMountJournal( frame, i.index )
8209
8210 end
8211
8212 end
8213
8214 ClearCursor( )
8215
8216 return
8217
8218 end
8219
8220
8221 if loc_id == ArkInventory.Const.Location.Token then
8222
8223 -- nothing to do
8224 return
8225
8226 end
8227
8228
8229 if loc_id == ArkInventory.Const.Location.Auction then
8230
8231 -- nothing to do
8232 return
8233
8234 end
8235
8236
8237 if loc_id == ArkInventory.Const.Location.Toybox then
8238
8239 if button == "LeftButton" then
8240
8241 --ArkInventory.Collection.Toybox.Summon( i.index )
8242 ArkInventory.Output( "sorry, toys can no longer be summoned by code, please drag the ", i.h, " to your actionbar to use instead" )
8243
8244 elseif button == "RightButton" then
8245
8246 --ArkInventory.MenuItemToybox( frame, i.index ) !!! to be done
8247
8248 end
8249
8250 ClearCursor( )
8251
8252 return
8253
8254 end
8255
8256
8257 if loc_id == ArkInventory.Const.Location.Heirloom then
8258
8259 if button == "LeftButton" then
8260
8261 --C_Heirloom.CreateHeirloom( i.item ) -- secure action, cant be done
8262
8263 elseif button == "RightButton" then
8264
8265 --ArkInventory.MenuItemHeirloom( frame, i.index ) !!! to be done
8266
8267 end
8268
8269 ClearCursor( )
8270
8271 return
8272
8273 end
8274
8275
8276end
8277
8278function ArkInventory.Frame_Item_OnDrag( frame )
8279
8280 if not ArkInventory.ValidFrame( frame ) then return end
8281
8282 local loc_id = frame.ARK_Data.loc_id
8283 local usedmycode = false
8284
8285 if SpellIsTargeting( ) or ArkInventory.Global.Location[loc_id].isOffline or ArkInventory.Global.Mode.Edit then
8286
8287 usedmycode = true
8288 -- do not drag / drag disabled
8289
8290 end
8291
8292 if not usedmycode then
8293 ContainerFrameItemButton_OnClick( frame, "LeftButton" )
8294 --ArkInventory.Frame_Item_OnMouseUp( frame, "LeftButton" )
8295 end
8296
8297end
8298
8299function ArkInventory.Frame_Item_Update_Cooldown( frame )
8300
8301 -- triggered when a cooldown is first started
8302
8303 if not ArkInventory.ValidFrame( frame ) then return end
8304
8305 local loc_id = frame.ARK_Data.loc_id
8306 local i = ArkInventory.Frame_Item_GetDB( frame )
8307
8308 local framename = frame:GetName( )
8309 local obj = _G[string.format( "%s%s", framename, ArkInventory.Const.Frame.Cooldown.Name )]
8310 if not obj then return end
8311
8312 if ArkInventory.Global.Location[loc_id].isOffline then
8313 obj:Hide( )
8314 return
8315 end
8316
8317 local codex = ArkInventory.GetLocationCodex( loc_id )
8318
8319 if not codex.style.slot.cooldown.show then
8320 obj:Hide( )
8321 return
8322 end
8323
8324 if i and i.h then
8325
8326 if loc_id == ArkInventory.Const.Location.Toybox and i.item then
8327
8328 local start, duration, enable = GetItemCooldown( i.item )
8329 if obj and start and duration then
8330
8331 --ArkInventory.Output( "toybox cooldown: ", obj:GetName( ) )
8332
8333 if enable then
8334 obj:Show( )
8335 else
8336 obj:Hide( )
8337 end
8338
8339 CooldownFrame_Set( obj, start, duration, enable )
8340
8341 else
8342
8343 obj:Hide( )
8344
8345 end
8346
8347 else
8348
8349 ContainerFrame_UpdateCooldown( frame.ARK_Data.blizzard_id, frame )
8350
8351 end
8352
8353 else
8354
8355 obj:Hide( )
8356
8357 end
8358
8359end
8360
8361function ArkInventory.Frame_Item_Update_Lock( frame, changer )
8362
8363 if not ArkInventory.ValidFrame( frame ) then return end
8364
8365 local loc_id = frame.ARK_Data.loc_id
8366 if ArkInventory.Global.Mode.Edit or ArkInventory.Global.Location[loc_id].isOffline then
8367 return
8368 end
8369
8370 local i = ArkInventory.Frame_Item_GetDB( frame )
8371
8372 local locked = false
8373
8374 if i and i.h then
8375
8376 local codex = ArkInventory.GetLocationCodex( loc_id )
8377
8378 if loc_id == ArkInventory.Const.Location.Vault then
8379 locked = select( 3, GetGuildBankItemInfo( frame.ARK_Data.bag_id, frame.ARK_Data.slot_id ) )
8380 elseif changer then
8381 locked = IsInventoryItemLocked( frame.ARK_Data.inv_id )
8382 else
8383 locked = select( 3, GetContainerItemInfo( frame.ARK_Data.blizzard_id, frame.ARK_Data.slot_id ) )
8384 end
8385
8386 end
8387
8388 ArkInventory.SetItemButtonDesaturate( frame, locked )
8389
8390 frame.locked = locked
8391
8392end
8393
8394function ArkInventory.Frame_Item_Update_Tint( frame )
8395
8396 if not ArkInventory.ValidFrame( frame ) then return end
8397
8398 local obj = frame.ArkItemTinted
8399 if not obj then return end
8400
8401 local loc_id = frame.ARK_Data.loc_id
8402 if ArkInventory.Global.Mode.Edit or ArkInventory.Global.Location[loc_id].isOffline then
8403 return
8404 end
8405
8406 local codex = ArkInventory.GetLocationCodex( loc_id )
8407 local tinted = false
8408
8409 if codex.style.slot.unusable.tint then
8410
8411 local i = ArkInventory.Frame_Item_GetDB( frame )
8412
8413 if i and i.h then
8414
8415 local osd = ArkInventory.ObjectStringDecode( i.h )
8416
8417 if loc_id == ArkInventory.Const.Location.Pet or osd.class == "battlepet" then
8418
8419 local player_id = ArkInventory.PlayerIDAccount( )
8420 local account = ArkInventory.GetPlayerStorage( player_id )
8421
8422 if account and codex.player.data.info and codex.player.data.info.level and codex.player.data.info.level < osd.level then
8423 tinted = true
8424 end
8425
8426 elseif loc_id == ArkInventory.Const.Location.Mount then
8427
8428 if not ArkInventory.Collection.Mount.IsUsable( i.index ) then
8429 tinted = true
8430 end
8431
8432 elseif loc_id == ArkInventory.Const.Location.Heirloom or loc_id == ArkInventory.Const.Location.Toybox then
8433
8434 ArkInventory.TooltipSetHyperlink( ArkInventory.Global.Tooltip.Scan, i.h )
8435
8436 if not ArkInventory.TooltipCanUse( ArkInventory.Global.Tooltip.Scan, true ) then
8437 tinted = true
8438 end
8439
8440 else
8441
8442 ArkInventory.TooltipSetHyperlink( ArkInventory.Global.Tooltip.Scan, i.h )
8443
8444 if not ArkInventory.TooltipCanUse( ArkInventory.Global.Tooltip.Scan ) then
8445 tinted = true
8446 end
8447
8448 end
8449
8450 end
8451
8452 end
8453
8454 if tinted then
8455 obj:Show( )
8456 else
8457 obj:Hide( )
8458 end
8459
8460end
8461
8462function ArkInventory.Frame_Item_Update_PetJournal( frame )
8463
8464 if not ArkInventory.ValidFrame( frame ) then return end
8465
8466 local i = ArkInventory.Frame_Item_GetDB( frame )
8467
8468 if frame.favorite then
8469
8470 if i and i.guid then
8471
8472 frame.active:SetShown( i.guid == ArkInventory.Collection.Pet.GetCurrent( ) )
8473 frame.slotted:SetShown( ArkInventory.Collection.Pet.IsSlotted( i.guid ) )
8474 frame.dead:SetShown( ( ArkInventory.Collection.Pet.GetStats( i.guid ) or 1 ) <= 0 )
8475 frame.favorite:SetShown( i.fav )
8476
8477 else
8478
8479 frame.active:Hide( )
8480 frame.slotted:Hide( )
8481 frame.dead:Hide( )
8482 frame.favorite:Hide( )
8483
8484 end
8485
8486 end
8487
8488end
8489
8490function ArkInventory.Frame_Item_Update_MountJournal( frame )
8491
8492 if not ArkInventory.ValidFrame( frame ) then return end
8493
8494 local i = ArkInventory.Frame_Item_GetDB( frame )
8495
8496 if frame.favorite then
8497 if i then
8498 frame.favorite:SetShown( i.fav )
8499 else
8500 frame.favorite:Hide( )
8501 end
8502 end
8503
8504end
8505
8506function ArkInventory.Frame_Item_Update_Toybox( frame )
8507
8508 if not ArkInventory.ValidFrame( frame ) then return end
8509
8510 local i = ArkInventory.Frame_Item_GetDB( frame )
8511
8512 if frame.favorite then
8513 if i then
8514 frame.favorite:SetShown( i.fav )
8515 else
8516 frame.favorite:Hide( )
8517 end
8518 end
8519
8520end
8521
8522function ArkInventory.Frame_Item_Update_Heirloom( frame )
8523
8524 if not ArkInventory.ValidFrame( frame ) then return end
8525
8526 local i = ArkInventory.Frame_Item_GetDB( frame )
8527
8528 if i then
8529
8530
8531
8532 else
8533
8534
8535
8536 end
8537
8538end
8539
8540function ArkInventory.Frame_Item_Update_Clickable( frame )
8541
8542 if not ArkInventory.ValidFrame( frame ) then return end
8543
8544 local loc_id = frame.ARK_Data.loc_id
8545 local click = true
8546
8547 if ArkInventory.Global.Mode.Edit or ArkInventory.Global.Location[loc_id].isOffline then
8548
8549 click = false
8550
8551 else
8552
8553 if loc_id == ArkInventory.Const.Location.Vault then
8554
8555 local bag_id = frame.ARK_Data.bag_id
8556 local _, _, _, canDeposit, numWithdrawals = GetGuildBankTabInfo( bag_id )
8557 if ( not canDeposit ) and ( numWithdrawals == 0 ) then
8558 click = false
8559 end
8560
8561 end
8562
8563 end
8564
8565
8566 if click then
8567 frame:RegisterForClicks( "LeftButtonUp", "RightButtonUp" )
8568 frame:RegisterForDrag( "LeftButton" )
8569 else
8570 -- disable clicks/drag when in edit mode or offline
8571 frame:RegisterForClicks( )
8572 frame:RegisterForDrag( )
8573 end
8574
8575end
8576
8577function ArkInventory.Frame_Item_OnLoad( frame, tainted )
8578
8579 --ArkInventory.Output( frame:GetName( ), " / level = ", frame:GetFrameLevel( ) )
8580
8581 local framename = frame:GetName( )
8582 local loc_id, bag_id, slot_id = string.match( framename, "^.-(%d+)ScrollContainerBag(%d+)Item(%d+)" )
8583
8584 assert( loc_id, string.format( "xml element '%s' is not an %s frame", framename, ArkInventory.Const.Program.Name ) )
8585 assert( bag_id, string.format( "xml element '%s' is not an %s frame", framename, ArkInventory.Const.Program.Name ) )
8586 assert( slot_id, string.format( "xml element '%s' is not an %s frame", framename, ArkInventory.Const.Program.Name ) )
8587
8588 loc_id = tonumber( loc_id )
8589 bag_id = tonumber( bag_id )
8590 slot_id = tonumber( slot_id )
8591
8592 frame:SetID( slot_id )
8593
8594 frame.ARK_Data = {
8595 loc_id = loc_id,
8596 bag_id = bag_id,
8597 blizzard_id = ArkInventory.InternalIdToBlizzardBagId( loc_id, bag_id ),
8598 slot_id = slot_id,
8599 tainted = tainted,
8600 init = true,
8601 }
8602
8603 -- because blizzard sometimes forgets to turn things off by default
8604 if frame.BattlepayItemTexture then
8605 frame.BattlepayItemTexture:Hide( )
8606 end
8607
8608 if frame.NewItemTexture then
8609 frame.NewItemTexture:Hide( )
8610 end
8611
8612 if tainted then
8613 ContainerFrameItemButton_OnLoad( frame )
8614 else
8615 if loc_id == ArkInventory.Const.Location.Bank and bag_id == 1 then
8616 BankFrameItemButton_OnLoad( frame )
8617 elseif loc_id == ArkInventory.Const.Location.Bank and bag_id == ArkInventory.Global.Location[loc_id].tabReagent then
8618 ReagentBankFrameItemButton_OnLoad( frame )
8619 else
8620 ContainerFrameItemButton_OnLoad( frame )
8621 end
8622 end
8623
8624 if tainted then
8625 frame.UpdateTooltip = ArkInventory.Frame_Item_OnEnter_Tainted
8626 else
8627 frame.UpdateTooltip = ArkInventory.Frame_Item_OnEnter
8628 end
8629
8630 frame.locked = not not tainted
8631
8632 if loc_id == ArkInventory.Const.Location.Vault then
8633
8634 -- replace the split function
8635 frame.SplitStack = function( button, split )
8636 local tab_id = frame.ARK_Data.bag_id
8637 local slot_id = frame.ARK_Data.slot_id
8638 SplitGuildBankItem( tab_id, slot_id, split )
8639 end
8640
8641 end
8642
8643
8644 -- adjust any fixed size blizzard subframes so they scale properly
8645
8646 local obj = _G[string.format( "%s%s", frame:GetName( ), "IconQuestTexture" )]
8647 if obj then
8648 obj:ClearAllPoints( )
8649 obj:SetPoint( "TOPLEFT", frame, 1, -1 )
8650 obj:SetPoint( "BOTTOMRIGHT", frame, -1, 1 )
8651 end
8652
8653 local obj = frame.NewItemTexture
8654 if obj then
8655 obj:ClearAllPoints( )
8656 obj:SetPoint( "TOPLEFT", frame, 1, -1 )
8657 obj:SetPoint( "BOTTOMRIGHT", frame, -1, 1 )
8658 end
8659
8660 frame:Hide( )
8661
8662 if not tainted then
8663 ArkInventory.API.ItemFrameLoaded( frame, loc_id, bag_id, slot_id )
8664 end
8665
8666end
8667
8668function ArkInventory.Frame_Item_ListEntry_OnLoad( frame )
8669
8670 --ArkInventory.Output( frame:GetName( ), " / level = ", frame:GetFrameLevel( ) )
8671
8672 local framename = frame:GetName( )
8673
8674 local loc_id, bag_id = string.match( framename, "^.-Frame(%d+)ScrollContainerBar(%d+)" )
8675 if loc_id then return end
8676
8677 local loc_id, bag_id, slot_id = string.match( framename, "^.-Frame(%d+)ScrollContainerBag(%d+)Item(%d+)" )
8678
8679 assert( loc_id, string.format( "xml element '%s' is not an %s frame", framename, ArkInventory.Const.Program.Name ) )
8680 assert( bag_id, string.format( "xml element '%s' is not an %s frame", framename, ArkInventory.Const.Program.Name ) )
8681 assert( slot_id, string.format( "xml element '%s' is not an %s frame", framename, ArkInventory.Const.Program.Name ) )
8682
8683 loc_id = tonumber( loc_id )
8684 bag_id = tonumber( bag_id )
8685 slot_id = tonumber( slot_id )
8686
8687 frame:SetID( slot_id )
8688
8689 frame.ARK_Data = {
8690 loc_id = loc_id,
8691 bag_id = bag_id,
8692 blizzard_id = ArkInventory.InternalIdToBlizzardBagId( loc_id, bag_id ),
8693 slot_id = slot_id,
8694 }
8695
8696 frame:Hide( )
8697
8698end
8699
8700function ArkInventory.Frame_Item_OnLoad_Tainted( frame )
8701 ArkInventory.Frame_Item_OnLoad( frame, true )
8702end
8703
8704function ArkInventory.Frame_Item_OnDragStart_PetJournal( frame )
8705
8706 if ArkInventory.Global.Mode.Edit then return end
8707
8708 local i = ArkInventory.Frame_Item_GetDB( frame )
8709
8710 if i and i.guid then
8711
8712 ArkInventory.Collection.Pet.PickupPet( i.guid, true )
8713
8714 if PetJournal:IsVisible( ) then
8715 PetJournal_UpdatePetLoadOut( )
8716 end
8717
8718 end
8719
8720end
8721
8722function ArkInventory.Frame_Item_OnDragStart_Toybox( frame )
8723
8724 if ArkInventory.Global.Mode.Edit then return end
8725
8726 local i = ArkInventory.Frame_Item_GetDB( frame )
8727
8728 if i and i.item then
8729
8730 C_ToyBox.PickupToyBoxItem( i.item )
8731
8732 end
8733
8734end
8735
8736function ArkInventory.Frame_Item_OnDragStart_Heirloom( frame )
8737
8738 if ArkInventory.Global.Mode.Edit then return end
8739
8740 local i = ArkInventory.Frame_Item_GetDB( frame )
8741
8742 if i and i.h then
8743
8744
8745
8746 end
8747
8748end
8749
8750function ArkInventory.Frame_Item_OnDragStart_MountJournal( frame )
8751
8752 if ArkInventory.Global.Mode.Edit then return end
8753
8754 local i = ArkInventory.Frame_Item_GetDB( frame )
8755 if i and i.slot_id then
8756 PickupCompanion( "MOUNT", i.slot_id )
8757 end
8758
8759end
8760
8761function ArkInventory.Frame_Item_Update( loc_id, bag_id, slot_id )
8762
8763 local framename, frame = ArkInventory.ContainerItemNameGet( loc_id, bag_id, slot_id )
8764
8765 if not ArkInventory.ValidFrame( frame ) then return end
8766
8767 ArkInventory.Frame_Item_Update_Lock( frame )
8768
8769 ArkInventory.Frame_Item_Update_Border( frame )
8770
8771 ArkInventory.Frame_Item_Update_Texture( frame )
8772
8773 ArkInventory.Frame_Item_Update_Count( frame )
8774 ArkInventory.Frame_Item_Update_Stock( frame )
8775
8776 ArkInventory.Frame_Item_Update_Quest( frame )
8777 ArkInventory.Frame_Item_Update_StatusIconUpgrade( frame )
8778 ArkInventory.Frame_Item_Update_StatusIconJunk( frame )
8779 ArkInventory.Frame_Item_Update_StatusIconTransmog( frame )
8780
8781 ArkInventory.Frame_Item_Update_Tint( frame )
8782 ArkInventory.Frame_Item_Update_Fade( frame )
8783
8784 if loc_id == ArkInventory.Const.Location.Pet then
8785 ArkInventory.Frame_Item_Update_PetJournal( frame )
8786 end
8787
8788 if loc_id == ArkInventory.Const.Location.Toybox then
8789 ArkInventory.Frame_Item_Update_Toybox( frame )
8790 end
8791
8792 if loc_id == ArkInventory.Const.Location.Heirloom then
8793 ArkInventory.Frame_Item_Update_Heirloom( frame )
8794 end
8795
8796 local codex = ArkInventory.GetLocationCodex( loc_id )
8797 ArkInventory.Frame_Item_Update_List( frame, codex.style.window.list )
8798
8799 ArkInventory.Frame_Item_Update_Cooldown( frame )
8800
8801 if frame == GameTooltip:GetOwner( ) then
8802 frame.UpdateTooltip( frame )
8803 end
8804
8805 if not frame.ARK_Data.tainted then
8806 ArkInventory.API.ItemFrameUpdated( frame, loc_id, bag_id, slot_id )
8807 end
8808
8809end
8810
8811function ArkInventory.Frame_Status_Update( frame )
8812
8813 local loc_id = frame.ARK_Data.loc_id
8814 local codex = ArkInventory.GetLocationCodex( loc_id )
8815 --ArkInventory.Output( ArkInventory.Global.Location[loc_id].Name, ", player = ", codex.player.current )
8816
8817 -- hide the status window if it's not needed
8818 local obj = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Status.Name )]
8819 if codex.style.status.hide then
8820 obj:Hide( )
8821 obj:SetHeight( 1 )
8822 return
8823 else
8824
8825 local height = codex.style.status.font.height
8826 ArkInventory.MediaFrameFontSet( obj, nil, height )
8827
8828 if height < ArkInventory.Const.Frame.Status.MinHeight then
8829 height = ArkInventory.Const.Frame.Status.MinHeight
8830 end
8831
8832 obj:SetHeight( height + ArkInventory.Const.Frame.Status.Height )
8833 obj:Show( )
8834
8835 end
8836
8837
8838
8839 -- update money
8840 local moneyFrameName = string.format( "%s%s", obj:GetName( ), "Gold" )
8841 local moneyFrame = _G[moneyFrameName]
8842 assert( moneyFrame, "moneyframe is nil" )
8843 --moneyFrame:SetHeight( height )
8844
8845 if ArkInventory.Global.Location[loc_id].isOffline then
8846 ArkInventory.MoneyFrame_SetType( moneyFrame, "STATIC" )
8847 MoneyFrame_Update( moneyFrameName, codex.player.data.info.money or 0 )
8848 --SetMoneyFrameColor( moneyFrameName, 0.75, 0.75, 0.75 )
8849 else
8850 SetMoneyFrameColor( moneyFrameName, 1, 1, 1 )
8851 if loc_id == ArkInventory.Const.Location.Vault then
8852 ArkInventory.MoneyFrame_SetType( moneyFrame, "GUILDBANK" )
8853 else
8854 ArkInventory.MoneyFrame_SetType( moneyFrame, "PLAYER" )
8855 end
8856 end
8857
8858
8859 -- update the empty slot count
8860 local obj = _G[string.format( "%s%s%s", frame:GetName( ), ArkInventory.Const.Frame.Status.Name, "EmptyText" )]
8861 if obj then
8862 if codex.style.status.emptytext.show then
8863 local y = ArkInventory.Frame_Status_Update_Empty( loc_id, codex )
8864 obj:SetText( y )
8865 else
8866 obj:SetText( "" )
8867 end
8868 --obj:SetHeight( height )
8869 end
8870
8871
8872 -- update token tracking
8873 ArkInventory.Frame_Status_Update_Tracking( loc_id )
8874
8875end
8876
8877function ArkInventory.Frame_Status_Update_Empty( loc_id, codex, ldb )
8878
8879 -- build the empty slot count status string
8880
8881 local empty = { }
8882 local bags = codex.player.data.location[loc_id].bag
8883
8884 for k, bag in pairs( bags ) do
8885
8886 if not empty[bag.type] then
8887 empty[bag.type] = { ["count"] = 0, ["empty"] = 0, ["type"] = bag.type }
8888 end
8889
8890 if bag.status == ArkInventory.Const.Bag.Status.Active then
8891 empty[bag.type].count = empty[bag.type].count + bag.count
8892 empty[bag.type].empty = empty[bag.type].empty + bag.empty
8893 end
8894
8895 --ArkInventory.Output( "k=[", k, "] t=[", bag.type, "] c=[", bag.count, "], status=[", bag.status, "]" )
8896
8897 end
8898
8899 local ee = ArkInventory.Table.Sum( empty, function( a ) return a.empty end )
8900 local ts = codex.player.data.location[loc_id].slot_count
8901
8902 local y = { }
8903
8904 if ts == 0 then
8905
8906 y[#y + 1] = string.format( "%s%s%s", RED_FONT_COLOR_CODE, ArkInventory.Localise["STATUS_NO_DATA"], FONT_COLOR_CODE_CLOSE )
8907
8908 else
8909
8910 for t, e in ArkInventory.spairs( empty, function(a,b) return empty[a].type < empty[b].type end ) do
8911
8912 local c = HIGHLIGHT_FONT_COLOR_CODE
8913 local n = string.format( " %s", ArkInventory.Const.Slot.Data[t].name )
8914
8915 if ldb then
8916
8917 if codex.player.data.ldb.bags.colour then
8918 c = codex.style.slot.data[t].colour
8919 c = ArkInventory.ColourRGBtoCode( c.r, c.g, c.b )
8920 end
8921
8922 if not codex.player.data.ldb.bags.includetype then
8923 n = ""
8924 end
8925
8926 if codex.player.data.ldb.bags.full then
8927 y[#y + 1] = string.format( "%s%i/%i%s%s", c, e.count - e.empty, e.count, n, FONT_COLOR_CODE_CLOSE )
8928 else
8929 y[#y + 1] = string.format( "%s%i%s%s", c, e.empty, n, FONT_COLOR_CODE_CLOSE )
8930 end
8931
8932 else
8933
8934 if codex.style.status.emptytext.colour then
8935 c = codex.style.slot.data[t].colour
8936 c = ArkInventory.ColourRGBtoCode( c.r, c.g, c.b )
8937 end
8938
8939 if not codex.style.status.emptytext.includetype then
8940 n = ""
8941 end
8942
8943 if codex.player.data.info.player_id == ArkInventory.PlayerIDAccount( ) then
8944 y[#y + 1] = string.format( "%s%i%s%s", c, e.count, n, FONT_COLOR_CODE_CLOSE )
8945 elseif codex.style.status.emptytext.full then
8946 y[#y + 1] = string.format( "%s%i/%i%s%s", c, e.count - e.empty, e.count, n, FONT_COLOR_CODE_CLOSE )
8947 else
8948 y[#y + 1] = string.format( "%s%i%s%s", c, e.empty, n, FONT_COLOR_CODE_CLOSE )
8949 end
8950
8951 end
8952
8953 end
8954
8955 end
8956
8957 return string.format( "|cfff9f9f9%s", table.concat( y, ", " ) )
8958
8959end
8960
8961function ArkInventory.Frame_Status_Update_Tracking( loc_id )
8962
8963 if not ArkInventory:IsEnabled( ) then return end
8964
8965 if loc_id and loc_id ~= ArkInventory.Const.Location.Bag then
8966 return
8967 end
8968
8969 local frame = ArkInventory.Frame_Main_Get( ArkInventory.Const.Location.Bag )
8970 frame = _G[string.format( "%s%s", frame:GetName( ), ArkInventory.Const.Frame.Status.Name )]
8971
8972 for i = 1, MAX_WATCHED_TOKENS do
8973
8974 local obj = _G[string.format( "%s%s%s", frame:GetName( ), "Tracking", i )]
8975
8976 local name, count, icon, currencyID = GetBackpackCurrencyInfo( i )
8977
8978 if currencyID then
8979
8980 local name, amount, icon, earnedThisWeek, weeklyMax, totalMax, isDiscovered, quality = GetCurrencyInfo( currencyID )
8981
8982 obj.currencyID = currencyID
8983
8984 ArkInventory.SetTexture( obj.icon, icon )
8985 obj.count:SetText( FormatLargeNumber( amount ) )
8986 obj:SetWidth( 2 * obj.icon:GetWidth( ) + obj.count:GetWidth( ) )
8987 obj:Show( )
8988
8989 else
8990
8991 obj:SetWidth( 1 )
8992 obj:Hide( )
8993
8994 end
8995
8996 end
8997
8998end
8999
9000
9001function ArkInventory.Frame_Changer_Update( loc_id )
9002
9003 if not ArkInventory.Global.Location[loc_id].hasChanger then return end
9004
9005 if loc_id == ArkInventory.Const.Location.Bag then
9006
9007 for bag_id in pairs( ArkInventory.Global.Location[loc_id].Bags ) do
9008
9009 local frame = _G[string.format( "%s%s%s%s%s", ArkInventory.Const.Frame.Main.Name, loc_id, ArkInventory.Const.Frame.Changer.Name, "WindowBag", bag_id )]
9010
9011 if bag_id == 1 then
9012 ArkInventory.Frame_Changer_Primary_Update( frame )
9013 else
9014 ArkInventory.Frame_Changer_Slot_Update( frame )
9015 end
9016
9017 end
9018
9019 elseif loc_id == ArkInventory.Const.Location.Bank then
9020
9021 ArkInventory.Frame_Changer_Bank_Update( )
9022
9023 elseif loc_id == ArkInventory.Const.Location.Vault then
9024
9025 ArkInventory.Frame_Changer_Vault_Update( )
9026
9027 end
9028
9029
9030 local frame = _G[string.format( "%s%s", ArkInventory.Const.Frame.Main.Name, loc_id )]
9031 ArkInventory.Frame_Status_Update( frame )
9032
9033end
9034
9035function ArkInventory.Frame_Changer_Primary_Update( frame )
9036
9037 if not ArkInventory.ValidFrame( frame ) then return end
9038
9039 local loc_id = frame.ARK_Data.loc_id
9040 local bag_id = frame.ARK_Data.bag_id
9041 local codex = ArkInventory.GetLocationCodex( loc_id )
9042
9043 ArkInventory.Frame_Item_Update_Fade( frame, true )
9044
9045 ArkInventory.Frame_Item_Update_Border( frame, true )
9046
9047 if codex.player.data.option[loc_id].bag[bag_id].display == false then
9048 SetItemButtonTextureVertexColor( frame, 1.0, 0.1, 0.1 )
9049 else
9050 SetItemButtonTextureVertexColor( frame, 1.0, 1.0, 1.0 )
9051 end
9052
9053 local bag = codex.player.data.location[loc_id].bag[bag_id]
9054
9055 SetItemButtonCount( frame, bag.count )
9056
9057 if bag.status == ArkInventory.Const.Bag.Status.Active then
9058 ArkInventory.SetItemButtonStock( frame, bag.empty )
9059 else
9060 ArkInventory.SetItemButtonStock( frame, nil, bag.status )
9061 end
9062
9063 ArkInventory.MediaFrameFontSet( frame, nil, codex.style.slot.itemcount.font.height )
9064
9065end
9066
9067function ArkInventory.Frame_Changer_Bank_Update( )
9068
9069 local loc_id = ArkInventory.Const.Location.Bank
9070
9071 local parent = _G[string.format( "%s%s%s%s", ArkInventory.Const.Frame.Main.Name, loc_id, ArkInventory.Const.Frame.Changer.Name, "Window" )]
9072
9073 if not parent:IsVisible( ) then
9074-- return
9075 end
9076
9077 for x = 1, ArkInventory.Global.Location[loc_id].bagCount do
9078
9079 local frame = _G[string.format( "%s%s%s%s%s", ArkInventory.Const.Frame.Main.Name, loc_id, ArkInventory.Const.Frame.Changer.Name, "WindowBag", x )]
9080
9081 if x == 1 then
9082 ArkInventory.Frame_Changer_Primary_Update( frame )
9083 elseif x == 2 then
9084 ArkInventory.Frame_Changer_Bank_ReagentBank_Update( frame )
9085 else
9086 ArkInventory.Frame_Changer_Slot_Update( frame )
9087 end
9088
9089 end
9090
9091 -- update blizzards frame as well because the static dialog box uses the data in it
9092 UpdateBagSlotStatus( )
9093
9094end
9095
9096function ArkInventory.Frame_Changer_Bank_ReagentBank_Update( frame )
9097
9098 local loc_id = frame.ARK_Data.loc_id
9099 local bag_id = frame.ARK_Data.bag_id
9100
9101 local codex = ArkInventory.GetLocationCodex( loc_id )
9102 local bag = codex.player.data.location[loc_id].bag[bag_id]
9103
9104 --ArkInventory.Output( "who[", codex.player.data.info.name, "].loc[", loc_id, "].bag[", bag_id, "]" )
9105
9106 if bag.count > 0 then
9107
9108 frame.size = bag.count or 0
9109 ArkInventory.SetItemButtonTexture( frame, bag.texture )
9110 SetItemButtonCount( frame, frame.size )
9111
9112 else
9113
9114 frame.size = 0
9115 ArkInventory.SetItemButtonTexture( frame, bag.texture or ArkInventory.Const.Texture.Empty.Bag )
9116 SetItemButtonCount( frame, frame.size )
9117
9118 end
9119
9120 if bag.status == ArkInventory.Const.Bag.Status.Active then
9121 ArkInventory.SetItemButtonStock( frame, bag.empty )
9122 else
9123 ArkInventory.SetItemButtonStock( frame, nil, bag.status )
9124 end
9125
9126 ArkInventory.Frame_Item_Update_Fade( frame, true )
9127
9128 ArkInventory.Frame_Item_Update_Border( frame, true )
9129
9130 if codex.player.data.option[loc_id].bag[bag_id].display == false then
9131 SetItemButtonTextureVertexColor( frame, 1.0, 0.1, 0.1 )
9132 else
9133 if bag.status == ArkInventory.Const.Bag.Status.Purchase then
9134 SetItemButtonTextureVertexColor( frame, 1.0, 0.1, 0.1 )
9135 else
9136 SetItemButtonTextureVertexColor( frame, 1.0, 1.0, 1.0 )
9137 end
9138 end
9139
9140 ArkInventory.MediaFrameFontSet( frame, nil, codex.style.slot.itemcount.font.height )
9141
9142end
9143
9144function ArkInventory.Frame_Changer_Vault_Tab_OnEnter( frame )
9145
9146 if not frame then return end
9147
9148 local loc_id = frame.ARK_Data.loc_id
9149 local bag_id = frame.ARK_Data.bag_id
9150 local codex = ArkInventory.GetLocationCodex( loc_id )
9151
9152 if ArkInventory.db.option.tooltip.show then
9153
9154 ArkInventory.GameTooltipSetPosition( frame, true )
9155
9156 local bag = codex.player.data.location[loc_id].bag[bag_id]
9157
9158 if bag and bag.name then
9159 GameTooltip:SetText( string.format( ArkInventory.Localise["VAULT_TAB_NAME"], bag_id, bag.name ) )
9160 GameTooltip:AddLine( string.format( ArkInventory.Localise["VAULT_TAB_ACCESS"], bag.access ) )
9161 if bag.withdraw then
9162 GameTooltip:AddLine( string.format( ArkInventory.Localise["VAULT_TAB_REMAINING_WITHDRAWALS"], bag.withdraw ) )
9163 end
9164 --GameTooltip:AddLine( string.format( NUM_GUILDBANK_TABS_PURCHASED, GetNumGuildBankTabs( ), MAX_BUY_GUILDBANK_TABS ) )
9165 GameTooltip:Show( )
9166 else
9167 GameTooltip:Hide( )
9168 end
9169
9170 CursorUpdate( frame )
9171
9172 end
9173
9174 --ArkInventory.BagHighlight( frame, true )
9175
9176end
9177
9178function ArkInventory.Frame_Changer_Vault_Tab_OnLoad( frame )
9179 ArkInventory.Frame_Changer_Slot_OnLoad( frame )
9180 if frame.ARK_Data.bag_id <= MAX_GUILDBANK_TABS then
9181 frame:Show( )
9182 frame.UpdateTooltip = ArkInventory.Frame_Changer_Vault_Tab_OnEnter
9183 end
9184end
9185
9186function ArkInventory.Frame_Changer_Vault_Tab_OnClick( frame, button, mode )
9187
9188 if not ArkInventory.ValidFrame( frame ) then return end
9189
9190 local loc_id = frame.ARK_Data.loc_id
9191 local bag_id = frame.ARK_Data.bag_id
9192
9193 local codex = ArkInventory.GetLocationCodex( loc_id )
9194 local mode = mode or ArkInventory.Global.Location[loc_id].view_mode
9195 local tab = codex.player.data.location[loc_id].bag[bag_id]
9196
9197 --ArkInventory.Output( "Tab_OnClick(", frame:GetName( ), ", ", button, ", ", mode, ")" )
9198
9199 if tab.name == nil then
9200 return
9201 end
9202
9203 if tab.status == ArkInventory.Const.Bag.Status.Purchase then
9204
9205 if button == "LeftButton" then
9206 if bag_id <= MAX_BUY_GUILDBANK_TABS then
9207 StaticPopup_Show( "CONFIRM_BUY_GUILDBANK_TAB" )
9208 end
9209 end
9210
9211 else
9212
9213 if button == nil then
9214
9215 -- drag'n'drop (drop)
9216
9217 if not ArkInventory.Global.Location[loc_id].isOffline then
9218 --ArkInventory.PutItemInGuildBank( tab_id )
9219 end
9220
9221 else
9222
9223 if ArkInventory.Global.Location[loc_id].isOffline then
9224
9225 ArkInventory.Global.Location[loc_id].view_tab = bag_id
9226 ArkInventory.Global.Location[loc_id].view_mode = mode
9227
9228 for x in pairs( ArkInventory.Global.Location[loc_id].Bags ) do
9229 if x == ArkInventory.Global.Location[loc_id].view_tab then
9230 codex.player.data.option[loc_id].bag[x].display = true
9231 else
9232 codex.player.data.option[loc_id].bag[x].display = false
9233 end
9234 end
9235
9236 --ArkInventory.OutputWarning( "Frame_Changer_Vault_Tab_OnClick - .Recalculate" )
9237 ArkInventory.Frame_Main_Generate( loc_id, ArkInventory.Const.Window.Draw.Recalculate )
9238
9239 return
9240
9241 end
9242
9243 if mode == ArkInventory.Global.Location[loc_id].view_mode and bag_id == ArkInventory.Global.Location[loc_id].view_tab then
9244 --ArkInventory.Output( "same tab, same mode, ignored" )
9245 return
9246 end
9247
9248 if tab.status == ArkInventory.Const.Bag.Status.NoAccess then
9249 --ArkInventory.Output( "no access to this tab, ignored" )
9250 return
9251 end
9252
9253 ArkInventory.VaultTabClick( bag_id, mode )
9254
9255 end
9256
9257 end
9258
9259end
9260
9261function ArkInventory.Frame_Changer_Vault_Action_OnEnter( frame )
9262
9263 local loc_id = ArkInventory.Const.Location.Vault
9264
9265end
9266
9267function ArkInventory.Frame_Changer_Vault_Action_OnLoad( frame )
9268
9269 local loc_id = ArkInventory.Const.Location.Vault
9270
9271end
9272
9273function ArkInventory.Frame_Changer_Vault_Action_OnClick( frame, button, mode )
9274
9275 local loc_id = ArkInventory.Const.Location.Vault
9276
9277 ArkInventory.MenuChangerVaultActionOpen( frame )
9278
9279end
9280
9281function ArkInventory.Frame_Changer_Vault_Update( )
9282
9283 local loc_id = ArkInventory.Const.Location.Vault
9284 local parent = string.format( "%s%s%s%s", ArkInventory.Const.Frame.Main.Name, loc_id, ArkInventory.Const.Frame.Changer.Name, "Window" )
9285
9286 if not _G[parent]:IsVisible( ) then
9287-- return
9288 end
9289
9290 for bag_id in pairs( ArkInventory.Global.Location[loc_id].Bags ) do
9291 local frame = _G[string.format( "%s%s%s", parent, "Bag", bag_id )]
9292 ArkInventory.Frame_Changer_Slot_Update( frame )
9293 end
9294
9295 local buttonAction = _G[string.format( "%s%s", parent, "Action" )]
9296
9297 if ArkInventory.Global.Location[loc_id].isOffline then
9298 if buttonAction then buttonAction:Hide( ) end
9299 else
9300 if buttonAction then buttonAction:Show( ) end
9301 end
9302
9303end
9304
9305function ArkInventory.Frame_Changer_Secondary_OnDragStart( frame )
9306
9307 if not ArkInventory.ValidFrame( frame ) then return end
9308
9309 local loc_id = frame.ARK_Data.loc_id
9310
9311 if InCombatLockdown( ) or ArkInventory.Global.Location[loc_id].isOffline or loc_id == ArkInventory.Const.Location.Vault then
9312 return
9313 end
9314
9315 local bag_id = frame.ARK_Data.bag_id
9316 local inv_id = ArkInventory.InventoryIDGet( loc_id, bag_id )
9317
9318 --ArkInventory.Output( "pick up bag ", loc_id, ".", bag_id, " = ", inv_id )
9319
9320 PickupBagFromSlot( inv_id )
9321
9322end
9323
9324function ArkInventory.Frame_Changer_Secondary_OnReceiveDrag( frame )
9325
9326 if not ArkInventory.ValidFrame( frame ) then return end
9327
9328 local loc_id = frame.ARK_Data.loc_id
9329
9330 if ArkInventory.Global.Location[loc_id].isOffline then
9331 return
9332 end
9333
9334 ArkInventory.Frame_Changer_Slot_OnClick( frame )
9335
9336end
9337
9338function ArkInventory.Frame_Changer_Slot_OnLoad( frame )
9339
9340 local framename = frame:GetName( )
9341 local loc_id, bag_id = string.match( framename, "^" .. ArkInventory.Const.Frame.Main.Name .. "(%d+).-(%d+)$" )
9342
9343 loc_id = tonumber( loc_id )
9344 bag_id = tonumber( bag_id )
9345
9346 frame.ARK_Data = {
9347 loc_id = loc_id,
9348 bag_id = bag_id,
9349 blizzard_id = ArkInventory.InternalIdToBlizzardBagId( loc_id, bag_id ),
9350 inv_id = ArkInventory.InventoryIDGet( loc_id, bag_id ),
9351 }
9352
9353 if frame.BattlepayItemTexture then
9354 frame.BattlepayItemTexture:Hide( )
9355 end
9356
9357 if frame.NewItemTexture then
9358 frame.NewItemTexture:Hide( )
9359 end
9360
9361 frame.SplitStack = nil
9362
9363 frame.locked = nil
9364
9365 frame:RegisterForClicks( "LeftButtonUp", "RightButtonUp" )
9366
9367 if ( loc_id == ArkInventory.Const.Location.Bag and bag_id > 1 ) or ( loc_id == ArkInventory.Const.Location.Bank and bag_id > 1 and bag_id ~= ArkInventory.Global.Location[loc_id].tabReagent ) then
9368 frame:RegisterForDrag( "LeftButton" )
9369 end
9370
9371 if bag_id == 1 then
9372 ArkInventory.SetItemButtonTexture( frame, ArkInventory.Global.Location[loc_id].Texture )
9373 elseif loc_id == ArkInventory.Const.Location.Bank and bag_id == ArkInventory.Global.Location[loc_id].tabReagent then
9374 ArkInventory.SetItemButtonTexture( frame, ArkInventory.Global.Location[loc_id].Texture )
9375 else
9376 ArkInventory.SetItemButtonTexture( frame, ArkInventory.Const.Texture.Empty.Bag )
9377 end
9378
9379 local obj = frame.Count
9380 if obj ~= nil then
9381 obj:SetPoint( "BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, 2 )
9382 obj:SetPoint( "LEFT", frame, "LEFT", 0, 0 )
9383 end
9384
9385 local obj = _G[string.format( "%s%s", framename, "Stock" )]
9386 if obj ~= nil then
9387 obj:SetPoint( "TOPLEFT", frame, "TOPLEFT", 0, -2 )
9388 obj:SetPoint( "RIGHT", frame, "RIGHT", 0, 0 )
9389 end
9390
9391 frame:Show( )
9392
9393end
9394
9395function ArkInventory.Frame_Changer_Slot_OnClick( frame, button )
9396
9397 local loc_id = frame.ARK_Data.loc_id
9398 local bag_id = frame.ARK_Data.bag_id
9399
9400 --ArkInventory.Output( "Frame_Changer_Slot_OnClick( ", frame:GetName( ), ", ", button, " )" )
9401
9402 local codex = ArkInventory.GetLocationCodex( loc_id )
9403 local bag = codex.player.data.location[loc_id].bag[bag_id]
9404
9405 if IsModifiedClick( "CHATLINK" ) then
9406 if bag and bag.h and bag.count > 0 then
9407 ChatEdit_InsertLink( bag.h )
9408 end
9409 return
9410 end
9411
9412 if ArkInventory.Global.Mode.Edit then
9413 ArkInventory.MenuBagOpen( frame )
9414 return
9415 end
9416
9417 if ArkInventory.Global.Location[loc_id].isOffline then
9418 return
9419 end
9420
9421 if button == nil then
9422
9423 -- drop from drag'n'drop
9424 if loc_id == ArkInventory.Const.Location.Bag and bag_id == 1 then
9425 PutItemInBackpack( )
9426 elseif loc_id == ArkInventory.Const.Location.Bank and bag_id == 1 then
9427 ArkInventory.PutItemInBank( )
9428 elseif loc_id == ArkInventory.Const.Location.Bank and bag_id == ArkInventory.Global.Location[loc_id].tabReagent then
9429 ArkInventory.PutItemInReagentBank( )
9430 end
9431
9432 return
9433
9434 elseif button == "RightButton" then
9435
9436 ArkInventory.MenuBagOpen( frame )
9437
9438 elseif button == "LeftButton" then
9439
9440 if loc_id == ArkInventory.Const.Location.Bank then
9441 if bag and bag.status == ArkInventory.Const.Bag.Status.Purchase then
9442 PlaySound( SOUNDKIT.IG_MAINMENU_OPTION )
9443 if bag_id == ArkInventory.Global.Location[loc_id].tabReagent then
9444 StaticPopup_Show( "CONFIRM_BUY_REAGENTBANK_TAB" )
9445 else
9446 StaticPopup_Show( "CONFIRM_BUY_BANK_SLOT" )
9447 end
9448 return
9449 end
9450 end
9451
9452 if CursorHasItem( ) then
9453
9454 if loc_id == ArkInventory.Const.Location.Bag and bag_id == 1 then
9455 PutItemInBackpack( )
9456 return
9457 end
9458
9459 if loc_id == ArkInventory.Const.Location.Bank and bag_id == 1 then
9460 ArkInventory.PutItemInBank( )
9461 return
9462 end
9463
9464 if loc_id == ArkInventory.Const.Location.Bank and bag_id == ArkInventory.Global.Location[loc_id].tabReagent then
9465 ArkInventory.PutItemInReagentBank( )
9466 return
9467 end
9468
9469 local inv_id = ArkInventory.InventoryIDGet( loc_id, bag_id )
9470 --ArkInventory.Output( "drop item into ", loc_id, ".", bag_id, " / inventory slot ", inv_id )
9471 PutItemInBag( inv_id )
9472
9473 else
9474
9475 if loc_id == ArkInventory.Const.Location.Bag and bag_id == 1 then
9476 -- do nothing
9477 return
9478 end
9479
9480 if loc_id == ArkInventory.Const.Location.Bank and ( bag_id == 1 or bag_id == ArkInventory.Global.Location[loc_id].tabReagent ) then
9481 -- do nothing
9482 return
9483 end
9484
9485 -- pick up the bag in the slot
9486 ArkInventory.Frame_Changer_Secondary_OnDragStart( frame )
9487
9488 end
9489
9490 end
9491
9492end
9493
9494function ArkInventory.Frame_Changer_Slot_OnEnter( frame )
9495
9496 local loc_id = frame.ARK_Data.loc_id
9497 local bag_id = frame.ARK_Data.bag_id
9498
9499 local codex = ArkInventory.GetLocationCodex( loc_id )
9500 local bag = codex.player.data.location[loc_id].bag[bag_id]
9501
9502 if ArkInventory.db.option.tooltip.show then
9503
9504 ArkInventory.GameTooltipSetPosition( frame, true )
9505
9506 if bag_id == 1 then
9507
9508 if loc_id == ArkInventory.Const.Location.Bag then
9509 GameTooltip:SetText( BACKPACK_TOOLTIP, 1.0, 1.0, 1.0 )
9510 elseif loc_id == ArkInventory.Const.Location.Bank then
9511 GameTooltip:SetText( ArkInventory.Localise["BANK"], 1.0, 1.0, 1.0 )
9512 end
9513
9514 elseif ArkInventory.Global.Location[loc_id].isOffline then
9515
9516 if not bag or bag.count == 0 then
9517
9518 -- do nothing
9519
9520 else
9521
9522 if loc_id == ArkInventory.Const.Location.Bank and bag_id == ArkInventory.Global.Location[loc_id].tabReagent then
9523
9524 GameTooltip:SetText( ArkInventory.Localise["REAGENTBANK"], 1.0, 1.0, 1.0 )
9525
9526 elseif bag.h then
9527
9528 GameTooltip:SetHyperlink( bag.h )
9529
9530 else
9531
9532 GameTooltip:SetText( ArkInventory.Localise["STATUS_NO_DATA"], 1.0, 1.0, 1.0 )
9533
9534 end
9535
9536 end
9537
9538 else
9539
9540 if bag and bag.status == ArkInventory.Const.Bag.Status.Purchase then
9541
9542 if loc_id == ArkInventory.Const.Location.Bank then
9543
9544 if bag_id == ArkInventory.Global.Location[loc_id].tabReagent then
9545 GameTooltip:SetText( ArkInventory.Localise["TOOLTIP_PURCHASE_BANK_TAB_REAGENT"] )
9546 else
9547 GameTooltip:SetText( ArkInventory.Localise["TOOLTIP_PURCHASE_BANK_BAG_SLOT"] )
9548 end
9549
9550 end
9551
9552 elseif bag and bag.status == ArkInventory.Const.Bag.Status.Active then
9553
9554 if loc_id == ArkInventory.Const.Location.Bank and bag_id == ArkInventory.Global.Location[loc_id].tabReagent then
9555
9556 GameTooltip:SetText( ArkInventory.Localise["REAGENTBANK"], 1.0, 1.0, 1.0 )
9557
9558 elseif bag.h then
9559
9560 GameTooltip:SetInventoryItem( "player", ArkInventory.InventoryIDGet( loc_id, bag_id ) )
9561
9562 end
9563
9564 elseif bag and bag.status == ArkInventory.Const.Bag.Status.Unknown then
9565
9566 GameTooltip:SetText( ArkInventory.Localise["STATUS_NO_DATA"] )
9567
9568 end
9569
9570 end
9571
9572 CursorUpdate( frame )
9573
9574 end
9575
9576 ArkInventory.BagHighlight( frame, true )
9577
9578end
9579
9580function ArkInventory.Frame_Changer_Slot_Update( frame )
9581
9582 if not ArkInventory.ValidFrame( frame ) then return end
9583
9584 local loc_id = frame.ARK_Data.loc_id
9585 local bag_id = frame.ARK_Data.bag_id
9586 local slot_id = frame.ARK_Data.slot_id
9587
9588 local codex = ArkInventory.GetLocationCodex( loc_id )
9589 local bag = codex.player.data.location[loc_id].bag[bag_id]
9590
9591 --ArkInventory.Output( "changer update[", codex.player.data.info.name, "].loc[", loc_id, "].bag[", bag_id, "]" )
9592
9593 if bag.count > 0 then
9594 frame.size = bag.count or 0
9595 else
9596 frame.size = 0
9597 end
9598
9599 ArkInventory.Frame_Item_Update_Border( frame, true )
9600
9601 ArkInventory.SetItemButtonTexture( frame, bag.texture or ArkInventory.Const.Texture.Empty.Bag )
9602 SetItemButtonCount( frame, frame.size )
9603
9604 if bag.status == ArkInventory.Const.Bag.Status.Active then
9605 ArkInventory.SetItemButtonStock( frame, bag.empty )
9606 else
9607 ArkInventory.SetItemButtonStock( frame, nil, bag.status )
9608 end
9609
9610 ArkInventory.Frame_Item_Update_Fade( frame, true )
9611
9612 ArkInventory.Frame_Item_Update_Lock( frame, true )
9613
9614
9615
9616 -- tint non displayed bags (except at the vault where they are faded)
9617 if codex.player.data.option[loc_id].bag[bag_id].display == false then
9618 if loc_id == ArkInventory.Const.Location.Vault then
9619 -- only tint no acess bags at the vault
9620 if bag.status == ArkInventory.Const.Bag.Status.NoAccess then
9621 SetItemButtonTextureVertexColor( frame, 1.0, 0.1, 0.1 )
9622 end
9623 else
9624 SetItemButtonTextureVertexColor( frame, 1.0, 0.1, 0.1 )
9625 end
9626 else
9627 if bag.status == ArkInventory.Const.Bag.Status.Purchase then
9628 SetItemButtonTextureVertexColor( frame, 1.0, 0.1, 0.1 )
9629 else
9630 SetItemButtonTextureVertexColor( frame, 1.0, 1.0, 1.0 )
9631 end
9632 end
9633
9634 ArkInventory.MediaFrameFontSet( frame, nil, codex.style.slot.itemcount.font.height )
9635
9636end
9637
9638function ArkInventory.Frame_Changer_Slot_Update_Lock( loc_id, bag_id )
9639
9640 local frame = _G[string.format( "%s%s%sWindowBag%s", ArkInventory.Const.Frame.Main.Name, loc_id, ArkInventory.Const.Frame.Changer.Name, bag_id )]
9641
9642 if not ArkInventory.ValidFrame( frame ) then return end
9643
9644 if ArkInventory.Global.Location[loc_id].isOffline then return end
9645
9646 local me = ArkInventory.GetPlayerCodex( )
9647 if me.player.data.location[loc_id].bag[bag_id].h then
9648
9649 local inv_id = ArkInventory.InventoryIDGet( loc_id, bag_id )
9650 local locked = IsInventoryItemLocked( inv_id )
9651 ArkInventory.SetItemButtonDesaturate( frame, locked )
9652 frame.locked = locked
9653
9654 else
9655
9656 frame.locked = false
9657
9658 end
9659
9660end
9661
9662function ArkInventory.Frame_Changer_Generic_OnLeave( frame )
9663 GameTooltip:Hide( )
9664 ResetCursor( )
9665 ArkInventory.BagHighlight( frame, false )
9666end
9667
9668function ArkInventory.BagHighlight( frame, show )
9669
9670 if not ArkInventory.ValidFrame( frame ) then return end
9671
9672 local loc_id = frame.ARK_Data.loc_id
9673 local bag_id = frame.ARK_Data.bag_id
9674
9675 if loc_id ~=nil and bag_id ~= nil then
9676
9677 local codex = ArkInventory.GetLocationCodex( loc_id )
9678
9679 local b = codex.player.data.location[loc_id].bag[bag_id]
9680 if not b then
9681 return
9682 end
9683
9684 local name = string.format( "%s%s%s%s%s", ArkInventory.Const.Frame.Main.Name, loc_id, ArkInventory.Const.Frame.Container.Name, "Bag", bag_id )
9685 local frame = _G[name]
9686 if not frame then
9687 return
9688 end
9689
9690 local enabled = codex.style.changer.highlight.show
9691 local colour = codex.style.changer.highlight.colour
9692
9693 for slot_id in pairs( b.slot ) do
9694 local obj = _G[string.format( "%s%s%s%s", name, "Item", slot_id, "ArkBagHighlight" )]
9695 if obj then
9696 ArkInventory.SetTexture( obj, enabled and show, colour.r, colour.g, colour.b, 0.3 )
9697 end
9698 end
9699
9700 end
9701
9702end
9703
9704
9705function ArkInventory.MyHook(...)
9706 if not ArkInventory:IsHooked(...) then
9707 ArkInventory:RawHook(...)
9708 end
9709end
9710
9711function ArkInventory.MyUnhook(...)
9712 if ArkInventory:IsHooked(...) then
9713 ArkInventory:Unhook(...)
9714 end
9715end
9716
9717function ArkInventory.MySecureHook(...)
9718 if not ArkInventory:IsHooked(...) then
9719 ArkInventory:SecureHook(...)
9720 end
9721end
9722
9723function ArkInventory.HookOpenBackpack( self, ... )
9724
9725 --ArkInventory.Output( "HookOpenBackpack( )" )
9726
9727 local loc_id = ArkInventory.Const.Location.Bag
9728
9729 if ArkInventory.LocationIsControlled( loc_id ) then
9730 -- original function returns state of backpack being open at time of call
9731 local BACKPACK_WAS_OPEN = ArkInventory.Frame_Main_Get( loc_id ):IsVisible( )
9732 ArkInventory.Frame_Main_Show( loc_id )
9733 return BACKPACK_WAS_OPEN
9734 end
9735
9736 ArkInventory.hooks.OpenBackpack( ... )
9737
9738end
9739
9740function ArkInventory.HookToggleBackpack( self, ... )
9741
9742 --ArkInventory.Output( "HookToggleBackpack( )" )
9743
9744 local loc_id = ArkInventory.Const.Location.Bag
9745
9746 if ArkInventory.LocationIsControlled( loc_id ) then
9747 ArkInventory.Frame_Main_Toggle( loc_id )
9748 return
9749 end
9750
9751 ArkInventory.hooks.ToggleBackpack( ... )
9752
9753end
9754
9755function ArkInventory.HookOpenBag( self, ... )
9756
9757 local blizzard_id = ...
9758
9759 --ArkInventory.Output( "HookOpenBag( ", blizzard_id, " )" )
9760
9761 if blizzard_id then
9762
9763 local loc_id = ArkInventory.BlizzardBagIdToInternalId( blizzard_id )
9764
9765 if loc_id and ( loc_id == ArkInventory.Const.Location.Bag or ( loc_id == ArkInventory.Const.Location.Bank and ArkInventory.Global.Mode.Bank ) ) then
9766 if ArkInventory.LocationIsControlled( loc_id ) then
9767 ArkInventory.Frame_Main_Show( loc_id )
9768 return
9769 end
9770 end
9771
9772 end
9773
9774 ArkInventory.hooks.OpenBag( ... )
9775
9776end
9777
9778function ArkInventory.HookToggleBag( self, ... )
9779
9780 local blizzard_id = ...
9781
9782 --ArkInventory.Output( "HookToggleBag( ", blizzard_id, " )" )
9783
9784 if blizzard_id then
9785
9786 local loc_id = ArkInventory.BlizzardBagIdToInternalId( blizzard_id )
9787
9788 if loc_id and ( loc_id == ArkInventory.Const.Location.Bag or ( loc_id == ArkInventory.Const.Location.Bank and ArkInventory.Global.Mode.Bank ) ) then
9789 if ArkInventory.LocationIsControlled( loc_id ) then
9790 ArkInventory.Frame_Main_Toggle( loc_id )
9791 return
9792 end
9793 end
9794
9795 end
9796
9797 ArkInventory.hooks.ToggleBag( ... )
9798
9799end
9800
9801function ArkInventory.HookOpenAllBags( self, who, ... )
9802
9803 if who then
9804
9805 who = who:GetName( )
9806 local BACKPACK_WAS_OPEN = ArkInventory.Frame_Main_Get( ArkInventory.Const.Location.Bag ):IsVisible( )
9807 --ArkInventory.Output( "OpenAllBags: ", who, " / ", BACKPACK_WAS_OPEN )
9808
9809 if who == "MerchantFrame" then
9810
9811 if ArkInventory.LocationIsControlled( ArkInventory.Const.Location.Bag ) then
9812
9813 -- blizzard auto-opens the backpack when you talk to a merchant, do we want that to happen or not
9814 if not ArkInventory.db.option.auto.open.merchant and not BACKPACK_WAS_OPEN then
9815 -- it wasnt already opened, blizzard is about the open it, so stop them
9816 return
9817 end
9818
9819 -- this is supposed to stop selling junk to merchants that wont buy anything from you
9820 -- theres no way to work that out though so sometimes youre screwed no matter what and it will just spit out errors
9821 if MerchantBuyBackItemItemButton and MerchantBuyBackItemItemButton:IsVisible( ) then
9822 if GetMerchantNumItems( ) > 0 then
9823 --ArkInventory.Output( "auto sell starting" )
9824 ArkInventory.JunkSell( )
9825 end
9826 end
9827
9828 end
9829
9830 elseif who == "MailFrame" then
9831
9832 if ArkInventory.LocationIsControlled( ArkInventory.Const.Location.Bag ) then
9833
9834 -- blizzard auto-opens the backpack when you open the mailbox, do we want that to happen or not
9835 if not ArkInventory.db.option.auto.open.mail and not BACKPACK_WAS_OPEN then
9836 -- it wasnt already opened, blizzard is about the open it, so stop them
9837 return
9838 end
9839
9840 end
9841
9842 elseif who == "ScrappingMachineFrame" then
9843
9844 if ArkInventory.LocationIsControlled( ArkInventory.Const.Location.Bag ) then
9845
9846 -- blizzard auto-opens the backpack when you open the scrapping machine, do we want that to happen or not
9847 if not ArkInventory.db.option.auto.open.scrap and not BACKPACK_WAS_OPEN then
9848 -- it wasnt already opened, blizzard is about the open it, so stop them
9849 return
9850 end
9851
9852 end
9853
9854 elseif who == "ExtVendor" then
9855
9856 -- third party addon, replaces entire vendor interface
9857
9858 if ArkInventory.LocationIsControlled( ArkInventory.Const.Location.Bag ) then
9859
9860 -- blizzard auto-opens the backpack when you talk to a merchant, do we want that to happen or not
9861 if not ArkInventory.db.option.auto.open.merchant and not BACKPACK_WAS_OPEN then
9862 -- it wasnt already opened, blizzard is about the open it, so stop them
9863 return
9864 end
9865
9866 end
9867
9868 else
9869
9870 ArkInventory.OutputWarning( "Uncoded event to be cleaned up: OpenAllBags from ", who )
9871
9872 end
9873
9874 end
9875
9876
9877 local loc_id = ArkInventory.Const.Location.Bag
9878 if ArkInventory.LocationIsControlled( loc_id ) then
9879 ArkInventory.Frame_Main_Show( loc_id )
9880 else
9881 CloseAllBags( )
9882 end
9883
9884 if ArkInventory.Global.Mode.Bank then
9885
9886 local loc_id = ArkInventory.Const.Location.Bank
9887 if not ArkInventory.LocationIsControlled( loc_id ) then
9888 for x = NUM_BAG_SLOTS + 1, NUM_BAG_SLOTS + NUM_BANKBAGSLOTS do
9889 if GetContainerNumSlots( x ) > 0 then
9890 CloseBag( x )
9891 end
9892 end
9893 end
9894
9895 end
9896
9897 local loc_id = ArkInventory.Const.Location.Bag
9898 if not ArkInventory.LocationIsControlled( loc_id ) then
9899 ArkInventory.hooks.OpenAllBags( )
9900 end
9901
9902 if ArkInventory.Global.Mode.Bank then
9903
9904 local loc_id = ArkInventory.Const.Location.Bank
9905 if not ArkInventory.LocationIsControlled( loc_id ) then
9906 for x = NUM_BAG_SLOTS + 1, NUM_BAG_SLOTS + NUM_BANKBAGSLOTS do
9907 if GetContainerNumSlots( x ) > 0 then
9908 ArkInventory.hooks.OpenBag( x )
9909 end
9910 end
9911 end
9912
9913 end
9914
9915end
9916
9917function ArkInventory.HookToggleAllBags( self, ... )
9918
9919 --ArkInventory.Output( "HookToggleAllBags( )" )
9920
9921 if ArkInventory.LocationIsControlled( ArkInventory.Const.Location.Bag ) and ArkInventory.LocationIsControlled( ArkInventory.Const.Location.Bank ) then
9922 ArkInventory.Frame_Main_Toggle( ArkInventory.Const.Location.Bag )
9923 return
9924 end
9925
9926 if not ArkInventory.LocationIsControlled( ArkInventory.Const.Location.Bag ) and not ArkInventory.LocationIsControlled( ArkInventory.Const.Location.Bank ) then
9927 ArkInventory.hooks.ToggleAllBags( ... )
9928 return
9929 end
9930
9931 -- i have control of the bags, but not the bank
9932
9933 local loc_id = ArkInventory.Const.Location.Bag
9934 if not ArkInventory.LocationIsControlled( loc_id ) then
9935
9936 local bagsOpen = 0
9937 local bagsTotal = 0
9938
9939 bagsTotal = bagsTotal + 1
9940 if IsBagOpen( 0 ) then
9941 bagsOpen = bagsOpen + 1
9942 CloseBackpack( )
9943 end
9944
9945 for x = 1, NUM_BAG_SLOTS do
9946 if GetContainerNumSlots( x ) > 0 then
9947 bagsTotal = bagsTotal + 1
9948 if IsBagOpen( x ) then
9949 bagsOpen = bagsOpen + 1
9950 CloseBag( x )
9951 end
9952 end
9953 end
9954
9955 if bagsOpen < bagsTotal then
9956
9957 ArkInventory.hooks.OpenBackpack( )
9958 for x = 1, NUM_BAG_SLOTS do
9959 if GetContainerNumSlots( x ) > 0 then
9960 ArkInventory.hooks.OpenBag( x )
9961 end
9962 end
9963
9964 end
9965
9966 end
9967
9968
9969 -- i have control of the bank, but not the bags
9970
9971 if ArkInventory.Global.Mode.Bank then
9972
9973 local loc_id = ArkInventory.Const.Location.Bank
9974 if not ArkInventory.LocationIsControlled( loc_id ) then
9975
9976 local bagsOpen = 0
9977 local bagsTotal = 0
9978
9979 bagsTotal = bagsTotal + 1
9980 local BACKPACK_WAS_OPEN = ArkInventory.Frame_Main_Get( ArkInventory.Const.Location.Bag ):IsVisible( )
9981 if BACKPACK_WAS_OPEN then
9982 bagsOpen = bagsOpen + 1
9983 ArkInventory.Frame_Main_Hide( ArkInventory.Const.Location.Bag )
9984 end
9985
9986 if bagsOpen < bagsTotal then
9987
9988 ArkInventory.Frame_Main_Show( ArkInventory.Const.Location.Bag )
9989
9990 else
9991
9992 bagsOpen = 0
9993 bagsTotal = 0
9994
9995 for x = NUM_BAG_SLOTS + 1, NUM_BAG_SLOTS + NUM_BANKBAGSLOTS do
9996 if GetContainerNumSlots( x ) > 0 then
9997 bagsTotal = bagsTotal + 1
9998 if IsBagOpen( x ) then
9999 bagsOpen = bagsOpen + 1
10000 CloseBag( x )
10001 end
10002 end
10003 end
10004
10005 if bagsOpen < bagsTotal then
10006
10007 ArkInventory.Frame_Main_Show( ArkInventory.Const.Location.Bag )
10008
10009 for x = NUM_BAG_SLOTS + 1, NUM_BAG_SLOTS + NUM_BANKBAGSLOTS do
10010 if GetContainerNumSlots( x ) > 0 then
10011 ArkInventory.hooks.OpenBag( x )
10012 end
10013 end
10014
10015 end
10016
10017 end
10018
10019 end
10020
10021 end
10022
10023end
10024
10025function ArkInventory.HookDoNothing( self )
10026 -- ArkInventory.OutputDebug( "HookDoNothing( )" )
10027 -- do nothing
10028end
10029
10030function ArkInventory.HookGuildBankPopupOkayButton_OnClick( self )
10031
10032 --ArkInventory.OutputDebug( "GuildBankPopupOkayButton_OnClick( )" )
10033 --ArkInventory.hooks.GuildBankPopupOkayButton_OnClick( )
10034
10035 local loc_id = ArkInventory.Const.Location.Vault
10036
10037 if not ArkInventory.Global.Location[loc_id].isOffline then
10038 ArkInventory.Frame_Main_Generate( loc_id )
10039 end
10040
10041end
10042
10043function ArkInventory.HookVoidStorageShow( )
10044
10045 --ArkInventory.Output( "void storage opened" )
10046
10047 if not ArkInventory:IsEnabled( ) then return end
10048
10049 local loc_id = ArkInventory.Const.Location.Void
10050
10051 if not ArkInventory.LocationIsMonitored( loc_id ) then return end
10052
10053 ArkInventory.Global.Mode.Void = true
10054 ArkInventory.Global.Location[loc_id].isOffline = false
10055
10056 ArkInventory.ScanLocation( loc_id )
10057
10058
10059 ArkInventory.Frame_Main_DrawStatus( loc_id, ArkInventory.Const.Window.Draw.Refresh )
10060
10061 if ArkInventory.LocationIsControlled( loc_id ) then
10062 ArkInventory.Frame_Main_Show( loc_id )
10063 end
10064
10065 if ArkInventory.db.option.auto.open.void and ArkInventory.LocationIsControlled( ArkInventory.Const.Location.Bag ) then
10066 ArkInventory.Frame_Main_Show( ArkInventory.Const.Location.Bag )
10067 end
10068
10069 ArkInventory.Frame_Main_Generate( loc_id )
10070
10071end
10072
10073function ArkInventory.HookVoidStorageHide( )
10074
10075 --ArkInventory.Output( "void storage closed" )
10076
10077 if not ArkInventory:IsEnabled( ) then return end
10078
10079 local loc_id = ArkInventory.Const.Location.Void
10080
10081 if not ArkInventory.LocationIsMonitored( loc_id ) then return end
10082
10083 ArkInventory.Global.Mode.Void = false
10084 ArkInventory.Global.Location[loc_id].isOffline = true
10085
10086 ArkInventory.Frame_Main_DrawStatus( loc_id, ArkInventory.Const.Window.Draw.Refresh )
10087
10088 if ArkInventory.LocationIsControlled( loc_id ) then
10089 ArkInventory.Frame_Main_Hide( loc_id )
10090 end
10091
10092 if ArkInventory.db.option.auto.close.void and ArkInventory.LocationIsControlled( ArkInventory.Const.Location.Bag ) then
10093 ArkInventory.Frame_Main_Hide( ArkInventory.Const.Location.Bag )
10094 end
10095
10096 if not ArkInventory.LocationIsSaved( loc_id ) then
10097 local me = ArkInventory.GetPlayerCodex( )
10098 ArkInventory.EraseSavedData( me.player.data.info.player_id, loc_id, not me.player.data.location[loc_id].notify )
10099 end
10100
10101 ArkInventory.Frame_Main_Generate( loc_id )
10102
10103end
10104
10105function ArkInventory.HookVoidStorageEvent( self, event )
10106
10107 --ArkInventory.Output( "void storage event ", event )
10108
10109end
10110
10111function ArkInventory.HookFloatingBattlePet_Show( ... )
10112
10113 -- speciesID, level, breedQuality, maxHealth, power, speed, customName, bPetID
10114
10115 if not ArkInventory:IsEnabled( ) then return end
10116
10117 if not ArkInventory.db.option.tooltip.battlepet.enable then return end
10118
10119 local h = ArkInventory.BattlepetBaseHyperlink( ... )
10120
10121 FloatingBattlePetTooltip:Hide( )
10122
10123 if not ItemRefTooltip:IsVisible( ) then
10124 ItemRefTooltip:SetOwner( UIParent, "ANCHOR_PRESERVE" )
10125 end
10126
10127 if ItemRefTooltip:IsShown( ) and ItemRefTooltip.ARKTTD[1] == h then
10128 ItemRefTooltip:Hide( )
10129 else
10130 ArkInventory.TooltipBuildBattlepet( ItemRefTooltip, h )
10131 end
10132
10133end
10134
10135function ArkInventory.HookCPetJournalSetFavorite( ... )
10136 ArkInventory:SendMessage( "EVENT_ARKINV_COLLECTION_PET_UPDATE_BUCKET", "SET_FAVOURITE" )
10137end
10138
10139function ArkInventory.HookCPetJournalSetCustomName( ... )
10140 ArkInventory:SendMessage( "EVENT_ARKINV_COLLECTION_PET_UPDATE_BUCKET", "RENAME" )
10141end
10142
10143function ArkInventory.HookCToyboxSetFavorite( ... )
10144 ArkInventory:SendMessage( "EVENT_ARKINV_COLLECTION_TOYBOX_UPDATE_BUCKET", "SET_FAVOURITE" )
10145end
10146
10147function ArkInventory.LoadAddOn( addonname )
10148 if IsAddOnLoaded( addonname ) then
10149 return true
10150 else
10151 local loaded, reason = LoadAddOn( addonname )
10152 if reason then
10153 ArkInventory.OutputError( "Failed to load ", addonname, ": ", getglobal( "ADDON_" .. reason ) )
10154 end
10155 return not not loaded
10156 end
10157end
10158
10159function ArkInventory.BlizzardAPIHook( disable, reload )
10160
10161 -- required blizzard internal addons - load them here as they expect to be loaded after the user has logged in, they usually have issues if you try to load them too early
10162 ArkInventory.LoadAddOn( "Blizzard_GuildBankUI" )
10163 ArkInventory.LoadAddOn( "Blizzard_VoidStorageUI" )
10164 ArkInventory.LoadAddOn( "Blizzard_Collections" )
10165 --ArkInventory.LoadAddOn( "Blizzard_ScrappingMachineUI" )
10166
10167 local tooltip_functions = {
10168 "SetAuctionSellItem",
10169 "SetBagItem", "SetInventoryItem", "SetItemByID",
10170 "SetCraftItem", --"SetCraftSpell",
10171 "SetBackpackToken", "SetCurrencyByID", "SetCurrencyToken", "SetCurrencyTokenByID",
10172 "SetGuildBankItem",
10173 "SetHeirloomByItemID",
10174 "SetHyperlink", "SetHyperlinkCompareItem",
10175 "SetInboxItem", "SetSendMailItem",
10176 "SetLootItem", "SetLootRollItem",
10177 "SetMerchantItem", "SetMerchantCostItem", "SetBuybackItem",
10178 "SetQuestItem", "SetQuestLogSpecialItem", "SetQuestLogItem",
10179 "SetQuestCurrency", "SetQuestLogCurrency", "LogCurrency",
10180 --"SetQuestLogRewardSpell","SetQuestRewardSpell",
10181 "SetTradePlayerItem", "SetTradeTargetItem",
10182 "SetVoidItem", "SetVoidDepositItem", "SetVoidWithdrawalItem",
10183 "SetRecipeReagentItem", "SetRecipeResultItem",
10184 "SetAuctionItem",
10185 "SetToyByItemID",
10186-- "SetText",
10187 "ClearLines", "FadeOut",
10188
10189-- dont ever hook these functions or they'll cause double ups
10190 -- "SetUnit" -- > conflicts with OnSetUnit
10191 }
10192
10193
10194 if not ArkInventory.Global.BlizzardAPIHook then
10195
10196 -- void storage
10197 VoidStorageFrame:HookScript( "OnShow", ArkInventory.HookVoidStorageShow )
10198 VoidStorageFrame:HookScript( "OnHide", ArkInventory.HookVoidStorageHide )
10199
10200 -- collections
10201 PetJournal:HookScript( "OnHide", ArkInventory.Collection.Pet.OnHide )
10202 MountJournal:HookScript( "OnHide", ArkInventory.Collection.Mount.OnHide )
10203 HeirloomsJournal:HookScript( "OnHide", ArkInventory.Collection.Heirloom.OnHide )
10204 ToyBox:HookScript( "OnHide", ArkInventory.Collection.Toybox.OnHide )
10205 TokenFrame:HookScript( "OnHide", ArkInventory.Collection.Currency.OnHide )
10206 ReputationFrame:HookScript( "OnHide", ArkInventory.Collection.Reputation.OnHide )
10207
10208 ArkInventory.Global.BlizzardAPIHook = true
10209
10210 end
10211
10212
10213 if not disable and not reload then
10214
10215 -- backpack functions
10216 ArkInventory:RawHook( "OpenBackpack", "HookOpenBackpack", true )
10217 ArkInventory:RawHook( "ToggleBackpack", "HookToggleBackpack", true )
10218 ArkInventory:SecureHook( "BackpackTokenFrame_Update", ArkInventory.Frame_Status_Update_Tracking )
10219
10220 -- bag functions
10221 ArkInventory:RawHook( "OpenBag", "HookOpenBag", true )
10222 ArkInventory:RawHook( "ToggleBag", "HookToggleBag", true )
10223 ArkInventory:RawHook( "OpenAllBags", "HookOpenAllBags", true )
10224 if ToggleAllBags then
10225 ArkInventory:RawHook( "ToggleAllBags", "HookToggleAllBags", true )
10226 end
10227
10228 -- mailbox fuctions
10229 ArkInventory:SecureHook( "SendMail", ArkInventory.HookMailSend )
10230 ArkInventory:SecureHook( "ReturnInboxItem", ArkInventory.HookMailReturn )
10231
10232 -- battlepet functions
10233 ArkInventory:SecureHook( C_PetJournal, "SetFavorite", ArkInventory.HookCPetJournalSetFavorite )
10234 ArkInventory:SecureHook( C_PetJournal, "SetCustomName", ArkInventory.HookCPetJournalSetCustomName )
10235
10236 -- toybox functions
10237 ArkInventory:SecureHook( C_ToyBox, "SetIsFavorite", ArkInventory.HookCToyboxSetFavorite )
10238
10239 -- tooltips
10240 for _, func in pairs( tooltip_functions ) do
10241 local myfunc = "HookTooltip"..func
10242 if not ArkInventory[myfunc] then
10243 ArkInventory.OutputWarning( "code issue - function for [", myfunc, "] was not found!" )
10244 end
10245 end
10246
10247 for _, obj in pairs( ArkInventory.Global.Tooltip.WOW ) do
10248 if obj then
10249
10250 ArkInventory.TooltipDataReset( obj )
10251
10252 for _, func in pairs( tooltip_functions ) do
10253 local myfunc = "HookTooltip"..func
10254 if obj[func] and ArkInventory[myfunc] then
10255 ArkInventory:SecureHook( obj, func, ArkInventory[myfunc] )
10256 end
10257 end
10258
10259 obj:HookScript( "OnHide", ArkInventory.HookTooltipOnHide )
10260 obj:HookScript( "OnUpdate", ArkInventory.HookTooltipOnUpdate )
10261
10262 -- battlepet mouseovers
10263 if obj:HasScript( "OnTooltipSetUnit" ) then
10264 obj:HookScript( "OnTooltipSetUnit", ArkInventory.HookTooltipOnSetUnit )
10265 end
10266
10267 if obj:HasScript( "OnTooltipSetItem" ) then
10268 --obj:HookScript( "OnTooltipSetItem", ArkInventory.HookTooltipOnSetItem )
10269 end
10270
10271 if obj:HasScript( "OnTooltipSetSpell" ) then
10272 --obj:HookScript( "OnTooltipSetSpell", ArkInventory.HookTooltipOnSetSpell )
10273 end
10274
10275 end
10276 end
10277
10278 -- battlepet tooltips
10279 ArkInventory:SecureHook( "BattlePetToolTip_Show", ArkInventory.HookBattlePetToolTip_Show )
10280 ArkInventory:SecureHook( "FloatingBattlePet_Show", ArkInventory.HookFloatingBattlePet_Show )
10281
10282 end
10283
10284
10285 if disable then
10286 ArkInventory.Frame_Main_Hide( )
10287 end
10288
10289
10290 -- bank
10291 if disable or not ArkInventory.LocationIsControlled( ArkInventory.Const.Location.Bank ) then
10292 BankFrame_OnHide( BankFrame )
10293 BankFrame:RegisterEvent( "BANKFRAME_OPENED" )
10294 else
10295 CloseBankFrame( )
10296 BankFrame:UnregisterEvent( "BANKFRAME_OPENED" )
10297 end
10298
10299
10300 -- guild bank
10301 if not GuildBankFrame or not GuildBankPopupFrame then
10302
10303 ArkInventory.OutputWarning( "GuildBankFrame or GuildBankPopupFrame are missing, cannot monitor or override vault" )
10304
10305 else
10306
10307 if disable or not ArkInventory.LocationIsControlled( ArkInventory.Const.Location.Vault ) then
10308
10309 -- restore guild bank functions
10310
10311 UIParent:RegisterEvent( "GUILDBANKFRAME_OPENED" )
10312
10313 GuildBankFrame:RegisterEvent( "GUILDBANKBAGSLOTS_CHANGED" )
10314 GuildBankFrame:RegisterEvent( "GUILDBANK_ITEM_LOCK_CHANGED" )
10315 GuildBankFrame:RegisterEvent( "GUILDBANK_UPDATE_TABS" )
10316 GuildBankFrame:RegisterEvent( "GUILDBANK_UPDATE_MONEY" )
10317 GuildBankFrame:RegisterEvent( "GUILDBANK_UPDATE_TEXT" )
10318 GuildBankFrame:RegisterEvent( "GUILD_ROSTER_UPDATE" )
10319 GuildBankFrame:RegisterEvent( "GUILDBANKLOG_UPDATE" )
10320 GuildBankFrame:RegisterEvent( "GUILDTABARD_UPDATE" )
10321
10322 -- anchor pop-up to blizzard frame
10323 local frame = _G["GuildBankFrame"]
10324 if frame then
10325 GuildBankPopupFrame:ClearAllPoints( )
10326 GuildBankPopupFrame:SetPoint( "TOPLEFT", frame, "TOPRIGHT", -4, -30 )
10327 end
10328
10329 else
10330
10331 -- sever guild bank functions
10332
10333 UIParent:UnregisterEvent( "GUILDBANKFRAME_OPENED" )
10334
10335 GuildBankFrame:UnregisterEvent( "GUILDBANKBAGSLOTS_CHANGED" )
10336 GuildBankFrame:UnregisterEvent( "GUILDBANK_ITEM_LOCK_CHANGED" )
10337 GuildBankFrame:UnregisterEvent( "GUILDBANK_UPDATE_TABS" )
10338 GuildBankFrame:UnregisterEvent( "GUILDBANK_UPDATE_MONEY" )
10339 GuildBankFrame:UnregisterEvent( "GUILDBANK_UPDATE_TEXT" )
10340 GuildBankFrame:UnregisterEvent( "GUILD_ROSTER_UPDATE" )
10341 GuildBankFrame:UnregisterEvent( "GUILDBANKLOG_UPDATE" )
10342 GuildBankFrame:UnregisterEvent( "GUILDTABARD_UPDATE" )
10343
10344 GuildBankFrame:Hide( )
10345
10346 -- anchor popup to AI frame
10347 local frame = _G[string.format( ArkInventory.Const.Frame.Main.Name, ArkInventory.Const.Location.Vault )]
10348 if frame then
10349 GuildBankPopupFrame:Hide( )
10350 GuildBankPopupFrame:ClearAllPoints( )
10351 GuildBankPopupFrame:SetPoint( "TOPLEFT", frame, "TOPRIGHT", -4, -30 )
10352 end
10353
10354 end
10355
10356 end
10357
10358
10359 -- tooltips
10360 if disable or not ArkInventory.db.option.tooltip.show then
10361 for _, obj in pairs( ArkInventory.Global.Tooltip.WOW ) do
10362 ArkInventory.TooltipDataReset( tooltip )
10363 end
10364 else
10365 for _, obj in pairs( ArkInventory.Global.Tooltip.WOW ) do
10366 if obj then
10367
10368 if ArkInventory.db.option.tooltip.scale.enabled then
10369 if not obj.IsEmbedded then
10370 -- do not scale embedded tooltips, theyre already scaled from their parent
10371 obj:SetScale( ArkInventory.db.option.tooltip.scale.amount or 1 )
10372 end
10373 end
10374
10375 end
10376 end
10377 end
10378
10379 -- battlepet tooltips
10380 if disable or not ArkInventory.db.option.tooltip.battlepet.enable then
10381 ItemRefTooltip:Hide( )
10382 else
10383 FloatingBattlePetTooltip:Hide( )
10384 end
10385
10386
10387end
10388
10389
10390
10391function ArkInventory.ClassColourRGB( class )
10392
10393 if not class then return end
10394
10395 local ct = nil
10396
10397 -- reminder: ct is now pointing to a secured variable, if you change it you'll taint it and screw up AI (and a lot of other mods as well) - so dont.
10398
10399 if class == "GUILD" then
10400 ct = ORANGE_FONT_COLOR
10401 elseif class == "ACCOUNT" then
10402 ct = YELLOW_FONT_COLOR
10403 else
10404 ct = ( CUSTOM_CLASS_COLORS and CUSTOM_CLASS_COLORS[class] ) or RAID_CLASS_COLORS[class]
10405 end
10406
10407 if not ct then
10408 return
10409 end
10410
10411 local c = { r = ct.r <= 1 and ct.r >= 0 and ct.r or 0, g = ct.g <= 1 and ct.g >= 0 and ct.g or 0, b = ct.b <= 1 and ct.b >= 0 and ct.b or 0 }
10412
10413 return c
10414
10415end
10416
10417function ArkInventory.ClassColourCode( class )
10418
10419 local c = ArkInventory.ClassColourRGB( class )
10420
10421 if not c then
10422 return FONT_COLOR_CODE_CLOSE
10423 end
10424
10425 return string.format( "|cff%02x%02x%02x", c.r * 255, c.g * 255, c.b * 255 )
10426
10427end
10428
10429function ArkInventory.ColourRGBtoCode( r, g, b )
10430
10431 if not r or not g or not b then
10432 return FONT_COLOR_CODE_CLOSE
10433 end
10434
10435 local r = r <= 1 and r >= 0 and r or 0
10436 local g = g <= 1 and g >= 0 and g or 0
10437 local b = b <= 1 and b >= 0 and b or 0
10438
10439 return string.format( "|cff%02x%02x%02x", r * 255, g * 255, b * 255 )
10440
10441end
10442
10443function ArkInventory.ColourCodetoRGB( c )
10444
10445 if not c then
10446 return 1, 1, 1
10447 end
10448
10449 local a, r, g, b = string.match( c, "|c(%x%x)(%x%x)(%x%x)(%x%x)" )
10450
10451 a = tonumber( a ) / 255
10452 r = tonumber( r ) / 255
10453 g = tonumber( g ) / 255
10454 b = tonumber( b ) / 255
10455
10456 return r, g, b, a
10457
10458end
10459
10460function ArkInventory.StripColourCodes( txt )
10461 local txt = txt or ""
10462 txt = string.gsub( txt, "|c%x%x%x%x%x%x%x%x", "" )
10463 txt = string.gsub( txt, "|c%x%x %x%x%x%x%x", "" ) -- the trading parts colour has a space instead of a zero for some weird reason
10464 txt = string.gsub( txt, "|r", "" )
10465 return txt
10466end
10467
10468function ArkInventory.PT_ItemInSets( item, setnames )
10469
10470 if not item or not setnames then return false end
10471
10472 for setname in string.gmatch( setnames, "[^,]+" ) do
10473
10474 local r = ArkInventory.Lib.PeriodicTable:ItemInSet( item, string.trim( setname ) )
10475
10476 if r then
10477 return true
10478 end
10479
10480 end
10481
10482 return false
10483
10484end
10485
10486function ArkInventory.ContainerNameGet( loc_id )
10487 if loc_id ~= nil then
10488 local name = string.format( "%s%s%s", ArkInventory.Const.Frame.Main.Name, loc_id, ArkInventory.Const.Frame.Container.Name )
10489 return name, _G[name]
10490 end
10491end
10492
10493function ArkInventory.ContainerBagNameGet( loc_id, bag_id )
10494 local name = ArkInventory.ContainerNameGet( loc_id )
10495 if name and bag_id ~= nil then
10496 name = string.format( "%s%s%s", name, "Bag", bag_id )
10497 return name, _G[name]
10498 end
10499end
10500
10501function ArkInventory.ContainerItemNameGet( loc_id, bag_id, slot_id )
10502 local name = ArkInventory.ContainerBagNameGet( loc_id, bag_id )
10503 if name and slot_id ~= nil then
10504 name = string.format( "%s%s%s", name, "Item", slot_id )
10505 return name, _G[name]
10506 end
10507end
10508
10509function ArkInventory.ToggleChanger( loc_id )
10510 local codex = ArkInventory.GetLocationCodex( loc_id )
10511 codex.style.changer.hide = not codex.style.changer.hide
10512 ArkInventory.Frame_Main_Generate( nil, ArkInventory.Const.Window.Draw.Refresh )
10513end
10514
10515function ArkInventory.ToggleEditMode( )
10516 ArkInventory.Global.Mode.Edit = not ArkInventory.Global.Mode.Edit
10517 --ArkInventory.OutputWarning( "ToggleEditMode - .restart window draw" )
10518 ArkInventory.Frame_Main_Generate( nil, ArkInventory.Const.Window.Draw.Restart )
10519 --ArkInventory.Frame_Bar_Paint_All( )
10520end
10521
10522function ArkInventory.GameTooltipSetPosition( frame, bottom )
10523
10524 local frame = frame or UIParent
10525 GameTooltip:SetOwner( frame, "ANCHOR_NONE" )
10526
10527 local anchorFromLeft = frame:GetLeft( ) + ( frame:GetRight( ) - frame:GetLeft( ) ) / 2 < GetScreenWidth( ) / 2
10528
10529 if bottom then
10530 if anchorFromLeft then
10531 GameTooltip:SetAnchorType( "ANCHOR_BOTTOMRIGHT" )
10532 else
10533 GameTooltip:SetAnchorType( "ANCHOR_BOTTOMLEFT" )
10534 end
10535 else
10536 if anchorFromLeft then
10537 GameTooltip:SetAnchorType( "ANCHOR_RIGHT" )
10538 else
10539 GameTooltip:SetAnchorType( "ANCHOR_LEFT" )
10540 end
10541 end
10542
10543end
10544
10545function ArkInventory.GameTooltipSetText( frame, txt, r, g, b, bottom )
10546 ArkInventory.GameTooltipSetPosition( frame, bottom )
10547 GameTooltip:SetText( txt or "text is missing", r or 1, g or 1, b or 1 )
10548 GameTooltip:Show( )
10549end
10550
10551function ArkInventory.GameTooltipSetHyperlink( frame, h )
10552
10553 ArkInventory.GameTooltipSetPosition( frame )
10554
10555 local osd = ArkInventory.ObjectStringDecode( h )
10556 if osd.class == "battlepet" then
10557
10558 ArkInventory.TooltipBuildBattlepet( GameTooltip, h )
10559
10560 elseif osd.class == "reputation" then
10561
10562 ArkInventory.TooltipBuildReputation( GameTooltip, h )
10563
10564 elseif osd.class == "copper" then
10565
10566 SetTooltipMoney( GameTooltip, osd.amount )
10567 GameTooltip:Show( )
10568
10569 elseif osd.class == "empty" then
10570
10571 GameTooltip:ClearLines( )
10572 GameTooltip:Hide( )
10573
10574 else
10575
10576 GameTooltip:SetHyperlink( h )
10577
10578 end
10579
10580end
10581
10582function ArkInventory.GameTooltipHide( )
10583 GameTooltip:Hide( )
10584end
10585
10586function ArkInventory.PTItemSearch( h )
10587
10588 -- sourced from pt3.0 because someone decided that it didnt belong in pt3.1
10589
10590 local osd = ArkInventory.ObjectStringDecode( h )
10591 local item = osd.id
10592
10593 if not item or item <= 0 then
10594 return nil
10595 end
10596
10597 local matches = { }
10598 local c = 0
10599 for k, v in pairs( ArkInventory.Lib.PeriodicTable.sets ) do
10600 local _, set = ArkInventory.Lib.PeriodicTable:ItemInSet( item, k )
10601 if set then
10602 local have
10603 for _, v in ipairs( matches ) do
10604 if v == set then
10605 have = true
10606 end
10607 end
10608 if not have then
10609 c = c + 1
10610 matches[c] = set
10611 end
10612 end
10613 end
10614
10615 if #matches > 0 then
10616 table.sort( matches )
10617 return matches
10618 end
10619
10620end
10621
10622function ArkInventory.Frame_Vault_Log_Update( )
10623
10624 local loc_id = ArkInventory.Const.Location.Vault
10625
10626 local numTransactions = 0
10627 if GuildBankFrame.mode == "log" then
10628 numTransactions = GetNumGuildBankTransactions( ArkInventory.Global.Location[loc_id].view_tab ) or 0
10629 elseif GuildBankFrame.mode == "moneylog" then
10630 numTransactions = GetNumGuildBankMoneyTransactions( ) or 0
10631 end
10632
10633 local maxLines = numTransactions
10634
10635 if GuildBankFrame.mode == "moneylog" then
10636 maxLines = maxLines + 2
10637 end
10638
10639 if numTransactions == 0 then
10640 maxLines = 1
10641 end
10642
10643 local obj = _G[string.format( "%s%s%s%s", ArkInventory.Const.Frame.Main.Name, loc_id, ArkInventory.Const.Frame.Log.Name, ArkInventory.Const.Frame.Scrolling.List )]
10644 obj:SetMaxLines( maxLines )
10645 obj:ScrollToTop( )
10646
10647 local tab = ArkInventory.Global.Location[loc_id].view_tab
10648
10649 --obj:SetInsertMode( "TOP" )
10650 --obj:AddMessage( "-*- end of list -*-" )
10651
10652 if numTransactions == 0 then
10653 obj:AddMessage( ArkInventory.Localise["NO_DATA_AVAILABLE"] )
10654 end
10655
10656 local msg, transaction, name, h, count, tab1, tab2, amount, year, month, day, hour, money
10657
10658 for i = 1, numTransactions do
10659
10660 if GuildBankFrame.mode == "log" then
10661 transaction, name, h, count, tab1, tab2, year, month, day, hour = GetGuildBankTransaction( tab, i )
10662 elseif GuildBankFrame.mode == "moneylog" then
10663 transaction, name, amount, year, month, day, hour = GetGuildBankMoneyTransaction( i )
10664 end
10665
10666 if not name then
10667 name = UNKNOWN
10668 end
10669
10670 name = string.format( "%s%s%s", NORMAL_FONT_COLOR_CODE, name, FONT_COLOR_CODE_CLOSE )
10671
10672 if GuildBankFrame.mode == "log" then
10673
10674 if transaction == "deposit" then
10675 msg = format( GUILDBANK_DEPOSIT_FORMAT, name, h )
10676 if count > 1 then
10677 msg = string.format( "%s%s", msg, string.format( GUILDBANK_LOG_QUANTITY, count ) )
10678 end
10679 elseif transaction == "withdraw" then
10680 msg = string.format( GUILDBANK_WITHDRAW_FORMAT, name, h )
10681 if count > 1 then
10682 msg = string.format( "%s%s", msg, format( GUILDBANK_LOG_QUANTITY, count ) )
10683 end
10684 elseif transaction == "move" then
10685 msg = format( GUILDBANK_MOVE_FORMAT, name, h, count, GetGuildBankTabInfo( tab1 ), GetGuildBankTabInfo( tab2 ) )
10686 end
10687
10688 elseif GuildBankFrame.mode == "moneylog" then
10689
10690 money = GetDenominationsFromCopper( amount )
10691
10692 if transaction == "deposit" then
10693 msg = format( GUILDBANK_DEPOSIT_MONEY_FORMAT, name, money )
10694 elseif transaction == "withdraw" then
10695 msg = format( GUILDBANK_WITHDRAW_MONEY_FORMAT, name, money )
10696 elseif transaction == "repair" then
10697 msg = format( GUILDBANK_REPAIR_MONEY_FORMAT, name, money )
10698 elseif transaction == "withdrawForTab" then
10699 msg = format( GUILDBANK_WITHDRAWFORTAB_MONEY_FORMAT, name, money )
10700 elseif transaction == "buyTab" then
10701 msg = format( GUILDBANK_BUYTAB_MONEY_FORMAT, name, money )
10702 end
10703
10704 end
10705
10706 if msg then
10707 obj:AddMessage( string.format( "%s%s%s", msg, GUILD_BANK_LOG_TIME_PREPEND, string.format( GUILD_BANK_LOG_TIME, RecentTimeDate( year, month, day, hour ) ) ) )
10708 end
10709
10710 end
10711
10712 if GuildBankFrame.mode == "moneylog" then
10713 obj:AddMessage( " " )
10714 obj:AddMessage( string.format( "%s %s", GUILDBANK_CASHFLOW, GetDenominationsFromCopper( GetGuildBankBonusDepositMoney( ) ) ) )
10715 end
10716
10717 --ArkInventory.OutputWarning( "Frame_Vault_Log_Update - .Recalculate" )
10718 ArkInventory.Frame_Main_Generate( loc_id, ArkInventory.Const.Window.Draw.Recalculate )
10719
10720end
10721
10722function ArkInventory.Frame_Vault_Info_Update( )
10723
10724 local loc_id = ArkInventory.Const.Location.Vault
10725 local tab = ArkInventory.Global.Location[loc_id].view_tab
10726 local obj = _G[string.format( "%s%s%s%s", ArkInventory.Const.Frame.Main.Name, loc_id, ArkInventory.Const.Frame.Info.Name, "ScrollInfo" )]
10727 local text = GetGuildBankText( tab )
10728
10729 if text then
10730 obj.text = text
10731 obj:SetText( text )
10732 else
10733 obj.text = ""
10734 obj:SetText( "" )
10735 end
10736
10737 --ArkInventory.OutputWarning( "Frame_Vault_Info_Update - .Recalculate" )
10738 ArkInventory.Frame_Main_Generate( loc_id, ArkInventory.Const.Window.Draw.Recalculate )
10739
10740end
10741
10742function ArkInventory.Frame_Vault_Info_Changed( self )
10743
10744 local loc_id = ArkInventory.Const.Location.Vault
10745 local tab = ArkInventory.Global.Location[loc_id].view_tab
10746 local button = _G[self:GetParent( ):GetParent( ):GetName( ).."Save"]
10747
10748 if tab <= GetNumGuildBankTabs( ) and CanEditGuildTabInfo( tab ) and self:GetText( ) ~= self.text then
10749 button:Enable( )
10750 else
10751 button:Disable( )
10752 end
10753
10754end
10755
10756function ArkInventory.ScrollingMessageFrame_Scroll( parent, name, direction )
10757
10758 if not parent or not name then
10759 return
10760 end
10761
10762 local obj = _G[string.format( "%s%s", parent:GetName( ), name )]
10763 if not obj then
10764 return
10765 end
10766
10767 local i = obj:GetInsertMode( )
10768
10769 if i == "TOP" then
10770
10771 if direction == "up" and not obj:AtBottom( ) then
10772 obj:ScrollDown( )
10773 elseif direction == "pageup" and not obj:AtBottom( ) then
10774 obj:PageDown( )
10775 elseif direction == "down" and not obj:AtTop( ) then
10776 obj:ScrollUp( )
10777 elseif direction == "pagedown" and not obj:AtTop( ) then
10778 obj:PageUp( )
10779 end
10780
10781 else
10782
10783 if direction == "up" and not obj:AtTop( ) then
10784 obj:ScrollUp( )
10785 elseif direction == "pageup" and not obj:AtTop( ) then
10786 obj:PageUp( )
10787 elseif direction == "down" and not obj:AtBottom( ) then
10788 obj:ScrollDown( )
10789 elseif direction == "pagedown" and not obj:AtBottom( ) then
10790 obj:PageDown( )
10791 end
10792
10793 end
10794
10795end
10796
10797function ArkInventory.ScrollingMessageFrame_ScrollWheel( parent, name, direction )
10798
10799 if direction == 1 then
10800 ArkInventory.ScrollingMessageFrame_Scroll( parent, name, "up" )
10801 else
10802 ArkInventory.ScrollingMessageFrame_Scroll( parent, name, "down" )
10803 end
10804
10805end
10806
10807function ArkInventory.LocationIsMonitored( loc_id ) -- listen for changes in this location
10808 local me = ArkInventory.GetPlayerCodex( loc_id )
10809 return me.profile.location[loc_id].monitor
10810end
10811
10812function ArkInventory.LocationIsControlled( loc_id )
10813 local me = ArkInventory.GetPlayerCodex( loc_id )
10814 return me.profile.location[loc_id].override
10815end
10816
10817function ArkInventory.LocationIsSaved( loc_id )
10818 local me = ArkInventory.GetPlayerCodex( loc_id )
10819 return me.profile.location[loc_id].save
10820end
10821
10822function ArkInventory.DisplayName1( p )
10823 -- window titles (normal)
10824 if p.class == "ACCOUNT" then
10825 return p.name or ArkInventory.Localise["UNKNOWN"]
10826 else
10827 return string.format( "%s\n%s > %s", p.name or ArkInventory.Localise["UNKNOWN"], p.faction_local or ArkInventory.Localise["UNKNOWN"], p.realm or ArkInventory.Localise["UNKNOWN"] )
10828 end
10829end
10830
10831function ArkInventory.DisplayName2( p )
10832 -- switch menu
10833 if p.class == "ACCOUNT" then
10834 return p.name or ArkInventory.Localise["UNKNOWN"]
10835 else
10836 return string.format( "%s > %s > %s", p.realm or ArkInventory.Localise["UNKNOWN"], p.faction_local or ArkInventory.Localise["UNKNOWN"], p.name or ArkInventory.Localise["UNKNOWN"] )
10837 end
10838end
10839
10840function ArkInventory.DisplayName3( p, paint, ref )
10841
10842 -- tooltip item/gold count
10843 assert( p, "code error: argument is missing" )
10844
10845 local me = ArkInventory.GetPlayerCodex( )
10846 local ref = ref or me.player.data.info
10847
10848 local name = p.name
10849 if paint then
10850 name = string.format( "%s%s", ArkInventory.ClassColourCode( p.class ), p.name or ArkInventory.Localise["UNKNOWN"] )
10851 end
10852
10853 local realm = p.realm or ArkInventory.Localise["UNKNOWN"]
10854 if p.class == "ACCOUNT" or realm == ref.realm then
10855 realm = ""
10856 else
10857 realm = string.format( " - %s", realm )
10858 end
10859
10860 local faction_local = p.faction_local or ArkInventory.Localise["UNKNOWN"]
10861 if p.class == "ACCOUNT" or faction_local == ref.faction_local then
10862 faction_local = ""
10863 else
10864 faction_local = string.format( " [%s]", faction_local )
10865 end
10866
10867 return string.format( "%s%s%s", name, realm, faction_local )
10868
10869end
10870
10871function ArkInventory.DisplayName4( p, f )
10872 -- switch character
10873 if p.class == "ACCOUNT" then
10874 return string.format( "%s%s|r", ArkInventory.ClassColourCode( p.class ), p.name or ArkInventory.Localise["UNKNOWN"] )
10875 else
10876 if p.faction == f then
10877 -- same faction
10878 return string.format( "%s%s (%s:%s)", ArkInventory.ClassColourCode( p.class ), p.name or ArkInventory.Localise["UNKNOWN"], p.class_local or ArkInventory.Localise["UNKNOWN"], p.level or ArkInventory.Localise["UNKNOWN"] )
10879 else
10880 -- different faction so display faction name
10881 --return string.format( "%s%s (%s:%s) |cff7f7f7f[%s]|r", ArkInventory.ClassColourCode( p.class ), p.name or ArkInventory.Localise["UNKNOWN"], p.class_local or ArkInventory.Localise["UNKNOWN"], p.level or ArkInventory.Localise["UNKNOWN"], p.faction_local or ArkInventory.Localise["UNKNOWN"] )
10882 return string.format( "%s%s (%s:%s) [%s]|r", ArkInventory.ClassColourCode( p.class ), p.name or ArkInventory.Localise["UNKNOWN"], p.class_local or ArkInventory.Localise["UNKNOWN"], p.level or ArkInventory.Localise["UNKNOWN"], p.faction_local or ArkInventory.Localise["UNKNOWN"] )
10883 end
10884 end
10885end
10886
10887function ArkInventory.DisplayName5( p )
10888 -- window titles (thin)
10889 return string.format( "%s", p.name or ArkInventory.Localise["UNKNOWN"] )
10890end
10891
10892function ArkInventory.MemoryUsed( c )
10893
10894 if c then
10895 collectgarbage( "stop" )
10896 end
10897
10898 --UpdateAddOnMemoryUsage( )
10899
10900 --local am = GetAddOnMemoryUsage( ArkInventory.Const.Program.Name ) * 1000
10901 local am = collectgarbage( "count" )
10902
10903 if not c then
10904 collectgarbage( "restart" )
10905 end
10906
10907 return am
10908
10909end
10910
10911function ArkInventory.TimeAsMinutes( )
10912 return math.floor( time( date( '*t' ) ) / 60 ) -- minutes
10913end
10914
10915function ArkInventory.ItemAgeGet( age )
10916
10917 if age and type( age ) == "number" then
10918
10919 local s = ArkInventory.Localise["DHMS"]
10920
10921 local x = ArkInventory.TimeAsMinutes( ) - age
10922 local m = x + 1 -- push seconds up so that items with less than a minute get displayed
10923
10924 local d = math.floor( m / 1440 )
10925 m = math.floor( m - d * 1440 )
10926 local h = math.floor( m / 60 )
10927 m = math.floor( m - h * 60 )
10928
10929 local t = ""
10930
10931--[[
10932 if d > 0 then
10933 t = string.format( "%d%s ", d, string.sub( s, 1, 1 ) )
10934 end
10935
10936 if h > 0 or ( d > 0 and m > 0 ) then
10937 t = string.format( "%s%d%s ", t, h, string.sub( s, 2, 2 ) )
10938 end
10939
10940 if m > 0 and d == 0 then -- only show minutes if were not into days
10941 t = string.format( "%s%d%s", t, m, string.sub( s, 3, 3 ) )
10942 end
10943]]--
10944
10945 if d > 0 then
10946 t = string.format( "%d:%d%s", d, h, string.sub( s, 1, 1 ) )
10947 elseif h > 0 then
10948 t = string.format( "%d:%d%s", h, m, string.sub( s, 2, 2 ) )
10949 else
10950 t = string.format( "%d%s", m, string.sub( s, 3, 3 ) )
10951 end
10952
10953 return x, string.trim( t )
10954
10955 end
10956
10957 return false, ""
10958
10959end
10960
10961function ArkInventory.StartupChecks( )
10962
10963end
10964
10965function ArkInventory.UiSetEditBoxLabel( frame, label )
10966 assert( frame and label, "code error: argument is missing" )
10967 _G[string.format( "%s%s", frame:GetName( ), "Label" )]:SetText( label )
10968end
10969
10970function ArkInventory.UiTabToNext( frame, c, p, n )
10971
10972 assert( frame and c and p and n, "code error: argument is missing" )
10973
10974 local f = frame:GetName( )
10975 f = string.sub( f, 1, string.len( f ) - string.len( c ) )
10976
10977 if IsShiftKeyDown( ) then
10978 f = string.format( "%s%s", f, p )
10979 else
10980 f = string.format( "%s%s", f, n )
10981 end
10982
10983 local w = _G[f]
10984 assert( w, "code error: invalid prev/next argument" )
10985 w:SetFocus( )
10986
10987end
10988
10989function ArkInventory.FrameDragStart( frame )
10990
10991 --ArkInventory.Output( "START: ", frame:GetName( ), " / level = ", frame:GetFrameLevel( ), " / strata = ", frame:GetFrameStrata( ) )
10992
10993 frame.ARK_Data.Level = frame:GetFrameLevel( )
10994
10995 frame:StartMoving( )
10996
10997end
10998
10999function ArkInventory.FrameDragStop( frame )
11000
11001 frame:StopMovingOrSizing( )
11002
11003 --ArkInventory.Output( "STOP: ", frame:GetName( ), " / level = ", frame:GetFrameLevel( ), " / strata = ", frame:GetFrameStrata( ) )
11004
11005 ArkInventory.Frame_Main_Anchor_Save( frame )
11006
11007 frame:SetUserPlaced( false )
11008
11009end
11010
11011function ArkInventory.Frame_Search_Paint( )
11012
11013
11014 if ArkInventory.Search.frame then
11015 ArkInventorySearch.Frame_Paint( )
11016 end
11017
11018end
11019
11020function ArkInventory.ThreadRunning( thread_id )
11021
11022 if not ArkInventory.Global.Thread.Use then
11023 return false
11024 end
11025
11026 local data = ArkInventory.Global.Thread.data[thread_id]
11027 if data and data.thread and type( data.thread ) == "thread" and coroutine.status( data.thread ) ~= "dead" then
11028 return true
11029 end
11030
11031 return false
11032
11033end
11034
11035function ArkInventory.ThreadStart( thread_id, thread_func )
11036
11037 local threads = ArkInventory.Global.Thread.data
11038
11039 if threads[thread_id] then
11040
11041 ArkInventory.OutputThread( string.format( "%s restarting", thread_id ) )
11042
11043 else
11044
11045 local tz = debugprofilestop( )
11046
11047 ArkInventory.OutputThread( string.format( "%s starting", thread_id ) )
11048 threads[thread_id] = {
11049 timer = nil, -- if the thread needs to wait before running again then this needs to be set
11050 duration = 0, -- how long the thread actually ran for
11051 }
11052
11053
11054 if thread_id == ArkInventory.Global.Thread.Format.JunkSell then
11055 threads[thread_id].timer = ArkInventory.db.option.thread.timeout.junksell
11056 end
11057
11058 end
11059
11060 threads[thread_id].resumed = debugprofilestop( )
11061 threads[thread_id].thread = coroutine.create( thread_func )
11062
11063 ARKINV_ThreadTimer:Show( )
11064
11065end
11066
11067function ArkInventory.ThreadResume( )
11068
11069 local threads = ArkInventory.Global.Thread.data
11070
11071 --ArkInventory.Output( threads )
11072
11073 local tz = debugprofilestop( )
11074
11075 -- we only run the first suspended thread, then we return, we dont keep looping here
11076
11077 for thread_id, data in ArkInventory.spairs( threads, function( a, b ) return a < b end ) do
11078
11079 if data and data.thread and type( data.thread ) == "thread" then
11080
11081 if coroutine.status( data.thread ) == "suspended" then
11082
11083 if data.timer then
11084
11085 -- threads that have to wait a certain amount of time before they can run again
11086
11087 if data.duration < data.timer then
11088
11089 -- increment duration until timer is reached
11090
11091 if data.duration == 0 then
11092 data.resumed = tz - 1 -- needs a small offset or duration never gets off zero
11093 end
11094
11095 data.duration = tz - data.resumed
11096
11097 --ArkInventory.OutputThread( string.format( "%s %s waiting %0.2fms (%0.2fms)", thread_id, coroutine.status( data.thread ), data.duration, data.timer ) )
11098
11099 return false
11100
11101 else
11102
11103 --ArkInventory.OutputThread( string.format( "%s %s waited %0.2fms (%0.2fms)", thread_id, coroutine.status( data.thread ), data.duration, data.timer ) )
11104
11105 local ok, errmsg = coroutine.resume( data.thread )
11106 -- yields come back here
11107
11108 data.duration = 0
11109
11110 if not ok then
11111 ArkInventory.OutputError( errmsg )
11112 error( errmsg )
11113 end
11114
11115 return false
11116
11117 end
11118
11119 else
11120
11121 -- threads that can only run for so long
11122
11123 data.resumed = tz
11124
11125 local ok, errmsg = coroutine.resume( data.thread )
11126 -- yields come back here
11127
11128 tz = debugprofilestop( ) - data.resumed
11129 data.duration = data.duration + tz
11130 ArkInventory.OutputThread( string.format( "%s %s after %0.2fms (%0.2fms)", thread_id, coroutine.status( data.thread ), tz, data.duration ) )
11131
11132 if not ok then
11133 ArkInventory.OutputError( errmsg )
11134 error( errmsg )
11135 end
11136
11137 return false
11138
11139 end
11140
11141 else
11142
11143 ArkInventory.OutputThread( thread_id, ": clearing (state is ", coroutine.status( data.thread ), ")" )
11144 ArkInventory.Global.Thread.data[thread_id] = nil
11145 return false
11146
11147 end
11148
11149 else
11150
11151 ArkInventory.OutputThread( thread_id, ": clearing (not a thread)" )
11152 ArkInventory.Global.Thread.data[thread_id] = nil
11153 return false
11154
11155 end
11156
11157 end
11158
11159 return true
11160
11161end
11162
11163function ArkInventory.ThreadYield( thread_id )
11164
11165 if not ArkInventory.Global.Thread.Use then return end
11166
11167 local threads = ArkInventory.Global.Thread.data
11168
11169 local thread_id = thread_id or ArkInventory.Global.Thread.Format.Force
11170 local tz = debugprofilestop( )
11171 local duration = tz - threads[thread_id].resumed
11172
11173 local timeout = ArkInventory.db.option.thread.timeout.normal
11174
11175 if thread_id == ArkInventory.Global.Thread.Format.Tooltip then
11176
11177 timeout = ArkInventory.db.option.thread.timeout.tooltip
11178
11179 elseif thread_id == ArkInventory.Global.Thread.Format.JunkSell then
11180
11181 thread_id = ArkInventory.Global.Thread.Format.Force
11182
11183 else
11184
11185 if InCombatLockdown( ) then
11186 timeout = ArkInventory.db.option.thread.timeout.combat
11187 end
11188
11189 end
11190
11191 if thread_id == ArkInventory.Global.Thread.Format.Force or duration >= timeout then
11192
11193 if thread_id == ArkInventory.Global.Thread.Format.Force then
11194 ArkInventory.OutputThread( GREEN_FONT_COLOR_CODE, string.format( "%s forced yield (%0.0fms)", thread_id, duration ) )
11195 else
11196 --ArkInventory.OutputThread( GREEN_FONT_COLOR_CODE, string.format( "%s yielding %0.0f >= %0.0f", thread_id, duration, timeout ) )
11197 end
11198
11199 ARKINV_ThreadTimer:Show( )
11200 coroutine.yield( )
11201
11202 else
11203
11204 --ArkInventory.OutputThread( GREEN_FONT_COLOR_CODE, string.format( "%s continue %0.0f >= %0.0f", thread_id, duration, timeout ) )
11205
11206 end
11207
11208end
11209
11210function ArkInventory.ThreadYield_Scan( thread_id )
11211 ArkInventory.ThreadYield( thread_id )
11212end
11213
11214function ArkInventory.ThreadYield_Window( loc_id )
11215 local thread_id
11216 if loc_id then
11217 thread_id = string.format( ArkInventory.Global.Thread.Format.Window, loc_id )
11218 end
11219 ArkInventory.ThreadYield( thread_id )
11220end