Mercurial > wow > ouroloot
comparison gui.lua @ 37:cd745a18d7c7
Mostly code cosmetic tweaks. Split up EOI and History dropdown tables. Draw attention to realm names in popups, as they don't have to match the currently-played realm.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Sat, 10 Dec 2011 01:04:16 +0000 |
parents | f62d582c5c52 |
children | 8f7ec6ccf5e3 |
comparison
equal
deleted
inserted
replaced
36:f62d582c5c52 | 37:cd745a18d7c7 |
---|---|
56 local _tabtexts, _taborder -- filled out in gui block scope | 56 local _tabtexts, _taborder -- filled out in gui block scope |
57 | 57 |
58 -- Working around this bug: | 58 -- Working around this bug: |
59 -- http://forums.wowace.com/showpost.php?p=295202&postcount=31 | 59 -- http://forums.wowace.com/showpost.php?p=295202&postcount=31 |
60 do | 60 do |
61 local function FixFrameLevel (level, ...) | 61 local function fix_frame_level (level, ...) |
62 for i = 1, select("#", ...) do | 62 for i = 1, select("#", ...) do |
63 local button = select(i, ...) | 63 local button = select(i, ...) |
64 button:SetFrameLevel(level) | 64 button:SetFrameLevel(level) |
65 end | 65 end |
66 end | 66 end |
67 | 67 |
68 local function FixMenuFrameLevels() | 68 local function fix_menu_frame_levels() |
69 local f = DropDownList1 | 69 local f = _G.DropDownList1 |
70 local i = 1 | 70 local i = 1 |
71 while f do | 71 while f do |
72 FixFrameLevel (f:GetFrameLevel() + 2, f:GetChildren()) | 72 fix_frame_level (f:GetFrameLevel() + 2, f:GetChildren()) |
73 i = i + 1 | 73 i = i + 1 |
74 f = _G["DropDownList"..i] | 74 f = _G["DropDownList"..i] |
75 end | 75 end |
76 end | 76 end |
77 | 77 |
78 -- To fix Blizzard's bug caused by the new "self:SetFrameLevel(2);" | 78 -- To fix Blizzard's bug caused by the new "self:SetFrameLevel(2);" |
79 hooksecurefunc("UIDropDownMenu_CreateFrames", FixMenuFrameLevels) | 79 hooksecurefunc("UIDropDownMenu_CreateFrames", fix_menu_frame_levels) |
80 end | 80 end |
81 | 81 |
82 | 82 |
83 ------ Behind the scenes routines | 83 ------ Behind the scenes routines |
84 -- Text generation | 84 -- Text generation |
324 | 324 |
325 end | 325 end |
326 | 326 |
327 | 327 |
328 ------ Main GUI Window | 328 ------ Main GUI Window |
329 -- Lots of shared data here, kept in a large local scope. For readability, | 329 local _d -- display when it's open, eoiST when it's not |
330 -- indentation of the scope as a whole is kicked left a notch. | |
331 do | |
332 local _d | |
333 local function setstatus(txt) _d:SetStatusText(txt) end | 330 local function setstatus(txt) _d:SetStatusText(txt) end |
334 local function statusy_OnLeave() setstatus("") end | 331 local function statusy_OnLeave() setstatus("") end |
335 local tabgroup_tabs | 332 local tabgroup_tabs |
336 | 333 |
337 --[[ | 334 --[[ |
370 tabs_OnGroupSelected[v] = tabs_generated_text_OGS | 367 tabs_OnGroupSelected[v] = tabs_generated_text_OGS |
371 end | 368 end |
372 end | 369 end |
373 end | 370 end |
374 | 371 |
375 -- Tab 1: Events Of Interest | 372 --[[ |
376 -- This actually takes up quite a bit of the file. | 373 Dropdown menu handling |
374 ]] | |
375 -- forward decls | |
377 local eoi_editcell | 376 local eoi_editcell |
377 | |
378 local dropdownfuncs | |
379 do | |
380 local ddf_mt = { | |
381 __index = { | |
382 -- more stuff should be moved into this table | |
383 [CLOSE] = function() CloseDropDownMenus() end, | |
384 } | |
385 } | |
386 dropdownfuncs = function(t) | |
387 return setmetatable(t, ddf_mt) | |
388 end | |
389 end | |
378 | 390 |
379 local function dropdownmenu_handler (ddbutton, subfunc, arg) | 391 local function dropdownmenu_handler (ddbutton, subfunc, arg) |
380 local i = _d and _d.GetUserData and _d:GetUserData("DD loot index") | 392 local i = _d and _d.GetUserData and _d:GetUserData("DD loot index") |
381 if i then | 393 if i then |
382 subfunc(i,arg) | 394 subfunc(i,arg) |
412 end | 424 end |
413 return initial | 425 return initial |
414 end | 426 end |
415 | 427 |
416 local dropdownmenuframe = CreateFrame("Frame", "OuroLootDropDownMenu", nil, "UIDropDownMenuTemplate") | 428 local dropdownmenuframe = CreateFrame("Frame", "OuroLootDropDownMenu", nil, "UIDropDownMenuTemplate") |
417 local dropdownfuncs | 429 |
418 dropdownfuncs = { | 430 |
419 [CLOSE] = function() CloseDropDownMenus() end, | 431 -- Tab 1: Events Of Interest |
420 | 432 -- This actually takes up quite a bit of the file. |
433 local eoi_dropdownfuncs | |
434 eoi_dropdownfuncs = dropdownfuncs{ | |
421 df_INSERT = function(rowi,text) | 435 df_INSERT = function(rowi,text) |
422 local which = (text == 'loot') and "OUROL_EOI_INSERT_LOOT" or "OUROL_EOI_INSERT" | 436 local which = (text == 'loot') and "OUROL_EOI_INSERT_LOOT" or "OUROL_EOI_INSERT" |
423 local dialog = StaticPopup_Show(which,text) | 437 local dialog = StaticPopup_Show(which,text) |
424 dialog.editBox:SetScript("OnTextChanged",StaticPopup_EditBoxOnTextChanged) | 438 dialog.editBox:SetScript("OnTextChanged",StaticPopup_EditBoxOnTextChanged) |
425 dialog.data = {rowindex=rowi, display=_d, kind=text} | 439 dialog.data = {rowindex=rowi, display=_d, kind=text} |
432 if gone.kind == 'loot' and IsShiftKeyDown() then | 446 if gone.kind == 'loot' and IsShiftKeyDown() then |
433 addon:_delHistoryEntry (rowi, gone) | 447 addon:_delHistoryEntry (rowi, gone) |
434 end | 448 end |
435 end, | 449 end, |
436 | 450 |
437 ["Delete this history event"] = function(rowi) | |
438 --local gone = tremove(g_loot,rowi) | |
439 --addon:Print("Removed %s.", | |
440 --gone.itemlink or gone.bosskill or gone.startday.text) | |
441 end, | |
442 | |
443 ["Delete remaining entries for this day"] = function(rowi,kind) | 451 ["Delete remaining entries for this day"] = function(rowi,kind) |
444 -- if kind is boss, also need to stop at new timestamp | 452 -- if kind is boss, also need to stop at new timestamp |
445 local fencepost = addon._find_timeboss_fencepost (kind, rowi) | 453 local fencepost = addon._find_timeboss_fencepost (kind, rowi) |
446 local count = fencepost and (fencepost-rowi) or (#g_loot-rowi+1) | 454 local count = fencepost and (fencepost-rowi) or (#g_loot-rowi+1) |
447 repeat | 455 repeat |
448 dropdownfuncs.df_DELETE(rowi) | 456 eoi_dropdownfuncs.df_DELETE(rowi) |
449 count = count - 1 | 457 count = count - 1 |
450 until count < 1 | 458 until count < 1 |
451 end, | 459 end, |
452 | 460 |
453 ["Rebroadcast this loot entry"] = function(rowi) | 461 ["Rebroadcast this loot entry"] = function(rowi) |
510 dialog.data = {index=rowi, display=_d} | 518 dialog.data = {index=rowi, display=_d} |
511 end, | 519 end, |
512 } | 520 } |
513 -- Would be better to move the %arg to this list rather than below, but | 521 -- Would be better to move the %arg to this list rather than below, but |
514 -- that's a lot of extra effort that doesn't buy much in return. | 522 -- that's a lot of extra effort that doesn't buy much in return. |
515 dropdownfuncs["Delete this loot event"] = dropdownfuncs.df_DELETE | 523 eoi_dropdownfuncs["Delete this loot event"] = eoi_dropdownfuncs.df_DELETE |
516 dropdownfuncs["Delete this boss event"] = dropdownfuncs.df_DELETE | 524 eoi_dropdownfuncs["Delete this boss event"] = eoi_dropdownfuncs.df_DELETE |
517 dropdownfuncs["Insert new loot entry"] = dropdownfuncs.df_INSERT | 525 eoi_dropdownfuncs["Insert new loot entry"] = eoi_dropdownfuncs.df_INSERT |
518 dropdownfuncs["Insert new boss kill event"] = dropdownfuncs.df_INSERT | 526 eoi_dropdownfuncs["Insert new boss kill event"] = eoi_dropdownfuncs.df_INSERT |
519 dropdownfuncs["Mark as disenchanted"] = dropdownfuncs["Mark as normal"] | 527 eoi_dropdownfuncs["Mark as disenchanted"] = eoi_dropdownfuncs["Mark as normal"] |
520 dropdownfuncs["Mark as guild vault"] = dropdownfuncs["Mark as normal"] | 528 eoi_dropdownfuncs["Mark as guild vault"] = eoi_dropdownfuncs["Mark as normal"] |
521 dropdownfuncs["Mark as offspec"] = dropdownfuncs["Mark as normal"] | 529 eoi_dropdownfuncs["Mark as offspec"] = eoi_dropdownfuncs["Mark as normal"] |
522 dropdownfuncs["Delete remaining entries for this boss"] = dropdownfuncs["Delete remaining entries for this day"] | 530 eoi_dropdownfuncs["Delete remaining entries for this boss"] = |
523 dropdownfuncs["Rebroadcast this day"] = dropdownfuncs["Rebroadcast this boss"] | 531 eoi_dropdownfuncs["Delete remaining entries for this day"] |
532 eoi_dropdownfuncs["Rebroadcast this day"] = eoi_dropdownfuncs["Rebroadcast this boss"] | |
524 local eoi_time_dropdown = gen_easymenu_table( | 533 local eoi_time_dropdown = gen_easymenu_table( |
525 {{ | 534 {{ |
526 -- this is the dropdown title, text filled in on the fly | 535 -- this is the dropdown title, text filled in on the fly |
527 isTitle = true, | 536 isTitle = true, |
528 notClickable = true, | 537 notClickable = true, |
532 "Rebroadcast this day%time|Broadcasts everything from here down until a new day.", | 541 "Rebroadcast this day%time|Broadcasts everything from here down until a new day.", |
533 "Delete remaining entries for this day%time|Erases everything from here down until a new day.", | 542 "Delete remaining entries for this day%time|Erases everything from here down until a new day.", |
534 "Insert new loot entry%loot|Inserts new loot above this one, prompting you for information.", | 543 "Insert new loot entry%loot|Inserts new loot above this one, prompting you for information.", |
535 "Insert new boss kill event%boss|Inserts new event above this one, prompting you for information.", | 544 "Insert new boss kill event%boss|Inserts new event above this one, prompting you for information.", |
536 CLOSE | 545 CLOSE |
537 }, dropdownfuncs) | 546 }, eoi_dropdownfuncs) |
538 local eoi_loot_dropdown = gen_easymenu_table( | 547 local eoi_loot_dropdown = gen_easymenu_table( |
539 {{ | 548 {{ |
540 -- this is the dropdown title, text filled in on the fly | 549 -- this is the dropdown title, text filled in on the fly |
541 notClickable = true, | 550 notClickable = true, |
542 notCheckable = true, | 551 notCheckable = true, |
553 "Insert new loot entry%loot|Inserts new loot above this one, prompting you for information.", | 562 "Insert new loot entry%loot|Inserts new loot above this one, prompting you for information.", |
554 "Insert new boss kill event%boss|Inserts new event above this one, prompting you for information.", | 563 "Insert new boss kill event%boss|Inserts new event above this one, prompting you for information.", |
555 "Edit note|Same as double-clicking in the notes column.", | 564 "Edit note|Same as double-clicking in the notes column.", |
556 "--", | 565 "--", |
557 CLOSE | 566 CLOSE |
558 }, dropdownfuncs) | 567 }, eoi_dropdownfuncs) |
559 local eoi_player_dropdown = gen_easymenu_table( | 568 local eoi_player_dropdown = gen_easymenu_table( |
560 { | 569 { |
561 { | 570 { |
562 -- this is the dropdown title, text filled in on the fly | 571 -- this is the dropdown title, text filled in on the fly |
563 isTitle = true, | 572 isTitle = true, |
573 }, | 582 }, |
574 }, | 583 }, |
575 { | 584 { |
576 "Show only this player", | 585 "Show only this player", |
577 CLOSE | 586 CLOSE |
578 }, dropdownfuncs) | 587 }, eoi_dropdownfuncs) |
579 local eoi_boss_dropdown = gen_easymenu_table( | 588 local eoi_boss_dropdown = gen_easymenu_table( |
580 {{ | 589 {{ |
581 -- this is the dropdown title, text filled in on the fly | 590 -- this is the dropdown title, text filled in on the fly |
582 isTitle = true, | 591 isTitle = true, |
583 notClickable = true, | 592 notClickable = true, |
590 "Delete remaining entries for this boss%boss|Erases everything from here down until a new boss/day.", | 599 "Delete remaining entries for this boss%boss|Erases everything from here down until a new boss/day.", |
591 "Insert new loot entry%loot|Inserts new loot above this one, prompting you for information.", | 600 "Insert new loot entry%loot|Inserts new loot above this one, prompting you for information.", |
592 "Insert new boss kill event%boss|Inserts new event above this one, prompting you for information.", | 601 "Insert new boss kill event%boss|Inserts new event above this one, prompting you for information.", |
593 "--", | 602 "--", |
594 CLOSE | 603 CLOSE |
595 }, dropdownfuncs) | 604 }, eoi_dropdownfuncs) |
596 local hist_dropdown = gen_easymenu_table( | |
597 {{ | |
598 -- this is the dropdown title, text filled in on the fly | |
599 notClickable = true, | |
600 notCheckable = true, | |
601 }}, | |
602 { | |
603 "Delete this history event|Permanent, no going back!", | |
604 --"Delete remaining entries for this boss%boss|Erases everything from here down until a new boss/day", | |
605 "--", | |
606 CLOSE | |
607 }, dropdownfuncs) | |
608 | 605 |
609 --[[ quoted verbatim from lib-st docs: | 606 --[[ quoted verbatim from lib-st docs: |
610 rowFrame This is the UI Frame table for the row. | 607 rowFrame This is the UI Frame table for the row. |
611 cellFrame This is the UI Frame table for the cell in the row. | 608 cellFrame This is the UI Frame table for the cell in the row. |
612 data This is the data table supplied to the scrolling table (in case you lost it :) ) | 609 data This is the data table supplied to the scrolling table (in case you lost it :) ) |
706 for i = 1, #raiders do | 703 for i = 1, #raiders do |
707 local name = raiders[i] | 704 local name = raiders[i] |
708 raiders[i] = { | 705 raiders[i] = { |
709 text = name, | 706 text = name, |
710 func = dropdownmenu_handler, | 707 func = dropdownmenu_handler, |
711 arg1 = dropdownfuncs.df_REASSIGN, | 708 arg1 = eoi_dropdownfuncs.df_REASSIGN, |
712 arg2 = name, | 709 arg2 = name, |
713 notCheckable = true, | 710 notCheckable = true, |
714 } | 711 } |
715 end | 712 end |
716 eoi_player_dropdown[2].menuList = | 713 eoi_player_dropdown[2].menuList = |
717 gen_easymenu_table (raiders, {"Enter name...",CLOSE}, dropdownfuncs) | 714 gen_easymenu_table (raiders, {"Enter name...",CLOSE}, eoi_dropdownfuncs) |
718 if e.disposition == 'shard' or e.disposition == 'gvault' then | 715 if e.disposition == 'shard' or e.disposition == 'gvault' then |
719 eoi_player_dropdown[2].disabled = true | 716 eoi_player_dropdown[2].disabled = true |
720 eoi_player_dropdown[2].tooltipTitle = "Cannot Reassign" | 717 eoi_player_dropdown[2].tooltipTitle = "Cannot Reassign" |
721 eoi_player_dropdown[2].tooltipText = "You must first mark this item as 'normal' or 'offspec' before reassignment." | 718 eoi_player_dropdown[2].tooltipText = "You must first mark this item as 'normal' or 'offspec' before reassignment." |
722 else | 719 else |
1001 end | 998 end |
1002 -- ...and call it. | 999 -- ...and call it. |
1003 return tabs_OnGroupSelected["eoi"](ocontainer,specials) | 1000 return tabs_OnGroupSelected["eoi"](ocontainer,specials) |
1004 end | 1001 end |
1005 | 1002 |
1003 | |
1006 -- Tab 2/3 (generated text) | 1004 -- Tab 2/3 (generated text) |
1007 function tabs_generated_text_OGS (container, specials, text_kind) | 1005 function tabs_generated_text_OGS (container, specials, text_kind) |
1008 container:SetLayout("Fill") | 1006 container:SetLayout("Fill") |
1009 local box = GUI:Create("MultiLineEditBox") | 1007 local box = GUI:Create("MultiLineEditBox") |
1010 box:SetFullWidth(true) | 1008 box:SetFullWidth(true) |
1052 end) | 1050 end) |
1053 specials:AddChild(w) | 1051 specials:AddChild(w) |
1054 _populate_text_specials (box, specials, mkbutton, text_kind) | 1052 _populate_text_specials (box, specials, mkbutton, text_kind) |
1055 end | 1053 end |
1056 | 1054 |
1055 | |
1057 -- Tab 4: History | 1056 -- Tab 4: History |
1058 -- Much of the implementation here follows a similar desgin for the first | 1057 -- Much of the implementation here follows a similar desgin for the first |
1059 -- tab's handling of ST objects. We will even reuse its controlling tables | 1058 -- tab's handling of ST objects. We will even reuse its controlling tables |
1060 -- when feasible. | 1059 -- when feasible. |
1061 do | 1060 local histST, hist_dropdownfuncs |
1062 local histST | 1061 |
1063 local hist_st_cols = { | 1062 hist_dropdownfuncs = dropdownfuncs{ |
1064 { -- col 1 | 1063 ["Delete this loot history"] = function(rowi) |
1065 name = "Player", | 1064 --local gone = tremove(g_loot,rowi) |
1066 width = 130, | 1065 --addon:Print("Removed %s.", |
1067 DoCellUpdate = eoi_st_col2_DoCellUpdate, | 1066 --gone.itemlink or gone.bosskill or gone.startday.text) |
1068 }, | 1067 end, |
1069 { -- col 2 | 1068 } |
1070 name = "Most Recent Loot", | 1069 local hist_dropdown = gen_easymenu_table( |
1071 width = 250, | 1070 {{ |
1072 DoCellUpdate = hist_st_col2_DoCellUpdate, | 1071 -- this is the dropdown title, text filled in on the fly |
1073 }, | 1072 notClickable = true, |
1074 { -- col 3 | 1073 notCheckable = true, |
1075 name = "When", | 1074 }}, |
1076 width = 250, | 1075 { |
1077 DoCellUpdate = hist_st_col3_DoCellUpdate, | 1076 "Delete this loot history|Permanent, no going back!", |
1078 defaultsort = "asc", | 1077 --"Delete remaining entries for this boss%boss|Erases everything from here down until a new boss/day", |
1079 sort = "asc", | 1078 "--", |
1080 sortnext = 1, | 1079 CLOSE |
1081 }, | 1080 }, hist_dropdownfuncs) |
1081 | |
1082 local hist_st_cols = { | |
1083 { -- col 1 | |
1084 name = "Player", | |
1085 width = 130, | |
1086 DoCellUpdate = eoi_st_col2_DoCellUpdate, | |
1087 }, | |
1088 { -- col 2 | |
1089 name = "Most Recent Loot", | |
1090 width = 250, | |
1091 DoCellUpdate = hist_st_col2_DoCellUpdate, | |
1092 }, | |
1093 { -- col 3 | |
1094 name = "When", | |
1095 width = 250, | |
1096 DoCellUpdate = hist_st_col3_DoCellUpdate, | |
1097 defaultsort = "asc", | |
1098 sort = "asc", | |
1099 sortnext = 1, | |
1100 }, | |
1101 } | |
1102 | |
1103 local hist_normal_status = | |
1104 [[Click on a row to view all history for that player only. (Click column headers to re-sort.)]] | |
1105 local hist_name_status = | |
1106 [[Right-click on any row to return to normal history display.]] | |
1107 | |
1108 local history_filter_by_recent = function (st, e) | |
1109 if e.kind ~= 'history' then return true end | |
1110 return e.cols[2].OLi == 1 | |
1111 end | |
1112 | |
1113 local history_filter_who | |
1114 local history_filter_by_name = function (st, e) | |
1115 if e.kind ~= 'history' then return true end | |
1116 return e.OLwho == history_filter_who | |
1117 end | |
1118 | |
1119 -- Loot column | |
1120 local function hist_st_col2_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable, ...) | |
1121 print("col2 DCU", realrow) | |
1122 end | |
1123 | |
1124 -- Formatted timestamp column | |
1125 local function hist_st_col3_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable, ...) | |
1126 print("col3 DCU", realrow) | |
1127 if not fShow then | |
1128 cellFrame.text:SetText("") | |
1129 return | |
1130 end | |
1131 | |
1132 local d = data[realrow] | |
1133 local cell = d.cols[column] | |
1134 | |
1135 cellFrame.text:SetText(cell.value) | |
1136 cellFrame.text:SetTextColor(1,1,1,1) | |
1137 | |
1138 --if d.kind ~= 'loot' then | |
1139 stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[d.kind]) | |
1140 --else | |
1141 -- table:SetHighLightColor (rowFrame, table:GetDefaultHighlightBlank()) | |
1142 --end | |
1143 end | |
1144 | |
1145 local function hist_st_OnClick (rowFrame, cellFrame, data, cols, row, realrow, column, stable, button, ...) | |
1146 if (row == nil) or (realrow == nil) then return false end -- click column header, do default resorting | |
1147 local h = data[realrow] | |
1148 local kind = h.kind | |
1149 | |
1150 if history_filter_who and button == "RightButton" then -- now filtering and wanting not to | |
1151 history_filter_who = nil | |
1152 stable:SetFilter(history_filter_by_recent) | |
1153 setstatus(hist_normal_status) | |
1154 elseif (not history_filter_who) and button == "LeftButton" then -- not filtering and wanting to | |
1155 history_filter_who = h.OLwho | |
1156 stable:SetFilter(history_filter_by_name) | |
1157 setstatus(hist_name_status) | |
1158 end | |
1159 | |
1160 return true -- do not do anything further | |
1161 end | |
1162 | |
1163 --[[ | |
1164 local function hist_st_OnDoubleClick (rowFrame, cellFrame, data, cols, row, realrow, column, stable, button, ...) | |
1165 if (row == nil) or (realrow == nil) then return true end -- they clicked on column header, suppress reordering | |
1166 local h = data[realrow] | |
1167 local kind = h.kind | |
1168 | |
1169 return true -- do not do anything further | |
1170 end]] | |
1171 | |
1172 -- Tab 4: History (implementation) | |
1173 tabs_OnGroupSelected["hist"] = function(container,specials) | |
1174 histST = LibStub("ScrollingTable"):CreateST(hist_st_cols,eoi_st_displayed_rows,eoi_st_rowheight) | |
1175 _d:SetUserData("histST",histST) | |
1176 if addon.author_debug then | |
1177 _G.OLHST = histST | |
1178 end | |
1179 | |
1180 if not eoi_st_otherrow_bgcolortable_default then | |
1181 eoi_st_otherrow_bgcolortable_default = histST:GetDefaultHighlightBlank() | |
1182 setmetatable(eoi_st_otherrow_bgcolortable, {__index = function (bg, key) | |
1183 return eoi_st_otherrow_bgcolortable_default | |
1184 end}) | |
1185 end | |
1186 | |
1187 addon:_build_history_names() | |
1188 addon:_fill_out_hist_data(1) | |
1189 histST:SetData(addon.history.st) | |
1190 histST:RegisterEvents{ | |
1191 OnEnter = eoi_st_OnEnter, | |
1192 OnLeave = eoi_st_OnLeave, | |
1193 OnClick = hist_st_OnClick, | |
1194 --OnDoubleClick = hist_st_OnDoubleClick, | |
1082 } | 1195 } |
1083 | 1196 local oldrefresh = histST.Refresh |
1084 local hist_normal_status = [[Click on a row to view all history for that player only. (Click column headers to re-sort.)]] | 1197 histST.Refresh = function (self, opt_index) |
1085 local hist_name_status = [[Right-click on any row to return to normal history display.]] | 1198 addon:_fill_out_hist_data(opt_index) |
1086 | 1199 return oldrefresh(self) |
1087 local history_filter_by_recent = function (st, e) | 1200 end |
1088 if e.kind ~= 'history' then return true end | 1201 histST.OuroLoot_Refresh = function (self, opt_index) |
1089 return e.cols[2].OLi == 1 | 1202 addon:_fill_out_hist_data(opt_index) |
1090 end | 1203 self:SortData() -- calls hooked refresh |
1091 | 1204 end |
1092 local history_filter_who | 1205 |
1093 local history_filter_by_name = function (st, e) | 1206 histST:SetFilter(history_filter_by_recent) |
1094 if e.kind ~= 'history' then return true end | 1207 |
1095 return e.OLwho == history_filter_who | 1208 -- Zaps history for the given realm, or the current (current-playing |
1096 end | 1209 -- realm, not currently-displayed realm) one if not specified. |
1097 | 1210 local function reset_current_realm (opt_realmname) |
1098 -- Loot column | 1211 local r = assert(opt_realmname or GetRealmName()) |
1099 local function hist_st_col2_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable, ...) | 1212 -- new .history table: |
1100 print("col2 DCU", realrow) | 1213 addon.history_all[r] = addon:_prep_new_history_category (nil, r) |
1101 end | 1214 addon.history = addon.history_all[r] |
1102 | 1215 addon.hist_clean = nil |
1103 -- Formatted timestamp column | 1216 -- new .history.st table: |
1104 local function hist_st_col3_DoCellUpdate (rowFrame, cellFrame, data, cols, row, realrow, column, fShow, stable, ...) | 1217 histST:OuroLoot_Refresh() |
1105 print("col3 DCU", realrow) | 1218 histST:SetData(addon.history.st) |
1106 if not fShow then | 1219 end |
1107 cellFrame.text:SetText("") | |
1108 return | |
1109 end | |
1110 | |
1111 local d = data[realrow] | |
1112 local cell = d.cols[column] | |
1113 | |
1114 cellFrame.text:SetText(cell.value) | |
1115 cellFrame.text:SetTextColor(1,1,1,1) | |
1116 | |
1117 --if d.kind ~= 'loot' then | |
1118 stable:SetHighLightColor (rowFrame, eoi_st_otherrow_bgcolortable[d.kind]) | |
1119 --else | |
1120 -- table:SetHighLightColor (rowFrame, table:GetDefaultHighlightBlank()) | |
1121 --end | |
1122 end | |
1123 | |
1124 local function hist_st_OnClick (rowFrame, cellFrame, data, cols, row, realrow, column, stable, button, ...) | |
1125 if (row == nil) or (realrow == nil) then return false end -- click column header, do default resorting | |
1126 local h = data[realrow] | |
1127 local kind = h.kind | |
1128 | |
1129 if history_filter_who and button == "RightButton" then -- now filtering and wanting not to | |
1130 history_filter_who = nil | |
1131 stable:SetFilter(history_filter_by_recent) | |
1132 setstatus(hist_normal_status) | |
1133 elseif (not history_filter_who) and button == "LeftButton" then -- not filtering and wanting to | |
1134 history_filter_who = h.OLwho | |
1135 stable:SetFilter(history_filter_by_name) | |
1136 setstatus(hist_name_status) | |
1137 end | |
1138 | |
1139 return true -- do not do anything further | |
1140 end | |
1141 | |
1142 --[[ | |
1143 local function hist_st_OnDoubleClick (rowFrame, cellFrame, data, cols, row, realrow, column, stable, button, ...) | |
1144 if (row == nil) or (realrow == nil) then return true end -- they clicked on column header, suppress reordering | |
1145 local h = data[realrow] | |
1146 local kind = h.kind | |
1147 | |
1148 return true -- do not do anything further | |
1149 end]] | |
1150 | 1220 |
1151 tabs_OnGroupSelected["hist"] = function(container,specials) | 1221 tabs_OnGroupSelected["hist"] = function(container,specials) |
1152 histST = LibStub("ScrollingTable"):CreateST(hist_st_cols,eoi_st_displayed_rows,eoi_st_rowheight) | 1222 local st_widget = GUI:Create("lib-st") |
1153 _d:SetUserData("histST",histST) | 1223 -- don't need _d:GetUserData("histST") here, as it's already a local |
1154 if addon.author_debug then | 1224 histST:OuroLoot_Refresh() |
1155 _G.OLHST = histST | 1225 st_widget:WrapST(histST) |
1156 end | 1226 st_widget.head_offset = 15 |
1157 | 1227 st_widget.tail_offset = 0 |
1158 if not eoi_st_otherrow_bgcolortable_default then | 1228 container:SetLayout("Fill") |
1159 eoi_st_otherrow_bgcolortable_default = histST:GetDefaultHighlightBlank() | 1229 container:AddChild(st_widget) |
1160 setmetatable(eoi_st_otherrow_bgcolortable, {__index = function (bg, key) | 1230 setstatus(hist_normal_status) |
1161 return eoi_st_otherrow_bgcolortable_default | 1231 |
1162 end}) | 1232 local b |
1163 end | 1233 do |
1164 | 1234 local realms,current = {},1 |
1165 addon:_build_history_names() | 1235 for realmname,histtable in pairs(addon.history_all) do |
1166 addon:_fill_out_hist_data(1) | 1236 if type(histtable) == 'table' then |
1167 histST:SetData(addon.history.st) | 1237 tinsert(realms,realmname) |
1168 histST:RegisterEvents{ | 1238 if addon.history == histtable then current = #realms end |
1169 OnEnter = eoi_st_OnEnter, | |
1170 OnLeave = eoi_st_OnLeave, | |
1171 OnClick = hist_st_OnClick, | |
1172 --OnDoubleClick = hist_st_OnDoubleClick, | |
1173 } | |
1174 local oldrefresh = histST.Refresh | |
1175 histST.Refresh = function (self, opt_index) | |
1176 addon:_fill_out_hist_data(opt_index) | |
1177 return oldrefresh(self) | |
1178 end | |
1179 histST.OuroLoot_Refresh = function (self, opt_index) | |
1180 addon:_fill_out_hist_data(opt_index) | |
1181 self:SortData() -- calls hooked refresh | |
1182 end | |
1183 | |
1184 histST:SetFilter(history_filter_by_recent) | |
1185 | |
1186 -- Zaps history for the given realm, or the current (current-playing | |
1187 -- realm, not currently-displayed realm) one if not specified. | |
1188 local function reset_current_realm (opt_realmname) | |
1189 local r = assert(opt_realmname or GetRealmName()) | |
1190 -- new .history table: | |
1191 addon.history_all[r] = addon:_prep_new_history_category (nil, r) | |
1192 addon.history = addon.history_all[r] | |
1193 addon.hist_clean = nil | |
1194 -- new .history.st table: | |
1195 histST:OuroLoot_Refresh() | |
1196 histST:SetData(addon.history.st) | |
1197 end | |
1198 | |
1199 tabs_OnGroupSelected["hist"] = function(container,specials) | |
1200 local st_widget = GUI:Create("lib-st") | |
1201 -- don't need _d:GetUserData("histST") here, as it's already a local | |
1202 histST:OuroLoot_Refresh() | |
1203 st_widget:WrapST(histST) | |
1204 st_widget.head_offset = 15 | |
1205 st_widget.tail_offset = 0 | |
1206 container:SetLayout("Fill") | |
1207 container:AddChild(st_widget) | |
1208 setstatus(hist_normal_status) | |
1209 | |
1210 local b | |
1211 do | |
1212 local realms,current = {},1 | |
1213 for realmname,histtable in pairs(addon.history_all) do | |
1214 if type(histtable) == 'table' then | |
1215 tinsert(realms,realmname) | |
1216 if addon.history == histtable then current = #realms end | |
1217 end | |
1218 end | 1239 end |
1219 b = mkbutton("Dropdown", nil, "", [[Which realm to display]]) | |
1220 b:SetFullWidth(true) | |
1221 b:SetLabel() -- required even when empty, see ace3 ticket #234 | |
1222 b:SetList(realms) | |
1223 b:SetValue(current) | |
1224 b:SetCallback("OnValueChanged", function(_dd,event,choice) | |
1225 local r = realms[choice] | |
1226 addon.history = addon:_prep_new_history_category (addon.history_all[r], r) | |
1227 addon.hist_clean = nil | |
1228 histST:OuroLoot_Refresh() | |
1229 histST:SetData(addon.history.st) | |
1230 -- Reset filters to normal | |
1231 history_filter_who = nil | |
1232 histST:SetFilter(history_filter_by_recent) | |
1233 setstatus(hist_normal_status) | |
1234 return addon:redisplay() | |
1235 end) | |
1236 specials:AddChild(b) | |
1237 end | 1240 end |
1238 | 1241 b = mkbutton("Dropdown", nil, "", [[Which realm to display]]) |
1239 --[[ b = GUI:Create("Spacer") b:SetFullWidth(true) b:SetHeight(10) specials:AddChild(b) ]] | |
1240 | |
1241 b = mkbutton("Regenerate", | |
1242 [[Erases all history entries from the displayed realm, and regenerates it from current loot information.]]) | |
1243 b:SetFullWidth(true) | 1242 b:SetFullWidth(true) |
1244 b:SetDisabled (#addon.history == 0) | 1243 b:SetLabel() -- required even when empty, see ace3 ticket #234 |
1245 b:SetCallback("OnClick", function(_b) | 1244 b:SetList(realms) |
1246 addon:rewrite_history (addon.history.realm) | 1245 b:SetValue(current) |
1246 b:SetCallback("OnValueChanged", function(_dd,event,choice) | |
1247 local r = realms[choice] | |
1248 addon.history = addon:_prep_new_history_category (addon.history_all[r], r) | |
1249 addon.hist_clean = nil | |
1247 histST:OuroLoot_Refresh() | 1250 histST:OuroLoot_Refresh() |
1248 histST:SetData(addon.history.st) | 1251 histST:SetData(addon.history.st) |
1249 addon:Print("%s history has been regenerated.", addon.history.realm) | 1252 -- Reset filters to normal |
1253 history_filter_who = nil | |
1254 histST:SetFilter(history_filter_by_recent) | |
1255 setstatus(hist_normal_status) | |
1250 return addon:redisplay() | 1256 return addon:redisplay() |
1251 end) | 1257 end) |
1252 specials:AddChild(b) | 1258 specials:AddChild(b) |
1253 | 1259 end |
1254 b = mkbutton('hist_clear', "Clear Realm History", | 1260 |
1255 [[|cffff1010Erases absolutely all> history entries from the displayed realm.]]) | 1261 --[[ b = GUI:Create("Spacer") b:SetFullWidth(true) b:SetHeight(10) specials:AddChild(b) ]] |
1256 b:SetFullWidth(true) | 1262 |
1257 b:SetCallback("OnClick", function (_b) | 1263 b = mkbutton("Regenerate", |
1258 local dialog = StaticPopup_Show("OUROL_HIST_CLEAR", addon.history.realm) | 1264 [[Erases all history entries from the displayed realm, and regenerates it from current loot information.]]) |
1259 dialog.data = addon | 1265 b:SetFullWidth(true) |
1260 dialog.data2 = function(_addon) | 1266 b:SetDisabled (#addon.history == 0) |
1261 reset_current_realm(_addon.history.realm) | 1267 b:SetCallback("OnClick", function(_b) |
1262 end | 1268 local dialog = StaticPopup_Show("OUROL_HIST_REGEN", addon.history.realm) |
1263 end) | 1269 dialog.data = addon |
1264 specials:AddChild(b) | 1270 dialog.data2 = function(_addon) |
1265 | 1271 _addon:rewrite_history (_addon.history.realm) |
1266 b = mkbutton('hist_clear_all', "Clear All History", | 1272 histST:OuroLoot_Refresh() |
1267 [[|cffff1010Erases absolutely all> history entries from ALL realms.]]) | 1273 histST:SetData(_addon.history.st) |
1268 b:SetFullWidth(true) | 1274 end |
1269 b:SetCallback("OnClick", function (_b) | 1275 end) |
1270 local dialog = StaticPopup_Show("OUROL_HIST_CLEAR", "ALL realms") | 1276 specials:AddChild(b) |
1271 dialog.data = addon | 1277 |
1272 dialog.data2 = function(_addon) | 1278 b = mkbutton('hist_clear', "Clear Realm History", |
1273 _addon.history_all = {} | 1279 [[|cffff1010Erases absolutely all> history entries from the displayed realm.]]) |
1274 reset_current_realm() | 1280 b:SetFullWidth(true) |
1275 end | 1281 b:SetCallback("OnClick", function (_b) |
1276 end) | 1282 local dialog = StaticPopup_Show("OUROL_HIST_CLEAR", addon.history.realm) |
1277 specials:AddChild(b) | 1283 dialog.data = addon |
1278 | 1284 dialog.data2 = function(_addon) |
1279 b = mkbutton('hist_clear_old', "Clear Older", | 1285 reset_current_realm(_addon.history.realm) |
1280 [[Preserves only the latest loot entry for each player on the displayed realm, removing all earlier ones.]]) | 1286 end |
1281 b:SetFullWidth(true) | 1287 end) |
1282 b:SetCallback("OnClick", function (_b) | 1288 specials:AddChild(b) |
1283 local dialog = StaticPopup_Show("OUROL_HIST_PREEN", addon.history.realm) | 1289 |
1284 dialog.data = addon | 1290 b = mkbutton('hist_clear_all', "Clear All History", |
1285 dialog.data2 = function(_addon) | 1291 [[|cffff1010Erases absolutely all> history entries from ALL realms.]]) |
1286 _addon:preen_history(_addon.history.realm) | 1292 b:SetFullWidth(true) |
1287 _addon.hist_clean = nil | 1293 b:SetCallback("OnClick", function (_b) |
1288 histST:OuroLoot_Refresh() | 1294 local dialog = StaticPopup_Show("OUROL_HIST_CLEAR", "ALL realms") |
1289 end | 1295 dialog.data = addon |
1290 end) | 1296 dialog.data2 = function(_addon) |
1291 specials:AddChild(b) | 1297 _addon.history_all = {} |
1292 end | 1298 reset_current_realm() |
1293 return tabs_OnGroupSelected["hist"](container,specials) | 1299 end |
1294 end | 1300 end) |
1295 end | 1301 specials:AddChild(b) |
1302 | |
1303 b = mkbutton('hist_clear_old', "Clear Older", | |
1304 [[Preserves only the latest loot entry for each player on the displayed realm, removing all earlier ones.]]) | |
1305 b:SetFullWidth(true) | |
1306 b:SetCallback("OnClick", function (_b) | |
1307 local dialog = StaticPopup_Show("OUROL_HIST_PREEN", addon.history.realm) | |
1308 dialog.data = addon | |
1309 dialog.data2 = function(_addon) | |
1310 _addon:preen_history(_addon.history.realm) | |
1311 _addon.hist_clean = nil | |
1312 histST:OuroLoot_Refresh() | |
1313 end | |
1314 end) | |
1315 specials:AddChild(b) | |
1316 end | |
1317 return tabs_OnGroupSelected["hist"](container,specials) | |
1318 end | |
1319 | |
1296 | 1320 |
1297 -- Tab 5: Help (content in verbage.lua) | 1321 -- Tab 5: Help (content in verbage.lua) |
1298 do | 1322 do |
1299 local tabs_help_OnGroupSelected_func = function (treeg,event,category) | 1323 local tabs_help_OnGroupSelected_func = function (treeg,event,category) |
1300 treeg:ReleaseChildren() | 1324 treeg:ReleaseChildren() |
1341 else | 1365 else |
1342 left:SelectByValue("basic") | 1366 left:SelectByValue("basic") |
1343 end | 1367 end |
1344 end | 1368 end |
1345 end | 1369 end |
1370 | |
1346 | 1371 |
1347 -- Tab 6: Options / Advanced | 1372 -- Tab 6: Options / Advanced |
1348 do | 1373 do |
1349 local function mkoption (opt, label, width, desc, opt_func) | 1374 local function mkoption (opt, label, width, desc, opt_func) |
1350 local w = mkbutton("CheckBoxSmallLabel", nil, "", desc) | 1375 local w = mkbutton("CheckBoxSmallLabel", nil, "", desc) |
1989 -- Essentially a re-click on the current tab (if the current tab were clickable). | 2014 -- Essentially a re-click on the current tab (if the current tab were clickable). |
1990 function addon:redisplay () | 2015 function addon:redisplay () |
1991 tabs_OnGroupSelected_func (unpack(tabs_OnGroupSelected_func_args)) | 2016 tabs_OnGroupSelected_func (unpack(tabs_OnGroupSelected_func_args)) |
1992 end | 2017 end |
1993 | 2018 |
1994 end -- local 'do' scope | |
1995 | |
1996 | 2019 |
1997 ------ Popup dialogs | 2020 ------ Popup dialogs |
1998 -- Callback for each Next/Accept stage of inserting a new loot row via dropdown | 2021 -- Callback for each Next/Accept stage of inserting a new loot row via dropdown |
1999 local function eoi_st_insert_OnAccept_boss (dialog, data) | 2022 local function eoi_st_insert_OnAccept_boss (dialog, data) |
2000 if data.all_done then | 2023 if data.all_done then |
2100 OnAccept = function (dialog, addon) | 2123 OnAccept = function (dialog, addon) |
2101 addon:Clear(--[[verbose_p=]]true) | 2124 addon:Clear(--[[verbose_p=]]true) |
2102 end, | 2125 end, |
2103 } | 2126 } |
2104 | 2127 |
2128 StaticPopupDialogs["OUROL_HIST_REGEN"] = flib.StaticPopup{ | |
2129 -- Concatenate this once at load time. There is no ITEM_QUALITY_LEGENDARY constant. | |
2130 text = "Erase all history entries from " .. ITEM_QUALITY_COLORS[5].hex .. "%s|r, and generate it anew from current loot?", | |
2131 button1 = YES, | |
2132 button2 = NO, | |
2133 OnAccept = function (dialog, addon, data2) | |
2134 data2(addon) | |
2135 addon:Print("%s history has been regenerated.", addon.history.realm) | |
2136 addon:redisplay() | |
2137 end, | |
2138 } | |
2139 | |
2105 StaticPopupDialogs["OUROL_HIST_CLEAR"] = flib.StaticPopup{ | 2140 StaticPopupDialogs["OUROL_HIST_CLEAR"] = flib.StaticPopup{ |
2106 text = "Erase all history entries from %s?", | 2141 -- Concatenate this once at load time. There is no ITEM_QUALITY_LEGENDARY constant. |
2142 text = "Erase all history entries from " .. ITEM_QUALITY_COLORS[5].hex .. "%s|r?", | |
2107 button1 = YES, | 2143 button1 = YES, |
2108 button2 = NO, | 2144 button2 = NO, |
2109 OnAccept = function (dialog, addon, data2) | 2145 OnAccept = function (dialog, addon, data2) |
2110 data2(addon) | 2146 data2(addon) |
2111 addon:Print("Stimpy, you eeediot, you've pushed the history erase button!") | 2147 addon:Print("Stimpy, you eeediot, you've pushed the history erase button!") |
2112 addon:redisplay() | 2148 addon:redisplay() |
2113 end, | 2149 end, |
2114 } | 2150 } |
2115 | 2151 |
2116 StaticPopupDialogs["OUROL_HIST_PREEN"] = flib.StaticPopup{ | 2152 StaticPopupDialogs["OUROL_HIST_PREEN"] = flib.StaticPopup{ |
2117 text = "Erase all but the latest entry for players on %s?", | 2153 -- Concatenate this once at load time. There is no ITEM_QUALITY_LEGENDARY constant. |
2154 text = "Erase all but the latest entry for players on " .. ITEM_QUALITY_COLORS[5].hex .. "%s|r?", | |
2118 button1 = YES, | 2155 button1 = YES, |
2119 button2 = NO, | 2156 button2 = NO, |
2120 OnAccept = function (dialog, addon, data2) | 2157 OnAccept = function (dialog, addon, data2) |
2121 data2(addon) | 2158 data2(addon) |
2122 addon:Print("All loot prior to the most recent entries has been erased.") | 2159 addon:Print("All loot prior to the most recent entries has been erased.") |