vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --===========================================================================-- |
2 | ---------------------------- LootTracker by PNB ---------------------------- |
||
3 | --===========================================================================-- |
||
4 | -- LootTrackerItemDetailsUI.lua |
||
5 | -- |
||
6 | -- Code behind the item details UI |
||
7 | --===========================================================================-- |
||
8 | |||
9 | |||
10 | ------------------------------------------------------------------------------ |
||
11 | -- SetItem |
||
12 | ------------------------------------------------------------------------------ |
||
13 | |||
14 | function LT_SetItem(item) |
||
15 | |||
16 | LT_DebugMessage(2, string.format("Viewing item %s", item.Name)); |
||
17 | |||
18 | LT_ItemDetails:Show(); |
||
19 | LT_PlayerDetails:Hide(); |
||
20 | LT_KillDetails:Hide(); |
||
21 | LT_SettingsFrame:Hide(); |
||
22 | |||
23 | local qualityColor = LT_QualityColors[tostring(item.Quality)]; |
||
24 | local description = LT_ColorText(item.Name, qualityColor); |
||
25 | |||
26 | LT_Item_DescriptionText:SetText(description); |
||
27 | |||
28 | local value = item.Value; |
||
29 | if (value == nil) then |
||
30 | value = 0; |
||
31 | end |
||
32 | |||
33 | local gold, silver, copper = LT_GetValueByCoinType(value); |
||
34 | |||
35 | LT_GoldEditBox:SetText(gold); |
||
36 | LT_SilverEditBox:SetText(silver); |
||
37 | LT_CopperEditBox:SetText(copper); |
||
38 | |||
39 | LT_ItemDetails.Data = item; |
||
40 | LT_RecipientsList.Data = item; |
||
41 | LT_SourcesList.Data = item; |
||
42 | |||
43 | LT_UpdateGenericScroller(LT_RecipientsList); |
||
44 | LT_UpdateGenericScroller(LT_SourcesList); |
||
45 | |||
46 | end |
||
47 | |||
48 | |||
49 | ------------------------------------------------------------------------------ |
||
50 | -- ItemDetails_SetValue |
||
51 | ------------------------------------------------------------------------------ |
||
52 | |||
53 | function LT_ItemDetails_SetValue() |
||
54 | |||
55 | local gold = tonumber(LT_GoldEditBox:GetText()); |
||
56 | local silver = tonumber(LT_SilverEditBox:GetText()); |
||
57 | local copper = tonumber(LT_CopperEditBox:GetText()); |
||
58 | |||
59 | local value = LT_GetValueFromCoins(gold, silver, copper); |
||
60 | |||
61 | local item = LT_ItemDetails.Data; |
||
62 | |||
63 | LT_DebugMessage(1, string.format("Setting new value on %s: %d", item.Name, value)); |
||
64 | |||
65 | item.Value = value; |
||
66 | |||
67 | end |
||
68 | |||
69 | |||
70 | ------------------------------------------------------------------------------ |
||
71 | -- Sources_GetTotal |
||
72 | ------------------------------------------------------------------------------ |
||
73 | |||
74 | function LT_Sources_GetTotal(scroller) |
||
75 | |||
76 | if (scroller.Data == nil) then |
||
77 | LT_DebugMessage(1, "No item: Unable to get Sources total"); |
||
78 | return 0; |
||
79 | end |
||
80 | |||
81 | if (scroller.Data.Sources == nil) then |
||
82 | return 0; |
||
83 | end |
||
84 | |||
85 | local uniqueCount = 0; |
||
86 | local totalCount = 0; |
||
87 | local totalCountReceived = 0; |
||
88 | foreach(scroller.Data.Sources, function(k,v) |
||
89 | |||
90 | uniqueCount = uniqueCount + 1; |
||
91 | totalCount = totalCount + v; |
||
92 | |||
93 | end); |
||
94 | foreach(scroller.Data.Recipients, function(k,v) |
||
95 | |||
96 | totalCountReceived = totalCountReceived + v; |
||
97 | |||
98 | end); |
||
99 | |||
100 | scroller.TotalCount = totalCountReceived; |
||
101 | scroller.UnknownCount = totalCountReceived - totalCount; |
||
102 | |||
103 | if (totalCount ~= totalCountReceived) then |
||
104 | -- Add one entry for the unknown sources |
||
105 | uniqueCount = uniqueCount + 1; |
||
106 | end |
||
107 | |||
108 | return uniqueCount; |
||
109 | |||
110 | end |
||
111 | |||
112 | ------------------------------------------------------------------------------ |
||
113 | -- Sources_GetItemLabel |
||
114 | ------------------------------------------------------------------------------ |
||
115 | |||
116 | function LT_Sources_GetItemLabel(scroller, index) |
||
117 | |||
118 | if (scroller.Data == nil) then |
||
119 | return "Unknown"; |
||
120 | end |
||
121 | |||
122 | local label, data = LT_GetItemLabel(scroller, scroller.Data.Sources, index, LT_Scroller_GetPercentageLabel); |
||
123 | return label, data; |
||
124 | |||
125 | end |
||
126 | |||
127 | |||
128 | ------------------------------------------------------------------------------ |
||
129 | -- Recipients_GetTotal |
||
130 | ------------------------------------------------------------------------------ |
||
131 | |||
132 | function LT_Recipients_GetTotal(scroller) |
||
133 | |||
134 | if (scroller.Data == nil) then |
||
135 | LT_DebugMessage(1, "No item: Unable to get Recipients total"); |
||
136 | return 0; |
||
137 | end |
||
138 | |||
139 | if (scroller.Data.Recipients == nil) then |
||
140 | LT_DebugMessage(1, "No recipients: Unable to get Recipients total"); |
||
141 | return 0; |
||
142 | end |
||
143 | |||
144 | local uniqueCount = 0; |
||
145 | local totalCount = 0; |
||
146 | foreach(scroller.Data.Recipients, function(k,v) |
||
147 | |||
148 | uniqueCount = uniqueCount + 1; |
||
149 | totalCount = totalCount + v; |
||
150 | |||
151 | end); |
||
152 | |||
153 | scroller.TotalCount = totalCount; |
||
154 | |||
155 | return uniqueCount; |
||
156 | |||
157 | end |
||
158 | |||
159 | ------------------------------------------------------------------------------ |
||
160 | -- Recipients_GetItemLabel |
||
161 | ------------------------------------------------------------------------------ |
||
162 | |||
163 | function LT_Recipients_GetItemLabel(scroller, index) |
||
164 | |||
165 | if (scroller.Data == nil) then |
||
166 | return "Unknown"; |
||
167 | end |
||
168 | |||
169 | local label, data = LT_GetItemLabel(scroller, scroller.Data.Recipients, index, LT_Scroller_GetPercentageLabel); |
||
170 | return label, data; |
||
171 | |||
172 | end |
||
173 | |||
174 | |||
175 | ------------------------------------------------------------------------------ |
||
176 | -- OnItemButtonClicked |
||
177 | ------------------------------------------------------------------------------ |
||
178 | |||
179 | function LT_OnItemButtonClicked(button) |
||
180 | |||
181 | local name = button.Data; |
||
182 | |||
183 | LT_DebugMessage(2, string.format("Clicked %s", name)); |
||
184 | |||
185 | local items = LT_GetItems(); |
||
186 | local item = items[name]; |
||
187 | |||
188 | if (item ~= nil) then |
||
189 | LT_SetItem(item); |
||
190 | end |
||
191 | |||
192 | end |
||
193 | |||
194 | |||
195 | ------------------------------------------------------------------------------ |
||
196 | -- InitializeDropDown |
||
197 | -- TESTING |
||
198 | ------------------------------------------------------------------------------ |
||
199 | |||
200 | function LT_InitializeDropDown() |
||
201 | |||
202 | local info = {}; |
||
203 | info.text = "Test"; |
||
204 | info.func = LT_OnPlayerButtonClicked; |
||
205 | --info.arg1 = value.index; |
||
206 | UIDropDownMenu_AddButton(info); |
||
207 | |||
208 | end |
||
209 | |||
210 |