Mercurial > wow > ouroloot
comparison 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 |
comparison
equal
deleted
inserted
replaced
68:3bed6d51e077 | 69:8442272a8418 |
---|---|
709 isTitle = true, | 709 isTitle = true, |
710 notClickable = true, | 710 notClickable = true, |
711 notCheckable = true, | 711 notCheckable = true, |
712 }}, | 712 }}, |
713 { | 713 { |
714 "Change from 'wipe' to 'kill'|Also collapses other wipe entries.", | 714 "Change from 'wipe' to 'kill'|Also collapses previous wipe entries.", |
715 "Rebroadcast this boss%boss|Broadcasts the kill event and all subsequent loot until next boss.", | 715 "Rebroadcast this boss%boss|Broadcasts the kill event and all subsequent loot until next boss.", |
716 "Delete this boss event|Permanent, no going back!", | 716 "Delete this boss event|Permanent, no going back!", |
717 "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.", | 717 "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.", |
718 "Insert new loot entry%loot|Inserts new loot above this one, prompting you for information.", | 718 "Insert new loot entry%loot|Inserts new loot above this one, prompting you for information.", |
719 "Insert new boss kill event%boss|Inserts new event above this one, prompting you for information.", | 719 "Insert new boss kill event%boss|Inserts new event above this one, prompting you for information.", |
2193 tabs_OnGroupSelected_func (unpack(tabs_OnGroupSelected_func_args)) | 2193 tabs_OnGroupSelected_func (unpack(tabs_OnGroupSelected_func_args)) |
2194 end | 2194 end |
2195 | 2195 |
2196 | 2196 |
2197 ------ Popup dialogs | 2197 ------ Popup dialogs |
2198 -- Callback for each Next/Accept stage of inserting a new loot row via dropdown | |
2199 local function eoi_st_insert_OnAccept_boss (dialog, data) | |
2200 if data.all_done then | |
2201 -- It'll probably be the final entry in the table, but there might have | |
2202 -- been real loot happening at the same time. | |
2203 local boss_index = addon._addLootEntry{ | |
2204 kind = 'boss', | |
2205 bossname = (OuroLootSV_opts.snarky_boss and addon.boss_abbrev[data.name] or data.name) or data.name, | |
2206 reason = 'kill', | |
2207 instance = data.instance, | |
2208 duration = 0, | |
2209 } | |
2210 local entry = tremove(g_loot,boss_index) | |
2211 tinsert(g_loot,data.rowindex,entry) | |
2212 addon:_mark_boss_kill(data.rowindex) | |
2213 data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.rowindex) | |
2214 dialog.data = nil -- free up memory | |
2215 addon:Print("Inserted %s %s (entry %d).", data.kind, data.name, data.rowindex) | |
2216 return | |
2217 end | |
2218 | |
2219 local text = dialog.editBox:GetText() | |
2220 | |
2221 -- second click | |
2222 if data.name and text then | |
2223 data.instance = text | |
2224 data.all_done = true | |
2225 -- in future do one more thing, for now just jump to the check | |
2226 return eoi_st_insert_OnAccept_boss (dialog, data) | |
2227 end | |
2228 | |
2229 -- first click | |
2230 if text then | |
2231 data.name = text | |
2232 local getinstance = StaticPopup_Show("OUROL_EOI_INSERT","instance") | |
2233 getinstance.data = data | |
2234 getinstance.editBox:SetText((addon.instance_tag())) | |
2235 -- This suppresses auto-hide (which would case the getinstance dialog | |
2236 -- to go away), but only when mouse clicking. OnEnter is on its own. | |
2237 return true | |
2238 end | |
2239 end | |
2240 | |
2241 local function eoi_st_insert_OnAccept_loot (dialog, data) | |
2242 if data.all_done then | |
2243 --local real_rebroadcast, real_enabled = addon.rebroadcast, addon.enabled | |
2244 --g_rebroadcast, g_enabled = false, true | |
2245 data.display:Hide() | |
2246 local loot_index = addon:CHAT_MSG_LOOT ("manual", data.recipient, data.name, data.notes) | |
2247 --g_rebroadcast, g_enabled = real_g_rebroadcast, real_g_enabled | |
2248 local entry = tremove(g_loot,loot_index) | |
2249 tinsert(g_loot,data.rowindex,entry) | |
2250 --data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.rowindex) | |
2251 addon:_fill_out_eoi_data(data.rowindex) | |
2252 addon:BuildMainDisplay() | |
2253 dialog.data = nil | |
2254 addon:Print("Inserted %s %s (entry %d).", data.kind, data.name, data.rowindex) | |
2255 return | |
2256 end | |
2257 | |
2258 local text = dialog.editBox:GetText():trim() | |
2259 | |
2260 -- third click | |
2261 if data.name and data.recipient and text then | |
2262 data.notes = (text ~= "<none>") and text or nil | |
2263 data.all_done = true | |
2264 return eoi_st_insert_OnAccept_loot (dialog, data) | |
2265 end | |
2266 | |
2267 -- second click | |
2268 if data.name and text then | |
2269 data.recipient = text | |
2270 local getnotes = StaticPopup_Show("OUROL_EOI_INSERT","notes") | |
2271 getnotes.data = data | |
2272 getnotes.editBox:SetText("<none>") | |
2273 getnotes.editBox:HighlightText() | |
2274 return true | |
2275 end | |
2276 | |
2277 -- first click | |
2278 if text then | |
2279 data.name = text | |
2280 dialog:Hide() -- technically a "different" one about to be shown | |
2281 local getrecipient = StaticPopup_Show("OUROL_EOI_INSERT","recipient") | |
2282 getrecipient.data = data | |
2283 getrecipient.editBox:SetText("") | |
2284 return true | |
2285 end | |
2286 end | |
2287 | |
2288 local function eoi_st_insert_OnAccept (dialog, data) | |
2289 if data.kind == 'boss' then | |
2290 return eoi_st_insert_OnAccept_boss (dialog, data) | |
2291 elseif data.kind == 'loot' then | |
2292 return eoi_st_insert_OnAccept_loot (dialog, data) | |
2293 end | |
2294 end | |
2295 | |
2296 StaticPopupDialogs["OUROL_CLEAR"] = flib.StaticPopup{ | 2198 StaticPopupDialogs["OUROL_CLEAR"] = flib.StaticPopup{ |
2297 text = "Clear current loot information and text?", | 2199 text = "Clear current loot information and text?", |
2298 button1 = YES, | 2200 button1 = YES, |
2299 button2 = NO, | 2201 button2 = NO, |
2300 OnAccept = function (dialog, addon) | 2202 OnAccept = function (dialog, addon) |
2354 dialog.editBox:HighlightText() | 2256 dialog.editBox:HighlightText() |
2355 end, | 2257 end, |
2356 } | 2258 } |
2357 | 2259 |
2358 StaticPopupDialogs["OUROL_REMIND"] = flib.StaticPopup{ | 2260 StaticPopupDialogs["OUROL_REMIND"] = flib.StaticPopup{ |
2359 text = "Do you wish to activate Ouro Loot?\n\n(Hit the Escape key to close this window without clicking)", | 2261 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)", |
2360 button1 = "Activate recording", -- "accept", left | 2262 button1 = "Activate recording", -- "accept", left |
2361 button3 = "Broadcast only", -- "alt", middle | 2263 button2 = "Broadcast Only", -- "cancel", middle |
2362 button2 = "Help", -- "cancel", right | 2264 button3 = HELP_LABEL, -- "alt", right |
2363 OnAccept = function (dialog, addon) | 2265 OnAccept = function (dialog, addon) |
2364 addon:Activate() | 2266 addon:Activate() |
2365 end, | 2267 end, |
2366 OnAlt = function (dialog, addon) | 2268 noCancelOnEscape = true, |
2269 OnCancel = function (dialog, addon) | |
2367 addon:Activate(nil,true) | 2270 addon:Activate(nil,true) |
2368 end, | 2271 end, |
2369 OnCancel = function (dialog, addon) | 2272 OnAlt = function (dialog, addon) |
2370 -- hitting escape also calls this, but the 3rd arg would be "clicked" | 2273 -- hitting escape also calls this, but the 3rd arg would be "clicked" |
2371 -- in both cases, not useful here. | 2274 -- in both cases, not useful here. |
2372 local helpbutton = dialog.button2 | 2275 local helpbutton = dialog.button2 |
2373 local ismousing = MouseIsOver(helpbutton) | 2276 local ismousing = MouseIsOver(helpbutton) |
2374 if ismousing then | 2277 if ismousing then |
2378 else | 2281 else |
2379 addon.popped = true | 2282 addon.popped = true |
2380 end | 2283 end |
2381 end, | 2284 end, |
2382 } | 2285 } |
2286 | |
2287 -- Callback for each Next/Accept stage of inserting a new loot or boss row via | |
2288 -- dropdown. Thanks to noCancelOnReuse, each Show done here will technically | |
2289 -- Hide and redisplay the same dialog, passing along the same 'data' structure | |
2290 -- each time. The topmost call to our OnAccept will then finish by hiding the | |
2291 -- (very last) dialog. | |
2292 -- | |
2293 -- This is really, really hideous to read. | |
2294 local function eoi_st_insert_OnAccept_boss (dialog, data, data2) | |
2295 if data.all_done then | |
2296 -- It'll probably be the final entry in the table, but there might have | |
2297 -- been real loot happening at the same time. | |
2298 local boss_index = addon._addBossEntry{ | |
2299 kind = 'boss', | |
2300 bossname = (OuroLootSV_opts.snarky_boss and addon.boss_abbrev[data.name] or data.name) or data.name, | |
2301 reason = 'kill', | |
2302 instance = data.instance, | |
2303 duration = 0, | |
2304 maxsize = data.max_raid_size, | |
2305 raidersnap = data.yes_snap or {}, | |
2306 } | |
2307 local entry = tremove(g_loot,boss_index) | |
2308 tinsert(g_loot,data.rowindex,entry) | |
2309 addon:_mark_boss_kill(data.rowindex) | |
2310 data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.rowindex) | |
2311 dialog.data = nil -- free up memory | |
2312 addon:Print("Inserted %s %s (entry %d).", data.kind, data.name, data.rowindex) | |
2313 return | |
2314 end | |
2315 | |
2316 -- third click | |
2317 if data.name and data.instance then | |
2318 data.all_done = true | |
2319 -- this is how we distinguish OnAccept from OnCancel ("clicked"); the | |
2320 -- 3rd param is handled all in StaticPopup_OnClick | |
2321 if data2 ~= 'clicked' then | |
2322 data.yes_snap = data.maybe_snap | |
2323 end | |
2324 return eoi_st_insert_OnAccept_boss (dialog, data) | |
2325 end | |
2326 | |
2327 local text = dialog.editBox:GetText():trim() | |
2328 | |
2329 -- second click | |
2330 if data.name and text then | |
2331 data.instance = text | |
2332 -- not "resuing" this dialog in the same sense as with loot | |
2333 dialog.data = nil | |
2334 dialog:Hide() | |
2335 local getsnap = StaticPopup_Show("OUROL_EOI_INSERT_INCLUDE_RAIDERSNAP") | |
2336 getsnap.data = data | |
2337 return true | |
2338 end | |
2339 | |
2340 -- first click | |
2341 if text then | |
2342 data.name = text | |
2343 local maybe_instance | |
2344 data.maybe_snap, data.max_raid_size, maybe_instance = addon:snapshot_raid() | |
2345 local getinstance = StaticPopup_Show("OUROL_EOI_INSERT","instance") | |
2346 getinstance.data = data | |
2347 getinstance.editBox:SetText(maybe_instance) | |
2348 -- This suppresses auto-hide (which would cause the getinstance dialog | |
2349 -- to go away), but only when mouse clicking. OnEnter is on its own. | |
2350 return true | |
2351 end | |
2352 end | |
2353 | |
2354 local function eoi_st_insert_OnAccept_loot (dialog, data) | |
2355 if data.all_done then | |
2356 --local real_rebroadcast, real_enabled = addon.rebroadcast, addon.enabled | |
2357 --g_rebroadcast, g_enabled = false, true | |
2358 data.display:Hide() | |
2359 local loot_index = addon:CHAT_MSG_LOOT ("manual", data.recipient, data.name, data.notes) | |
2360 --g_rebroadcast, g_enabled = real_g_rebroadcast, real_g_enabled | |
2361 local entry = tremove(g_loot,loot_index) | |
2362 tinsert(g_loot,data.rowindex,entry) | |
2363 --data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.rowindex) | |
2364 addon:_fill_out_eoi_data(data.rowindex) | |
2365 addon:BuildMainDisplay() | |
2366 dialog.data = nil | |
2367 addon:Print("Inserted %s %s (entry %d).", data.kind, data.name, data.rowindex) | |
2368 return | |
2369 end | |
2370 | |
2371 local text = dialog.editBox:GetText():trim() | |
2372 | |
2373 -- third click | |
2374 if data.name and data.recipient and text then | |
2375 data.notes = (text ~= "<none>") and text or nil | |
2376 data.all_done = true | |
2377 return eoi_st_insert_OnAccept_loot (dialog, data) | |
2378 end | |
2379 | |
2380 -- second click | |
2381 if data.name and text then | |
2382 data.recipient = text | |
2383 local getnotes = StaticPopup_Show("OUROL_EOI_INSERT","notes") | |
2384 getnotes.data = data | |
2385 getnotes.editBox:SetText("<none>") | |
2386 getnotes.editBox:HighlightText() | |
2387 return true | |
2388 end | |
2389 | |
2390 -- first click | |
2391 if text then | |
2392 data.name = text | |
2393 dialog:Hide() -- technically a "different" one about to be shown | |
2394 local getrecipient = StaticPopup_Show("OUROL_EOI_INSERT","recipient") | |
2395 getrecipient.data = data | |
2396 getrecipient.editBox:SetText("") | |
2397 return true | |
2398 end | |
2399 end | |
2400 | |
2401 local function eoi_st_insert_OnAccept (dialog, data) | |
2402 if data.kind == 'boss' then | |
2403 return eoi_st_insert_OnAccept_boss (dialog, data) | |
2404 elseif data.kind == 'loot' then | |
2405 return eoi_st_insert_OnAccept_loot (dialog, data) | |
2406 end | |
2407 end | |
2383 | 2408 |
2384 -- The data member here is a table built with: | 2409 -- The data member here is a table built with: |
2385 -- {rowindex=<GUI row receiving click>, display=_d, kind=<loot/boss>} | 2410 -- {rowindex=<GUI row receiving click>, display=_d, kind=<loot/boss>} |
2386 do | 2411 do |
2387 local t = flib.StaticPopup{ | 2412 local t = flib.StaticPopup{ |
2406 end | 2431 end |
2407 end | 2432 end |
2408 t.enterClicksFirstButton = nil -- no effect with editbox focused | 2433 t.enterClicksFirstButton = nil -- no effect with editbox focused |
2409 t.OnAccept = eoi_st_insert_OnAccept | 2434 t.OnAccept = eoi_st_insert_OnAccept |
2410 StaticPopupDialogs["OUROL_EOI_INSERT"] = t | 2435 StaticPopupDialogs["OUROL_EOI_INSERT"] = t |
2411 end | 2436 |
2412 | 2437 -- This seems to be gratuitous use of metatables, really. |
2413 -- This seems to be gratuitous use of metatables, really. | |
2414 do | |
2415 local OEIL = { | 2438 local OEIL = { |
2416 text = "Paste the new item into here, then click Next or press Enter:", | 2439 text = "Paste the new item into here, then click Next or press Enter:", |
2417 __index = StaticPopupDialogs["OUROL_EOI_INSERT"] | 2440 __index = StaticPopupDialogs["OUROL_EOI_INSERT"] |
2418 } | 2441 } |
2419 StaticPopupDialogs["OUROL_EOI_INSERT_LOOT"] = setmetatable(OEIL,OEIL) | 2442 StaticPopupDialogs["OUROL_EOI_INSERT_LOOT"] = setmetatable(OEIL,OEIL) |
2423 if dialogname then | 2446 if dialogname then |
2424 _G[dialogname.."EditBox"]:SetText(link) | 2447 _G[dialogname.."EditBox"]:SetText(link) |
2425 return true | 2448 return true |
2426 end | 2449 end |
2427 end) | 2450 end) |
2451 | |
2452 t = flib.StaticPopup{ | |
2453 -- Concatenate this once at load time. There is no ITEM_QUALITY_LEGENDARY constant. | |
2454 text = "Include a snapshot of the " .. ITEM_QUALITY_COLORS[5].hex | |
2455 .. "CURRENT|r raid?\n\nClicking '" .. YES .. "' will allow this entry to " | |
2456 .. "appear in attendance lists, but with the roster as it is NOW, not as it " | |
2457 .. "was THEN. Clicking '" .. NO .."' means this kill cannot be included in " | |
2458 .. "attendance.\n\n(Enter = '" .. YES .."', Escape = '" .. CANCEL .. "')", | |
2459 button1 = YES, -- "accept", left | |
2460 button2 = NO, -- "cancel", middle | |
2461 button3 = CANCEL, -- "alt", right | |
2462 } | |
2463 -- Hitting Escape still hides the frame, but doesn't run OnCancel (which | |
2464 -- is for the "No" button, not the "Cancel"/OnAlt button). Dizzy yet? | |
2465 t.noCancelOnEscape = true | |
2466 t.OnAccept = eoi_st_insert_OnAccept_boss | |
2467 t.OnCancel = eoi_st_insert_OnAccept_boss | |
2468 StaticPopupDialogs["OUROL_EOI_INSERT_INCLUDE_RAIDERSNAP"] = t | |
2428 end | 2469 end |
2429 | 2470 |
2430 StaticPopupDialogs["OUROL_REASSIGN_ENTER"] = flib.StaticPopup{ | 2471 StaticPopupDialogs["OUROL_REASSIGN_ENTER"] = flib.StaticPopup{ |
2431 text = "Enter the player name:", | 2472 text = "Enter the player name:", |
2432 button1 = ACCEPT, | 2473 button1 = ACCEPT, |