Mercurial > wow > ouroloot
comparison gui.lua @ 96:780b7e0eeeeb
Break the options panel out of gui.lua into new options.lua. Move default item lists from verbage.lua there also. Redo options panel as a tree instead of a massive scrolling thing, and prepare data structures to let plugins/etc add their own options code.
| author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
|---|---|
| date | Thu, 26 Jul 2012 20:46:00 +0000 |
| parents | 3546c7b55986 |
| children | ba5ff82dcf19 |
comparison
equal
deleted
inserted
replaced
| 95:3546c7b55986 | 96:780b7e0eeeeb |
|---|---|
| 58 -- for the official source of mouseover tab titles, etc. Not completely | 58 -- for the official source of mouseover tab titles, etc. Not completely |
| 59 -- hidden because we need to reach in and fiddle too often to be worth it. | 59 -- hidden because we need to reach in and fiddle too often to be worth it. |
| 60 tabtexts = { | 60 tabtexts = { |
| 61 ["eoi"] = {title=[[Loot]], desc=[[Observed loot, plus boss kills and other events of interest]]}, | 61 ["eoi"] = {title=[[Loot]], desc=[[Observed loot, plus boss kills and other events of interest]]}, |
| 62 ["hist"] = {title=[[History]], desc=[[A short semi-permanent record]]}, | 62 ["hist"] = {title=[[History]], desc=[[A short semi-permanent record]]}, |
| 63 ["opt"] = {title=[[Options]], desc=[[Options for fine-tuning behavior]]}, | |
| 64 }, | 63 }, |
| 65 taborder = { "eoi" }, | 64 taborder = { "eoi" }, |
| 66 taborder_APPEND = { "hist", "help", "opt" }, | 65 taborder_APPEND = { "hist", "help", "opt" }, |
| 67 } | 66 } |
| 68 addon.gui_state_pointer = gui -- only during loading, then cleaned out | 67 addon.gui_state_pointer = gui -- only during loading, then cleaned out |
| 88 local IsInRaid = IsInRaid or (function() return GetNumRaidMembers() > 0 end) | 87 local IsInRaid = IsInRaid or (function() return GetNumRaidMembers() > 0 end) |
| 89 | 88 |
| 90 -- En masse forward decls of symbols defined inside local blocks | 89 -- En masse forward decls of symbols defined inside local blocks |
| 91 local _generate_text, _populate_text_specials, _markup | 90 local _generate_text, _populate_text_specials, _markup |
| 92 local eoi_dropdownfuncs -- filled out in gui block scope | 91 local eoi_dropdownfuncs -- filled out in gui block scope |
| 93 local _do_debugging_tooltip, _hide_debugging_tooltip, _build_debugging_tooltip | 92 local _hide_debugging_tooltip, _build_debugging_tooltip |
| 94 local _new_rebroadcast_hyperlink | 93 local _new_rebroadcast_hyperlink |
| 95 | 94 |
| 96 --[[ | 95 --[[ |
| 97 This is a table of callback functions, each responsible for drawing a tab | 96 This is a table of callback functions, each responsible for drawing a tab |
| 98 into the container passed in the first argument. Special-purpose buttons | 97 into the container passed in the first argument. Special-purpose buttons |
| 513 do | 512 do |
| 514 local debug_tt | 513 local debug_tt |
| 515 | 514 |
| 516 local _creators, _builders = {}, {} | 515 local _creators, _builders = {}, {} |
| 517 local function _create_tooltip() | 516 local function _create_tooltip() |
| 518 local which = assert(tonumber(_do_debugging_tooltip)) | 517 local which = assert(tonumber(gui._do_debugging_tooltip)) |
| 519 if type(_creators[which]) == 'function' then | 518 if type(_creators[which]) == 'function' then |
| 520 _creators[which]() | 519 _creators[which]() |
| 521 end | 520 end |
| 522 debug_tt = _creators[which] | 521 debug_tt = _creators[which] |
| 523 end | 522 end |
| 524 function _build_debugging_tooltip (parent, index) | 523 function _build_debugging_tooltip (parent, index) |
| 525 local which = assert(tonumber(_do_debugging_tooltip)) | 524 local which = assert(tonumber(gui._do_debugging_tooltip)) |
| 526 if type(_builders[which]) == 'function' then | 525 if type(_builders[which]) == 'function' then |
| 527 _builders[which](parent,index) | 526 _builders[which](parent,index) |
| 528 end | 527 end |
| 529 end | 528 end |
| 530 function _hide_debugging_tooltip() | 529 function _hide_debugging_tooltip() |
| 1081 if (row == nil) or (realrow == nil) then return end -- mouseover column header | 1080 if (row == nil) or (realrow == nil) then return end -- mouseover column header |
| 1082 local e = data[realrow] | 1081 local e = data[realrow] |
| 1083 local kind = e.kind | 1082 local kind = e.kind |
| 1084 local tt = GameTooltip -- can this be hoisted? does GT ever get securely replaced? | 1083 local tt = GameTooltip -- can this be hoisted? does GT ever get securely replaced? |
| 1085 | 1084 |
| 1086 if _do_debugging_tooltip and column == 1 and kind ~= 'hist' then | 1085 if gui._do_debugging_tooltip and column == 1 and kind ~= 'hist' then |
| 1087 _build_debugging_tooltip (cellFrame, realrow) | 1086 _build_debugging_tooltip (cellFrame, realrow) |
| 1088 end | 1087 end |
| 1089 if (kind == 'loot' and column == 1) or (kind == 'hist' and column == 2) then | 1088 if (kind == 'loot' and column == 1) or (kind == 'hist' and column == 2) then |
| 1090 tt:SetOwner (cellFrame, "ANCHOR_RIGHT", -20, 0) | 1089 tt:SetOwner (cellFrame, "ANCHOR_RIGHT", -20, 0) |
| 1091 if e.cache_miss then | 1090 if e.cache_miss then |
| 1894 | 1893 |
| 1895 | 1894 |
| 1896 -- Tab 5: Help (content in verbage.lua) | 1895 -- Tab 5: Help (content in verbage.lua) |
| 1897 | 1896 |
| 1898 | 1897 |
| 1899 -- Tab 6: Options / Advanced | 1898 -- Tab 6: Options (content in options.lua) |
| 1900 do | |
| 1901 -- Local ref to OuroLootSV_opts, which may be reassigned after load. | |
| 1902 -- So instead this is updated when the tab is displayed. | |
| 1903 local opts | |
| 1904 local function mkoption (opt, label, width, desc, opt_func) | |
| 1905 local w = mkbutton("CheckBoxSmallLabel", nil, "", desc) | |
| 1906 w:SetRelativeWidth(width) | |
| 1907 w:SetType("checkbox") | |
| 1908 w:SetLabel(label) | |
| 1909 if opt then | |
| 1910 w:SetValue(opts[opt]) | |
| 1911 w:SetCallback("OnValueChanged", opt_func or (function(_w,event,value) | |
| 1912 opts[opt] = value | |
| 1913 end)) | |
| 1914 end | |
| 1915 return w | |
| 1916 end | |
| 1917 | |
| 1918 local function adv_careful_OnTextChanged (ebox,event,value) | |
| 1919 -- The EditBox widget's code will call an internal ShowButton routine | |
| 1920 -- after this callback returns. ShowButton will test for this flag: | |
| 1921 ebox:DisableButton (value == "") | |
| 1922 end | |
| 1923 | |
| 1924 -- Like the first tab, we use a pair of functions; first and repeating. | |
| 1925 local function adv_real (container, specials) | |
| 1926 local grp, w | |
| 1927 | |
| 1928 grp = AceGUI:Create("InlineGroup") | |
| 1929 grp:SetLayout("Flow") | |
| 1930 grp:PauseLayout() | |
| 1931 grp:SetFullWidth(true) | |
| 1932 grp:SetTitle("Debugging/Testing Options [not saved across sessions]") | |
| 1933 | |
| 1934 w = mkbutton("EditBox", 'comm_ident', addon.ident, | |
| 1935 [[Set tracking to 'Disabled' in the top-right dropdown, then change this field (click Okay or press Enter).]]) | |
| 1936 w:SetRelativeWidth(0.2) | |
| 1937 w:SetLabel("Addon channel ID") | |
| 1938 w:SetCallback("OnTextChanged", adv_careful_OnTextChanged) | |
| 1939 w:SetCallback("OnEnterPressed", function(_w,event,value) | |
| 1940 -- if they set it to blank spaces, they're boned. oh well. | |
| 1941 -- Re-enabling will take care of propogating this new value. | |
| 1942 addon.ident = (value == "") and "OuroLoot2" or value | |
| 1943 _w:SetText(addon.ident) | |
| 1944 addon:Print("Addon channel ID set to '".. addon.ident.. "' for rebroadcasting and listening.") | |
| 1945 end) | |
| 1946 w:SetDisabled(addon.enabled or addon.rebroadcast) | |
| 1947 grp:AddChild(w) | |
| 1948 | |
| 1949 w = mkbutton("EditBox", nil, addon.recent_messages.ttl, [[comm cache TTL]]) | |
| 1950 w:SetRelativeWidth(0.05) | |
| 1951 w:SetLabel("ttl") | |
| 1952 w:SetCallback("OnTextChanged", adv_careful_OnTextChanged) | |
| 1953 w:SetCallback("OnEnterPressed", function(_w,event,value) | |
| 1954 value = tonumber(value) or addon.recent_messages.ttl | |
| 1955 addon.recent_messages.ttl = value | |
| 1956 _w:SetText(tostring(value)) | |
| 1957 end) | |
| 1958 grp:AddChild(w) | |
| 1959 | |
| 1960 w = mkbutton("load nsaab1548", [[Cursed Darkhound]]) | |
| 1961 w:SetRelativeWidth(0.25) | |
| 1962 w:SetCallback("OnClick", function() | |
| 1963 for i, v in ipairs(DBM.AddOns) do | |
| 1964 if v.modId == "DBM-NotScaryAtAll" then | |
| 1965 DBM:LoadMod(v) | |
| 1966 break | |
| 1967 end | |
| 1968 end | |
| 1969 local mod = DBM:GetModByName("NotScaryAtAll") | |
| 1970 if mod then | |
| 1971 mod:EnableMod() | |
| 1972 addon:Print("Now tracking ID",mod.creatureId) | |
| 1973 else | |
| 1974 addon:Print("Can do nothing; DBM testing mod wasn't loaded.") | |
| 1975 end | |
| 1976 end) | |
| 1977 w:SetDisabled(addon.bossmod_registered ~= 'DBM') | |
| 1978 grp:AddChild(w) | |
| 1979 | |
| 1980 w = mkbutton("GC", [[full GC cycle]]) | |
| 1981 w:SetRelativeWidth(0.1) | |
| 1982 w:SetCallback("OnClick", function() | |
| 1983 local before = collectgarbage('count') | |
| 1984 collectgarbage('collect') | |
| 1985 local after = collectgarbage('count') | |
| 1986 addon:Print("Collected %d KB, %d KB still in use by Lua universe.", before-after, after) | |
| 1987 end) | |
| 1988 grp:AddChild(w) | |
| 1989 | |
| 1990 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(1) grp:AddChild(w) | |
| 1991 | |
| 1992 local simple = AceGUI:Create("SimpleGroup") | |
| 1993 simple:SetLayout("List") | |
| 1994 simple:SetRelativeWidth(0.3) | |
| 1995 w = mkbutton("Dropdown", nil, "", [[hovering over Item column only]]) | |
| 1996 w:SetFullWidth(true) | |
| 1997 w:SetLabel("loot debugging tooltip") | |
| 1998 w:SetList{ | |
| 1999 [1] = "Off", | |
| 2000 [2] = "/dump into tooltip", | |
| 2001 [3] = "small fixed fields", | |
| 2002 } | |
| 2003 w:SetValue(_do_debugging_tooltip or 1) | |
| 2004 w:SetCallback("OnValueChanged", function(_w,event,choice) | |
| 2005 _do_debugging_tooltip = choice > 1 and choice or nil | |
| 2006 end) | |
| 2007 simple:AddChild(w) | |
| 2008 | |
| 2009 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(10) simple:AddChild(w) | |
| 2010 | |
| 2011 w = AceGUI:Create("CheckBoxSmallLabel") | |
| 2012 w:SetFullWidth(true) | |
| 2013 w:SetType("checkbox") | |
| 2014 w:SetLabel("debug toggle --->") | |
| 2015 w:SetValue(addon.DEBUG_PRINT) | |
| 2016 w:SetCallback("OnValueChanged", function(_w,event,value) | |
| 2017 addon.DEBUG_PRINT = value | |
| 2018 addon:redisplay() | |
| 2019 end) | |
| 2020 simple:AddChild(w) | |
| 2021 w = AceGUI:Create("CheckBoxSmallLabel") | |
| 2022 w:SetFullWidth(true) | |
| 2023 w:SetType("checkbox") | |
| 2024 w:SetLabel("GOP history mode") | |
| 2025 w:SetValue(addon.history_suppress) | |
| 2026 w:SetCallback("OnValueChanged", function(_w,event,value) addon.history_suppress = value end) | |
| 2027 simple:AddChild(w) | |
| 2028 w = mkbutton("Clear All & Reload", | |
| 2029 [[No confirmation! |cffff1010Erases absolutely all> Ouro Loot saved variables and reloads the UI.]]) | |
| 2030 w:SetFullWidth(true) | |
| 2031 w:SetCallback("OnClick", function() | |
| 2032 addon:_clear_SVs() -- reloads | |
| 2033 end) | |
| 2034 simple:AddChild(w) | |
| 2035 grp:AddChild(simple) | |
| 2036 | |
| 2037 simple = AceGUI:Create("SimpleGroup") | |
| 2038 simple:SetLayout("List") | |
| 2039 simple:SetRelativeWidth(0.5) | |
| 2040 for d,v in pairs(addon.debug) do | |
| 2041 w = AceGUI:Create("CheckBoxSmallLabel") | |
| 2042 w:SetFullWidth(true) | |
| 2043 w:SetType("checkbox") | |
| 2044 w:SetLabel(d) | |
| 2045 if d == "notraid" then | |
| 2046 w:SetDescription[[Tick this before enabling to make the addon work outside of raid groups]] | |
| 2047 else | |
| 2048 if d == "alsolog" then | |
| 2049 w:SetDescription[[Also log all debug messages to disk. See print_log.lua in the addon folder for later viewing.]] | |
| 2050 end | |
| 2051 w:SetDisabled(not addon.DEBUG_PRINT) | |
| 2052 end | |
| 2053 w:SetValue(v) | |
| 2054 w:SetCallback("OnValueChanged", function(_w,event,value) addon.debug[d] = value end) | |
| 2055 simple:AddChild(w) | |
| 2056 end | |
| 2057 grp:AddChild(simple) | |
| 2058 | |
| 2059 simple = AceGUI:Create("SimpleGroup") | |
| 2060 simple:SetLayout("Flow") | |
| 2061 simple:SetRelativeWidth(0.85) | |
| 2062 w = mkbutton("MidS-H", [[not exactly an Easter egg, with sound]]) | |
| 2063 w:SetRelativeWidth(0.15) | |
| 2064 w:SetCallback("OnClick", function() | |
| 2065 PlaySoundFile ([[Sound\Music\WorldEvents\HordeFirepole.mp3]], "Master") | |
| 2066 end) | |
| 2067 simple:AddChild(w) | |
| 2068 w = mkbutton("MidS-A", [[not exactly an Easter egg, with sound]]) | |
| 2069 w:SetRelativeWidth(0.15) | |
| 2070 w:SetCallback("OnClick", function() | |
| 2071 PlaySoundFile ([[Sound\Music\WorldEvents\AllianceFirepole.mp3]], "Master") | |
| 2072 end) | |
| 2073 simple:AddChild(w) | |
| 2074 w = mkbutton("SFRR", [[test]]) | |
| 2075 w:SetRelativeWidth(0.15) | |
| 2076 w:SetCallback("OnClick", function() | |
| 2077 PlaySoundFile ([[Interface\AddOns\Ouro_Loot\sfrr.ogg]], "Master") | |
| 2078 end) | |
| 2079 simple:AddChild(w) | |
| 2080 grp:AddChild(simple) | |
| 2081 | |
| 2082 grp:ResumeLayout() | |
| 2083 container:AddChild(grp) | |
| 2084 AceGUI:ClearFocus() | |
| 2085 container:SetScroll(1000) -- scrollframe's max value | |
| 2086 end | |
| 2087 | |
| 2088 -- Initial lower panel function (unless debug mode is on during load, which | |
| 2089 -- means it was almost certainly hardcoded that way, which means it's | |
| 2090 -- probably me testing). | |
| 2091 local adv_lower | |
| 2092 if addon.DEBUG_PRINT then | |
| 2093 adv_lower = adv_real | |
| 2094 else | |
| 2095 function adv_lower (container, specials) | |
| 2096 local spacer = AceGUI:Create("Spacer") | |
| 2097 spacer:SetFullWidth(true) | |
| 2098 spacer:SetHeight(5) | |
| 2099 container:AddChild(spacer) | |
| 2100 local speedbump = AceGUI:Create("InteractiveLabel") | |
| 2101 speedbump:SetFullWidth(true) | |
| 2102 speedbump:SetFontObject(GameFontHighlightLarge) | |
| 2103 speedbump:SetImage[[Interface\DialogFrame\DialogAlertIcon]] | |
| 2104 speedbump:SetImageSize(50,50) | |
| 2105 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.") | |
| 2106 speedbump:SetCallback("OnClick", function (_sb) | |
| 2107 adv_lower = adv_real | |
| 2108 return addon:redisplay() | |
| 2109 end) | |
| 2110 container:AddChild(speedbump) | |
| 2111 spacer = AceGUI:Create("Spacer") | |
| 2112 spacer:SetFullWidth(true) | |
| 2113 spacer:SetHeight(5) | |
| 2114 container:AddChild(spacer) | |
| 2115 end | |
| 2116 end | |
| 2117 | |
| 2118 tabs_OnGroupSelected["opt"] = function(container,specials) | |
| 2119 opts = OuroLootSV_opts | |
| 2120 | |
| 2121 container:SetLayout("Fill") | |
| 2122 local scroll, grp, w | |
| 2123 | |
| 2124 scroll = AceGUI:Create("ScrollFrame") | |
| 2125 scroll:SetLayout("Flow") | |
| 2126 | |
| 2127 grp = AceGUI:Create("InlineGroup") | |
| 2128 grp:SetLayout("Flow") | |
| 2129 grp:SetFullWidth(true) | |
| 2130 grp:SetTitle("User Options [these are saved across sessions]") | |
| 2131 | |
| 2132 -- The relative width fields used to be done to take up less vertical | |
| 2133 -- space, but that turned out to look messy. Now they're just a | |
| 2134 -- straight line for the most part. | |
| 2135 | |
| 2136 -- the nubtoggle! | |
| 2137 w = mkoption('gui_noob', [[Show UI Tips]], 0.85, | |
| 2138 [[Toggles display of the "helpful tips" box on the right side. Useful if you've just installed/upgraded.]]) | |
| 2139 grp:AddChild(w) | |
| 2140 | |
| 2141 -- reminder popup | |
| 2142 w = mkoption ('popup_on_join', "Show reminder popup on new raid", 0.49, | |
| 2143 [[When joining a raid and not already tracking, display a dialog asking for instructions.]]) | |
| 2144 grp:AddChild(w) | |
| 2145 | |
| 2146 -- toggle scroll-to-bottom on first tab | |
| 2147 w = mkoption('scroll_to_bottom', "Scroll to bottom when opening display", 0.49, | |
| 2148 [[Scroll to the bottom of the loot window (most recent entries) when displaying the GUI.]]) | |
| 2149 grp:AddChild(w) | |
| 2150 | |
| 2151 -- chatty boss mode | |
| 2152 w = mkoption('chatty_on_kill', "Be chatty on boss kill", 0.49, | |
| 2153 [[Print something to chat output when the boss mod tells Ouro Loot about a successful boss kill.]]) | |
| 2154 grp:AddChild(w) | |
| 2155 | |
| 2156 -- less noise in main panel | |
| 2157 w = mkoption('no_tracking_wipes', "Do not track wipes", 0.49, | |
| 2158 [[Do not add 'wipe' entries on the main loot grid, or generate any text for them.]]) | |
| 2159 grp:AddChild(w) | |
| 2160 | |
| 2161 -- cutesy abbrevs | |
| 2162 w = mkoption('snarky_boss', "Use snarky boss names", 0.49, | |
| 2163 [[Irreverent replacement names for boss events. See abbreviations.lua for details.]]) | |
| 2164 grp:AddChild(w) | |
| 2165 | |
| 2166 -- LOD plugins in all cases | |
| 2167 w = mkoption('display_disabled_LODs', "Include disabled plugins", 0.49, | |
| 2168 [[Show loadable plugins even if they've been disabled (and offer to enable them). Relog to take effect.]]) | |
| 2169 grp:AddChild(w) | |
| 2170 | |
| 2171 -- showing the "(from Rebroadcasterdude)" in the notes column | |
| 2172 w = mkoption('display_bcast_from', "Show rebroadcasting player", 0.49, | |
| 2173 [[Include "from PlayerName" in the Notes column for loot that was broadcast to you. (Not included in forum output).]], | |
| 2174 function(_w,_e,value) | |
| 2175 opts.display_bcast_from = value | |
| 2176 addon.loot_clean = nil | |
| 2177 end) | |
| 2178 grp:AddChild(w) | |
| 2179 | |
| 2180 -- prefilling g_uniques with history | |
| 2181 w = mkoption('precache_history_uniques', "Prescan for faster handling", 0.49, | |
| 2182 [[See description under +Help -- Handy Tips -- Prescanning> for instructions.]]) | |
| 2183 grp:AddChild(w) | |
| 2184 | |
| 2185 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(5) grp:AddChild(w) | |
| 2186 | |
| 2187 -- possible keybindings | |
| 2188 do | |
| 2189 local pair = AceGUI:Create("InlineGroup") | |
| 2190 pair:SetLayout("List") | |
| 2191 pair:SetRelativeWidth(0.49) | |
| 2192 pair:SetTitle("Keybinding for '/ouroloot'") | |
| 2193 local editbox, checkbox | |
| 2194 editbox = mkbutton("EditBox", nil, opts.keybinding_text, | |
| 2195 [[Keybinding text format is fragile (ALT then CTRL then SHIFT)! Relog to take effect.]]) | |
| 2196 editbox:SetFullWidth(true) | |
| 2197 editbox:SetLabel("Keybinding text") | |
| 2198 editbox:SetCallback("OnEnterPressed", function(_w,event,value) | |
| 2199 opts.keybinding_text = value | |
| 2200 end) | |
| 2201 editbox:SetDisabled(not opts.keybinding) | |
| 2202 checkbox = mkoption('keybinding', "Register keybinding", 1, | |
| 2203 [[Register a keybinding to toggle the loot display. Relog to take effect.]], | |
| 2204 function (_w,_,value) | |
| 2205 opts.keybinding = value | |
| 2206 editbox:SetDisabled(not opts.keybinding) | |
| 2207 end) | |
| 2208 checkbox:SetFullWidth(true) | |
| 2209 pair:AddChild(checkbox) | |
| 2210 pair:AddChild(editbox) | |
| 2211 grp:AddChild(pair) | |
| 2212 end | |
| 2213 | |
| 2214 -- replacement for slashloot | |
| 2215 do | |
| 2216 local pair = AceGUI:Create("InlineGroup") | |
| 2217 pair:SetLayout("List") | |
| 2218 pair:SetRelativeWidth(0.49) | |
| 2219 pair:SetTitle('Synonyms for "/ouroloot"') | |
| 2220 local editbox, checkbox | |
| 2221 editbox = mkbutton("EditBox", nil, opts.slash_synonyms, | |
| 2222 [[Separate multiple synonyms with a comma. Relog to take effect.]]) | |
| 2223 editbox:SetFullWidth(true) | |
| 2224 editbox:SetLabel("Slash commands") | |
| 2225 editbox:SetCallback("OnEnterPressed", function(_e,event,value) | |
| 2226 -- Do the sanity checking here rather than at each login. | |
| 2227 -- This is not foolproof. That's okay. | |
| 2228 local t = { strsplit(',', tostring(value)) } | |
| 2229 for k,v in ipairs(t) do | |
| 2230 v = v:trim() | |
| 2231 if v:sub(1,1) ~= "/" then | |
| 2232 v = "/" .. v | |
| 2233 end | |
| 2234 t[k] = v | |
| 2235 end | |
| 2236 value = table.concat(t,',') | |
| 2237 _e:SetText(value) | |
| 2238 opts.slash_synonyms = value | |
| 2239 end) | |
| 2240 editbox:SetDisabled(not opts.register_slash_synonyms) | |
| 2241 checkbox = mkoption('register_slash_synonyms', "Register slash commands", 1, | |
| 2242 [[Register these slash commands as synonyms for "/ouroloot". Relog to take effect.]], | |
| 2243 function (_w,_,value) | |
| 2244 opts.register_slash_synonyms = value | |
| 2245 editbox:SetDisabled(not opts.register_slash_synonyms) | |
| 2246 end) | |
| 2247 checkbox:SetFullWidth(true) | |
| 2248 pair:AddChild(checkbox) | |
| 2249 pair:AddChild(editbox) | |
| 2250 grp:AddChild(pair) | |
| 2251 end | |
| 2252 | |
| 2253 -- chatty disposition/assignment changes | |
| 2254 do | |
| 2255 local chatgroup = AceGUI:Create("InlineGroup") | |
| 2256 chatgroup:SetLayout("List") | |
| 2257 chatgroup:SetRelativeWidth(0.49) | |
| 2258 chatgroup:SetTitle("Remote Changes Chat") | |
| 2259 local toggle, editbox | |
| 2260 toggle = mkoption('chatty_on_remote_changes', "Be chatty on remote changes", 1, | |
| 2261 [[Print something to chat when other users change recorded loot.]], | |
| 2262 function (_w,_,value) | |
| 2263 opts.chatty_on_remote_changes = value | |
| 2264 editbox:SetDisabled(not opts.chatty_on_remote_changes) | |
| 2265 end) | |
| 2266 toggle:SetFullWidth(true) | |
| 2267 chatgroup:AddChild(toggle) | |
| 2268 w = AceGUI:Create("Label") | |
| 2269 w:SetFullWidth(true) | |
| 2270 w:SetText("This controls the output of the |cff00ffff'Be chatty on remote changes'|r option. If this field is a number, it designates which chat frame to use. Otherwise it is the Lua variable name of a frame with AddMessage capability.") | |
| 2271 chatgroup:AddChild(w) | |
| 2272 editbox = mkbutton("EditBox", nil, opts.chatty_on_remote_changes_frame, | |
| 2273 [[1 = default chat frame, 2 = combat log, etc]]) | |
| 2274 editbox:SetFullWidth(true) | |
| 2275 editbox:SetLabel("Output Chatframe") | |
| 2276 editbox:SetCallback("OnTextChanged", adv_careful_OnTextChanged) | |
| 2277 editbox:SetCallback("OnEnterPressed", function(_w,event,value) | |
| 2278 local prev = opts.chatty_on_remote_changes_frame | |
| 2279 value = value:trim() | |
| 2280 value = tonumber(value) or value | |
| 2281 if addon:_set_remote_change_chatframe (value) then | |
| 2282 opts.chatty_on_remote_changes_frame = value | |
| 2283 _w:SetText(tostring(value)) | |
| 2284 _w.editbox:ClearFocus() | |
| 2285 else | |
| 2286 _w:SetText(tostring(prev)) | |
| 2287 end | |
| 2288 end) | |
| 2289 editbox:SetDisabled(not opts.chatty_on_remote_changes) | |
| 2290 chatgroup:AddChild(editbox) | |
| 2291 w = mkbutton("Chat Frame Numbers", | |
| 2292 [[Print each chat window number in its own frame, for easy reference in the editing field.]]) | |
| 2293 w:SetFullWidth(true) | |
| 2294 w:SetCallback("OnClick", function() | |
| 2295 for i = 1, NUM_CHAT_WINDOWS do | |
| 2296 local cf = _G['ChatFrame'..i] | |
| 2297 if not cf then break end | |
| 2298 addon:CFPrint (cf, "This is frame number |cffff0000%d|r.", i) | |
| 2299 end | |
| 2300 end) | |
| 2301 chatgroup:AddChild(w) | |
| 2302 grp:AddChild(chatgroup) | |
| 2303 end | |
| 2304 | |
| 2305 -- boss mod selection | |
| 2306 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(2) grp:AddChild(w) | |
| 2307 do | |
| 2308 local list = {} | |
| 2309 local current | |
| 2310 for k,v in ipairs(addon.bossmods) do | |
| 2311 list[k] = v.n | |
| 2312 if v.n == opts.bossmod then | |
| 2313 current = k | |
| 2314 end | |
| 2315 end | |
| 2316 w = mkbutton("Dropdown", nil, "", [[Which 'boss mod' to use.]]) | |
| 2317 w:SetRelativeWidth(0.2) | |
| 2318 w:SetLabel("Boss Mod:") | |
| 2319 w:SetList(list) | |
| 2320 w:SetValue(current) | |
| 2321 w:SetCallback("OnValueChanged", function(_w,event,choice) | |
| 2322 opts.bossmod = list[choice] | |
| 2323 end) | |
| 2324 grp:AddChild(w) | |
| 2325 end | |
| 2326 | |
| 2327 -- item filters | |
| 2328 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(2) grp:AddChild(w) | |
| 2329 do | |
| 2330 local warntext = "At least one of the items in the filter list was not in your game client's cache. This is okay. Just wait a few seconds, display some other Ouro Loot tab, and then display Options again." | |
| 2331 local cache_warn, cache_warned = false, false | |
| 2332 local function do_warning() | |
| 2333 if cache_warn and not cache_warned then | |
| 2334 cache_warned = true | |
| 2335 addon:Print(warntext) | |
| 2336 end | |
| 2337 end | |
| 2338 | |
| 2339 local filterlist, vaultlist = {}, {} | |
| 2340 for id in pairs(opts.itemfilter) do | |
| 2341 local iname, _, iquality = GetItemInfo(id) | |
| 2342 if iname then | |
| 2343 filterlist[id] = ITEM_QUALITY_COLORS[iquality].hex .. iname .. "|r" | |
| 2344 else | |
| 2345 cache_warn = true | |
| 2346 end | |
| 2347 end | |
| 2348 for id in pairs(opts.itemvault) do | |
| 2349 local iname, _, iquality = GetItemInfo(id) | |
| 2350 if iname then | |
| 2351 vaultlist[id] = ITEM_QUALITY_COLORS[iquality].hex .. iname .. "|r" | |
| 2352 else | |
| 2353 cache_warn = true | |
| 2354 end | |
| 2355 end | |
| 2356 | |
| 2357 w = AceGUI:Create("EditBoxDropDown") | |
| 2358 w:SetRelativeWidth(0.4) | |
| 2359 w:SetText("Item filter") | |
| 2360 w:SetEditBoxTooltip("Link items which should no longer be tracked.") | |
| 2361 w:SetList(filterlist) | |
| 2362 w:SetCallback("OnTextEnterPressed", function(_w, _, text) | |
| 2363 local iname, ilink, iquality = GetItemInfo(text:trim()) | |
| 2364 if not iname then | |
| 2365 return addon:Print("Error: %s is not a valid item name/link!", text) | |
| 2366 end | |
| 2367 local id = tonumber(ilink:match("item:(%d+)")) | |
| 2368 filterlist[id] = ITEM_QUALITY_COLORS[iquality].hex .. iname .. "|r" | |
| 2369 opts.itemfilter[id] = true | |
| 2370 addon:Print("Now filtering out", ilink) | |
| 2371 end) | |
| 2372 w:SetCallback("OnListItemClicked", function(_w, _, key_id, val_name) | |
| 2373 --local ilink = select(2,GetItemInfo(key_id)) | |
| 2374 opts.itemfilter[tonumber(key_id)] = nil | |
| 2375 --addon:Print("No longer filtering out", ilink) | |
| 2376 addon:Print("No longer filtering out", val_name) | |
| 2377 end) | |
| 2378 w:SetCallback("OnDropdownShown",do_warning) | |
| 2379 grp:AddChild(w) | |
| 2380 | |
| 2381 w = AceGUI:Create("Spacer") | |
| 2382 w:SetRelativeWidth(0.1) | |
| 2383 w:SetHeight(2) | |
| 2384 grp:AddChild(w) | |
| 2385 | |
| 2386 w = AceGUI:Create("EditBoxDropDown") | |
| 2387 w:SetRelativeWidth(0.4) | |
| 2388 w:SetText("Vault items") | |
| 2389 w:SetEditBoxTooltip("Link items which should be automatically marked as guild vault.") | |
| 2390 w:SetList(vaultlist) | |
| 2391 w:SetCallback("OnTextEnterPressed", function(_w, _, text) | |
| 2392 local iname, ilink, iquality = GetItemInfo(text:trim()) | |
| 2393 if not iname then | |
| 2394 return addon:Print("Error: %s is not a valid item name/link!", text) | |
| 2395 end | |
| 2396 local id = tonumber(ilink:match("item:(%d+)")) | |
| 2397 vaultlist[id] = ITEM_QUALITY_COLORS[iquality].hex .. iname .. "|r" | |
| 2398 opts.itemvault[id] = true | |
| 2399 addon:Print("Now auto-vaulting", ilink) | |
| 2400 end) | |
| 2401 w:SetCallback("OnListItemClicked", function(_w, _, key_id, val_name) | |
| 2402 --local ilink = select(2,GetItemInfo(key_id)) | |
| 2403 opts.itemfilter[tonumber(key_id)] = nil | |
| 2404 --addon:Print("No longer filtering out", ilink) | |
| 2405 addon:Print("No longer auto-vaulting", val_name) | |
| 2406 end) | |
| 2407 w:SetCallback("OnDropdownShown",do_warning) | |
| 2408 grp:AddChild(w) | |
| 2409 end | |
| 2410 | |
| 2411 addon.sender_list.sort() | |
| 2412 if #addon.sender_list.namesI > 0 then | |
| 2413 local senders = table.concat(addon.sender_list.namesI,'\n') -- sigh | |
| 2414 -- If 39 other people in the raid are running this, the label will | |
| 2415 -- explode... is it likely enough to care about? No. | |
| 2416 w = AceGUI:Create("Spacer") | |
| 2417 w:SetFullWidth(true) | |
| 2418 w:SetHeight(20) | |
| 2419 grp:AddChild(w) | |
| 2420 w = AceGUI:Create("Label") | |
| 2421 w:SetRelativeWidth(0.4) | |
| 2422 w:SetText(ITEM_QUALITY_COLORS[3].hex .."Echo from latest ping:|r\n"..senders) | |
| 2423 grp:AddChild(w) | |
| 2424 end | |
| 2425 | |
| 2426 scroll:AddChild(grp) | |
| 2427 | |
| 2428 w = mkbutton("ReloadUI", [[Does what you think it does. Loot information is written out and restored.]]) | |
| 2429 w:SetFullWidth(true) | |
| 2430 w:SetCallback("OnClick", ReloadUI) | |
| 2431 specials:AddChild(w) | |
| 2432 | |
| 2433 w = mkbutton("Ping!", | |
| 2434 [[Asks other raid users for their addon version and current status. Results displayed on User Options panel.]]) | |
| 2435 w:SetFullWidth(true) | |
| 2436 w:SetCallback("OnClick", function(_w) | |
| 2437 _w:SetText("5... 4... 3...") | |
| 2438 _w:SetDisabled(true) | |
| 2439 addon:DoPing() | |
| 2440 addon:ScheduleTimer(function(b) | |
| 2441 if b:IsVisible() then | |
| 2442 return addon:redisplay() | |
| 2443 end | |
| 2444 end, 5, _w) | |
| 2445 end) | |
| 2446 specials:AddChild(w) | |
| 2447 | |
| 2448 -- Add appropriate lower panel | |
| 2449 adv_lower (scroll, specials) | |
| 2450 | |
| 2451 -- Finish up | |
| 2452 container:AddChild(scroll) | |
| 2453 end | |
| 2454 end | |
| 2455 | 1899 |
| 2456 | 1900 |
| 2457 -- Simply to avoid recreating the same function over and over | 1901 -- Simply to avoid recreating the same function over and over |
| 2458 local tabs_OnGroupSelected_func_args = { [2] = "OnGroupSelected" } | 1902 local tabs_OnGroupSelected_func_args = { [2] = "OnGroupSelected" } |
| 2459 tabs_OnGroupSelected_func = function (tabs,event,group) | 1903 tabs_OnGroupSelected_func = function (tabs,event,group) |
| 2531 button:SetCallback("OnLeave", statusy_OnLeave) | 1975 button:SetCallback("OnLeave", statusy_OnLeave) |
| 2532 -- retrieval key may be specified as nil if all the parameters are given | 1976 -- retrieval key may be specified as nil if all the parameters are given |
| 2533 if opt_key then _d:SetUserData (opt_key, button) end | 1977 if opt_key then _d:SetUserData (opt_key, button) end |
| 2534 return button | 1978 return button |
| 2535 end | 1979 end |
| 1980 gui.mkbutton = mkbutton | |
| 2536 | 1981 |
| 2537 --[[ | 1982 --[[ |
| 2538 Creates the main window. | 1983 Creates the main window. |
| 2539 ]] | 1984 ]] |
| 2540 function addon:BuildMainDisplay (opt_tabselect) | 1985 function addon:BuildMainDisplay (opt_tabselect) |
| 2563 display:SetTitle(window_title) | 2008 display:SetTitle(window_title) |
| 2564 display:SetStatusText(self.status_text) | 2009 display:SetStatusText(self.status_text) |
| 2565 display:SetLayout("Flow") | 2010 display:SetLayout("Flow") |
| 2566 display:SetStatusTable{width=900,height=550} -- default height is 500 | 2011 display:SetStatusTable{width=900,height=550} -- default height is 500 |
| 2567 display:EnableResize(false) | 2012 display:EnableResize(false) |
| 2013 display:SetUserData("GUI state",gui) | |
| 2568 display:SetCallback("OnClose", function(_display) | 2014 display:SetCallback("OnClose", function(_display) |
| 2569 UIDROPDOWNMENU_SHOW_TIME = prev_fade_time | 2015 UIDROPDOWNMENU_SHOW_TIME = prev_fade_time |
| 2570 hide_noobtips_frame() | 2016 hide_noobtips_frame() |
| 2571 _d = nil | 2017 _d = nil |
| 2572 self.display = nil | 2018 self.display = nil |
