Mercurial > wow > ouroloot
comparison gui.lua @ 4:05caaf17b3ca
Get history window in a working state again in prep for redoing orders.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Sun, 24 Apr 2011 07:29:01 +0000 |
parents | 2753b9763882 |
children | 7adbc59de8fe |
comparison
equal
deleted
inserted
replaced
3:2753b9763882 | 4:05caaf17b3ca |
---|---|
17 wipe = { ["r"] = 0.3, ["g"] = 0.3, ["b"] = 0.3}, | 17 wipe = { ["r"] = 0.3, ["g"] = 0.3, ["b"] = 0.3}, |
18 kill = { ["r"] = 0.2, ["g"] = 0.2, ["b"] = 0.2}, | 18 kill = { ["r"] = 0.2, ["g"] = 0.2, ["b"] = 0.2}, |
19 time = { ["r"] = 0x0/255, ["g"] = 0x0/255, ["b"] = 1, ["a"] = 0.3}, | 19 time = { ["r"] = 0x0/255, ["g"] = 0x0/255, ["b"] = 1, ["a"] = 0.3}, |
20 } | 20 } |
21 eoi_st_otherrow_bgcolortable[""] = eoi_st_otherrow_bgcolortable["kill"] | 21 eoi_st_otherrow_bgcolortable[""] = eoi_st_otherrow_bgcolortable["kill"] |
22 eoi_st_otherrow_bgcolortable["realm"] = eoi_st_otherrow_bgcolortable["time"] | 22 --eoi_st_otherrow_bgcolortable["realm"] = eoi_st_otherrow_bgcolortable["time"] |
23 local eoi_st_otherrow_bgcolortable_default | 23 local eoi_st_otherrow_bgcolortable_default |
24 local eoi_st_lootrow_col3_colortable = { | 24 local eoi_st_lootrow_col3_colortable = { |
25 [""] = { text = "", r = 1.0, g = 1.0, b = 1.0, a = 1.0 }, | 25 [""] = { text = "", r = 1.0, g = 1.0, b = 1.0, a = 1.0 }, |
26 shard = { text = "shard", r = 0xa3/255, g = 0x35/255, b = 0xee/255, a = 1.0 }, | 26 shard = { text = "shard", r = 0xa3/255, g = 0x35/255, b = 0xee/255, a = 1.0 }, |
27 offspec = { text = "offspec", r = 0.78, g = 0.61, b = 0.43, a = 1.0 }, | 27 offspec = { text = "offspec", r = 0.78, g = 0.61, b = 0.43, a = 1.0 }, |
237 self.loot_clean = #g_loot | 237 self.loot_clean = #g_loot |
238 end | 238 end |
239 end | 239 end |
240 | 240 |
241 do | 241 do |
242 local offset | |
243 function addon:_fill_out_hist_data (opt_starting_index) | 242 function addon:_fill_out_hist_data (opt_starting_index) |
244 -- Clearing history finishes this function with #hist==0 and hist_clean==0. | 243 -- Clearing history finishes this function with #hist==0 and hist_clean==0. |
245 -- The next call typically detects this (#<1) and handles it. If loot is | 244 -- The next call typically detects this (#<1) and handles it. If loot is |
246 -- recorded before then, it results in hist_clean==0 and #hist==1, which | 245 -- recorded before then, it results in hist_clean==0 and #hist==1, which |
247 -- breaks the first iteration of the loop. Thus, the "extra" test here: | 246 -- breaks the first iteration of the loop. Thus, the "extra" test here: |
249 self.hist_clean = nil | 248 self.hist_clean = nil |
250 opt_starting_index = nil | 249 opt_starting_index = nil |
251 end | 250 end |
252 if not self.history.st then | 251 if not self.history.st then |
253 self.history.st = { | 252 self.history.st = { |
254 { kind = "realm", | 253 --[[{ kind = "realm", |
255 cols = setmetatable({ | 254 cols = setmetatable({ |
256 { value = self.history.realm }, | 255 { value = self.history.realm }, |
257 }, time_column1_used_mt) | 256 }, time_column1_used_mt) |
258 } | 257 }]] |
259 } | 258 } |
260 offset = #self.history.st | |
261 end | 259 end |
262 local st = self.history.st | 260 local st = self.history.st |
263 for i = (opt_starting_index or self.hist_clean or 1), #self.history do | 261 for i = (opt_starting_index or self.hist_clean or 1), #self.history do |
264 local h = self.history[i] | 262 local h = self.history[i] |
265 local sti = i+offset | 263 local sti = i |
266 if not st[sti] then | 264 if not st[sti] then |
267 st[sti] = { kind = "history" } | 265 st[sti] = { kind = "history" } |
268 end | 266 end |
269 local sth = st[sti] -- corresponding ST entry for h | 267 local sth = st[sti] -- corresponding ST entry for h |
270 | 268 |
274 {},--{ value = h[1].when }, | 272 {},--{ value = h[1].when }, |
275 } | 273 } |
276 | 274 |
277 if sth.shown ~= h[1].id then | 275 if sth.shown ~= h[1].id then |
278 -- things have changed, redo the row with new data | 276 -- things have changed, redo the row with new data |
279 local iname, ilink, iquality, _,_,_,_,_,_, itexture = GetItemInfo(h[1].id) | 277 local itexture = GetItemIcon(h[1].id) |
280 local textured = eoi_st_textured_item_format:format (itexture, self.quality_hexes[iquality], iname, h[1].count or "") | 278 local iname, ilink, iquality = GetItemInfo(h[1].id) |
279 local textured | |
280 if itexture and iname then | |
281 textured = eoi_st_textured_item_format:format (itexture, self.quality_hexes[iquality], iname, h[1].count or "") | |
282 sth.shown = h[1].id | |
283 else | |
284 textured = eoi_st_textured_item_format:format ([[ICONS\INV_Misc_QuestionMark]], self.quality_hexes[1], 'UNKNOWN', "") | |
285 end | |
281 sth.cols[2].value = textured | 286 sth.cols[2].value = textured |
282 sth.cols[3].value = h[1].when | 287 sth.cols[3].value = h[1].when |
283 sth.shown = h[1].id | |
284 end | 288 end |
285 | 289 |
286 end | 290 end |
287 self.hist_clean = #self.history | 291 self.hist_clean = #self.history |
288 end | 292 end |
701 | 705 |
702 return true -- do not do anything further | 706 return true -- do not do anything further |
703 end | 707 end |
704 | 708 |
705 local function hist_st_OnClick (rowFrame, cellFrame, data, cols, row, realrow, column, stable, button, ...) | 709 local function hist_st_OnClick (rowFrame, cellFrame, data, cols, row, realrow, column, stable, button, ...) |
706 if (row == nil) or (realrow == nil) then return true end -- click column header, suppress reordering FOR NOW | 710 if (row == nil) or (realrow == nil) then return false end -- click column header, do default resorting |
707 local h = data[realrow] | 711 local h = data[realrow] |
708 local kind = h.kind | 712 local kind = h.kind |
709 | 713 |
710 | 714 |
711 return true -- do not do anything further | 715 return true -- do not do anything further |
842 ST.OuroLoot_Refresh = function (self, opt_index) | 846 ST.OuroLoot_Refresh = function (self, opt_index) |
843 addon:_fill_out_eoi_data(opt_index) | 847 addon:_fill_out_eoi_data(opt_index) |
844 -- safety check begin | 848 -- safety check begin |
845 for i,e in ipairs(g_loot) do | 849 for i,e in ipairs(g_loot) do |
846 if type(e.cols) ~= 'table' then | 850 if type(e.cols) ~= 'table' then |
847 addon:Print("ARGH, index",i,"bad in refresh, refreshed at", opt_index, "type",type(e.cols), | 851 addon:Print("ARGH, index",i,"bad in eoi refresh, refreshed at", opt_index, "type",type(e.cols), |
848 "entry kind", e.kind, "data", e.itemname or e.bosskill or e.startday.text, | 852 "entry kind", e.kind, "data", e.itemname or e.bosskill or e.startday.text, |
849 "-- please take a screenshot and send to Farmbuyer.") | 853 "-- please take a screenshot and send to Farmbuyer.") |
850 tabledump(e) | 854 tabledump(e) |
851 end | 855 end |
852 end | 856 end |
981 _populate_text_specials (box, specials, mkbutton, text_kind) | 985 _populate_text_specials (box, specials, mkbutton, text_kind) |
982 end | 986 end |
983 | 987 |
984 -- Tab 4: History | 988 -- Tab 4: History |
985 -- Much of the implementation here follows a similar desgin for the first | 989 -- Much of the implementation here follows a similar desgin for the first |
986 -- tab's handling of ST objects. | 990 -- tab's handling of ST objects. We will even reuse its controlling tables |
991 -- when feasible. | |
987 do | 992 do |
988 local histST | 993 local histST |
989 local hist_st_cols = { | 994 local hist_st_cols = { |
990 { -- col 1 | 995 { -- col 1 |
991 name = "Player", | 996 name = "Player", |
999 }, | 1004 }, |
1000 { -- col 3 | 1005 { -- col 3 |
1001 name = "When", | 1006 name = "When", |
1002 width = 250, | 1007 width = 250, |
1003 DoCellUpdate = hist_st_col3_DoCellUpdate, | 1008 DoCellUpdate = hist_st_col3_DoCellUpdate, |
1009 defaultsort = "asc", | |
1010 sort = "asc", | |
1011 sortnext = 1, | |
1004 }, | 1012 }, |
1005 } | 1013 } |
1006 | 1014 |
1007 -- Loot column | 1015 -- Loot column |
1008 local function hist_st_col2_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable, ...) | 1016 local function hist_st_col2_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable, ...) |
1058 histST.OuroLoot_Refresh = function (self, opt_index) | 1066 histST.OuroLoot_Refresh = function (self, opt_index) |
1059 addon:_fill_out_hist_data(opt_index) | 1067 addon:_fill_out_hist_data(opt_index) |
1060 self:SortData() -- calls hooked refresh | 1068 self:SortData() -- calls hooked refresh |
1061 end | 1069 end |
1062 | 1070 |
1071 local function reset_current_realm() | |
1072 local r = assert(GetRealmName()) | |
1073 -- new .history table: | |
1074 addon.history_all[r] = addon:_prep_new_history_category (nil, r) | |
1075 addon.history = addon.history_all[r] | |
1076 addon.hist_clean = nil | |
1077 -- new .history.st table: | |
1078 histST:OuroLoot_Refresh() | |
1079 histST:SetData(addon.history.st) | |
1080 addon:Print("You've clicked the history erase button!") | |
1081 end | |
1082 | |
1063 tabs_OnGroupSelected["hist"] = function(container,specials) | 1083 tabs_OnGroupSelected["hist"] = function(container,specials) |
1064 local st_widget = GUI:Create("lib-st") | 1084 local st_widget = GUI:Create("lib-st") |
1065 histST:OuroLoot_Refresh() | 1085 histST:OuroLoot_Refresh() |
1066 st_widget:WrapST(histST) | 1086 st_widget:WrapST(histST) |
1087 st_widget.head_offset = 15 | |
1088 st_widget.tail_offset = 0 | |
1067 container:SetLayout("Fill") | 1089 container:SetLayout("Fill") |
1068 container:AddChild(st_widget) | 1090 container:AddChild(st_widget) |
1069 | 1091 |
1070 local b = mkbutton("Regenerate", | 1092 local b |
1071 [[Erases all history entries from current realm, and regenerate it from current loot information.]]) | 1093 do |
1094 local realms,current = {},1 | |
1095 for realmname,histtable in pairs(addon.history_all) do | |
1096 tinsert(realms,realmname) | |
1097 if addon.history == histtable then current = #realms end | |
1098 end | |
1099 b = mkbutton("Dropdown", nil, "", [[Which realm to display]]) | |
1100 b:SetFullWidth(true) | |
1101 b:SetLabel() -- required even when empty, see ace3 ticket #234 | |
1102 b:SetList(realms) | |
1103 b:SetValue(current) | |
1104 b:SetCallback("OnValueChanged", function(_dd,event,choice) | |
1105 print("chose realm", choice, realms[choice]) | |
1106 end) | |
1107 specials:AddChild(b) | |
1108 end | |
1109 | |
1110 --[[ | |
1111 b = GUI:Create("Spacer") | |
1112 b:SetFullWidth(true) | |
1113 b:SetHeight(10) | |
1114 specials:AddChild(b) | |
1115 ]] | |
1116 | |
1117 b = mkbutton("Regenerate", | |
1118 [[Erases all history entries from the displayed realm, and regenerates it from current loot information.]]) | |
1072 b:SetFullWidth(true) | 1119 b:SetFullWidth(true) |
1073 b:SetDisabled (#addon.history == 0) | 1120 b:SetDisabled (#addon.history == 0) |
1074 b:SetCallback("OnClick", function(_b) | 1121 b:SetCallback("OnClick", function(_b) |
1075 addon:Print("%s history has been regenerated.", addon.history.realm) | 1122 addon:Print("%s history has been regenerated.", addon.history.realm) |
1076 return addon:redisplay() | 1123 return addon:redisplay() |
1077 --return tabs_OnGroupSelected_func(container,"OnGroupSelected","hist") | 1124 --return tabs_OnGroupSelected_func(container,"OnGroupSelected","hist") |
1078 end) | 1125 end) |
1079 specials:AddChild(b) | 1126 specials:AddChild(b) |
1080 | 1127 |
1081 b = mkbutton('hist_clear_all', "Clear All History", | 1128 b = mkbutton('hist_clear', "Clear Realm History", |
1082 [[Erases ALL history entries from all realms.]]) | 1129 [[No confirmation! |cffff1010Erases absolutely all> history entries from the displayed realm.]]) |
1083 b:SetFullWidth(true) | 1130 b:SetFullWidth(true) |
1084 b:SetCallback("OnClick", function (_b) | 1131 b:SetCallback("OnClick", function (_b) |
1085 local r = GetRealmName() | 1132 reset_current_realm() |
1086 -- new .history table: | |
1087 addon.history_all[r] = addon:_prep_new_history_category (nil, r) | |
1088 addon.history = addon.history_all[r] | |
1089 addon.hist_clean = nil | |
1090 -- new .history.st table: | |
1091 histST:OuroLoot_Refresh() | |
1092 histST:SetData(addon.history.st) | |
1093 addon:Print("You've clicked the history erase button!") | |
1094 return addon:redisplay() | 1133 return addon:redisplay() |
1095 --return tabs_OnGroupSelected_func(container,"OnGroupSelected","hist") | |
1096 end) | 1134 end) |
1097 specials:AddChild(b) | 1135 specials:AddChild(b) |
1098 | 1136 |
1137 b = mkbutton('hist_clear_all', "Clear All History", | |
1138 [[No confirmation! |cffff1010Erases absolutely all> history entries from ALL realms.]]) | |
1139 b:SetFullWidth(true) | |
1140 b:SetCallback("OnClick", function (_b) | |
1141 addon.history_all = {} | |
1142 reset_current_realm() | |
1143 return addon:redisplay() | |
1144 end) | |
1145 specials:AddChild(b) | |
1146 | |
1099 b = mkbutton('hist_clear_old', "Clear Older", | 1147 b = mkbutton('hist_clear_old', "Clear Older", |
1100 [[Preserves only the latest loot entry for each player, removing all others.]]) | 1148 [[Preserves only the latest loot entry for each player on the current realm, removing all earlier ones.]]) |
1101 b:SetFullWidth(true) | 1149 b:SetFullWidth(true) |
1102 b:SetCallback("OnClick", function (_b) | 1150 b:SetCallback("OnClick", function (_b) |
1103 addon:Print("All loot prior to the most recent entries has been erased.") | 1151 addon:Print("All loot prior to the most recent entries has been erased.") |
1104 return addon:redisplay() | 1152 return addon:redisplay() |
1105 --return tabs_OnGroupSelected_func(container,"OnGroupSelected","hist") | 1153 --return tabs_OnGroupSelected_func(container,"OnGroupSelected","hist") |
1628 b:SetCallback("OnValueChanged", function(_dd,event,choice) | 1676 b:SetCallback("OnValueChanged", function(_dd,event,choice) |
1629 self:SetThreshold(choice) | 1677 self:SetThreshold(choice) |
1630 end) | 1678 end) |
1631 control:AddChild(b) | 1679 control:AddChild(b) |
1632 | 1680 |
1633 b = mkbutton("Clear", | 1681 b = mkbutton("Clear Loot", |
1634 [[+Erases> all current loot information and generated text (but not saved texts).]]) | 1682 [[+Erases> all current loot information and generated text (but not saved texts).]]) |
1635 b:SetFullWidth(true) | 1683 b:SetFullWidth(true) |
1636 b:SetCallback("OnClick", function() | 1684 b:SetCallback("OnClick", function() |
1637 StaticPopup_Show("OUROL_CLEAR").data = self | 1685 StaticPopup_Show("OUROL_CLEAR").data = self |
1638 end) | 1686 end) |