Mercurial > wow > ouroloot
diff gui.lua @ 69:8442272a8418
- Make sure popup dialogs are on top of Ace3's widgets.
- Minor code reorganization. Safety hook for future boss-entry code.
- Avoid same bug from a couple revs ago when adding manual boss kills.
- Ask players about snapshot data when manually entering boss kills.
- Blizzard rearranged the button order in 3-entry popups some time ago
and I failed to adapt the code until now.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Fri, 11 May 2012 03:08:12 +0000 |
parents | c01875b275ca |
children | cdee65c1bd8c |
line wrap: on
line diff
--- a/gui.lua Wed May 09 09:38:14 2012 +0000 +++ b/gui.lua Fri May 11 03:08:12 2012 +0000 @@ -711,7 +711,7 @@ notCheckable = true, }}, { - "Change from 'wipe' to 'kill'|Also collapses other wipe entries.", + "Change from 'wipe' to 'kill'|Also collapses previous wipe entries.", "Rebroadcast this boss%boss|Broadcasts the kill event and all subsequent loot until next boss.", "Delete this boss event|Permanent, no going back!", "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.", @@ -2195,104 +2195,6 @@ ------ Popup dialogs --- Callback for each Next/Accept stage of inserting a new loot row via dropdown -local function eoi_st_insert_OnAccept_boss (dialog, data) - if data.all_done then - -- It'll probably be the final entry in the table, but there might have - -- been real loot happening at the same time. - local boss_index = addon._addLootEntry{ - kind = 'boss', - bossname = (OuroLootSV_opts.snarky_boss and addon.boss_abbrev[data.name] or data.name) or data.name, - reason = 'kill', - instance = data.instance, - duration = 0, - } - local entry = tremove(g_loot,boss_index) - tinsert(g_loot,data.rowindex,entry) - addon:_mark_boss_kill(data.rowindex) - data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.rowindex) - dialog.data = nil -- free up memory - addon:Print("Inserted %s %s (entry %d).", data.kind, data.name, data.rowindex) - return - end - - local text = dialog.editBox:GetText() - - -- second click - if data.name and text then - data.instance = text - data.all_done = true - -- in future do one more thing, for now just jump to the check - return eoi_st_insert_OnAccept_boss (dialog, data) - end - - -- first click - if text then - data.name = text - local getinstance = StaticPopup_Show("OUROL_EOI_INSERT","instance") - getinstance.data = data - getinstance.editBox:SetText((addon.instance_tag())) - -- This suppresses auto-hide (which would case the getinstance dialog - -- to go away), but only when mouse clicking. OnEnter is on its own. - return true - end -end - -local function eoi_st_insert_OnAccept_loot (dialog, data) - if data.all_done then - --local real_rebroadcast, real_enabled = addon.rebroadcast, addon.enabled - --g_rebroadcast, g_enabled = false, true - data.display:Hide() - local loot_index = addon:CHAT_MSG_LOOT ("manual", data.recipient, data.name, data.notes) - --g_rebroadcast, g_enabled = real_g_rebroadcast, real_g_enabled - local entry = tremove(g_loot,loot_index) - tinsert(g_loot,data.rowindex,entry) - --data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.rowindex) - addon:_fill_out_eoi_data(data.rowindex) - addon:BuildMainDisplay() - dialog.data = nil - addon:Print("Inserted %s %s (entry %d).", data.kind, data.name, data.rowindex) - return - end - - local text = dialog.editBox:GetText():trim() - - -- third click - if data.name and data.recipient and text then - data.notes = (text ~= "<none>") and text or nil - data.all_done = true - return eoi_st_insert_OnAccept_loot (dialog, data) - end - - -- second click - if data.name and text then - data.recipient = text - local getnotes = StaticPopup_Show("OUROL_EOI_INSERT","notes") - getnotes.data = data - getnotes.editBox:SetText("<none>") - getnotes.editBox:HighlightText() - return true - end - - -- first click - if text then - data.name = text - dialog:Hide() -- technically a "different" one about to be shown - local getrecipient = StaticPopup_Show("OUROL_EOI_INSERT","recipient") - getrecipient.data = data - getrecipient.editBox:SetText("") - return true - end -end - -local function eoi_st_insert_OnAccept (dialog, data) - if data.kind == 'boss' then - return eoi_st_insert_OnAccept_boss (dialog, data) - elseif data.kind == 'loot' then - return eoi_st_insert_OnAccept_loot (dialog, data) - end -end - StaticPopupDialogs["OUROL_CLEAR"] = flib.StaticPopup{ text = "Clear current loot information and text?", button1 = YES, @@ -2356,17 +2258,18 @@ } StaticPopupDialogs["OUROL_REMIND"] = flib.StaticPopup{ - text = "Do you wish to activate Ouro Loot?\n\n(Hit the Escape key to close this window without clicking)", + text = "Do you wish to activate Ouro Loot?\n\n(Hit the Escape key to close this window without clicking; Enter is the same as Activate)", button1 = "Activate recording", -- "accept", left - button3 = "Broadcast only", -- "alt", middle - button2 = "Help", -- "cancel", right + button2 = "Broadcast Only", -- "cancel", middle + button3 = HELP_LABEL, -- "alt", right OnAccept = function (dialog, addon) addon:Activate() end, - OnAlt = function (dialog, addon) + noCancelOnEscape = true, + OnCancel = function (dialog, addon) addon:Activate(nil,true) end, - OnCancel = function (dialog, addon) + OnAlt = function (dialog, addon) -- hitting escape also calls this, but the 3rd arg would be "clicked" -- in both cases, not useful here. local helpbutton = dialog.button2 @@ -2381,6 +2284,128 @@ end, } +-- Callback for each Next/Accept stage of inserting a new loot or boss row via +-- dropdown. Thanks to noCancelOnReuse, each Show done here will technically +-- Hide and redisplay the same dialog, passing along the same 'data' structure +-- each time. The topmost call to our OnAccept will then finish by hiding the +-- (very last) dialog. +-- +-- This is really, really hideous to read. +local function eoi_st_insert_OnAccept_boss (dialog, data, data2) + if data.all_done then + -- It'll probably be the final entry in the table, but there might have + -- been real loot happening at the same time. + local boss_index = addon._addBossEntry{ + kind = 'boss', + bossname = (OuroLootSV_opts.snarky_boss and addon.boss_abbrev[data.name] or data.name) or data.name, + reason = 'kill', + instance = data.instance, + duration = 0, + maxsize = data.max_raid_size, + raidersnap = data.yes_snap or {}, + } + local entry = tremove(g_loot,boss_index) + tinsert(g_loot,data.rowindex,entry) + addon:_mark_boss_kill(data.rowindex) + data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.rowindex) + dialog.data = nil -- free up memory + addon:Print("Inserted %s %s (entry %d).", data.kind, data.name, data.rowindex) + return + end + + -- third click + if data.name and data.instance then + data.all_done = true + -- this is how we distinguish OnAccept from OnCancel ("clicked"); the + -- 3rd param is handled all in StaticPopup_OnClick + if data2 ~= 'clicked' then + data.yes_snap = data.maybe_snap + end + return eoi_st_insert_OnAccept_boss (dialog, data) + end + + local text = dialog.editBox:GetText():trim() + + -- second click + if data.name and text then + data.instance = text + -- not "resuing" this dialog in the same sense as with loot + dialog.data = nil + dialog:Hide() + local getsnap = StaticPopup_Show("OUROL_EOI_INSERT_INCLUDE_RAIDERSNAP") + getsnap.data = data + return true + end + + -- first click + if text then + data.name = text + local maybe_instance + data.maybe_snap, data.max_raid_size, maybe_instance = addon:snapshot_raid() + local getinstance = StaticPopup_Show("OUROL_EOI_INSERT","instance") + getinstance.data = data + getinstance.editBox:SetText(maybe_instance) + -- This suppresses auto-hide (which would cause the getinstance dialog + -- to go away), but only when mouse clicking. OnEnter is on its own. + return true + end +end + +local function eoi_st_insert_OnAccept_loot (dialog, data) + if data.all_done then + --local real_rebroadcast, real_enabled = addon.rebroadcast, addon.enabled + --g_rebroadcast, g_enabled = false, true + data.display:Hide() + local loot_index = addon:CHAT_MSG_LOOT ("manual", data.recipient, data.name, data.notes) + --g_rebroadcast, g_enabled = real_g_rebroadcast, real_g_enabled + local entry = tremove(g_loot,loot_index) + tinsert(g_loot,data.rowindex,entry) + --data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.rowindex) + addon:_fill_out_eoi_data(data.rowindex) + addon:BuildMainDisplay() + dialog.data = nil + addon:Print("Inserted %s %s (entry %d).", data.kind, data.name, data.rowindex) + return + end + + local text = dialog.editBox:GetText():trim() + + -- third click + if data.name and data.recipient and text then + data.notes = (text ~= "<none>") and text or nil + data.all_done = true + return eoi_st_insert_OnAccept_loot (dialog, data) + end + + -- second click + if data.name and text then + data.recipient = text + local getnotes = StaticPopup_Show("OUROL_EOI_INSERT","notes") + getnotes.data = data + getnotes.editBox:SetText("<none>") + getnotes.editBox:HighlightText() + return true + end + + -- first click + if text then + data.name = text + dialog:Hide() -- technically a "different" one about to be shown + local getrecipient = StaticPopup_Show("OUROL_EOI_INSERT","recipient") + getrecipient.data = data + getrecipient.editBox:SetText("") + return true + end +end + +local function eoi_st_insert_OnAccept (dialog, data) + if data.kind == 'boss' then + return eoi_st_insert_OnAccept_boss (dialog, data) + elseif data.kind == 'loot' then + return eoi_st_insert_OnAccept_loot (dialog, data) + end +end + -- The data member here is a table built with: -- {rowindex=<GUI row receiving click>, display=_d, kind=<loot/boss>} do @@ -2408,10 +2433,8 @@ t.enterClicksFirstButton = nil -- no effect with editbox focused t.OnAccept = eoi_st_insert_OnAccept StaticPopupDialogs["OUROL_EOI_INSERT"] = t -end --- This seems to be gratuitous use of metatables, really. -do + -- This seems to be gratuitous use of metatables, really. local OEIL = { text = "Paste the new item into here, then click Next or press Enter:", __index = StaticPopupDialogs["OUROL_EOI_INSERT"] @@ -2425,6 +2448,24 @@ return true end end) + + t = flib.StaticPopup{ + -- Concatenate this once at load time. There is no ITEM_QUALITY_LEGENDARY constant. + text = "Include a snapshot of the " .. ITEM_QUALITY_COLORS[5].hex + .. "CURRENT|r raid?\n\nClicking '" .. YES .. "' will allow this entry to " + .. "appear in attendance lists, but with the roster as it is NOW, not as it " + .. "was THEN. Clicking '" .. NO .."' means this kill cannot be included in " + .. "attendance.\n\n(Enter = '" .. YES .."', Escape = '" .. CANCEL .. "')", + button1 = YES, -- "accept", left + button2 = NO, -- "cancel", middle + button3 = CANCEL, -- "alt", right + } + -- Hitting Escape still hides the frame, but doesn't run OnCancel (which + -- is for the "No" button, not the "Cancel"/OnAlt button). Dizzy yet? + t.noCancelOnEscape = true + t.OnAccept = eoi_st_insert_OnAccept_boss + t.OnCancel = eoi_st_insert_OnAccept_boss + StaticPopupDialogs["OUROL_EOI_INSERT_INCLUDE_RAIDERSNAP"] = t end StaticPopupDialogs["OUROL_REASSIGN_ENTER"] = flib.StaticPopup{