Mercurial > wow > ouroloot
comparison gui.lua @ 76:124da015c4a2
- Some more debugging aids (logging error/assert, auto-enable of testing
panel, reminder of GOP history mode)
- Move (finally!) hypertext handling code out to each call site.
- Fix some bugs in previous alpha code.
- Initial-but-mostly-tested code to handle items that have a "unique" field
which are in fact always the same (for example, elementium gem cluster).
Still need to test the case in which a remote tracker sees them first.
- The rest of the variable-cutoff history cleanup.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Fri, 08 Jun 2012 08:05:37 +0000 |
parents | 676fb79a4ae2 |
children | a07c9dd79f3a |
comparison
equal
deleted
inserted
replaced
75:676fb79a4ae2 | 76:124da015c4a2 |
---|---|
56 local g_loot = nil | 56 local g_loot = nil |
57 local g_generated = nil | 57 local g_generated = nil |
58 local window_title = "Ouro Loot" | 58 local window_title = "Ouro Loot" |
59 local dirty_tabs = nil | 59 local dirty_tabs = nil |
60 | 60 |
61 local error = addon.error | |
62 local assert = addon.assert | |
63 | |
61 local pairs, ipairs, tinsert, tremove, tostring, tonumber = | 64 local pairs, ipairs, tinsert, tremove, tostring, tonumber = |
62 pairs, ipairs, table.insert, table.remove, tostring, tonumber | 65 pairs, ipairs, table.insert, table.remove, tostring, tonumber |
63 | 66 |
64 local pprint, tabledump = addon.pprint, flib.tabledump | 67 local pprint, tabledump = addon.pprint, flib.tabledump |
65 local GetItemInfo, ITEM_QUALITY_COLORS = GetItemInfo, ITEM_QUALITY_COLORS | 68 local GetItemInfo, ITEM_QUALITY_COLORS = GetItemInfo, ITEM_QUALITY_COLORS |
162 end | 165 end |
163 g_generated = g_generated or {} | 166 g_generated = g_generated or {} |
164 g_loot[text_type] = g_loot[text_type] or "" | 167 g_loot[text_type] = g_loot[text_type] or "" |
165 | 168 |
166 if g_loot.printed[text_type] >= #g_loot then return false end | 169 if g_loot.printed[text_type] >= #g_loot then return false end |
167 assert(addon.loot_clean == #g_loot, tostring(addon.loot_clean) .. " ~= " .. #g_loot) | 170 assert (addon.loot_clean == #g_loot, |
171 tostring(addon.loot_clean) .. " ~= " .. #g_loot) | |
168 -- if glc is nil, #==0 test already returned | 172 -- if glc is nil, #==0 test already returned |
169 | 173 |
170 local ok,ret = pcall (f, text_type, g_loot, g_loot.printed[text_type], g_generated, accumulator) | 174 local ok,ret = pcall (f, text_type, g_loot, g_loot.printed[text_type], g_generated, accumulator) |
171 if not ok then | 175 if not ok then |
172 error(("ERROR: text generator '%s' failed: %s"):format(text_type, ret)) | 176 error(("ERROR: text generator '%s' failed: %s"):format(text_type, ret)) |
173 return false | 177 return false -- why is this here again? |
174 end | 178 end |
175 if ret then | 179 if ret then |
176 g_loot.printed[text_type] = #g_loot | 180 g_loot.printed[text_type] = #g_loot |
177 g_generated[text_type] = (g_generated[text_type] or "") .. table.concat(accumulator,'\n') .. '\n' | 181 g_generated[text_type] = (g_generated[text_type] or "") .. table.concat(accumulator,'\n') .. '\n' |
178 end | 182 end |
1886 container:AddChild(grp) | 1890 container:AddChild(grp) |
1887 GUI:ClearFocus() | 1891 GUI:ClearFocus() |
1888 container:SetScroll(1000) -- scrollframe's max value | 1892 container:SetScroll(1000) -- scrollframe's max value |
1889 end | 1893 end |
1890 | 1894 |
1891 -- Initial lower panel function | 1895 -- Initial lower panel function (unless debug mode is on during load, which |
1892 local function adv_lower (container, specials) | 1896 -- means it was almost certainly hardcoded that way, which means it's |
1893 local spacer = GUI:Create("Spacer") | 1897 -- probably me testing). |
1894 spacer:SetFullWidth(true) | 1898 local adv_lower |
1895 spacer:SetHeight(5) | 1899 if addon.DEBUG_PRINT then |
1896 container:AddChild(spacer) | 1900 adv_lower = adv_real |
1897 local speedbump = GUI:Create("InteractiveLabel") | 1901 else |
1898 speedbump:SetFullWidth(true) | 1902 function adv_lower (container, specials) |
1899 speedbump:SetFontObject(GameFontHighlightLarge) | 1903 local spacer = GUI:Create("Spacer") |
1900 speedbump:SetImage("Interface\\DialogFrame\\DialogAlertIcon") | 1904 spacer:SetFullWidth(true) |
1901 speedbump:SetImageSize(50,50) | 1905 spacer:SetHeight(5) |
1902 speedbump:SetText("The debugging/testing settings on the rest of this panel can" | 1906 container:AddChild(spacer) |
1903 .." seriously bork up the addon if you make a mistake. If you're okay" | 1907 local speedbump = GUI:Create("InteractiveLabel") |
1904 .." with the possibility of losing data, click this warning to load the panel.") | 1908 speedbump:SetFullWidth(true) |
1905 speedbump:SetCallback("OnClick", function (_sb) | 1909 speedbump:SetFontObject(GameFontHighlightLarge) |
1906 adv_lower = adv_real | 1910 speedbump:SetImage("Interface\\DialogFrame\\DialogAlertIcon") |
1907 return addon:redisplay() | 1911 speedbump:SetImageSize(50,50) |
1908 --return tabs_OnGroupSelected_func(container.parent,"OnGroupSelected","opt") | 1912 speedbump:SetText("The debugging/testing settings on the rest of this panel can seriously bork up the addon if you make a mistake. If you're okay with the possibility of losing data, click this warning to load the panel.") |
1909 end) | 1913 speedbump:SetCallback("OnClick", function (_sb) |
1910 container:AddChild(speedbump) | 1914 adv_lower = adv_real |
1911 spacer = GUI:Create("Spacer") | 1915 return addon:redisplay() |
1912 spacer:SetFullWidth(true) | 1916 --return tabs_OnGroupSelected_func(container.parent,"OnGroupSelected","opt") |
1913 spacer:SetHeight(5) | 1917 end) |
1914 container:AddChild(spacer) | 1918 container:AddChild(speedbump) |
1919 spacer = GUI:Create("Spacer") | |
1920 spacer:SetFullWidth(true) | |
1921 spacer:SetHeight(5) | |
1922 container:AddChild(spacer) | |
1923 end | |
1915 end | 1924 end |
1916 | 1925 |
1917 tabs_OnGroupSelected["opt"] = function(container,specials) | 1926 tabs_OnGroupSelected["opt"] = function(container,specials) |
1918 opts = OuroLootSV_opts | 1927 opts = OuroLootSV_opts |
1919 | 1928 |
2231 spec:ReleaseChildren() | 2240 spec:ReleaseChildren() |
2232 local h = GUI:Create("Heading") | 2241 local h = GUI:Create("Heading") |
2233 h:SetFullWidth(true) | 2242 h:SetFullWidth(true) |
2234 h:SetText(_tabtexts[group].title) | 2243 h:SetText(_tabtexts[group].title) |
2235 spec:AddChild(h) | 2244 spec:AddChild(h) |
2245 do | |
2246 addon.sender_list.sort() | |
2247 local fmt = "Received broadcast data from %d |4player:players;." | |
2248 if addon.history_suppress then | |
2249 -- this is the druid class color reworked into hex | |
2250 fmt = fmt .. " |cffff7d0aHistory recording suppressed.|r" | |
2251 end | |
2252 tabs.titletext:SetFormattedText (fmt, addon.sender_list.activeI) | |
2253 end | |
2236 return tabs_OnGroupSelected[group](tabs,spec,group) | 2254 return tabs_OnGroupSelected[group](tabs,spec,group) |
2237 --[====[ | 2255 --[====[ |
2238 Unfortunately, :GetHeight() called on anything useful out of a TabGroup | 2256 Unfortunately, :GetHeight() called on anything useful out of a TabGroup |
2239 returns the static default size (about 50 pixels) until the refresh | 2257 returns the static default size (about 50 pixels) until the refresh |
2240 cycle *after* all the frames are shown. Trying to fix it up after a | 2258 cycle *after* all the frames are shown. Trying to fix it up after a |
2476 local titletext_orig_fo = tabs.titletext:GetFontObject() | 2494 local titletext_orig_fo = tabs.titletext:GetFontObject() |
2477 tabs.titletext:SetFontObject(GameFontNormalSmall) | 2495 tabs.titletext:SetFontObject(GameFontNormalSmall) |
2478 tabs:SetCallback("OnRelease", function(_tabs) | 2496 tabs:SetCallback("OnRelease", function(_tabs) |
2479 tabs.titletext:SetFontObject(titletext_orig_fo) | 2497 tabs.titletext:SetFontObject(titletext_orig_fo) |
2480 end) | 2498 end) |
2481 do | |
2482 self.sender_list.sort() | |
2483 tabs.titletext:SetFormattedText("Received broadcast data from %d |4player:players;.", | |
2484 self.sender_list.activeI) | |
2485 end | |
2486 tabs:SetRelativeWidth(0.99-rhs_width) | 2499 tabs:SetRelativeWidth(0.99-rhs_width) |
2487 tabs:SetFullHeight(true) | 2500 tabs:SetFullHeight(true) |
2488 tabs:SetTabs(tabgroup_tabs) | 2501 tabs:SetTabs(tabgroup_tabs) |
2489 tabs:SetCallback("OnGroupSelected", tabs_OnGroupSelected_func) | 2502 tabs:SetCallback("OnGroupSelected", tabs_OnGroupSelected_func) |
2490 tabs:SetCallback("OnTabEnter", function(_tabs,event,value,tab) | 2503 tabs:SetCallback("OnTabEnter", function(_tabs,event,value,tab) |
2491 setstatus(_tabtexts[value].desc) | 2504 setstatus(_tabtexts[value].desc) |
2492 end) | 2505 end) |
2493 tabs:SetCallback("OnTabLeave", statusy_OnLeave) | 2506 tabs:SetCallback("OnTabLeave", statusy_OnLeave) |
2494 tabs:SetUserData("special buttons group",tab_specials) | 2507 tabs:SetUserData("special buttons group",tab_specials) |
2495 tabs:SelectTab(opt_tabselect or "eoi") | 2508 tabs:SelectTab((opt_tabselect and #opt_tabselect>0) |
2509 and opt_tabselect or "eoi") | |
2496 | 2510 |
2497 display:AddChildren (tabs, control) | 2511 display:AddChildren (tabs, control) |
2498 display:ApplyStatus() | 2512 display:ApplyStatus() |
2499 | 2513 |
2500 display:Show() -- without this, only appears every *other* function call | 2514 display:Show() -- without this, only appears every *other* function call |