comparison gui.lua @ 84:c87bf3e756f3

Properly handle dropdown menus for the History tab now, initially with delete-item and delete-player entries. Some code cleanup and notes for future work.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Thu, 21 Jun 2012 02:17:26 +0000
parents 940e53dd18c3
children 703bbe61d12d
comparison
equal deleted inserted replaced
83:940e53dd18c3 84:c87bf3e756f3
12 12
13 ------ Constants 13 ------ Constants
14 local eoi_st_rowheight = 20 14 local eoi_st_rowheight = 20
15 local eoi_st_displayed_rows = math.floor(416/eoi_st_rowheight) 15 local eoi_st_displayed_rows = math.floor(416/eoi_st_rowheight)
16 local eoi_st_textured_item_format = "|T%s:"..(eoi_st_rowheight-2).."|t %s[%s]|r%s" 16 local eoi_st_textured_item_format = "|T%s:"..(eoi_st_rowheight-2).."|t %s[%s]|r%s"
17 -- This can get indexed by kind/reason/etc, and will default to lib-st's
18 -- default "blank" background at runtime.
17 local eoi_st_otherrow_bgcolortable = { 19 local eoi_st_otherrow_bgcolortable = {
18 wipe = { ["r"] = 0.3, ["g"] = 0.3, ["b"] = 0.3}, 20 wipe = { ["r"] = 0.3, ["g"] = 0.3, ["b"] = 0.3},
19 kill = { ["r"] = 0.2, ["g"] = 0.2, ["b"] = 0.2}, 21 kill = { ["r"] = 0.2, ["g"] = 0.2, ["b"] = 0.2},
20 time = { ["r"] = 0x0/255, ["g"] = 0x0/255, ["b"] = 1, ["a"] = 0.3}, 22 time = { ["r"] = 0x0/255, ["g"] = 0x0/255, ["b"] = 1, ["a"] = 0.3},
21 } 23 }
22 eoi_st_otherrow_bgcolortable[""] = eoi_st_otherrow_bgcolortable["kill"] 24 eoi_st_otherrow_bgcolortable[""] = eoi_st_otherrow_bgcolortable["kill"]
23 --eoi_st_otherrow_bgcolortable["realm"] = eoi_st_otherrow_bgcolortable["time"]
24 local eoi_st_otherrow_bgcolortable_default 25 local eoi_st_otherrow_bgcolortable_default
25 local eoi_st_lootrow_col3_colortable = { 26 local eoi_st_lootrow_col3_colortable = {
26 normal = { text = "", r = "ff", g = "ff", b = "ff" }, 27 normal = { text = "", r = "ff", g = "ff", b = "ff" },
27 shard = { text = "shard", r = "a3", g = "35", b = "ee" }, 28 shard = { text = "shard", r = "a3", g = "35", b = "ee" },
28 offspec = { text = "offspec", r = "c6", g = "9b", b = "6d" }, 29 offspec = { text = "offspec", r = "c6", g = "9b", b = "6d" },
151 do 152 do
152 local text_gen_funcs, specials_gen_funcs = {}, {} 153 local text_gen_funcs, specials_gen_funcs = {}, {}
153 local accumulator = {} 154 local accumulator = {}
154 155
155 -- Can do clever things by passing other halting points as zero 156 -- Can do clever things by passing other halting points as zero
156 function addon:zero_printed_fenceposts(zero) 157 function addon:zero_printed_fenceposts (zero)
157 for t in pairs(text_gen_funcs) do 158 for t in pairs(text_gen_funcs) do
158 g_loot.printed[t] = zero or g_loot.printed[t] or 0 159 g_loot.printed[t] = zero or g_loot.printed[t] or 0
159 end 160 end
160 end 161 end
161 162
173 text_gen_funcs[text_type] = generator 174 text_gen_funcs[text_type] = generator
174 specials_gen_funcs[text_type] = opt_specgen 175 specials_gen_funcs[text_type] = opt_specgen
175 dirty_tabs = true 176 dirty_tabs = true
176 end 177 end
177 178
178 -- Called by tabs_generated_text_OGS 179 -- These two called by tabs_generated_text_OGS
180 -- tabs_OnGroupSelected_func will catch propagated errors
179 function _generate_text (text_type) 181 function _generate_text (text_type)
180 local f = text_gen_funcs[text_type] 182 local f = text_gen_funcs[text_type]
181 if not f then 183 if not f then
182 error(("Generator called for unregistered text type '%s'."):format(text_type)) 184 error(("Generator called for unregistered text type '%s'."):format(text_type))
183 end 185 end
190 -- if glc is nil, #==0 test already returned 192 -- if glc is nil, #==0 test already returned
191 193
192 local ok,ret = pcall (f, text_type, g_loot, g_loot.printed[text_type], g_generated, accumulator) 194 local ok,ret = pcall (f, text_type, g_loot, g_loot.printed[text_type], g_generated, accumulator)
193 if not ok then 195 if not ok then
194 error(("ERROR: text generator '%s' failed: %s"):format(text_type, ret)) 196 error(("ERROR: text generator '%s' failed: %s"):format(text_type, ret))
195 return false -- why is this here again?
196 end 197 end
197 if ret then 198 if ret then
198 g_loot.printed[text_type] = #g_loot 199 g_loot.printed[text_type] = #g_loot
199 g_generated[text_type] = (g_generated[text_type] or "") .. table.concat(accumulator,'\n') .. '\n' 200 g_generated[text_type] = (g_generated[text_type] or "") .. table.concat(accumulator,'\n') .. '\n'
200 end 201 end
202 return ret 203 return ret
203 end 204 end
204 function _populate_text_specials (editbox, specials, mkb, text_type) 205 function _populate_text_specials (editbox, specials, mkb, text_type)
205 local f = specials_gen_funcs[text_type] 206 local f = specials_gen_funcs[text_type]
206 if not f then return end 207 if not f then return end
207 pcall (f, text_type, editbox, specials, mkb) 208 local ok,ret = pcall (f, text_type, editbox, specials, mkb)
209 if not ok then
210 error(("ERROR: special widget creation for '%s' failed: %s"):format(text_type, ret))
211 end
208 end 212 end
209 213
210 -- LOD tab has been clicked on. 214 -- LOD tab has been clicked on.
211 local function _handle_LOD (tabs_container,specials,tabtitle) 215 local function _handle_LOD (tabs_container,specials,tabtitle)
212 -- "tabtitle" here is the name in _taborder, not the colorized string 216 -- "tabtitle" here is the name in _taborder, not the colorized string
287 FIXME just move this functionality to a per-entry function and call it once 291 FIXME just move this functionality to a per-entry function and call it once
288 in _addlootentry. --actually no, then the columnar data won't be updated once 292 in _addlootentry. --actually no, then the columnar data won't be updated once
289 the backend data is changed on the fly. 293 the backend data is changed on the fly.
290 ]] 294 ]]
291 do 295 do
292 local grammar = { -- not worth making a mt for this
293 [2] = "nd",
294 [3] = "rd",
295 }
296
297 function addon:_fill_out_eoi_data (opt_starting_index) 296 function addon:_fill_out_eoi_data (opt_starting_index)
298 if #g_loot < 1 then 297 if #g_loot < 1 then
299 --pprint('_f_o_e_d', "#g_loot<1") 298 --pprint('_f_o_e_d', "#g_loot<1")
300 self.loot_clean = nil 299 self.loot_clean = nil
301 opt_starting_index = nil 300 opt_starting_index = nil
344 e.duration = e.duration or 0 -- can occasionally miss getting set 343 e.duration = e.duration or 0 -- can occasionally miss getting set
345 if e.reason == 'kill' then 344 if e.reason == 'kill' then
346 if e.attempts == 1 then 345 if e.attempts == 1 then
347 v = "one-shot" 346 v = "one-shot"
348 else 347 else
349 v = ("kill on %d%s attempt"):format(e.attempts or 0, grammar[e.attempts] or "th") 348 v = ("kill on %d%s attempt"):format(e.attempts or 0,
349 e.attempts==2 and "nd" or e.attempts==3 and "rd" or "th")
350 end 350 end
351 v = ("%s (%d:%.2d)"):format(v, math.floor(e.duration/60), math.floor(e.duration%60)) 351 v = ("%s (%d:%.2d)"):format(v, math.floor(e.duration/60), math.floor(e.duration%60))
352 elseif e.reason == 'wipe' then 352 elseif e.reason == 'wipe' then
353 v = ("wipe (%d:%.2d)"):format(math.floor(e.duration/60), math.floor(e.duration%60)) 353 v = ("wipe (%d:%.2d)"):format(math.floor(e.duration/60), math.floor(e.duration%60))
354 end 354 end
420 col1.value = player.name -- may spiffy this up in future 420 col1.value = player.name -- may spiffy this up in future
421 421
422 for li,unique in ipairs(player.unique) do 422 for li,unique in ipairs(player.unique) do
423 local col2 = new() 423 local col2 = new()
424 col2.OLi = li 424 col2.OLi = li
425 col2.OLu = unique
425 local col3 = new() 426 local col3 = new()
426 col3.value = player.when[unique] 427 col3.value = player.when[unique]
427 428
428 local id = player.id[unique] 429 local id = player.id[unique]
429 local itexture = GetItemIcon(id) 430 local itexture = GetItemIcon(id)
437 ITEM_QUALITY_COLORS[ITEM_QUALITY_COMMON].hex, 'UNKNOWN - REDISPLAY LATER', "") 438 ITEM_QUALITY_COLORS[ITEM_QUALITY_COMMON].hex, 'UNKNOWN - REDISPLAY LATER', "")
438 cache_okay = false 439 cache_okay = false
439 end 440 end
440 col2.value = textured 441 col2.value = textured
441 442
443 -- To facilitate sharing lib-st routines between EOI and this
444 -- one, we do some of the same fields: 'kind' and 'itemlink'.
445 -- These aren't used outside of the GUI. These become our data
446 -- table arguments to the lib-st routines (thus 'e' locals).
442 local dotcols = new (col1, col2, col3) 447 local dotcols = new (col1, col2, col3)
443 local st_entry = new() 448 local st_entry = new()
444 st_entry.kind = 'history' 449 st_entry.kind = 'hist'
445 st_entry.OLwho = player.name 450 st_entry.OLwho = player.name
446 st_entry.cols = dotcols 451 st_entry.cols = dotcols
447 st_entry.itemlink = ilink -- for onenter and onclick 452 st_entry.itemlink = ilink -- for onenter and onclick
448 tinsert (st, st_entry) 453 tinsert (st, st_entry)
449 end 454 end
710 _tabtexts = { 715 _tabtexts = {
711 ["eoi"] = {title=[[Loot]], desc=[[Observed loot, plus boss kills and other events of interest]]}, 716 ["eoi"] = {title=[[Loot]], desc=[[Observed loot, plus boss kills and other events of interest]]},
712 ["hist"] = {title=[[History]], desc=[[A short semi-permanent record]]}, 717 ["hist"] = {title=[[History]], desc=[[A short semi-permanent record]]},
713 ["help"] = {title=[[Help]], desc=[[Instructions, reminders, and tips for non-obvious features]]}, 718 ["help"] = {title=[[Help]], desc=[[Instructions, reminders, and tips for non-obvious features]]},
714 ["opt"] = {title=[[Options]], desc=[[Options for fine-tuning behavior]]}, 719 ["opt"] = {title=[[Options]], desc=[[Options for fine-tuning behavior]]},
715 --["adv"] = {title=[[Advanced]], desc=[[Debugging and testing]]},
716 } 720 }
717 --if addon.author_debug then
718 _taborder = { "eoi", "hist", "help", "opt" } 721 _taborder = { "eoi", "hist", "help", "opt" }
719 --else _taborder = { "eoi", "help", "opt" } end
720 722
721 do 723 do
722 local next_insertion_position = 2 -- position in _taborder 724 local next_insertion_position = 2 -- position in _taborder
723 local removed, saved_offset 725 local removed, saved_offset
724 726
777 end 779 end
778 dirty_tabs = nil 780 dirty_tabs = nil
779 end 781 end
780 782
781 --[[ 783 --[[
782 Dropdown menu handling 784 Dropdown menu handling; this has grown in ungainly directions.
783 ]] 785 ]]
784 -- forward decls 786 -- forward decls
785 local eoi_editcell 787 local eoi_editcell
786 788
787 local dropdownfuncs 789 local dropdownfuncs
796 return setmetatable(t, ddf_mt) 798 return setmetatable(t, ddf_mt)
797 end 799 end
798 end 800 end
799 801
800 local function dropdownmenu_handler (ddbutton, subfunc, arg) 802 local function dropdownmenu_handler (ddbutton, subfunc, arg)
801 local i = _d and _d.GetUserData and _d:GetUserData("DD loot index") 803 local i = _d and _d.GetUserData and _d:GetUserData("DD index")
802 if i then 804 if i then
803 subfunc(i,arg) 805 subfunc(i,arg)
804 _d:GetUserData("eoiST"):OuroLoot_Refresh(i) 806 _d:GetUserData("which ST"):OuroLoot_Refresh(i)
805 end 807 end
806 end 808 end
807 809
808 local function gen_easymenu_table (initial, list, funcs) 810 local function gen_easymenu_table (initial, list, funcs)
809 for _,tag in ipairs(list) do 811 for _,tag in ipairs(list) do
846 dialog.editBox:SetScript("OnTextChanged",StaticPopup_EditBoxOnTextChanged) 848 dialog.editBox:SetScript("OnTextChanged",StaticPopup_EditBoxOnTextChanged)
847 dialog.data = {rowindex=rowi, display=_d, kind=text} 849 dialog.data = {rowindex=rowi, display=_d, kind=text}
848 end, 850 end,
849 851
850 df_DELETE = function(rowi) 852 df_DELETE = function(rowi)
851 local gone = tremove(g_loot,rowi) 853 local gone = tremove (g_loot, rowi)
852 addon:Print("Removed %s.", 854 addon:Print("Removed %s.",
853 gone.itemlink or gone.bossname or gone.startday.text) 855 gone.itemlink or gone.bossname or gone.startday.text)
854 if gone.kind == 'loot' and IsShiftKeyDown() then 856 if gone.kind == 'loot' and IsShiftKeyDown() then
855 addon:_delHistoryEntry (rowi, gone) 857 local okay,err = addon:_delHistoryEntry (gone)
858 if okay then
859 addon:Print("Removed history entry %s from '%s'.",
860 gone.itemlink, gone.person)
861 else
862 addon:Print(err)
863 end
856 end 864 end
857 end, 865 end,
858 866
859 ["Delete remaining entries for this day"] = function(rowi,kind) 867 ["Delete remaining entries for this day"] = function(rowi,kind)
860 -- if kind is boss, also need to stop at new timestamp 868 -- if kind is boss, also need to stop at new timestamp
910 -- the fillout function called automatically will start too far down the list 918 -- the fillout function called automatically will start too far down the list
911 _d:GetUserData("eoiST"):OuroLoot_Refresh() 919 _d:GetUserData("eoiST"):OuroLoot_Refresh()
912 end, 920 end,
913 921
914 ["Edit note"] = function(rowi) 922 ["Edit note"] = function(rowi)
915 eoi_editcell (rowi, _d:GetUserData("DD loot cell")) 923 eoi_editcell (rowi, _d:GetUserData("DD cell"))
916 end, 924 end,
917 925
918 df_REASSIGN = function(rowi,to_whom) 926 df_REASSIGN = function(rowi,to_whom)
919 addon:reassign_loot ("local", rowi, to_whom) 927 addon:reassign_loot ("local", rowi, to_whom)
920 CloseDropDownMenus() -- also need to close parent menu 928 CloseDropDownMenus() -- also need to close parent menu
944 notClickable = true, 952 notClickable = true,
945 notCheckable = true, 953 notCheckable = true,
946 }}, 954 }},
947 { 955 {
948 "Rebroadcast this day%time|Broadcasts everything from here down until a new day.", 956 "Rebroadcast this day%time|Broadcasts everything from here down until a new day.",
949 "Delete remaining entries for this day%time|Erases everything from here down until a new day.\n\nHold down the Shift key to also delete the players' corresponding History entry.", 957 "Delete remaining entries for this day%time|Erases everything from here down until a new day.\n\nHold down the Shift key to also delete the corresponding entries from player History.",
950 "Insert new loot entry%loot|Inserts new loot above this one, prompting you for information.", 958 "Insert new loot entry%loot|Inserts new loot above this one, prompting you for information.",
951 "Insert new boss kill event%boss|Inserts new event above this one, prompting you for information.", 959 "Insert new boss kill event%boss|Inserts new event above this one, prompting you for information.",
952 CLOSE 960 CLOSE
953 }, eoi_dropdownfuncs) 961 }, eoi_dropdownfuncs)
954 local eoi_loot_dropdown = gen_easymenu_table( 962 local eoi_loot_dropdown = gen_easymenu_table(
962 "Mark as offspec%offspec", 970 "Mark as offspec%offspec",
963 "Mark as guild vault%gvault", 971 "Mark as guild vault%gvault",
964 "Mark as normal|This is the default. Selecting any 'Mark as <x>' action blanks out extra notes about who broadcast this entry, etc.", 972 "Mark as normal|This is the default. Selecting any 'Mark as <x>' action blanks out extra notes about who broadcast this entry, etc.",
965 "--", 973 "--",
966 "Rebroadcast this loot entry|Sends this loot event, including special notes, as if it just happened.", 974 "Rebroadcast this loot entry|Sends this loot event, including special notes, as if it just happened.",
967 "Delete this loot event|Permanent, no going back!\n\nHold down the Shift key to also delete the player's corresponding History entry.", 975 "Delete this loot event|Permanent, no going back!\n\nHold down the Shift key to also delete the corresponding entry from player's History.",
968 "Delete remaining entries for this boss%boss|Erases everything from here down until a new boss/day.\n\nHold down the Shift key to also delete the players' corresponding History entry.", 976 "Delete remaining entries for this boss%boss|Erases everything from here down until a new boss/day.\n\nHold down the Shift key to also delete the corresponding entries from player History.",
969 "Insert new loot entry%loot|Inserts new loot above this one, prompting you for information.", 977 "Insert new loot entry%loot|Inserts new loot above this one, prompting you for information.",
970 "Insert new boss kill event%boss|Inserts new event above this one, prompting you for information.", 978 "Insert new boss kill event%boss|Inserts new event above this one, prompting you for information.",
971 "Edit note|Same as double-clicking in the notes column.", 979 "Edit note|Same as double-clicking in the notes column.",
972 "--", 980 "--",
973 CLOSE 981 CLOSE
1001 }}, 1009 }},
1002 { 1010 {
1003 "Change from 'wipe' to 'kill'|Also collapses previous wipe entries.", -- KILLWIPE 1011 "Change from 'wipe' to 'kill'|Also collapses previous wipe entries.", -- KILLWIPE
1004 "Rebroadcast this boss%boss|Broadcasts the kill event and all subsequent loot until next boss.", 1012 "Rebroadcast this boss%boss|Broadcasts the kill event and all subsequent loot until next boss.",
1005 "Delete this boss event|Permanent, no going back!", 1013 "Delete this boss event|Permanent, no going back!",
1006 "Delete remaining entries for this boss%boss|Erases everything from here down until a new boss/day.\n\nHold down the Shift key to also delete the player's corresponding History entry.", 1014 "Delete remaining entries for this boss%boss|Erases everything from here down until a new boss/day.\n\nHold down the Shift key to also delete the corresponding entries from player History.",
1007 "Insert new loot entry%loot|Inserts new loot above this one, prompting you for information.", 1015 "Insert new loot entry%loot|Inserts new loot above this one, prompting you for information.",
1008 "Insert new boss kill event%boss|Inserts new event above this one, prompting you for information.", 1016 "Insert new boss kill event%boss|Inserts new event above this one, prompting you for information.",
1009 "--", 1017 "--",
1010 CLOSE 1018 CLOSE
1011 }, eoi_dropdownfuncs) 1019 }, eoi_dropdownfuncs)
1012 1020
1013 --[[ quoted verbatim from lib-st docs: 1021 --[[ quoted verbatim from lib-st docs (table->stable for obvious reasons):
1014 rowFrame This is the UI Frame table for the row. 1022 rowFrame This is the UI Frame table for the row.
1015 cellFrame This is the UI Frame table for the cell in the row. 1023 cellFrame This is the UI Frame table for the cell in the row.
1016 data This is the data table supplied to the scrolling table (in case you lost it :) ) 1024 data This is the data table supplied to the scrolling table (in case you lost it :) )
1017 cols This is the cols table supplied to the scrolling table (again, in case you lost it :) ) 1025 cols This is the cols table supplied to the scrolling table (again, in case you lost it :) )
1018 row This is the number of the UI row that the event was triggered for.<br/> ex. If your scrolling table only shows ten rows, this number will be a number between 1 and 10. 1026 row This is the number of the UI row that the event was triggered for.<br/> ex. If your scrolling table only shows ten rows, this number will be a number between 1 and 10.
1019 realrow This is the exact row index (after sorting and filtering) in the data table of what data is displayed in the row you triggered the event in. (NOT the UI row!) 1027 realrow This is the exact row index (after sorting and filtering) in the data table of what data is displayed in the row you triggered the event in. (NOT the UI row!)
1020 column This is the index of which column the event was triggered in. 1028 column This is the index of which column the event was triggered in.
1021 table This is a reference to the scrollingtable table. 1029 stable This is a reference to the scrollingtable table.
1022 ... Any arguments generated by the '''NORMAL''' Blizzard event triggered by the frame are passed as is. 1030 ... Any arguments generated by the '''NORMAL''' Blizzard event triggered by the frame are passed as is.
1023 ]] 1031 ]]
1024 local function eoi_st_OnEnter (rowFrame, cellFrame, data, cols, row, realrow, column, table, button, ...) 1032 local function eoi_st_OnEnter (rowFrame, cellFrame, data, cols, row, realrow, column, stable, motion)
1025 if (row == nil) or (realrow == nil) then return end -- mouseover column header 1033 if (row == nil) or (realrow == nil) then return end -- mouseover column header
1026 local e = data[realrow] 1034 local e = data[realrow]
1027 local kind = e.kind 1035 local kind = e.kind
1028 local tt = GameTooltip -- can this be hoisted? does GT ever get securely replaced? 1036 local tt = GameTooltip -- can this be hoisted? does GT ever get securely replaced?
1029 1037
1030 if _do_debugging_tooltip and column == 1 and kind~='history' then -- FIXME history 1038 if _do_debugging_tooltip and column == 1 and kind ~= 'hist' then
1031 _build_debugging_tooltip (cellFrame, realrow) 1039 _build_debugging_tooltip (cellFrame, realrow)
1032 end 1040 end
1033 if (kind == 'loot' and column == 1) or (kind == 'history' and column == 2) then 1041 if (kind == 'loot' and column == 1) or (kind == 'hist' and column == 2) then
1034 tt:SetOwner (cellFrame, "ANCHOR_RIGHT", -20, 0) 1042 tt:SetOwner (cellFrame, "ANCHOR_RIGHT", -20, 0)
1035 if e.cache_miss then 1043 if e.cache_miss then
1036 tt:ClearLines() 1044 tt:ClearLines()
1037 tt:AddLine("Missing Cache Data") 1045 tt:AddLine("Missing Cache Data")
1038 tt:AddLine([[Wait a few seconds, then type]], 0.8, 0.8, 0.8, 1) 1046 tt:AddLine([[Wait a few seconds, then type]], 0.8, 0.8, 0.8, 1)
1069 1077
1070 end 1078 end
1071 1079
1072 return false -- continue with default highlighting behavior 1080 return false -- continue with default highlighting behavior
1073 end 1081 end
1074 local function eoi_st_OnLeave (rowFrame, cellFrame, data, cols, row, realrow, column, table, button, ...) 1082 local function eoi_st_OnLeave (rowFrame, cellFrame, data, cols, row, realrow, column, stable, motion)
1075 GameTooltip:Hide() 1083 GameTooltip:Hide()
1076 _hide_debugging_tooltip() 1084 _hide_debugging_tooltip()
1077 if row and realrow and data[realrow].kind ~= 'loot' then 1085 if row and realrow and data[realrow].kind ~= 'loot' then
1078 table:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[data[realrow].reason or data[realrow].kind]) 1086 stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[data[realrow].reason or data[realrow].kind])
1079 return true -- do not do anything further 1087 return true -- do not do anything further
1080 else 1088 else
1081 --setstatus("") 1089 --setstatus("")
1082 return false -- continue with default un-highlighting behavior 1090 return false -- continue with default un-highlighting behavior
1083 end 1091 end
1084 end 1092 end
1085 1093
1086 local function eoi_st_OnClick (rowFrame, cellFrame, data, cols, row, realrow, column, stable, button, ...) 1094 local function eoi_st_OnClick (rowFrame, cellFrame, data, cols, row, realrow, column, stable, button, down)
1087 if (row == nil) or (realrow == nil) then return true end -- click column header, suppress reordering 1095 if (row == nil) or (realrow == nil) then return true end -- click column header, suppress reordering
1088 local e = data[realrow] 1096 local e = data[realrow]
1089 local kind = e.kind 1097 local kind = e.kind
1090 1098
1091 -- Check for shift-clicking a loot line 1099 -- Check for shift-clicking a loot line
1092 if IsModifiedClick("CHATLINK") and 1100 if IsModifiedClick("CHATLINK") and kind == 'loot' and column == 1
1093 ((kind == 'loot' and column == 1) or (kind == 'history' and column == 2))
1094 then 1101 then
1095 ChatEdit_InsertLink (e.itemlink) 1102 ChatEdit_InsertLink (e.itemlink)
1096 return true -- do not do anything further 1103 return true -- do not do anything further
1097 end 1104 end
1098 1105
1099 -- Remaining actions are all right-click 1106 -- Remaining actions are all right-click
1100 if button ~= "RightButton" then return true end 1107 if button ~= "RightButton" then return true end
1101 _d:SetUserData("DD loot index", realrow) 1108 _d:SetUserData("DD index", realrow)
1102 1109
1103 if kind == 'loot' and (column == 1 or column == 3) then 1110 if kind == 'loot' and (column == 1 or column == 3) then
1104 _d:SetUserData("DD loot cell", cellFrame) 1111 _d:SetUserData("DD cell", cellFrame)
1105 eoi_loot_dropdown[1].text = e.itemlink 1112 eoi_loot_dropdown[1].text = e.itemlink
1106 EasyMenu (eoi_loot_dropdown, dropdownmenuframe, cellFrame, 0, 0, "MENU") 1113 EasyMenu (eoi_loot_dropdown, dropdownmenuframe, cellFrame, 0, 0, "MENU")
1107 1114
1108 elseif kind == 'loot' and column == 2 then 1115 elseif kind == 'loot' and column == 2 then
1109 eoi_player_dropdown[1].text = e.person 1116 eoi_player_dropdown[1].text = e.person
1144 1151
1145 elseif kind == 'time' then 1152 elseif kind == 'time' then
1146 eoi_time_dropdown[1].text = e.startday.text 1153 eoi_time_dropdown[1].text = e.startday.text
1147 EasyMenu (eoi_time_dropdown, dropdownmenuframe, cellFrame, 0, 0, "MENU") 1154 EasyMenu (eoi_time_dropdown, dropdownmenuframe, cellFrame, 0, 0, "MENU")
1148 1155
1149 elseif kind == 'history' then -- XXX need to move this into new onclick handler
1150 _d:SetUserData("DD loot cell", cellFrame)
1151 hist_dropdown[1].text = e.itemlink
1152 EasyMenu (hist_dropdown, dropdownmenuframe, cellFrame, 0, 0, "MENU")
1153 end 1156 end
1154 1157
1155 return true -- do not do anything further 1158 return true -- do not do anything further
1156 end 1159 end
1157 1160
1189 box.frame:SetFrameLevel(cell_frame:GetFrameLevel()+1) 1192 box.frame:SetFrameLevel(cell_frame:GetFrameLevel()+1)
1190 box.frame:Show() 1193 box.frame:Show()
1191 setstatus("Press Enter or click Okay to accept changes, or press Escape to cancel them.") 1194 setstatus("Press Enter or click Okay to accept changes, or press Escape to cancel them.")
1192 end 1195 end
1193 1196
1194 local function eoi_st_OnDoubleClick (rowFrame, cellFrame, data, cols, row, realrow, column, stable, button, ...) 1197 local function eoi_st_OnDoubleClick (rowFrame, cellFrame, data, cols, row, realrow, column, stable, button)
1195 if (row == nil) or (realrow == nil) then return true end -- they clicked on column header, suppress reordering 1198 if (row == nil) or (realrow == nil) then return true end -- they clicked on column header, suppress reordering
1196 local e = data[realrow] 1199 local e = data[realrow]
1197 local kind = e.kind 1200 local kind = e.kind
1198 1201
1199 --_d:SetUserData("DD loot index", realrow) 1202 --_d:SetUserData("DD index", realrow)
1200 if kind == 'loot' and column == 3 and button == "LeftButton" then 1203 if kind == 'loot' and column == 3 and button == "LeftButton" then
1201 eoi_editcell (realrow, cellFrame) 1204 eoi_editcell (realrow, cellFrame)
1202 end 1205 end
1203 1206
1204 return true -- do not do anything further 1207 return true -- do not do anything further
1205 end 1208 end
1206 1209
1207 -- Used for EOI column 2 and Hist column 1. Both are player name columns. 1210 -- Used for EOI column 2 and Hist column 1. Both are player name columns.
1208 local function eoi_st_col2_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable, ...) 1211 local function eoi_st_col2_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable)
1209 if not fShow then 1212 if not fShow then
1210 cellFrame.text:SetText("") 1213 cellFrame.text:SetText("")
1211 if cellFrame.icontexture then 1214 if cellFrame.icontexture then
1212 cellFrame.icontexture:Hide() 1215 cellFrame.icontexture:Hide()
1213 end 1216 end
1245 end 1248 end
1246 1249
1247 --if e.kind ~= 'loot' then 1250 --if e.kind ~= 'loot' then
1248 stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[e.reason or e.kind or ""]) 1251 stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[e.reason or e.kind or ""])
1249 --else 1252 --else
1250 -- table:SetHighLightColor (rowFrame, table:GetDefaultHighlightBlank()) 1253 -- stable:SetHighLightColor (rowFrame, table:GetDefaultHighlightBlank())
1251 --end 1254 --end
1252 end 1255 end
1253 1256
1254 local eoi_st_cols = { 1257 local eoi_st_cols = {
1255 { -- col 1 1258 { -- col 1
1350 1353
1351 -- Now set up the future drawing function... 1354 -- Now set up the future drawing function...
1352 tabs_OnGroupSelected["eoi"] = function(container,specials) 1355 tabs_OnGroupSelected["eoi"] = function(container,specials)
1353 local st_widget = GUI:Create("lib-st") 1356 local st_widget = GUI:Create("lib-st")
1354 local st = _d:GetUserData("eoiST") 1357 local st = _d:GetUserData("eoiST")
1358
1359 _d:SetUserData("which ST",st)
1355 1360
1356 -- This is actually required each time 1361 -- This is actually required each time
1357 _d:SetUserData ("player filter clear", player_filter_all) 1362 _d:SetUserData ("player filter clear", player_filter_all)
1358 _d:SetUserData ("player filter by name", player_filter_by_name) 1363 _d:SetUserData ("player filter by name", player_filter_by_name)
1359 1364
1499 -- Tab 4: History 1504 -- Tab 4: History
1500 -- Much of the implementation here follows a similar desgin for the first 1505 -- Much of the implementation here follows a similar desgin for the first
1501 -- tab's handling of ST objects. We will even reuse its controlling tables 1506 -- tab's handling of ST objects. We will even reuse its controlling tables
1502 -- when feasible. 1507 -- when feasible.
1503 local histST, hist_dropdownfuncs 1508 local histST, hist_dropdownfuncs
1509 local hist_normal_status =
1510 [[Click on a row to view all history for that player only. (Click column headers to re-sort.)]]
1511 local hist_name_status =
1512 [[Right-click on any row to return to normal history display.]]
1513
1514 local history_filter_by_recent = function (st, e)
1515 if e.kind ~= 'hist' then return true end
1516 return e.cols[2].OLi == 1
1517 end
1518
1519 local history_filter_who
1520 local history_filter_by_name = function (st, e)
1521 if e.kind ~= 'hist' then return true end
1522 return e.OLwho == history_filter_who
1523 end
1504 1524
1505 hist_dropdownfuncs = dropdownfuncs{ 1525 hist_dropdownfuncs = dropdownfuncs{
1506 ["Delete this loot history"] = function(rowi) 1526 ["Delete this loot event from history"] = function(rowi)
1507 --local gone = tremove(g_loot,rowi) 1527 local h = _d:GetUserData("DD history entry")
1508 --addon:Print("Removed %s.", 1528 local okay,err = addon:_delHistoryEntry (h.cols[2].OLu, h.itemlink)
1509 --gone.itemlink or gone.bossname or gone.startday.text) 1529 if okay then
1530 addon:Print("Removed history entry %s from '%s'.",
1531 h.itemlink, h.OLwho)
1532 else
1533 addon:Print(err)
1534 end
1535 end,
1536
1537 ["Delete this player's entire loot history"] = function(rowi)
1538 local h = _d:GetUserData("DD history entry")
1539 local name = h.OLwho
1540 local player_i = addon.history.byname[name]
1541 local gone = tremove (addon.history, player_i)
1542 assert(gone.name == name)
1543 addon:_build_history_names()
1544 addon:Print("Removed player '%s' from history (%d total entries).",
1545 name, #gone.unique)
1510 end, 1546 end,
1511 } 1547 }
1512 local hist_dropdown = gen_easymenu_table( 1548 local hist_general_dropdown = gen_easymenu_table(
1549 {{
1550 -- this is the dropdown title, text filled in on the fly
1551 isTitle = true,
1552 notClickable = true,
1553 notCheckable = true,
1554 }},
1555 {
1556 "Delete this player's entire loot history|Permanent, no going back!",
1557 "--",
1558 CLOSE
1559 }, hist_dropdownfuncs)
1560 local hist_specific_dropdown = gen_easymenu_table(
1513 {{ 1561 {{
1514 -- this is the dropdown title, text filled in on the fly 1562 -- this is the dropdown title, text filled in on the fly
1515 notClickable = true, 1563 notClickable = true,
1516 notCheckable = true, 1564 notCheckable = true,
1517 }}, 1565 }},
1518 { 1566 {
1519 "Delete this loot history|Permanent, no going back!", 1567 "Delete this loot event from history|Permanent, no going back!",
1520 --"Delete remaining entries for this boss%boss|Erases everything from here down until a new boss/day",
1521 "--", 1568 "--",
1522 CLOSE 1569 CLOSE
1523 }, hist_dropdownfuncs) 1570 }, hist_dropdownfuncs)
1571
1572 -- Loot column
1573 --[[
1574 local function hist_st_col2_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable)
1575 end]]
1576
1577 -- Formatted timestamp column
1578 local function hist_st_col3_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable)
1579 if not fShow then
1580 cellFrame.text:SetText("")
1581 return
1582 end
1583
1584 local h = data[realrow]
1585 local cell = h.cols[column]
1586
1587 cellFrame.text:SetText(cell.value)
1588 cellFrame.text:SetTextColor(1,1,1,1)
1589
1590 --stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[h.kind])
1591 stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable_default)
1592 end
1593
1594 local function hist_st_OnClick (rowFrame, cellFrame, data, cols, row, realrow, column, stable, button, down)
1595 if (row == nil) or (realrow == nil) then return false end -- click column header, do default resorting
1596 local h = data[realrow]
1597 assert(h.kind=='hist')
1598
1599 -- Four button combinations we need to care about:
1600
1601 -- Shift-left pastes loot
1602 if IsModifiedClick("CHATLINK") and column == 2 then
1603 ChatEdit_InsertLink (h.itemlink)
1604 return true -- do not do anything further
1605 end
1606
1607 _d:SetUserData("DD index", realrow)
1608 _d:SetUserData("DD history entry", h)
1609
1610 -- The rest depends on whether we're filtering (focused in on a specific
1611 -- player) or not.
1612 if history_filter_who then
1613 -- Shift-right opens a menu
1614 if IsShiftKeyDown() and button == "RightButton" then
1615 hist_specific_dropdown[1].text = h.itemlink
1616 EasyMenu (hist_specific_dropdown, dropdownmenuframe, cellFrame, 0, 0, "MENU")
1617
1618 -- Right goes back to normal mode
1619 elseif button == "RightButton" then
1620 history_filter_who = nil
1621 stable:SetFilter(history_filter_by_recent)
1622 setstatus(hist_normal_status)
1623 end
1624
1625 else -- not focused
1626 -- Shift-right opens a menu
1627 if IsShiftKeyDown() and button == "RightButton" then
1628 hist_general_dropdown[1].text = h.OLwho
1629 EasyMenu (hist_general_dropdown, dropdownmenuframe, cellFrame, 0, 0, "MENU")
1630
1631 -- Left focuses on a specific player
1632 elseif button == "LeftButton" then
1633 history_filter_who = h.OLwho
1634 stable:SetFilter(history_filter_by_name)
1635 setstatus(hist_name_status)
1636 end
1637 end
1638
1639 return true -- do not do anything further
1640 end
1641
1642 --[[
1643 local function hist_st_OnDoubleClick (rowFrame, cellFrame, data, cols, row, realrow, column, stable, button)
1644 if (row == nil) or (realrow == nil) then return true end -- they clicked on column header, suppress reordering
1645 local h = data[realrow]
1646 assert(h.kind=='hist')
1647
1648 return true -- do not do anything further
1649 end]]
1524 1650
1525 local hist_st_cols = { 1651 local hist_st_cols = {
1526 { -- col 1 1652 { -- col 1
1527 name = "Player", 1653 name = "Player",
1528 width = 130, 1654 width = 130,
1529 DoCellUpdate = eoi_st_col2_DoCellUpdate, 1655 DoCellUpdate = eoi_st_col2_DoCellUpdate,
1530 }, 1656 },
1531 { -- col 2 1657 { -- col 2
1532 name = "Most Recent Loot", 1658 name = "Most Recent Loot",
1533 width = 250, 1659 width = 250,
1534 DoCellUpdate = hist_st_col2_DoCellUpdate, 1660 --DoCellUpdate = hist_st_col2_DoCellUpdate,
1535 }, 1661 },
1536 { -- col 3 1662 { -- col 3
1537 name = "When", 1663 name = "When",
1538 width = 250, 1664 width = 250,
1539 DoCellUpdate = hist_st_col3_DoCellUpdate, 1665 DoCellUpdate = hist_st_col3_DoCellUpdate,
1540 defaultsort = "asc", 1666 defaultsort = "asc",
1541 sort = "asc", 1667 sort = "asc",
1542 sortnext = 1, 1668 sortnext = 1,
1543 }, 1669 },
1544 } 1670 }
1545
1546 local hist_normal_status =
1547 [[Click on a row to view all history for that player only. (Click column headers to re-sort.)]]
1548 local hist_name_status =
1549 [[Right-click on any row to return to normal history display.]]
1550
1551 local history_filter_by_recent = function (st, e)
1552 if e.kind ~= 'history' then return true end
1553 return e.cols[2].OLi == 1
1554 end
1555
1556 local history_filter_who
1557 local history_filter_by_name = function (st, e)
1558 if e.kind ~= 'history' then return true end
1559 return e.OLwho == history_filter_who
1560 end
1561
1562 -- Loot column
1563 local function hist_st_col2_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable, ...)
1564 print("col2 DCU", realrow)
1565 end
1566
1567 -- Formatted timestamp column
1568 local function hist_st_col3_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable, ...)
1569 print("col3 DCU", realrow)
1570 if not fShow then
1571 cellFrame.text:SetText("")
1572 return
1573 end
1574
1575 local d = data[realrow]
1576 local cell = d.cols[column]
1577
1578 cellFrame.text:SetText(cell.value)
1579 cellFrame.text:SetTextColor(1,1,1,1)
1580
1581 --if d.kind ~= 'loot' then
1582 stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[d.kind])
1583 --else
1584 -- table:SetHighLightColor (rowFrame, table:GetDefaultHighlightBlank())
1585 --end
1586 end
1587
1588 local function hist_st_OnClick (rowFrame, cellFrame, data, cols, row, realrow, column, stable, button, ...)
1589 if (row == nil) or (realrow == nil) then return false end -- click column header, do default resorting
1590 local h = data[realrow]
1591 local kind = h.kind
1592
1593 if history_filter_who and button == "RightButton" then -- now filtering and wanting not to
1594 history_filter_who = nil
1595 stable:SetFilter(history_filter_by_recent)
1596 setstatus(hist_normal_status)
1597 elseif (not history_filter_who) and button == "LeftButton" then -- not filtering and wanting to
1598 history_filter_who = h.OLwho
1599 stable:SetFilter(history_filter_by_name)
1600 setstatus(hist_name_status)
1601 end
1602
1603 return true -- do not do anything further
1604 end
1605
1606 --[[
1607 local function hist_st_OnDoubleClick (rowFrame, cellFrame, data, cols, row, realrow, column, stable, button, ...)
1608 if (row == nil) or (realrow == nil) then return true end -- they clicked on column header, suppress reordering
1609 local h = data[realrow]
1610 local kind = h.kind
1611
1612 return true -- do not do anything further
1613 end]]
1614 1671
1615 -- Tab 4: History (implementation) 1672 -- Tab 4: History (implementation)
1616 tabs_OnGroupSelected["hist"] = function(container,specials) 1673 tabs_OnGroupSelected["hist"] = function(container,specials)
1617 histST = LibStub("ScrollingTable"):CreateST(hist_st_cols,eoi_st_displayed_rows,eoi_st_rowheight) 1674 histST = LibStub("ScrollingTable"):CreateST(hist_st_cols,eoi_st_displayed_rows,eoi_st_rowheight)
1618 _d:SetUserData("histST",histST) 1675 _d:SetUserData("histST",histST)
1662 end 1719 end
1663 1720
1664 tabs_OnGroupSelected["hist"] = function(container,specials) 1721 tabs_OnGroupSelected["hist"] = function(container,specials)
1665 local st_widget = GUI:Create("lib-st") 1722 local st_widget = GUI:Create("lib-st")
1666 -- don't need _d:GetUserData("histST") here, as it's already a local 1723 -- don't need _d:GetUserData("histST") here, as it's already a local
1724 _d:SetUserData("which ST",histST)
1667 histST:OuroLoot_Refresh() 1725 histST:OuroLoot_Refresh()
1668 st_widget:WrapST(histST) 1726 st_widget:WrapST(histST)
1669 st_widget.head_offset = 15 1727 st_widget.head_offset = 15
1670 st_widget.tail_offset = 0 1728 st_widget.tail_offset = 0
1671 container:SetLayout("Fill") 1729 container:SetLayout("Fill")
2178 editbox:SetDisabled(not opts.chatty_on_remote_changes) 2236 editbox:SetDisabled(not opts.chatty_on_remote_changes)
2179 chatgroup:AddChild(editbox) 2237 chatgroup:AddChild(editbox)
2180 w = mkbutton("Chat Frame Numbers", 2238 w = mkbutton("Chat Frame Numbers",
2181 [[Print each chat window number in its own frame, for easy reference in the editing field.]]) 2239 [[Print each chat window number in its own frame, for easy reference in the editing field.]])
2182 w:SetFullWidth(true) 2240 w:SetFullWidth(true)
2183 --w:SetDisabled(not opts.chatty_on_remote_changes)
2184 w:SetCallback("OnClick", function() 2241 w:SetCallback("OnClick", function()
2185 for i = 1, NUM_CHAT_WINDOWS do 2242 for i = 1, NUM_CHAT_WINDOWS do
2186 local cf = _G['ChatFrame'..i] 2243 local cf = _G['ChatFrame'..i]
2187 if not cf then break end 2244 if not cf then break end
2188 addon:CFPrint (cf, "This is frame number |cffff0000%d|r.", i) 2245 addon:CFPrint (cf, "This is frame number |cffff0000%d|r.", i)
2443 -- This probably causes taint... hm. 2500 -- This probably causes taint... hm.
2444 local prev_fade_time = UIDROPDOWNMENU_SHOW_TIME 2501 local prev_fade_time = UIDROPDOWNMENU_SHOW_TIME
2445 UIDROPDOWNMENU_SHOW_TIME = 4 2502 UIDROPDOWNMENU_SHOW_TIME = 4
2446 2503
2447 if dirty_tabs then 2504 if dirty_tabs then
2448 self:gui_init (g_loot, g_uniques) -- pointers known to be good by now 2505 -- pointers known to be good by now, pass them back in
2506 self:gui_init (g_loot, g_uniques)
2449 self:zero_printed_fenceposts() 2507 self:zero_printed_fenceposts()
2450 end 2508 end
2451 2509
2452 local display = GUI:Create("Frame") 2510 local display = GUI:Create("Frame")
2453 if _d then 2511 if _d then
3009 StaticPopupDialogs["OUROL_REASSIGN_ENTER"] = flib.StaticPopup{ 3067 StaticPopupDialogs["OUROL_REASSIGN_ENTER"] = flib.StaticPopup{
3010 text = "Enter the player name:", 3068 text = "Enter the player name:",
3011 button1 = ACCEPT, 3069 button1 = ACCEPT,
3012 button2 = CANCEL, 3070 button2 = CANCEL,
3013 hasEditBox = true, 3071 hasEditBox = true,
3014 --[[ XXX needed?
3015 OnShow = function(dialog)
3016 dialog.editBox:SetText("")
3017 dialog.editBox:SetFocus()
3018 end,]]
3019 OnAccept = function(dialog, data) 3072 OnAccept = function(dialog, data)
3020 local name = dialog.usertext --editBox:GetText() 3073 local name = dialog.usertext --editBox:GetText()
3021 addon:reassign_loot ("local", data.index, name) 3074 addon:reassign_loot ("local", data.index, name)
3022 data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.index) 3075 data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.index)
3023 end, 3076 end,
3027 text = "Enter a name for the loot collection:", 3080 text = "Enter a name for the loot collection:",
3028 button1 = ACCEPT, 3081 button1 = ACCEPT,
3029 button2 = CANCEL, 3082 button2 = CANCEL,
3030 hasEditBox = true, 3083 hasEditBox = true,
3031 maxLetters = 30, 3084 maxLetters = 30,
3032 --[[ XXX
3033 OnShow = function(dialog)
3034 dialog.editBox:SetText("")
3035 dialog.editBox:SetFocus()
3036 end,]]
3037 OnAccept = function(dialog)--, data) 3085 OnAccept = function(dialog)--, data)
3038 local name = dialog.usertext --editBox:GetText() 3086 local name = dialog.usertext --editBox:GetText()
3039 addon:save_saveas(name) 3087 addon:save_saveas(name)
3040 addon:BuildMainDisplay() 3088 addon:BuildMainDisplay()
3041 end, 3089 end,
3042 OnCancel = function(dialog)--, data, reason) 3090 OnCancel = function(dialog)--, data, reason)
3043 addon:BuildMainDisplay() 3091 addon:BuildMainDisplay()
3044 end, 3092 end,
3045 --[[XXX
3046 EditBoxOnEnterPressed = function(editbox)
3047 local dialog = editbox:GetParent()
3048 StaticPopupDialogs["OUROL_SAVE_SAVEAS"].OnAccept (dialog, dialog.data)
3049 dialog:Hide()
3050 end,]]
3051 } 3093 }
3052 3094
3053 3095
3054 -- Workaround this bug: http://us.battle.net/wow/en/forum/topic/3278901991 3096 -- Workaround this bug: http://us.battle.net/wow/en/forum/topic/3278901991
3055 if true then 3097 if true then