vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local SlotIdText = {
2 [1] = "HeadSlot",
3 [2] = "NeckSlot",
4 [3] = "ShoulderSlot",
5 [4] = "ShirtSlot",
6 [5] = "ChestSlot",
7 [6] = "WaistSlot",
8 [7] = "LegsSlot",
9 [8] = "FeetSlot",
10 [9] = "WristSlot",
11 [10] = "HandsSlot",
12 [11] = "Finger0Slot",
13 [12] = "Finger1Slot",
14 [13] = "Trinket0Slot",
15 [14] = "Trinket1Slot",
16 [15] = "BackSlot",
17 [16] = "MainHandSlot",
18 [17] = "SecondaryHandSlot",
19 [18] = "RangedSlot",
20 [19] = "TabardSlot",
21 };
22 -- [19] = "AmmoSlot",
23  
24 GuildAdsInspect = {};
25  
26 local function DEBUG_MSG(msg)
27 if (GUILDADS_DEBUG)
28 then
29 ChatFrame1:AddMessage(msg, 0.9, 0.9, 0.7);
30 end
31 end
32  
33 function GuildAdsInspectItemSlotButton_OnClick(button)
34 if ( button == "LeftButton" ) then
35 if ( IsShiftKeyDown() ) then
36 if ( ChatFrameEditBox:IsVisible() ) then
37 ChatFrameEditBox:Insert(GuildAdsInspect[this:GetID()]);
38 end
39 end
40 end
41 end
42  
43 function GuildAdsInspectItemSlotButton_OnEnter()
44 if (GuildAdsInspect[this:GetID()] ~= nil) then
45 GuildAdsInspect_SetTooltipItem(GuildAdsInspect[this:GetID()]);
46 end
47 end
48  
49 function GuildAdsInspectItemSlotButton_OnLeave()
50 GameTooltip:Hide();
51 end
52  
53 function GuildAdsInspect_SetAuthor(author, title)
54 GuildAdsInspectName:SetText(author);
55 GuildAdsInspectTitle:SetText(title);
56 GuildAdsInspectTime:SetText("");
57 GuildAdsInspectAuthor = author;
58 for slot=1,19,1 do
59 GuildAdsInspectItemSlotButton_Update(author, slot, nil, nil, 0);
60 end
61 GuildAdsInspectFrame:Show();
62 end
63  
64 function GuildAdsInspect_SetTime(author, inspectTime)
65 if (author ~= GuildAdsInspectAuthor) then
66 return;
67 end
68 GuildAdsInspectTime:SetText(inspectTime);
69 end
70  
71 function GuildAdsInspectItemSlotButton_OnLoad()
72 local slotName = this:GetName();
73 local id;
74 local textureName;
75 id, textureName = GetInventorySlotInfo(strsub(slotName,16));
76 this:SetID(id);
77 local texture = getglobal(slotName.."IconTexture");
78 texture:SetTexture(textureName);
79 this.backgroundTextureName = textureName;
80 end
81  
82 function GuildAdsInspect_SetTooltipItem(itemRef)
83 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
84 if (itemRef) then
85 GameTooltip:SetHyperlink(itemRef);
86 GuildAds_GameTooltip_AddTT(nil, itemRef, nil, 1);
87 end
88 end
89  
90 function GuildAdsInspectItemSlotButton_Update(author, slot, itemRef, textureName, count)
91 if (author ~= GuildAdsInspectAuthor) then
92 return;
93 end
94 DEBUG_MSG("[GuildAdsInspectItemSlotButton_Update] slot: "..slot);
95 button = getglobal("GuildAdsInspect"..SlotIdText[slot]);
96 if ( textureName ) then
97 SetItemButtonTexture(button, textureName);
98 SetItemButtonCount(button, count);
99 GuildAdsInspect[slot]= itemRef;
100 else
101 SetItemButtonTexture(button, button.backgroundTextureName);
102 SetItemButtonCount(button, 0);
103 GuildAdsInspect[slot] = nil;
104 end
105  
106 if ( GameTooltip:IsOwned(button) ) then
107 if ( textureName ) then
108 GuildAdsInspect_SetTooltipItem(itemRef);
109 else
110 GameTooltip:Hide();
111 end
112 end
113 end
114  
115 function GuildAdsInspectUser(user)
116 -- Init GuildAdsInspect
117 local title = GuildAds_GetPlayerInfo(user);
118 GuildAdsInspect_SetAuthor(user, title);
119 GuildAdsInspect_SetTime(user, "");
120  
121 -- Set inventory to the cache value
122 timeToSet = true;
123 local inventory = GAS_ProfileGetInventory(user);
124 for slot, data in inventory do
125 if (slot == "creationtime") then
126 GuildAdsInspect_SetTime(user, GAS_timeToString(data));
127 else
128 GuildAdsInspectItemSlotButton_Update(user, slot, data.ref, data.texture, data.count);
129 end
130 end
131 -- Send inspect request
132 GAC_SendRequestInspect(user);
133 end