Mercurial > wow > ouroloot
comparison gui.lua @ 125:a9cf9b2fbf9b
- Fix interactions with AddonLoader.
- Plugins get a :Print with a clickable prefix, with overrideable behaviors.
- 'Deactivate' event gets a [wrapper around] current raiders table.
- Fix sorting bug in player history data.
- Smarter status line text when viewing unfiltered history.
- Do not disable history regeneration button when current history is empty.
- :BuildMainDisplay can handle the CLI args now.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Sun, 19 Aug 2012 21:08:59 -0400 |
parents | fb4bda3ad05c |
children | 9232cacc9136 |
comparison
equal
deleted
inserted
replaced
124:1a248faf1a3b | 125:a9cf9b2fbf9b |
---|---|
456 | 456 |
457 do | 457 do |
458 function addon:_fill_out_hist_data (opt_starting_index) | 458 function addon:_fill_out_hist_data (opt_starting_index) |
459 local new, del = flib.new, flib.del | 459 local new, del = flib.new, flib.del |
460 | 460 |
461 if not self.history.st then | |
462 self.history.st = {} | |
463 self.hist_clean = nil | |
464 end | |
461 -- Clearing history finishes this function with #hist==0 and hist_clean==0. | 465 -- Clearing history finishes this function with #hist==0 and hist_clean==0. |
462 -- The next call typically detects this (#<1) and handles it. If loot is | 466 -- The next call typically detects this (#<1) and handles it. If loot is |
463 -- recorded before then, it results in hist_clean==0 and #hist==1, which | 467 -- recorded before then, it results in hist_clean==0 and #hist==1, which |
464 -- breaks the first iteration of the loop. Thus, the "extra" test here: | 468 -- breaks the first iteration of the loop. Thus, the "extra" test here: |
465 if #self.history < 1 or self.hist_clean == 0 then | 469 if #self.history < 1 or self.hist_clean == 0 then |
466 self.hist_clean = nil | 470 self.hist_clean = nil |
467 opt_starting_index = nil | 471 opt_starting_index = nil |
468 end | |
469 if not self.history.st then | |
470 self.history.st = {} | |
471 end | 472 end |
472 | 473 |
473 -- for now | 474 -- for now |
474 if self.hist_clean == #self.history then return end | 475 if self.hist_clean == #self.history then return end |
475 | 476 |
1863 st_widget.tail_offset = 0 | 1864 st_widget.tail_offset = 0 |
1864 container:SetLayout("Fill") | 1865 container:SetLayout("Fill") |
1865 container:AddChild(st_widget) | 1866 container:AddChild(st_widget) |
1866 -- If we're focused on one player, but have deleted all entries for | 1867 -- If we're focused on one player, but have deleted all entries for |
1867 -- that player, don't sit there stuck on a blank grid. | 1868 -- that player, don't sit there stuck on a blank grid. |
1868 if history_filter_who and #histST.filtered < 1 then | 1869 if history_filter_who and #histST.filtered > 0 then |
1870 setstatus(hist_name_status) | |
1871 else | |
1869 history_filter_who = nil | 1872 history_filter_who = nil |
1870 histST:SetFilter(history_filter_by_recent) | 1873 histST:SetFilter(history_filter_by_recent) |
1871 setstatus(hist_normal_status) | 1874 setstatus(hist_normal_status) |
1872 else | |
1873 setstatus(hist_name_status) | |
1874 end | 1875 end |
1875 | 1876 |
1876 local b | 1877 local b |
1877 do | 1878 do |
1878 local realms,current = {},1 | 1879 local realms,current = {},1 |
1905 --[[ b = AceGUI:Create("Spacer") b:SetFullWidth(true) b:SetHeight(10) specials:AddChild(b) ]] | 1906 --[[ b = AceGUI:Create("Spacer") b:SetFullWidth(true) b:SetHeight(10) specials:AddChild(b) ]] |
1906 | 1907 |
1907 b = mkbutton("Regenerate", | 1908 b = mkbutton("Regenerate", |
1908 [[Erases all history entries from the displayed realm, and regenerates it from current loot information.]]) | 1909 [[Erases all history entries from the displayed realm, and regenerates it from current loot information.]]) |
1909 b:SetFullWidth(true) | 1910 b:SetFullWidth(true) |
1910 b:SetDisabled (#addon.history == 0) | |
1911 b:SetCallback("OnClick", function(_b) | 1911 b:SetCallback("OnClick", function(_b) |
1912 local dialog = StaticPopup_Show("OUROL_HIST_REGEN", addon.history.realm) | 1912 local dialog = StaticPopup_Show("OUROL_HIST_REGEN", addon.history.realm) |
1913 dialog.data = addon | 1913 dialog.data = addon |
1914 dialog.data2 = function(_addon) | 1914 dialog.data2 = function(_addon) |
1915 _addon:rewrite_history (_addon.history.realm) | 1915 _addon:rewrite_history (_addon.history.realm) |
2068 return button | 2068 return button |
2069 end | 2069 end |
2070 gui.mkbutton = mkbutton | 2070 gui.mkbutton = mkbutton |
2071 | 2071 |
2072 --[[ | 2072 --[[ |
2073 Creates the main window. | 2073 Creates the main window. Can jump directly to a tab (and feed it CLI |
2074 routine arguments), if given the appropriate tab code. | |
2074 ]] | 2075 ]] |
2075 function addon:BuildMainDisplay (opt_tabselect) | 2076 function addon:BuildMainDisplay (opt_tabselect, opt_tabselect_CLI_arg) |
2076 if self.display then | 2077 if self.display then |
2077 -- try to get everything to update, rebuild, refresh... ugh, no | 2078 -- try to get everything to update, rebuild, refresh... ugh, no |
2078 self.display:Hide() | 2079 self.display:Hide() |
2079 end | 2080 end |
2080 if self.NOLOAD then | 2081 if self.NOLOAD then |
2282 tabs:SetCallback("OnTabEnter", function(_tabs,event,value,tab) | 2283 tabs:SetCallback("OnTabEnter", function(_tabs,event,value,tab) |
2283 setstatus(gui.tabtexts[value].desc) | 2284 setstatus(gui.tabtexts[value].desc) |
2284 end) | 2285 end) |
2285 tabs:SetCallback("OnTabLeave", statusy_OnLeave) | 2286 tabs:SetCallback("OnTabLeave", statusy_OnLeave) |
2286 tabs:SetUserData("special buttons group",tab_specials) | 2287 tabs:SetUserData("special buttons group",tab_specials) |
2287 tabs:SelectTab((opt_tabselect and #opt_tabselect>0) | 2288 |
2288 and opt_tabselect or "eoi") | 2289 local whichtab, tabargs = "eoi" |
2290 if opt_tabselect and #opt_tabselect > 0 then | |
2291 whichtab, tabargs = opt_tabselect, opt_tabselect_CLI_arg | |
2292 end | |
2293 tabs:SelectTab(whichtab) | |
2289 | 2294 |
2290 display:AddChildren (tabs, control) | 2295 display:AddChildren (tabs, control) |
2291 display:ApplyStatus() | 2296 display:ApplyStatus() |
2292 | |
2293 display:Show() -- without this, only appears every *other* function call | 2297 display:Show() -- without this, only appears every *other* function call |
2298 | |
2299 if tabargs and tabs_CLI_special[whichtab] then | |
2300 tabs_CLI_special[whichtab](tabargs) | |
2301 end | |
2294 return display | 2302 return display |
2295 end | 2303 end |
2296 | 2304 |
2297 -- Searches tab titles from left to right. | 2305 -- Searches tab title texts from left to right. |
2298 function addon:OpenMainDisplayToTab (text, opt_arg) | 2306 function addon:OpenMainDisplayToTab (text, opt_arg) |
2299 text = '^'..text:lower() | 2307 text = '^'..text:lower() |
2300 for _,tab in ipairs(gui.taborder) do | 2308 for _,tab in ipairs(gui.taborder) do |
2301 local v = gui.tabtexts[tab] | 2309 local v = gui.tabtexts[tab] |
2302 if v and v.title:lower():find(text) then | 2310 if v and v.title:lower():find(text) then |
2303 self:BuildMainDisplay(tab) | 2311 self:BuildMainDisplay (tab, opt_arg) |
2304 if opt_arg and tabs_CLI_special[tab] then | |
2305 tabs_CLI_special[tab](opt_arg) | |
2306 end | |
2307 return true | 2312 return true |
2308 end | 2313 end |
2309 end | 2314 end |
2310 end | 2315 end |
2311 | 2316 |
2382 } | 2387 } |
2383 | 2388 |
2384 StaticPopupDialogs["OUROL_HIST_REGEN"] = flib.StaticPopup{ | 2389 StaticPopupDialogs["OUROL_HIST_REGEN"] = flib.StaticPopup{ |
2385 -- Concatenate this once at load time. There is no ITEM_QUALITY_LEGENDARY constant. | 2390 -- Concatenate this once at load time. There is no ITEM_QUALITY_LEGENDARY constant. |
2386 text = "Erase all history entries from " .. ITEM_QUALITY_COLORS[5].hex | 2391 text = "Erase all history entries from " .. ITEM_QUALITY_COLORS[5].hex |
2387 .. "%s|r, and generate it anew from current loot?", | 2392 .. "%s|r, and generate it anew from current loot?|n|nNote this obeys the current setting of the 'Suppress history for cross-realm players' option.", |
2388 button1 = YES, | 2393 button1 = YES, |
2389 button2 = NO, | 2394 button2 = NO, |
2390 OnAccept = function (dialog, addon, data2) | 2395 OnAccept = function (dialog, addon, data2) |
2391 data2(addon) | 2396 data2(addon) |
2392 addon:Print("%s history has been regenerated.", addon.history.realm) | 2397 addon:Print("%s history has been regenerated.", addon.history.realm) |