vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- ----------------------------------------------------------------- |
2 | -- File: AllInOneBank.lua |
||
3 | -- |
||
4 | -- Purpose: Functions for AIOB WoW Window. |
||
5 | -- |
||
6 | -- Author: Ramble |
||
7 | -- |
||
8 | -- Credits: |
||
9 | -- Starven, for MyInventory |
||
10 | -- Kaitlin, for BankItems |
||
11 | -- Sarf, for the original concept of AllInOneInventory |
||
12 | -- ----------------------------------------------------------------- |
||
13 | ----------------------- |
||
14 | -- Saved Configuration |
||
15 | ----------------------- |
||
16 | AIOBProfile = {} |
||
17 | AIOB_VERSION = "1.5.2"; |
||
18 | |||
19 | local PlayerName = nil; -- Logged in player name |
||
20 | local bankPlayer = nil; -- viewing player pointer |
||
21 | local bankPlayerName = nil; -- Viewing player name |
||
22 | |||
23 | ------------------------ |
||
24 | -- Saved Function Calls |
||
25 | ------------------------ |
||
26 | local BankFrame_Saved = nil; |
||
27 | local PurchaseSlot_Saved = nil; |
||
28 | ----------------------- |
||
29 | -- Local Configuration |
||
30 | ----------------------- |
||
31 | local AIOB_Loaded = nil; |
||
32 | local AtBank = false; |
||
33 | |||
34 | AIOB_MAX_ID = 132; -- 6 * 18 slot bags, 24 Bankslots |
||
35 | AIOB_COLUMNS_MIN = 6; -- 6 Bags, so it has to be at least 6 wide |
||
36 | AIOB_COLUMNS_MAX = 18; -- Same as MI |
||
37 | AIOB_BASE_HEIGHT = 153; -- Height of Borders + Title + Bottom |
||
38 | AIOB_ROW_HEIGHT = 40; -- One Row |
||
39 | AIOB_BASE_WIDTH = 12; -- Width of the borders |
||
40 | AIOB_COL_WIDTH = 39; -- One Column |
||
41 | AIOB_FIRST_ITEM_OFFSET_X = 7; -- Leave room for the border |
||
42 | AIOB_FIRST_ITEM_OFFSET_Y = -28 - 39; -- Leave room for the title. |
||
43 | AIOB_ITEM_OFFSET_X = 39; -- Each is 39 apart |
||
44 | AIOB_ITEM_OFFSET_Y = -39; -- Each is 39 apart |
||
45 | |||
46 | AIOBDEBUG = 0; |
||
47 | -- Not Saved between Sessions |
||
48 | AIOBAllRealms = 0; |
||
49 | -- Saved Between Sessions |
||
50 | AIOBReplaceBank = 1; |
||
51 | AIOBColumns = 10; |
||
52 | AIOBFreeze = 0; |
||
53 | AIOBHighlightItems = 1; |
||
54 | AIOBHighlightBags = 1; |
||
55 | AIOBBagView = 0; |
||
56 | AIOBGraphics = 1; |
||
57 | AIOBBackground = 1; |
||
58 | AIOBShowPlayers = 1; |
||
59 | |||
60 | --InitializeProfile: Initializes a players profile {{{ |
||
61 | -- If Player's profile is not found, it makes a new one from defaults |
||
62 | -- If Player's profile is found, it loads the values from AIOBProfile |
||
63 | function AIOB_InitializeProfile() |
||
64 | if ( UnitName("player") ) then |
||
65 | PlayerName = UnitName('player').."|"..AIOB_Trim(GetCVar("realmName")); |
||
66 | AIOB_LoadSettings(); |
||
67 | |||
68 | AIOB_DEBUG("AIOB: Profile for "..PlayerName.." Initilized."); |
||
69 | AIOBFrame_PopulateFrame(); |
||
70 | -- TODO: why is this here? |
||
71 | -- AIOB_UpdateBagCost(AIOBProfile[PlayerName].Bags); |
||
72 | end |
||
73 | end |
||
74 | |||
75 | function AIOB_LoadSettings() |
||
76 | if ( AIOBProfile[PlayerName] == nil ) then |
||
77 | AIOBProfile[PlayerName] = {}; |
||
78 | AIOB_Print("Creating new Profile for "..PlayerName); |
||
79 | end |
||
80 | AIOBReplaceBank = AIOB_SavedOrDefault("ReplaceBank"); |
||
81 | AIOBColumns = AIOB_SavedOrDefault("Columns"); |
||
82 | AIOBFreeze = AIOB_SavedOrDefault("Freeze"); |
||
83 | AIOBHighlightItems = AIOB_SavedOrDefault("HighlightItems"); |
||
84 | AIOBHighlightBags = AIOB_SavedOrDefault("HighlightBags"); |
||
85 | AIOBBagView = AIOB_SavedOrDefault("BagView"); |
||
86 | AIOBGraphics = AIOB_SavedOrDefault("Graphics"); |
||
87 | AIOBBackground = AIOB_SavedOrDefault("Background"); |
||
88 | AIOBShowPlayers = AIOB_SavedOrDefault("ShowPlayers"); |
||
89 | |||
90 | AIOB_SetGraphics(); |
||
91 | AIOB_SetReplaceBank(); |
||
92 | AIOB_SetFreeze(); |
||
93 | end |
||
94 | function AIOB_SavedOrDefault(varname) |
||
95 | if PlayerName == nil or varname == nil then |
||
96 | AIOB_DEBUG("ERR: nil value"); |
||
97 | return nil; |
||
98 | end |
||
99 | if AIOBProfile[PlayerName][varname] == nil then -- Setting not set |
||
100 | AIOBProfile[PlayerName][varname] = getglobal("AIOB"..varname); -- Load Default |
||
101 | end |
||
102 | return AIOBProfile[PlayerName][varname]; -- Return Setting. |
||
103 | end |
||
104 | -- END Initialization }}} |
||
105 | function AIOB_GetPlayer(playerName) |
||
106 | if ( not AIOBProfile[playerName] ) then |
||
107 | AIOB_InitializeProfile(); |
||
108 | end |
||
109 | bankPlayerName = playerName; |
||
110 | UIDropDownMenu_SetSelectedValue(AIOBDropDown, bankPlayerName); |
||
111 | return AIOBProfile[playerName]; |
||
112 | end |
||
113 | |||
114 | function AIOB_GetBag(bagIndex) |
||
115 | local curBag |
||
116 | if bagIndex == BANK_CONTAINER then |
||
117 | curBag = bankPlayer["Bank"]; |
||
118 | else |
||
119 | curBag = bankPlayer["Bag"..bagIndex]; |
||
120 | end |
||
121 | return curBag; |
||
122 | end |
||
123 | |||
124 | function AIOB_GetBagsTotalSlots() |
||
125 | local slots = 24; |
||
126 | if bankPlayer == nil then |
||
127 | return slots; |
||
128 | end |
||
129 | for bag = 5, 10 do |
||
130 | local curBag = bankPlayer["Bag"..bag]; |
||
131 | if (curBag ~= nil) then |
||
132 | if curBag["s"] ~=nil then |
||
133 | slots = slots + curBag["s"]; |
||
134 | end |
||
135 | end |
||
136 | end |
||
137 | return slots; |
||
138 | end |
||
139 | |||
140 | -- == Event Handling == |
||
141 | -- OnLoad {{{ |
||
142 | function AIOBFrame_OnLoad() |
||
143 | AIOB_Register(); -- Slash Commands |
||
144 | this:RegisterEvent("PLAYER_ENTERING_WORLD"); |
||
145 | this:RegisterEvent("BAG_UPDATE"); |
||
146 | this:RegisterEvent("ITEM_LOCK_CHANGED"); |
||
147 | this:RegisterEvent("UPDATE_INVENTORY_ALERTS"); |
||
148 | this:RegisterEvent("BANKFRAME_OPENED"); |
||
149 | this:RegisterEvent("BANKFRAME_CLOSED"); |
||
150 | this:RegisterEvent("PLAYERBANKSLOTS_CHANGED"); |
||
151 | this:RegisterEvent("PLAYERBANKBAGSLOTS_CHANGED"); |
||
152 | this:RegisterEvent("PLAYER_MONEY"); |
||
153 | tinsert(UISpecialFrames, "AIOBFrame"); -- Esc Closes AIOB |
||
154 | end |
||
155 | |||
156 | function AIOB_Register() |
||
157 | SlashCmdList["AIOBSLASHMAIN"] = AIOB_ChatCommandHandler; |
||
158 | SLASH_AIOBSLASHMAIN1 = "/AIOB"; |
||
159 | this:RegisterEvent("VARIABLES_LOADED"); |
||
160 | end |
||
161 | -- End Load }}} |
||
162 | -- Confirm Dialog for buying bag slot {{{ |
||
163 | function AIOB_RegisterConfirm() |
||
164 | PurchaseSlot_Saved = PurchaseSlot; |
||
165 | PurchaseSlot = AIOB_PurchaseSlot; |
||
166 | StaticPopupDialogs["PURCHASE_BANKBAG"] = { |
||
167 | text = TEXT(AIOB_PURCHASE_CONFIRM_S), |
||
168 | button1 = TEXT(ACCEPT), |
||
169 | button2 = TEXT(CANCEL), |
||
170 | OnAccept = function() |
||
171 | PurchaseSlot_Saved(); |
||
172 | end, |
||
173 | showAlert = 1, |
||
174 | timeout = 0, |
||
175 | }; |
||
176 | end |
||
177 | |||
178 | function AIOB_PurchaseSlot() |
||
179 | if not StaticPopupDialogs["PURCHASE_BANKBAG"] then |
||
180 | return; |
||
181 | end |
||
182 | local cost = GetBankSlotCost(); |
||
183 | if cost < 10000 then |
||
184 | StaticPopupDialogs["PURCHASE_BANKBAG"]["text"] = format(AIOB_PURCHASE_CONFIRM_S,(cost/100)); |
||
185 | else |
||
186 | StaticPopupDialogs["PURCHASE_BANKBAG"]["text"] = format(AIOB_PURCHASE_CONFIRM_G,(cost/10000)); |
||
187 | end |
||
188 | StaticPopup_Show("PURCHASE_BANKBAG"); |
||
189 | end |
||
190 | -- End buy bag slot config }}} |
||
191 | -- Register with MyAddons |
||
192 | function AIOB_MyAddonsRegister() |
||
193 | if (myAddOnsFrame) then |
||
194 | myAddOnsList.AIOB = { |
||
195 | name = AIOB_MYADDON_NAME, |
||
196 | description = AIOB_MYADDON_DESCRIPTION, |
||
197 | version = AIOB_VERSION, |
||
198 | category = MYADDONS_CATEGORY_INVENTORY, |
||
199 | frame = "AIOBFrame", |
||
200 | optionsframe = "AIOBConfigFrame" |
||
201 | }; |
||
202 | end |
||
203 | end |
||
204 | |||
205 | function AIOBFrame_OnEvent(event) |
||
206 | if ( event == "VARIABLES_LOADED" ) then |
||
207 | AIOB_Loaded = 1; |
||
208 | AIOB_MyAddonsRegister(); |
||
209 | AIOB_InitializeProfile(); |
||
210 | if not BankBuyFrame then |
||
211 | AIOB_RegisterConfirm(); |
||
212 | end |
||
213 | end |
||
214 | if (not AIOB_Loaded) then |
||
215 | return; |
||
216 | end |
||
217 | |||
218 | if ( event == "PLAYER_ENTERING_WORLD" and bankPlayer == nil ) then |
||
219 | PlayerName = UnitName("player").."|"..AIOB_Trim(GetCVar("realmName")); |
||
220 | bankPlayer = AIOB_GetPlayer(PlayerName); |
||
221 | AIOB_InitializeProfile(); |
||
222 | AIOB_SaveMoney(); |
||
223 | elseif ( event == "BAG_UPDATE" ) then |
||
224 | if AtBank and arg1 >=5 and arg1 <=10 then |
||
225 | AIOBFrame_SaveItems(); |
||
226 | end |
||
227 | elseif (event == "PLAYERBANKSLOTS_CHANGED" or event=="PLAYERBANKBAGSLOTS_CHANGED") then |
||
228 | AIOBFrame_SaveItems(); |
||
229 | elseif ( event == "ITEM_LOCK_CHANGED" or event == "UPDATE_INVENTORY_ALERTS" ) then |
||
230 | if ( AtBank ) then |
||
231 | AIOBFrame_PopulateFrame(); |
||
232 | end |
||
233 | end |
||
234 | if (event == "BANKFRAME_OPENED") then |
||
235 | AtBank = true; |
||
236 | SetPortraitTexture(AIOBFramePortrait, "npc"); |
||
237 | AIOBFrameAtBankText:Show(); |
||
238 | OpenBackpack(); -- Open Backpack at Bank |
||
239 | bankPlayer = AIOB_GetPlayer(PlayerName); |
||
240 | AIOBFrame_SaveItems(); |
||
241 | AIOBFramePurchaseButton:Enable(); |
||
242 | if AIOBReplaceBank == 1 then |
||
243 | OpenAIOBFrame(); |
||
244 | end |
||
245 | elseif (event == "BANKFRAME_CLOSED") then |
||
246 | AtBank = false; |
||
247 | AIOBFramePortrait:SetTexture("Interface\\Addons\\AllInOneInventory\\Skin\\AIOBPortait"); |
||
248 | AIOBFrameAtBankText:Hide(); |
||
249 | AIOBFramePurchaseButton:Disable(); |
||
250 | CloseBackpack(); -- Close Backpack when leaving |
||
251 | if AIOBReplaceBank == 1 then |
||
252 | if AIOBFreeze == 0 then |
||
253 | CloseAIOBFrame(); |
||
254 | end |
||
255 | end |
||
256 | if StackSplitFrame:IsVisible() then |
||
257 | StackSplitFrame:Hide(); |
||
258 | end |
||
259 | elseif (event == "PLAYER_MONEY" ) then |
||
260 | AIOB_SaveMoney(); |
||
261 | return; |
||
262 | end |
||
263 | end |
||
264 | |||
265 | function AIOB_HighlightBag(bagID, bagName, isItem) |
||
266 | if AIOBHighlightBags == 0 and isItem then |
||
267 | return; |
||
268 | end |
||
269 | if AIOBHighlightItems == 0 and (not isItem) then |
||
270 | return; |
||
271 | end |
||
272 | if isItem then |
||
273 | if bagID > -1 then |
||
274 | getglobal("AIOBFrameBag"..bagID):LockHighlight(); |
||
275 | end |
||
276 | end |
||
277 | if(bankPlayer[bagName])then |
||
278 | local i, found; |
||
279 | for i=1, AIOB_MAX_ID do |
||
280 | local itemButton = getglobal("AIOBFrameItem"..i); |
||
281 | if not itemButton:IsVisible() then |
||
282 | break; |
||
283 | end |
||
284 | if itemButton.bagIndex == bagID then |
||
285 | found = true; |
||
286 | itemButton:LockHighlight(); |
||
287 | else |
||
288 | if found then |
||
289 | break; |
||
290 | end |
||
291 | end |
||
292 | end |
||
293 | end |
||
294 | end |
||
295 | |||
296 | function AIOB_GetCooldown(item) |
||
297 | if item["d"] then |
||
298 | local cooldownInfo = item["d"]; |
||
299 | local CoolDownRemaining; |
||
300 | if cooldownInfo and cooldownInfo["d"] and cooldownInfo["s"] then |
||
301 | CoolDownRemaining = cooldownInfo["d"] - (GetTime() - cooldownInfo["s"]); |
||
302 | else |
||
303 | CoolDownRemaining = 0; |
||
304 | end |
||
305 | if CoolDownRemaining <= 0 then |
||
306 | item["d"] = nil; |
||
307 | else |
||
308 | return cooldownInfo; |
||
309 | end |
||
310 | end |
||
311 | return nil; |
||
312 | end |
||
313 | |||
314 | function AIOB_GetCooldownString(cooldownInfo) |
||
315 | local CoolDownRemaining = cooldownInfo["d"] - (GetTime() - cooldownInfo["s"]); |
||
316 | -- 60 secs in a min |
||
317 | -- 3600 secs in an hour |
||
318 | -- 86400 secs in a day |
||
319 | local days, hours, minutes, seconds; |
||
320 | days = math.floor(CoolDownRemaining / 86400); |
||
321 | CoolDownRemaining = CoolDownRemaining - 86400 * days; |
||
322 | hours = math.floor(CoolDownRemaining / 3600); |
||
323 | CoolDownRemaining = CoolDownRemaining - 3600 * hours; |
||
324 | minutes = math.floor(CoolDownRemaining / 60); |
||
325 | seconds = math.floor(CoolDownRemaining - 60 * minutes); |
||
326 | if days > 0 then |
||
327 | return format(ITEM_COOLDOWN_TIME_DAYS_P1, days+1); |
||
328 | elseif hours > 0 then |
||
329 | return format(ITEM_COOLDOWN_TIME_HOURS_P1, hours+1); |
||
330 | elseif minutes > 0 then |
||
331 | return format(ITEM_COOLDOWN_TIME_MIN, minutes+1); |
||
332 | else |
||
333 | return format(ITEM_COOLDOWN_TIME_SEC, seconds); |
||
334 | end |
||
335 | end |
||
336 | |||
337 | function AIOB_MakeLink(item) |
||
338 | if item and item["l"] then |
||
339 | local name; |
||
340 | _,_,_, name = strfind(item["l"],"|H(item:%d+:%d+:%d+:%d+)|h%[(.-)%]|h|r"); |
||
341 | item["name"] = name; |
||
342 | item["l"] = nil; |
||
343 | end |
||
344 | if item and item["name"] then |
||
345 | local myHyperlink; |
||
346 | if ItemsMatrix_GetHyperlink then |
||
347 | myHyperlink = ItemsMatrix_GetHyperlink(item["name"]); |
||
348 | elseif LootLink_GetHyperlink then |
||
349 | myHyperlink = LootLink_GetHyperlink(item["name"]); |
||
350 | else |
||
351 | myHyperlink = AIOB_GetHyperlink(item); |
||
352 | end |
||
353 | if myHyperlink then |
||
354 | GameTooltip:Hide(); |
||
355 | GameTooltip:SetOwner(this,"ANCHOR_RIGHT"); |
||
356 | GameTooltip:SetHyperlink(myHyperlink); |
||
357 | if item["sb"] then |
||
358 | GameTooltipTextLeft2:SetText(ITEM_SOULBOUND); |
||
359 | end |
||
360 | if item["m"] then |
||
361 | GameTooltip:AddLine(format(ITEM_CREATED_BY, item["m"])); |
||
362 | end |
||
363 | local cooldownInfo = item["d"]; |
||
364 | if cooldownInfo and cooldownInfo["e"] and cooldownInfo["e"] > 0 and cooldownInfo["d"] > 0 then |
||
365 | CoolDownString = AIOB_GetCooldownString(cooldownInfo); |
||
366 | GameTooltip:AddLine(CoolDownString, 1.0, 1.0, 1.0); |
||
367 | end |
||
368 | GameTooltip:Show(); |
||
369 | end |
||
370 | end |
||
371 | end |
||
372 | |||
373 | function AIOBFrame_Button_OnEnter() |
||
374 | --show tooltip |
||
375 | local myLink, MadeBy, Soulbound, count; |
||
376 | local bagName = strsub(this:GetName(), 10, 13); |
||
377 | local curBag; |
||
378 | local cooldownInfo; |
||
379 | if AtBank then |
||
380 | local hasCooldown, repairCost; |
||
381 | GameTooltip:SetOwner(this,"ANCHOR_RIGHT"); |
||
382 | if (this.isBag) then |
||
383 | AIOB_HighlightBag(this:GetID(), bagName); |
||
384 | local inventoryID = BankButtonIDToInvSlotID(this:GetID(), 1); |
||
385 | hasCooldown, repairCost = GameTooltip:SetInventoryItem("player", inventoryID); |
||
386 | else |
||
387 | AIOB_HighlightBag(this.bagIndex, bagName, 1); |
||
388 | if this.bagIndex < 0 then |
||
389 | local newIndex =BankFrameItem1:GetInventorySlot(); |
||
390 | hasCooldown, repairCost = GameTooltip:SetInventoryItem("player", newIndex); |
||
391 | else |
||
392 | hasCooldown, repairCost = GameTooltip:SetBagItem(this.bagIndex, this.itemIndex); |
||
393 | end |
||
394 | end |
||
395 | |||
396 | else |
||
397 | if LootLink_AutoInfoOff then |
||
398 | LootLink_AutoInfoOff(); |
||
399 | end |
||
400 | if (this.isBag) then |
||
401 | AIOB_MakeLink(bankPlayer[bagName]); |
||
402 | AIOB_HighlightBag(this:GetID(), bagName); |
||
403 | else |
||
404 | AIOB_HighlightBag(this.bagIndex, bagName, 1); |
||
405 | curBag = AIOB_GetBag(this.bagIndex); |
||
406 | if curBag and curBag[this.itemIndex] then |
||
407 | AIOB_MakeLink(curBag[this.itemIndex]); |
||
408 | end |
||
409 | |||
410 | end |
||
411 | if LootLink_AutoInfoOn then |
||
412 | LootLink_AutoInfoOn(); |
||
413 | end |
||
414 | end |
||
415 | end |
||
416 | function AIOBFrame_Button_OnLeave() |
||
417 | if this.isBag then |
||
418 | local bagName= strsub(this:GetName(), 10, 13); |
||
419 | local i, found; |
||
420 | for i=1, AIOB_MAX_ID do |
||
421 | local itemButton = getglobal("AIOBFrameItem"..i); |
||
422 | if itemButton.bagIndex == this:GetID() then |
||
423 | found = true; |
||
424 | itemButton:UnlockHighlight(); |
||
425 | else |
||
426 | if found then |
||
427 | break; |
||
428 | end |
||
429 | end |
||
430 | end |
||
431 | else |
||
432 | if this.bagIndex > -1 then |
||
433 | getglobal("AIOBFrameBag"..(this.bagIndex)):UnlockHighlight(); |
||
434 | end |
||
435 | |||
436 | end |
||
437 | GameTooltip:Hide(); |
||
438 | end |
||
439 | |||
440 | function AIOBFrame_UpdateCooldown(button) |
||
441 | if (not button.bagIndex) or (not button.itemIndex) then |
||
442 | return; |
||
443 | end |
||
444 | local cooldown = getglobal(button:GetName().."Cooldown"); |
||
445 | local start, duration, enable = GetContainerItemCooldown(button.bagIndex, button.itemIndex); |
||
446 | CooldownFrame_SetTimer(cooldown, start, duration, enable); |
||
447 | if ( duration > 0 and enable == 0 ) then |
||
448 | SetItemButtonTextureVertexColor(button, 0.4, 0.4, 0.4); |
||
449 | end |
||
450 | end |
||
451 | |||
452 | function AIOBFrame_OnHide() |
||
453 | if AtBank then |
||
454 | CloseBankFrame(); |
||
455 | end |
||
456 | PlaySound("igBackPackClose"); |
||
457 | end |
||
458 | |||
459 | function AIOBFrame_OnShow() |
||
460 | if AtBank then |
||
461 | AIOBFramePurchaseButton:Enable(); |
||
462 | else |
||
463 | AIOBFramePurchaseButton:Disable(); |
||
464 | end |
||
465 | AIOB_UpdateTotalMoney(); |
||
466 | AIOBFrame_UpdateLookIfNeeded(); |
||
467 | PlaySound("igBackPackOpen"); |
||
468 | end |
||
469 | |||
470 | function AIOBFrameItemButton_OnLoad() |
||
471 | this:RegisterForClicks("LeftButtonUp", "RightButtonUp"); |
||
472 | this:RegisterForDrag("LeftButton"); |
||
473 | |||
474 | this.SplitStack = function(button, split) |
||
475 | SplitContainerItem(button:GetParent():GetID(), button:GetID(), split); |
||
476 | end |
||
477 | end |
||
478 | |||
479 | function AIOBFrameItemButton_OnClick(button, ignoreShift) |
||
480 | local myLink; |
||
481 | local item = AIOB_GetBag(this.bagIndex)[this.itemIndex]; |
||
482 | if (button == "LeftButton" ) then |
||
483 | if (IsShiftKeyDown() and (not ignoreShift)) then |
||
484 | if ChatFrameEditBox:IsVisible() or ( MacroFrameText and MacroFrameText:IsVisible() ) then |
||
485 | -- Insert Link |
||
486 | if ItemsMatrix_GetLink then |
||
487 | myLink = ItemsMatrix_GetLink(item["name"]); |
||
488 | elseif LootLink_GetLink then |
||
489 | myLink = LootLink_GetLink(item["name"]); |
||
490 | else |
||
491 | myLink = AIOB_GetLink(item); |
||
492 | end |
||
493 | if myLink then |
||
494 | if ChatFrameEditBox:IsVisible() then |
||
495 | ChatFrameEditBox:Insert(myLink); |
||
496 | elseif ( MacroFrameText and MacroFrameText:IsVisible() ) then |
||
497 | MacroFrameText:Insert(myLink); |
||
498 | end |
||
499 | end |
||
500 | else |
||
501 | if AtBank then |
||
502 | --Shift key down, left mouse button |
||
503 | local texture, itemCount, locked = GetContainerItemInfo(this.bagIndex, this.itemIndex); |
||
504 | if ( not locked ) then |
||
505 | this.SplitStack = function(button, split) |
||
506 | SplitContainerItem(button.bagIndex, button.itemIndex, split); |
||
507 | end |
||
508 | OpenStackSplitFrame(this.count, this, "BOTTOMRIGHT", "TOPRIGHT"); |
||
509 | end |
||
510 | end |
||
511 | end |
||
512 | else |
||
513 | -- no shift, left mouse button |
||
514 | if AtBank==true then |
||
515 | PickupContainerItem(this.bagIndex, this.itemIndex); |
||
516 | end |
||
517 | end |
||
518 | elseif (button == "RightButton") then |
||
519 | if AtBank==true then |
||
520 | UseContainerItem(this.bagIndex, this.itemIndex); |
||
521 | end |
||
522 | end |
||
523 | end |
||
524 | |||
525 | function AIOBFrameItemButtonBag_OnShiftClick(button, ignoreShift) |
||
526 | local bankBag = getglobal("BankFrameBag"..(tonumber(strsub(this:GetName(), 13, 15))-4)); |
||
527 | local inventoryID = BankButtonIDToInvSlotID(bankBag:GetID(), 1); |
||
528 | if ( ChatFrameEditBox:IsVisible() ) then |
||
529 | local bagName= strsub(this:GetName(), 10, 13); |
||
530 | local myLink; |
||
531 | if ItemsMatrix_GetLink then |
||
532 | myLink = ItemsMatrix_GetLink(bankPlayer[bagName]["name"]); |
||
533 | elseif LootLink_GetLink then |
||
534 | myLink = LootLink_GetLink(bankPlayer[bagName]["name"]); |
||
535 | else |
||
536 | myLink = AIOB_GetLink(bankPlayer[bagName]); |
||
537 | end |
||
538 | if myLink then |
||
539 | if ChatFrameEditBox:IsVisible() then |
||
540 | ChatFrameEditBox:Insert(myLink); |
||
541 | elseif ( MacroFrameText and MacroFrameText:IsVisible() ) then |
||
542 | MacroFrameText:Insert(myLink); |
||
543 | end |
||
544 | end |
||
545 | else |
||
546 | -- Shift key, no chat box |
||
547 | if AtBank then |
||
548 | PickupBagFromSlot(inventoryID); |
||
549 | PlaySound("BAGMENUBUTTONPRESS"); |
||
550 | end |
||
551 | end |
||
552 | end |
||
553 | function AIOBFrameItemButtonBag_OnClick(button, ignoreShift) |
||
554 | local bankBag = getglobal("BankFrameBag"..(tonumber(strsub(this:GetName(), 13, 15))-4)); |
||
555 | local inventoryID = BankButtonIDToInvSlotID(bankBag:GetID(), 1); |
||
556 | AIOB_DEBUG(bankBag:GetName().." "..inventoryID); |
||
557 | -- No ShiftKey |
||
558 | if AtBank then |
||
559 | local hadItem = PutItemInBag(inventoryID); |
||
560 | local id = this:GetID(); |
||
561 | end |
||
562 | end |
||
563 | -- == End Event Handling == |
||
564 | |||
565 | function AIOBFrame_SetColumns(col) |
||
566 | if ( type(col) ~= "number" ) then |
||
567 | col = tonumber(col); |
||
568 | end |
||
569 | if ( ( col >= AIOB_COLUMNS_MIN ) and ( col <= AIOB_COLUMNS_MAX ) ) then |
||
570 | AIOBColumns = col; |
||
571 | bankPlayer.Columns = AIOBColumns; |
||
572 | AIOBFrame_UpdateLook(getglobal("AIOBFrame"), AIOB_GetBagsTotalSlots()); |
||
573 | end |
||
574 | end |
||
575 | |||
576 | function AIOBFrame_GetAppropriateHeight(rows) |
||
577 | local height = AIOB_BASE_HEIGHT + ( AIOB_ROW_HEIGHT * (AIOBBagView - 1 + rows )); |
||
578 | if AIOBShowPlayers == 0 and AIOBGraphics == 0 then |
||
579 | height = height - AIOB_ROW_HEIGHT; |
||
580 | end |
||
581 | return height; |
||
582 | end |
||
583 | |||
584 | function AIOBFrame_GetAppropriateWidth(cols) |
||
585 | return AIOB_BASE_WIDTH + ( AIOB_COL_WIDTH * cols ); |
||
586 | end |
||
587 | |||
588 | function AIOBTitle_Update() |
||
589 | local i, j, totalSlots, takenSlots = 0, 0, 0, 0; |
||
590 | totalSlots = AIOB_GetBagsTotalSlots(); |
||
591 | -- Need to calculate Free slots. |
||
592 | if bankPlayer and bankPlayer["Bank"] then |
||
593 | for i = 1, 24 do |
||
594 | if bankPlayer["Bank"][i] then |
||
595 | takenSlots = takenSlots + 1; |
||
596 | end |
||
597 | end |
||
598 | for i = 5, 10 do |
||
599 | if bankPlayer["Bag"..i] and bankPlayer["Bag"..i]["s"] then |
||
600 | for j = 1, bankPlayer["Bag"..i]["s"] do |
||
601 | if bankPlayer["Bag"..i][j] then |
||
602 | takenSlots = takenSlots + 1; |
||
603 | end |
||
604 | end |
||
605 | end |
||
606 | end |
||
607 | end |
||
608 | |||
609 | if ( bankPlayerName ) then |
||
610 | local playername = AIOB_Split(bankPlayerName, "|"); |
||
611 | if ( AIOBColumns >= 9 ) then |
||
612 | AIOBFrameName:SetText(format(AIOB_FRAME_PLAYERANDREGION, playername[1], playername[2])); |
||
613 | else |
||
614 | AIOBFrameName:SetText(format(AIOB_FRAME_PLAYERONLY, playername[1])); |
||
615 | end |
||
616 | AIOBFrameName:SetTextColor(1.0, 1.0, 1.0); |
||
617 | end |
||
618 | AIOBFrameSlots:SetText(format(AIOB_FRAME_SLOTS, (totalSlots-takenSlots), (totalSlots))); |
||
619 | end |
||
620 | |||
621 | function AIOB_UpdateTotalMoney() |
||
622 | local totalMoney = 0; |
||
623 | for key, value in AIOBProfile do |
||
624 | local thisRealmPlayers = AIOB_Split(key, "|")[2]; |
||
625 | if AIOBAllRealms == 1 or thisRealmPlayers == AIOB_Trim(GetCVar("realmName")) then |
||
626 | if ( AIOBProfile[key].money ) then |
||
627 | totalMoney = totalMoney + AIOBProfile[key].money; |
||
628 | end |
||
629 | end |
||
630 | end |
||
631 | if AIOBColumns < 8 then |
||
632 | totalMoney = math.floor(totalMoney / 10000) * 10000; |
||
633 | end |
||
634 | MoneyFrame_Update("AIOB_MoneyFrameTotal", totalMoney); |
||
635 | end |
||
636 | |||
637 | function AIOB_UpdateBagCost(bags) |
||
638 | if not bags then |
||
639 | bags=0; |
||
640 | end |
||
641 | if bags < 6 then |
||
642 | AIOBFramePurchaseInfo:Show(); |
||
643 | local cost = AIOB_GetBankSlotCost(bags); |
||
644 | MoneyFrame_Update("AIOBFrameDetailMoneyFrame", cost); |
||
645 | if ( bankPlayer and bankPlayer["money"] and bankPlayer["money"] >= cost ) then |
||
646 | SetMoneyFrameColor("AIOBFrameDetailMoneyFrame", 1.0, 1.0, 1.0); |
||
647 | else |
||
648 | SetMoneyFrameColor("AIOBFrameDetailMoneyFrame", 1.0, 0.1, 0.1) |
||
649 | end |
||
650 | else |
||
651 | -- Hide frame |
||
652 | AIOBFramePurchaseInfo:Hide(); |
||
653 | end |
||
654 | end |
||
655 | |||
656 | function AIOBFrame_UpdateLookIfNeeded() |
||
657 | local slots = AIOB_GetBagsTotalSlots(); |
||
658 | if ( ( not AIOBFrame.size ) or ( slots ~= AIOBFrame.size ) ) then |
||
659 | AIOBFrame_UpdateLook(getglobal("AIOBFrame"), slots); |
||
660 | end |
||
661 | end |
||
662 | |||
663 | function AIOBFrame_UpdateLook(frame, frameSize) |
||
664 | frame.size = frameSize; |
||
665 | local name = frame:GetName(); |
||
666 | local columns = AIOBColumns; |
||
667 | |||
668 | local rows = ceil(frame.size / columns); |
||
669 | local height = AIOBFrame_GetAppropriateHeight(rows); |
||
670 | frame:SetHeight(height); |
||
671 | |||
672 | local width = AIOBFrame_GetAppropriateWidth(columns); |
||
673 | frame:SetWidth(width); |
||
674 | |||
675 | AIOBTitle_Update(); |
||
676 | if AIOBShowPlayers ==1 then |
||
677 | AIOBDropDown:Show(); |
||
678 | AIOB_AllRealms_Check:Show(); |
||
679 | --MYINVENTORY_BASE_HEIGHT = MYINVENTORY_BASE_HEIGHT - MYINVENTORY_ITEM_OFFSET_Y; |
||
680 | else |
||
681 | AIOBDropDown:Hide(); |
||
682 | AIOB_AllRealms_Check:Hide(); |
||
683 | end |
||
684 | for j=5,10 do |
||
685 | local bagButton=getglobal("AIOBFrameBag"..j); |
||
686 | bagButton:ClearAllPoints(); |
||
687 | if j == 5 then |
||
688 | bagButton:SetPoint("TOPLEFT", "AIOBBagButtonsBar", "TOPLEFT", 0, 0); |
||
689 | else |
||
690 | bagButton:SetPoint("TOPLEFT", "AIOBFrameBag"..(j-1), "TOPLEFT", AIOB_ITEM_OFFSET_X, 0); |
||
691 | end |
||
692 | bagButton:Show(); |
||
693 | end |
||
694 | local First_Y; |
||
695 | First_Y = AIOB_FIRST_ITEM_OFFSET_Y; |
||
696 | if AIOBBagView == 1 then |
||
697 | First_Y = AIOB_FIRST_ITEM_OFFSET_Y + AIOB_ITEM_OFFSET_Y; |
||
698 | AIOBBagButtonsBar:Show(); |
||
699 | else |
||
700 | First_Y = AIOB_FIRST_ITEM_OFFSET_Y; |
||
701 | AIOBBagButtonsBar:Hide(); |
||
702 | end |
||
703 | if (AIOBShowPlayers == 0 and AIOBGraphics == 0 ) then |
||
704 | AIOB_DEBUG("move up"); |
||
705 | First_Y = First_Y - AIOB_ITEM_OFFSET_Y; |
||
706 | AIOBBagButtonsBar:ClearAllPoints(); |
||
707 | AIOBBagButtonsBar:SetPoint("TOP", "AIOBFrame", "TOP", 0, -28); |
||
708 | else |
||
709 | AIOBBagButtonsBar:ClearAllPoints(); |
||
710 | AIOBBagButtonsBar:SetPoint("TOP", "AIOBFrame", "TOP", 0, -28-39); |
||
711 | |||
712 | end |
||
713 | for j=1, frame.size, 1 do |
||
714 | local itemButton = getglobal(name.."Item"..j); |
||
715 | -- Set first button |
||
716 | itemButton:ClearAllPoints(); |
||
717 | if ( j == 1 ) then |
||
718 | itemButton:SetPoint("TOPLEFT", name, "TOPLEFT", AIOB_FIRST_ITEM_OFFSET_X, First_Y); |
||
719 | else |
||
720 | if ( mod((j-1), columns) == 0 ) then |
||
721 | itemButton:SetPoint("TOPLEFT", name.."Item"..(j - columns), "TOPLEFT", 0, AIOB_ITEM_OFFSET_Y); |
||
722 | else |
||
723 | itemButton:SetPoint("TOPLEFT", name.."Item"..(j - 1), "TOPLEFT", AIOB_ITEM_OFFSET_X, 0); |
||
724 | end |
||
725 | end |
||
726 | |||
727 | itemButton.readable = readable; |
||
728 | itemButton:Show(); |
||
729 | end |
||
730 | local button = nil; |
||
731 | for i = frame.size+1, AIOB_MAX_ID do |
||
732 | button = getglobal("AIOBFrameItem"..i); |
||
733 | if ( button ) then |
||
734 | button:Hide(); |
||
735 | end |
||
736 | end |
||
737 | AIOBFrame_PopulateFrame(); |
||
738 | end |
||
739 | |||
740 | |||
741 | function AIOB_GetTooltipData() |
||
742 | local soulbound = nil; |
||
743 | local madeBy = nil; |
||
744 | local field; |
||
745 | local left, right; |
||
746 | |||
747 | for index = 1, 15, 1 do |
||
748 | field = getglobal("AIOBHiddenTooltipTextLeft"..index); |
||
749 | if( field and field:IsVisible() ) then |
||
750 | left = field:GetText(); |
||
751 | else |
||
752 | left = ""; |
||
753 | end |
||
754 | field = getglobal("AIOBHiddenTooltipTextRight"..index); |
||
755 | if( field and field:IsVisible() ) then |
||
756 | right = field:GetText(); |
||
757 | else |
||
758 | right = ""; |
||
759 | end |
||
760 | if ( string.find(left, ITEM_SOULBOUND) ) then |
||
761 | soulbound = 1; |
||
762 | end |
||
763 | local iStart, iEnd, val1 = string.find(left, "<Made by (.+)>"); |
||
764 | if (val1) then |
||
765 | madeBy = val1; |
||
766 | end |
||
767 | end |
||
768 | return soulbound, madeBy; |
||
769 | end |
||
770 | |||
771 | function AIOBFrame_SaveBagInfo(currPlayer, bagIndex, bagName) |
||
772 | if bagName=="Bank" then |
||
773 | return 24; |
||
774 | end |
||
775 | local bagNum_Slots = GetContainerNumSlots(bagIndex); |
||
776 | local bagNum_ID = BankButtonIDToInvSlotID(bagIndex, 1); |
||
777 | local itemLink = GetInventoryItemLink("player", bagNum_ID); |
||
778 | local texture = GetInventoryItemTexture("player", bagNum_ID); |
||
779 | local hasCooldown, repairCost = AIOBHiddenTooltip:SetInventoryItem("player", bagNum_ID); |
||
780 | local soulbound, madeBy = AIOB_GetTooltipData(); |
||
781 | if (itemLink) then |
||
782 | currPlayer[bagName]= {}; |
||
783 | AIOB_SaveItemData(currPlayer[bagName], itemLink, strsub(texture,17), bagNum_Slots, _ , _ , soulbound, madeBy, _); |
||
784 | return bagNum_Slots; |
||
785 | else |
||
786 | currPlayer[bagName] = nil; |
||
787 | return 0; |
||
788 | end |
||
789 | end |
||
790 | function AIOBSaveBagItem(currPlayer, bagNewIndex, itemIndex, bagName) |
||
791 | local itemLink = GetContainerItemLink(bagNewIndex, itemIndex); |
||
792 | local texture, itemCount, _, itemQuality = GetContainerItemInfo(bagNewIndex, itemIndex); |
||
793 | local hasCooldown, repairCost; |
||
794 | if bagNewIndex == BANK_CONTAINER then |
||
795 | local newIndex = 39 + itemIndex; |
||
796 | hasCooldown, repairCost = AIOBHiddenTooltip:SetInventoryItem("player", newIndex); |
||
797 | else |
||
798 | hasCooldown, repairCost = AIOBHiddenTooltip:SetBagItem(bagNewIndex, itemIndex); |
||
799 | end |
||
800 | local start, duration, enable = GetContainerItemCooldown(bagNewIndex, itemIndex); |
||
801 | local soulbound, madeBy = AIOB_GetTooltipData(); |
||
802 | local cooldown; |
||
803 | if hasCooldown and enable > 0 then |
||
804 | cooldown = { |
||
805 | ["s"] = start, |
||
806 | ["d"] = duration, |
||
807 | ["e"] = enable |
||
808 | }; |
||
809 | end |
||
810 | if (itemLink) then |
||
811 | currPlayer[bagName][itemIndex] = {}; |
||
812 | AIOB_SaveItemData(currPlayer[bagName][itemIndex], itemLink, strsub(texture,17), _, itemCount, itemQuality, soulbound, madeBy, cooldown); |
||
813 | else |
||
814 | currPlayer[bagName][itemIndex] = nil; |
||
815 | end |
||
816 | end |
||
817 | function AIOB_SaveItemData(AIOBItem, itemLink, texture, Slots, Count, Quality, soulbound, madeBy, Cooldown) |
||
818 | local myColor, myLink, name; |
||
819 | local _,_, myColor, myLink, name = strfind(itemLink, "|c(%x+)|Hitem:(%d+:%d+:%d+:%d+)|h%[(.-)%]|h|r"); |
||
820 | AIOBItem["name"] = name; |
||
821 | AIOBItem["i"] = texture; |
||
822 | AIOBItem["s"] = Slots; |
||
823 | AIOBItem["c"] = Count; |
||
824 | AIOBItem["q"] = Quality; |
||
825 | if (ItemsMatrix_GetLink or LootLink_GetLink) then |
||
826 | AIOBItem["color"] = nil; |
||
827 | AIOBItem["item"] = nil; |
||
828 | else |
||
829 | AIOBItem["color"] = myColor; |
||
830 | AIOBItem["item"] = myLink; |
||
831 | end |
||
832 | AIOBItem["sb"] = soulbound; |
||
833 | AIOBItem["m"] = madeBy; |
||
834 | AIOBItem["d"] = Cooldown; |
||
835 | end |
||
836 | |||
837 | function AIOB_SaveMoney() |
||
838 | if ( PlayerName ) then |
||
839 | if ( AIOBProfile[PlayerName] ) then |
||
840 | AIOBProfile[PlayerName]["money"] = GetMoney(); |
||
841 | end |
||
842 | if ( AIOB_MoneyFrame:IsVisible() ) then |
||
843 | MoneyFrame_Update("AIOB_MoneyFrame", bankPlayer.money); |
||
844 | AIOB_UpdateTotalMoney(); |
||
845 | end |
||
846 | end |
||
847 | end |
||
848 | |||
849 | function AIOBFrame_SaveItems() |
||
850 | local currPlayer=AIOBProfile[PlayerName]; |
||
851 | if currPlayer == nil then |
||
852 | return; |
||
853 | end |
||
854 | if not AtBank then |
||
855 | return; |
||
856 | end |
||
857 | AIOB_DEBUG("SaveItems"); |
||
858 | currPlayer.Bags, _ = GetNumBankSlots(); |
||
859 | local bagName, bagMaxIndex, bagNewIndex; |
||
860 | for bagNum = 0, currPlayer.Bags do |
||
861 | if bagNum == 0 then -- Is it the bank? |
||
862 | bagName = "Bank"; |
||
863 | bagNewIndex = BANK_CONTAINER; |
||
864 | else -- It's in a bag slot |
||
865 | bagName = "Bag"..(4+bagNum); |
||
866 | bagNewIndex = (4+bagNum); |
||
867 | end |
||
868 | if (not currPlayer[bagName]) then |
||
869 | AIOB_DEBUG("Clearing "..bagName); |
||
870 | currPlayer[bagName] = {} ; |
||
871 | end |
||
872 | bagMaxIndex = AIOBFrame_SaveBagInfo(currPlayer, bagNewIndex, bagName); |
||
873 | for itemIndex = 1, bagMaxIndex do |
||
874 | AIOBSaveBagItem(currPlayer, bagNewIndex, itemIndex, bagName); |
||
875 | end |
||
876 | end |
||
877 | for bagNum = 5+currPlayer.Bags, 10 do |
||
878 | currPlayer["Bag"..bagNum] = nil; |
||
879 | end |
||
880 | AIOB_SaveMoney(); |
||
881 | AIOBFrame_PopulateFrame(); |
||
882 | end |
||
883 | |||
884 | |||
885 | function AIOBFrame_PopulateFrame() |
||
886 | local texture, itemButton, itemCount, itemQuality; |
||
887 | local bagName, bagMaxIndex, bagNewIndex; |
||
888 | local buttonIndex = 1; |
||
889 | local BlankTexture; |
||
890 | local maxBags; |
||
891 | if not bankPlayer then |
||
892 | return; |
||
893 | end |
||
894 | if bankPlayer.Bags then |
||
895 | maxBags = bankPlayer.Bags; |
||
896 | else |
||
897 | maxBags = 0; |
||
898 | end |
||
899 | AIOB_UpdateBagCost(maxBags); |
||
900 | _, BlankTexture = GetInventorySlotInfo("Bag0Slot"); |
||
901 | for bagNum = 0, maxBags do |
||
902 | if bagNum == 0 then -- Is it the bank? |
||
903 | bagName = "Bank"; |
||
904 | bagNewIndex = BANK_CONTAINER; |
||
905 | bagMaxIndex = 24; |
||
906 | else |
||
907 | bagName = "Bag"..(4+bagNum); |
||
908 | bagNewIndex = (4+bagNum); |
||
909 | local bagButton = getglobal("AIOBFrameBag"..(bagNewIndex)); |
||
910 | SetItemButtonNormalTextureVertexColor(bagButton, 1.0,1.0,1.0); |
||
911 | SetItemButtonTextureVertexColor(bagButton, 1.0,1.0,1.0); |
||
912 | if bankPlayer[bagName] and bankPlayer[bagName]["s"] then |
||
913 | bagMaxIndex = bankPlayer[bagName]["s"]; |
||
914 | SetItemButtonTexture(bagButton, "Interface\\Icons\\"..bankPlayer[bagName]["i"]); |
||
915 | else |
||
916 | bagMaxIndex = 0; |
||
917 | SetItemButtonTexture(bagButton, BlankTexture); |
||
918 | end |
||
919 | end |
||
920 | for itemIndex = 1,bagMaxIndex do |
||
921 | itemButton = getglobal("AIOBFrameItem"..buttonIndex); |
||
922 | buttonIndex = buttonIndex + 1; |
||
923 | if(bankPlayer and bankPlayer[bagName] and bankPlayer[bagName][itemIndex]) then |
||
924 | texture = "Interface\\Icons\\"..bankPlayer[bagName][itemIndex]["i"]; |
||
925 | itemCount = bankPlayer[bagName][itemIndex]["c"]; |
||
926 | else |
||
927 | texture = nil; |
||
928 | itemCount = 0; |
||
929 | end |
||
930 | if(itemButton) then |
||
931 | local locked; |
||
932 | if AtBank then |
||
933 | texture, itemCount, locked, itemQuality, itemReadable = GetContainerItemInfo(bagNewIndex, itemIndex); |
||
934 | AIOBFrame_UpdateCooldown(itemButton); |
||
935 | else |
||
936 | locked = nil; |
||
937 | end |
||
938 | if bankPlayer[bagName] and bankPlayer[bagName][itemIndex] and bankPlayer[bagName][itemIndex]["d"] then |
||
939 | local cooldown = getglobal(itemButton:GetName().."Cooldown"); |
||
940 | local cooldownInfo = bankPlayer[bagName][itemIndex]["d"]; |
||
941 | if cooldownInfo and cooldownInfo["e"] then |
||
942 | local start, duration, enable = cooldownInfo["s"], cooldownInfo["d"], cooldownInfo["e"]; |
||
943 | if duration > 0 then |
||
944 | CooldownFrame_SetTimer(cooldown, start, duration, enable); |
||
945 | else |
||
946 | cooldown:Hide(); |
||
947 | end |
||
948 | else |
||
949 | cooldown:Hide(); |
||
950 | end |
||
951 | end |
||
952 | if bankPlayer[bagName] and bankPlayer[bagName][itemIndex] and bankPlayer[bagName][itemIndex]["q"] then |
||
953 | AIOB_UpdateBorder(itemButton, bankPlayer[bagName][itemIndex]["q"]); |
||
954 | else |
||
955 | AIOB_UpdateBorder(itemButton, itemQuality); |
||
956 | end |
||
957 | SetItemButtonTexture(itemButton, texture); |
||
958 | SetItemButtonCount(itemButton, itemCount); |
||
959 | SetItemButtonDesaturated(itemButton, locked, 0.5, 0.5, 0.5); |
||
960 | itemButton.bagIndex = bagNewIndex; |
||
961 | itemButton.itemIndex= itemIndex; |
||
962 | end |
||
963 | end |
||
964 | end |
||
965 | for bagNum = 5+maxBags, 10 do |
||
966 | local bagButton = getglobal("AIOBFrameBag"..(bagNum)); |
||
967 | SetItemButtonNormalTextureVertexColor(bagButton, 1.0,0.1,0.1); |
||
968 | SetItemButtonTextureVertexColor(bagButton, 1.0,0.1,0.1); |
||
969 | SetItemButtonTexture(bagButton, BlankTexture); |
||
970 | end |
||
971 | if ( bankPlayer and bankPlayer["money"] ) then |
||
972 | MoneyFrame_Update("AIOB_MoneyFrame", bankPlayer["money"]); |
||
973 | AIOB_MoneyFrame:Show(); |
||
974 | else |
||
975 | AIOB_MoneyFrame:Hide(); |
||
976 | end |
||
977 | AIOB_UpdateTotalMoney(); |
||
978 | AIOBFrame_UpdateLookIfNeeded(); |
||
979 | end |
||
980 | |||
981 | |||
982 | |||
983 | |||
984 | function AIOB_UpdateBorder(itemButton, itemQuality) |
||
985 | local color = { |
||
986 | ["r"]=0.5, |
||
987 | ["g"]=0.5, |
||
988 | ["b"]=0.5 }; |
||
989 | |||
990 | if ( itemQuality ) then |
||
991 | if itemQuality == -1 then |
||
992 | color = { |
||
993 | ["r"]=1, |
||
994 | ["g"]=1, |
||
995 | ["b"]=1 } -- white |
||
996 | elseif itemQuality == 1 then |
||
997 | color = { |
||
998 | ["r"]=0.5, |
||
999 | ["g"]=0.5, |
||
1000 | ["b"]=0.5 } -- grey |
||
1001 | elseif itemQuality == 2 then |
||
1002 | color = { |
||
1003 | ["r"]=0.0, |
||
1004 | ["g"]=1.0, |
||
1005 | ["b"]=0.0 } -- green |
||
1006 | elseif itemQuality == 3 then |
||
1007 | color = { |
||
1008 | ["r"]=0.5, |
||
1009 | ["g"]=0.5, |
||
1010 | ["b"]=1.0 } -- blue |
||
1011 | |||
1012 | elseif itemQuality == 4 then |
||
1013 | color = { |
||
1014 | ["r"]=0.7, |
||
1015 | ["g"]=0.1, |
||
1016 | ["b"]=1.0 } -- purple |
||
1017 | else |
||
1018 | color = { |
||
1019 | ["r"]=0.0, |
||
1020 | ["g"]=0.0, |
||
1021 | ["b"]=0.0 } -- black |
||
1022 | end |
||
1023 | end |
||
1024 | SetItemButtonNormalTextureVertexColor(itemButton, color.r, color.g, color.b); |
||
1025 | end |
||
1026 | |||
1027 | |||
1028 | |||
1029 | |||
1030 | -- == Viewing other peoples banks == |
||
1031 | function AIOB_UserDropDown_GetValue() |
||
1032 | if ( bankPlayerName ) then |
||
1033 | return bankPlayerName; |
||
1034 | else |
||
1035 | return (UnitName("player").."|"..AIOB_Trim(GetCVar("realmName"))); |
||
1036 | end |
||
1037 | end |
||
1038 | function AIOB_UserDropDown_OnLoad() |
||
1039 | UIDropDownMenu_Initialize(this, AIOB_UserDropDown_Initialize); |
||
1040 | UIDropDownMenu_SetSelectedValue(this, AIOB_UserDropDown_GetValue()); |
||
1041 | AIOBDropDown.tooltip = "You are viewing this player's bank contents."; |
||
1042 | UIDropDownMenu_SetWidth(140, AIOBDropDown); |
||
1043 | OptionsFrame_EnableDropDown(AIOBDropDown); |
||
1044 | end |
||
1045 | |||
1046 | function AIOB_UserDropDown_OnClick() |
||
1047 | if ( not bankPlayer ) then |
||
1048 | return; |
||
1049 | end |
||
1050 | if AtBank then |
||
1051 | CloseBankFrame(); |
||
1052 | OpenAIOBFrame(); |
||
1053 | end |
||
1054 | -- UIDropDownMenu_SetSelectedValue(AIOBDropDown, this.value); |
||
1055 | if ( this.value ) then |
||
1056 | bankPlayer = AIOB_GetPlayer(this.value); |
||
1057 | end |
||
1058 | AIOBFrame_PopulateFrame(); |
||
1059 | end |
||
1060 | |||
1061 | function AIOB_UserDropDown_Initialize() |
||
1062 | local selectedValue = UIDropDownMenu_GetSelectedValue(AIOBDropDown); |
||
1063 | local info; |
||
1064 | for key, value in AIOBProfile do |
||
1065 | local thisRealmPlayers = AIOB_Split(key, "|")[2]; |
||
1066 | if ( table.getn(AIOBProfile[key]) > 0 or AIOBProfile[key].money ) then |
||
1067 | if (AIOBAllRealms == 1 or thisRealmPlayers == AIOB_Trim(GetCVar("realmName")) ) then |
||
1068 | info = {}; |
||
1069 | info.text = AIOB_Split(key,"|")[1].." of "..AIOB_Split(key,"|")[2]; |
||
1070 | info.value = key; |
||
1071 | info.func = AIOB_UserDropDown_OnClick; |
||
1072 | if ( selectedValue == info.value ) then |
||
1073 | info.checked = 1; |
||
1074 | else |
||
1075 | info.checked = nil; |
||
1076 | end |
||
1077 | UIDropDownMenu_AddButton(info); |
||
1078 | end |
||
1079 | end |
||
1080 | end |
||
1081 | end |
||
1082 | |||
1083 | function AIOB_ShowAllRealms_Check_OnClick() |
||
1084 | if ( AIOBAllRealms == 0 ) then |
||
1085 | AIOBAllRealms = 1; |
||
1086 | else |
||
1087 | AIOBAllRealms = 0; |
||
1088 | end |
||
1089 | AIOB_UpdateTotalMoney(); |
||
1090 | end |
||
1091 | |||
1092 | function AIOB_ShowAllRealms_Check_OnShow() |
||
1093 | if ( AIOBAllRealms == 1 ) then |
||
1094 | this.checked = 1; |
||
1095 | else |
||
1096 | this.checked = nil; |
||
1097 | end |
||
1098 | OptionsFrame_EnableCheckBox(this); |
||
1099 | this:SetChecked(this.checked); |
||
1100 | this.tooltipText = "Check to show all saved characters, regardless of realm."; |
||
1101 | end |
||
1102 | |||
1103 | |||
1104 | -- === Toggle Functions === |
||
1105 | -- All toggling of options |
||
1106 | function ToggleAIOBFrame() |
||
1107 | if ( AIOBFrame:IsVisible() ) then |
||
1108 | CloseAIOBFrame(); |
||
1109 | else |
||
1110 | OpenAIOBFrame(); |
||
1111 | end |
||
1112 | end |
||
1113 | function CloseAIOBFrame() |
||
1114 | if AtBank then |
||
1115 | CloseBankFrame(); |
||
1116 | end |
||
1117 | if ( AIOBFrame:IsVisible() ) then |
||
1118 | HideUIPanel(AIOBFrame); |
||
1119 | end |
||
1120 | end |
||
1121 | function OpenAIOBFrame() |
||
1122 | AIOBFrame_UpdateLookIfNeeded(); |
||
1123 | ShowUIPanel(AIOBFrame, 1); |
||
1124 | end |
||
1125 | |||
1126 | function AIOB_Toggle_Option(option, value, quiet) |
||
1127 | if value == nil then |
||
1128 | if getglobal("AIOB"..option) == 1 then |
||
1129 | value = 0; |
||
1130 | else |
||
1131 | value = 1; |
||
1132 | end |
||
1133 | end |
||
1134 | setglobal("AIOB"..option, value); |
||
1135 | AIOBProfile[PlayerName][option] = value; |
||
1136 | if not quiet then |
||
1137 | local chat_message; |
||
1138 | local globalName = "AIOB_CHAT_"..string.upper(option); |
||
1139 | if value == 0 then |
||
1140 | globalName = globalName.."OFF"; |
||
1141 | else |
||
1142 | globalName = globalName.."ON"; |
||
1143 | end |
||
1144 | chat_message = getglobal(globalName); |
||
1145 | if ( chat_message ) then |
||
1146 | AIOB_Print(chat_message); |
||
1147 | else |
||
1148 | AIOB_DEBUG("ERROR: No global "..globalName); |
||
1149 | end |
||
1150 | end |
||
1151 | if option == "ReplaceBank" then |
||
1152 | AIOB_SetReplaceBank(); |
||
1153 | elseif option == "ShowPlayers" or option == "BagView" then |
||
1154 | AIOBFrame_UpdateLook(getglobal("AIOBFrame"),AIOB_GetBagsTotalSlots()); |
||
1155 | elseif option == "Graphics" or option == "Background" then |
||
1156 | AIOB_SetGraphics(); |
||
1157 | AIOBFrame_UpdateLook(getglobal("AIOBFrame"),AIOB_GetBagsTotalSlots()); |
||
1158 | elseif option == "Freeze" then |
||
1159 | AIOB_SetFreeze(); |
||
1160 | end |
||
1161 | end |
||
1162 | function AIOB_SetGraphics() |
||
1163 | if AIOBGraphics == 1 then |
||
1164 | AIOBFrame:SetBackdropColor(0,0,0,0); |
||
1165 | AIOBFrame:SetBackdropBorderColor(0,0,0,0); |
||
1166 | |||
1167 | AIOBFramePortrait:Show(); |
||
1168 | AIOBFrameTextureTopLeft:Show(); |
||
1169 | AIOBFrameTextureTopCenter:Show(); |
||
1170 | AIOBFrameTextureTopRight:Show(); |
||
1171 | AIOBFrameTextureLeft:Show(); |
||
1172 | AIOBFrameTextureCenter:Show(); |
||
1173 | AIOBFrameTextureRight:Show(); |
||
1174 | AIOBFrameTextureBottomLeft:Show(); |
||
1175 | AIOBFrameTextureBottomCenter:Show(); |
||
1176 | AIOBFrameTextureBottomRight:Show(); |
||
1177 | AIOBFrameName:ClearAllPoints(); |
||
1178 | AIOBFrameName:SetPoint("TOPLEFT", "AIOBFrame", "TOPLEFT", 70, -8); |
||
1179 | AIOBFrameCloseButton:ClearAllPoints(); |
||
1180 | AIOBFrameCloseButton:SetPoint("TOPRIGHT", "AIOBFrame", "TOPRIGHT", 10, 0); |
||
1181 | else |
||
1182 | if AIOBBackground==1 then |
||
1183 | AIOBFrame:SetBackdropColor(0,0,0,0.7); |
||
1184 | AIOBFrame:SetBackdropBorderColor(1,1,1,0.7); |
||
1185 | else |
||
1186 | AIOBFrame:SetBackdropColor(0,0,0,0); |
||
1187 | AIOBFrame:SetBackdropBorderColor(1,1,1,0); |
||
1188 | end |
||
1189 | |||
1190 | AIOBFramePortrait:Hide(); |
||
1191 | AIOBFrameTextureTopLeft:Hide(); |
||
1192 | AIOBFrameTextureTopCenter:Hide(); |
||
1193 | AIOBFrameTextureTopRight:Hide(); |
||
1194 | AIOBFrameTextureLeft:Hide(); |
||
1195 | AIOBFrameTextureCenter:Hide(); |
||
1196 | AIOBFrameTextureRight:Hide(); |
||
1197 | AIOBFrameTextureBottomLeft:Hide(); |
||
1198 | AIOBFrameTextureBottomCenter:Hide(); |
||
1199 | AIOBFrameTextureBottomRight:Hide(); |
||
1200 | AIOBFrameName:ClearAllPoints(); |
||
1201 | AIOBFrameName:SetPoint("TOPLEFT", "AIOBFrame", "TOPLEFT", 5, -6); |
||
1202 | AIOBFrameCloseButton:ClearAllPoints(); |
||
1203 | AIOBFrameCloseButton:SetPoint("TOPRIGHT", "AIOBFrame", "TOPRIGHT", 2, 2); |
||
1204 | end |
||
1205 | end |
||
1206 | function AIOB_SetFreeze() |
||
1207 | if AIOBFreeze == 1 then |
||
1208 | AIOBFreezeNormalTexture:SetTexture("Interface\\AddOns\\AllInOneInventory\\Skin\\LockButton-Locked-Up"); |
||
1209 | else |
||
1210 | AIOBFreezeNormalTexture:SetTexture("Interface\\AddOns\\AllInOneInventory\\Skin\\LockButton-Unlocked-Up"); |
||
1211 | end |
||
1212 | end |
||
1213 | |||
1214 | -- SetReplaceBank: Sets if AIOB replaces the official Bank frame |
||
1215 | -- Unhooks the Official blizzard frome from the opened and closed events |
||
1216 | function AIOB_SetReplaceBank() |
||
1217 | if BankFrame_Saved == nil then |
||
1218 | BankFrame_Saved = getglobal("BankFrame"); |
||
1219 | end |
||
1220 | if ( AIOBReplaceBank == 0 ) then |
||
1221 | BankFrame_Saved:RegisterEvent("BANKFRAME_OPENED"); |
||
1222 | BankFrame_Saved:RegisterEvent("BANKFRAME_CLOSED"); |
||
1223 | setglobal("BankFrame", BankFrame_Saved); |
||
1224 | BankFrame_Saved = nil; |
||
1225 | else |
||
1226 | if BankFrame_Saved:IsVisible() then |
||
1227 | BankFrame_Saved:Hide(); |
||
1228 | end |
||
1229 | BankFrame_Saved:UnregisterEvent("BANKFRAME_OPENED"); |
||
1230 | BankFrame_Saved:UnregisterEvent("BANKFRAME_CLOSED"); |
||
1231 | setglobal("BankFrame", AIOBFrameAtBankText); |
||
1232 | end |
||
1233 | end |
||
1234 | -- == End Toggle Functions == |
||
1235 | |||
1236 | -- Get Link and Get Hyperlink - maintain independance. |
||
1237 | function AIOB_GetLink(item) |
||
1238 | if item and item.color and item.item and item.name then |
||
1239 | local link = "|c"..item.color.."|H"..AIOB_GetHyperlink(item).."|h["..item.name.."]|h|r"; |
||
1240 | return link; |
||
1241 | end |
||
1242 | return nil; |
||
1243 | end |
||
1244 | |||
1245 | function AIOB_GetHyperlink(item) |
||
1246 | if item and item.item then |
||
1247 | local link = string.gsub(item.item, "(%d+):(%d+):(%d+):(%d+)", "%1:0:%3:%4"); |
||
1248 | return "item:"..link; |
||
1249 | end |
||
1250 | return nil; |
||
1251 | end |