Mercurial > wow > ouroloot
comparison gui.lua @ 75:676fb79a4ae2
StaticPopupDialog + Slider = controllable threshold for how far back to preserve events when preening history tables. (Updated preen routine written but not with this commit.)
| author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
|---|---|
| date | Fri, 01 Jun 2012 02:17:57 +0000 |
| parents | 5edaac60449b |
| children | 124da015c4a2 |
comparison
equal
deleted
inserted
replaced
| 74:5edaac60449b | 75:676fb79a4ae2 |
|---|---|
| 1635 end | 1635 end |
| 1636 end) | 1636 end) |
| 1637 specials:AddChild(b) | 1637 specials:AddChild(b) |
| 1638 | 1638 |
| 1639 b = mkbutton('hist_clear_old', "Clear Older", | 1639 b = mkbutton('hist_clear_old', "Clear Older", |
| 1640 [[Preserves only the latest loot entry for each player on the displayed realm, removing all earlier ones.]]) | 1640 [[Preserves only the latest loot entries for players on the displayed realm, removing all earlier ones.]]) |
| 1641 b:SetFullWidth(true) | 1641 b:SetFullWidth(true) |
| 1642 b:SetCallback("OnClick", function (_b) | 1642 b:SetCallback("OnClick", function (_b) |
| 1643 local dialog = StaticPopup_Show("OUROL_HIST_PREEN", addon.history.realm) | 1643 local dialog = StaticPopup_Show("OUROL_HIST_PREEN", '', addon.history.realm, addon) |
| 1644 dialog.data = addon | 1644 dialog.data = addon |
| 1645 dialog.data2 = function(_addon) | 1645 dialog.data2 = function (_addon, howmany) |
| 1646 _addon:preen_history(_addon.history.realm) | 1646 _addon:preen_history (_addon.history.realm, howmany) |
| 1647 _addon.hist_clean = nil | 1647 _addon.hist_clean = nil |
| 1648 histST:OuroLoot_Refresh() | 1648 histST:OuroLoot_Refresh() |
| 1649 end | 1649 end |
| 1650 end) | 1650 end) |
| 1651 specials:AddChild(b) | 1651 specials:AddChild(b) |
| 2516 tabs_OnGroupSelected_func (unpack(tabs_OnGroupSelected_func_args)) | 2516 tabs_OnGroupSelected_func (unpack(tabs_OnGroupSelected_func_args)) |
| 2517 end | 2517 end |
| 2518 | 2518 |
| 2519 | 2519 |
| 2520 ------ Popup dialogs | 2520 ------ Popup dialogs |
| 2521 local function build_my_slider_widget() | |
| 2522 local s = CreateFrame("Slider", "OuroLootSlider", nil, "OptionsSliderTemplate") | |
| 2523 s.text = OuroLootSliderText | |
| 2524 s.low = OuroLootSliderLow | |
| 2525 s.high = OuroLootSliderHigh | |
| 2526 s:SetScript("OnValueChanged", function (_s, value) | |
| 2527 _s.value = value -- conveniently, this is already of numeric type | |
| 2528 --_s.text:SetText(tostring(value)) | |
| 2529 if _s.DoOnValueChanged then | |
| 2530 _s:DoOnValueChanged() | |
| 2531 end | |
| 2532 end) | |
| 2533 build_my_slider_widget = nil | |
| 2534 return s | |
| 2535 end | |
| 2536 | |
| 2521 StaticPopupDialogs["OUROL_CLEAR"] = flib.StaticPopup{ | 2537 StaticPopupDialogs["OUROL_CLEAR"] = flib.StaticPopup{ |
| 2522 text = "Clear current loot information and text?", | 2538 text = "Clear current loot information and text?", |
| 2523 button1 = YES, | 2539 button1 = YES, |
| 2524 button2 = NO, | 2540 button2 = NO, |
| 2525 OnAccept = function (dialog, addon) | 2541 OnAccept = function (dialog, addon) |
| 2527 end, | 2543 end, |
| 2528 } | 2544 } |
| 2529 | 2545 |
| 2530 StaticPopupDialogs["OUROL_HIST_REGEN"] = flib.StaticPopup{ | 2546 StaticPopupDialogs["OUROL_HIST_REGEN"] = flib.StaticPopup{ |
| 2531 -- Concatenate this once at load time. There is no ITEM_QUALITY_LEGENDARY constant. | 2547 -- Concatenate this once at load time. There is no ITEM_QUALITY_LEGENDARY constant. |
| 2532 text = "Erase all history entries from " .. ITEM_QUALITY_COLORS[5].hex .. "%s|r, and generate it anew from current loot?", | 2548 text = "Erase all history entries from " .. ITEM_QUALITY_COLORS[5].hex |
| 2549 .. "%s|r, and generate it anew from current loot?", | |
| 2533 button1 = YES, | 2550 button1 = YES, |
| 2534 button2 = NO, | 2551 button2 = NO, |
| 2535 OnAccept = function (dialog, addon, data2) | 2552 OnAccept = function (dialog, addon, data2) |
| 2536 data2(addon) | 2553 data2(addon) |
| 2537 addon:Print("%s history has been regenerated.", addon.history.realm) | 2554 addon:Print("%s history has been regenerated.", addon.history.realm) |
| 2551 end, | 2568 end, |
| 2552 } | 2569 } |
| 2553 | 2570 |
| 2554 StaticPopupDialogs["OUROL_HIST_PREEN"] = flib.StaticPopup{ | 2571 StaticPopupDialogs["OUROL_HIST_PREEN"] = flib.StaticPopup{ |
| 2555 -- Concatenate this once at load time. There is no ITEM_QUALITY_LEGENDARY constant. | 2572 -- Concatenate this once at load time. There is no ITEM_QUALITY_LEGENDARY constant. |
| 2556 text = "Erase all but the latest entry for players on " .. ITEM_QUALITY_COLORS[5].hex .. "%s|r?", | 2573 text = "This will erase all but the latest " |
| 2574 .. ITEM_QUALITY_COLORS[ITEM_QUALITY_UNCOMMON].hex | |
| 2575 .. "%s|r for each player on " | |
| 2576 .. ITEM_QUALITY_COLORS[5].hex .. "%s|r. " .. CONTINUE .. "?", | |
| 2557 button1 = YES, | 2577 button1 = YES, |
| 2558 button2 = NO, | 2578 button2 = NO, |
| 2559 OnAccept = function (dialog, addon, data2) | 2579 OnShow = function (dialog, addon) |
| 2560 data2(addon) | 2580 local thistable = StaticPopupDialogs[dialog.which] |
| 2561 addon:Print("All loot prior to the most recent entries has been erased.") | 2581 -- StaticPopup_Resize does not take extraFrame into account, so we |
| 2582 -- hook the sizing method that _Resize calls at the end. | |
| 2583 dialog.saved_setheight = dialog.SetHeight | |
| 2584 dialog.SetHeight = function (d, h) | |
| 2585 return d.saved_setheight(d,h+35) | |
| 2586 end | |
| 2587 dialog.extraFrame:ClearAllPoints() | |
| 2588 dialog.extraFrame:SetPoint("TOP", dialog.text, "BOTTOM") | |
| 2589 dialog.extraFrame:SetWidth(150) | |
| 2590 dialog.extraFrame:SetHeight(35) | |
| 2591 dialog.extraFrame:Show() | |
| 2592 local slider = _G.OuroLootSlider or build_my_slider_widget() | |
| 2593 slider.DoOnValueChanged = function(s) | |
| 2594 dialog.text:SetFormattedText (thistable.text, | |
| 2595 s.value == 1 and "single entry" or (s.value .. " entries"), | |
| 2596 addon.history.realm) | |
| 2597 StaticPopup_Resize (dialog, "OUROL_HIST_PREEN") | |
| 2598 end | |
| 2599 slider:SetOrientation('HORIZONTAL') | |
| 2600 slider:SetMinMaxValues(1,30) | |
| 2601 slider:SetValueStep(1) | |
| 2602 slider.low:SetText("1") | |
| 2603 slider.high:SetText("30") | |
| 2604 --slider.tooltipText = ??? | |
| 2605 slider:SetParent(dialog.extraFrame) | |
| 2606 slider:ClearAllPoints() | |
| 2607 slider:SetPoint("TOPLEFT",dialog.extraFrame,"TOPLEFT",0, -15) | |
| 2608 slider:SetPoint("BOTTOMRIGHT",dialog.extraFrame,"BOTTOMRIGHT",0, 0) | |
| 2609 slider:Show() | |
| 2610 -- This causes OnValueChanged to fire, reformatting the text. Except | |
| 2611 -- IF the slider has already been shown, and IF at the time it was hidden | |
| 2612 -- it had the same value here, THEN there is technically no "change" | |
| 2613 -- and no event is fired. We work around this clever optimization by | |
| 2614 -- doing a pair of set's, forcing the last one to fire OVC. | |
| 2615 slider:SetValue(1) | |
| 2616 slider:SetValue(5) | |
| 2617 end, | |
| 2618 OnAccept = function (dialog, addon, callback) | |
| 2619 local howmany = assert(tonumber(_G.OuroLootSlider.value)) | |
| 2620 callback (addon, howmany) | |
| 2621 addon:Print("All loot prior to the most recent %d |4entry:entries; has been erased.", howmany) | |
| 2562 addon:redisplay() | 2622 addon:redisplay() |
| 2623 end, | |
| 2624 OnHide = function (dialog, addon) | |
| 2625 dialog.SetHeight = nil | |
| 2626 dialog.saved_setheight = nil | |
| 2627 dialog.extraFrame:ClearAllPoints() | |
| 2628 _G.OuroLootSlider:Hide() -- parent is hidden, why is this required? | |
| 2629 _G.OuroLootSlider:ClearAllPoints() | |
| 2630 _G.OuroLootSlider:SetParent(nil) | |
| 2563 end, | 2631 end, |
| 2564 } | 2632 } |
| 2565 | 2633 |
| 2566 StaticPopupDialogs["OUROL_URL"] = { --flib.StaticPopup{ | 2634 StaticPopupDialogs["OUROL_URL"] = { --flib.StaticPopup{ |
| 2567 text = "Use Control-C or equivalent to copy this URL to your system clipboard:", | 2635 text = "Use Control-C or equivalent to copy this URL to your system clipboard:", |
| 2731 | 2799 |
| 2732 -- The data member here is a table built with: | 2800 -- The data member here is a table built with: |
| 2733 -- {rowindex=<GUI row receiving click>, display=_d, kind=<loot/boss>} | 2801 -- {rowindex=<GUI row receiving click>, display=_d, kind=<loot/boss>} |
| 2734 do | 2802 do |
| 2735 local t = flib.StaticPopup{ | 2803 local t = flib.StaticPopup{ |
| 2736 text = "Enter name of new %s, then click Next or press Enter:", | 2804 text = "Enter name of new %s, then click "..CONTINUE.." or press Enter:", |
| 2737 button1 = "Next >", | 2805 button1 = CONTINUE.." ->", |
| 2738 button2 = CANCEL, | 2806 button2 = CANCEL, |
| 2739 hasEditBox = true, | 2807 hasEditBox = true, |
| 2740 editBoxWidth = 350, | 2808 editBoxWidth = 350, |
| 2741 maxLetters = 50, | 2809 maxLetters = 50, |
| 2742 noCancelOnReuse = true, | 2810 noCancelOnReuse = true, |
| 2757 t.OnAccept = eoi_st_insert_OnAccept | 2825 t.OnAccept = eoi_st_insert_OnAccept |
| 2758 StaticPopupDialogs["OUROL_EOI_INSERT"] = t | 2826 StaticPopupDialogs["OUROL_EOI_INSERT"] = t |
| 2759 | 2827 |
| 2760 -- This seems to be gratuitous use of metatables, really. | 2828 -- This seems to be gratuitous use of metatables, really. |
| 2761 local OEIL = { | 2829 local OEIL = { |
| 2762 text = "Paste the new item into here, then click Next or press Enter:", | 2830 text = "Paste the new item into here, then click "..CONTINUE.." or press Enter:", |
| 2763 __index = StaticPopupDialogs["OUROL_EOI_INSERT"] | 2831 __index = StaticPopupDialogs["OUROL_EOI_INSERT"] |
| 2764 } | 2832 } |
| 2765 StaticPopupDialogs["OUROL_EOI_INSERT_LOOT"] = setmetatable(OEIL,OEIL) | 2833 StaticPopupDialogs["OUROL_EOI_INSERT_LOOT"] = setmetatable(OEIL,OEIL) |
| 2766 | 2834 |
| 2767 hooksecurefunc("ChatEdit_InsertLink", function (link,...) | 2835 hooksecurefunc("ChatEdit_InsertLink", function (link,...) |
