comparison gui.lua @ 95:3546c7b55986

Move generation of the Help tab to the same file as the help text. Allow registration of arbitrary tab controls, not just text generation. Move some shared data out of the addon table into a 'gui' state table in preparation for more of the same. Clean some cruft out of the default itemfilter list.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Thu, 26 Jul 2012 03:34:56 +0000
parents db1d5d09e5f5
children 780b7e0eeeeb
comparison
equal deleted inserted replaced
94:db1d5d09e5f5 95:3546c7b55986
41 addon.disposition_colors = eoi_st_lootrow_col3_colortable 41 addon.disposition_colors = eoi_st_lootrow_col3_colortable
42 local function eoi_st_lootrow_col3_colortable_func (data, _, realrow) 42 local function eoi_st_lootrow_col3_colortable_func (data, _, realrow)
43 local disp = data[realrow].disposition 43 local disp = data[realrow].disposition
44 return eoi_st_lootrow_col3_colortable[disp or 'normal'] 44 return eoi_st_lootrow_col3_colortable[disp or 'normal']
45 end 45 end
46 addon.time_column1_used_mt = { __index = { 46 local time_column1_used_mt = { __index = {
47 [2] = {value=""}, 47 [2] = {value=""},
48 [3] = {value=""}, 48 [3] = {value=""},
49 } } 49 } }
50 local time_column1_used_mt = addon.time_column1_used_mt
51 50
52 51
53 ------ Globals 52 ------ Globals
54 local GUI = LibStub("AceGUI-3.0") 53 local AceGUI = LibStub("AceGUI-3.0")
55 local flib = LibStub("LibFarmbuyer") 54 local flib = LibStub("LibFarmbuyer")
55
56 local gui = {
57 -- These are used to build the tabgroup_tabs array fed to TabGroup, and
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.
60 tabtexts = {
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]]},
63 ["opt"] = {title=[[Options]], desc=[[Options for fine-tuning behavior]]},
64 },
65 taborder = { "eoi" },
66 taborder_APPEND = { "hist", "help", "opt" },
67 }
68 addon.gui_state_pointer = gui -- only during loading, then cleaned out
69 if addon.author_debug then
70 _G.OLgui = gui
71 end
56 72
57 local g_loot = nil 73 local g_loot = nil
58 local g_uniques = nil 74 local g_uniques = nil
59 local g_generated = nil 75 local g_generated = nil
60 local window_title = "Ouro Loot" 76 local window_title = "Ouro Loot"
71 local GetNumRaidMembers = GetNumGroupMembers or GetNumRaidMembers 87 local GetNumRaidMembers = GetNumGroupMembers or GetNumRaidMembers
72 local IsInRaid = IsInRaid or (function() return GetNumRaidMembers() > 0 end) 88 local IsInRaid = IsInRaid or (function() return GetNumRaidMembers() > 0 end)
73 89
74 -- En masse forward decls of symbols defined inside local blocks 90 -- En masse forward decls of symbols defined inside local blocks
75 local _generate_text, _populate_text_specials, _markup 91 local _generate_text, _populate_text_specials, _markup
76 local eoi_dropdownfuncs, _tabtexts, _taborder -- filled out in gui block scope 92 local eoi_dropdownfuncs -- filled out in gui block scope
77 local _do_debugging_tooltip, _hide_debugging_tooltip, _build_debugging_tooltip 93 local _do_debugging_tooltip, _hide_debugging_tooltip, _build_debugging_tooltip
78 local _new_rebroadcast_hyperlink 94 local _new_rebroadcast_hyperlink
79 95
80 --[[ 96 --[[
81 This is a table of callback functions, each responsible for drawing a tab 97 This is a table of callback functions, each responsible for drawing a tab
133 -- Text generation 149 -- Text generation
134 do 150 do
135 local text_gen_funcs, specials_gen_funcs = {}, {} 151 local text_gen_funcs, specials_gen_funcs = {}, {}
136 local accumulator = {} 152 local accumulator = {}
137 153
154 local function _reg (tab_code, title, description, --[[unused]]generator,
155 opt_specgen, opt_noobtip, opt_cli
156 )
157 assert(type(tab_code)=='string')
158 assert(type(title)=='string')
159 assert(type(description)=='string')
160 gui.tabtexts[tab_code] = { title=title, desc=description }
161 if not gui.suppress_taborder then
162 gui:tabposition_insert (tab_code)
163 end
164 if opt_specgen then
165 assert(type(opt_specgen)=='function')
166 specials_gen_funcs[tab_code] = opt_specgen
167 end
168 if opt_noobtip then
169 if type(opt_noobtip) == 'string' then
170 noob_tips[tab_code] = _markup(opt_noobtip)
171 elseif type(opt_noobtip) == 'function' then
172 noob_tips[tab_code] = opt_noobtip
173 else
174 error(("Optional new user tip argument for '%s' must be a string or function!"):format(tab_code))
175 end
176 end
177 if opt_cli then
178 assert(type(opt_cli)=='function')
179 tabs_CLI_special[tab_code] = opt_cli
180 end
181 dirty_tabs = true
182 end
183
138 -- Can do clever things by passing other halting points as zero 184 -- Can do clever things by passing other halting points as zero
139 function addon:zero_printed_fenceposts (zero) 185 function addon:zero_printed_fenceposts (zero)
140 for t in pairs(text_gen_funcs) do 186 for t in pairs(text_gen_funcs) do
141 g_loot.printed[t] = zero or g_loot.printed[t] or 0 187 g_loot.printed[t] = zero or g_loot.printed[t] or 0
142 end 188 end
145 function addon:registered_textgen_iter() 191 function addon:registered_textgen_iter()
146 return pairs(text_gen_funcs) 192 return pairs(text_gen_funcs)
147 end 193 end
148 194
149 -- This function is called during load, so be careful! 195 -- This function is called during load, so be careful!
150 function addon:register_text_generator (text_type, title, description, generator, opt_specgen) 196 function addon:register_text_generator (text_type, title, description,
197 generator, opt_specgen, opt_noobtip, opt_cli
198 )
199 if self.NOLOAD then return end
151 if type(generator) ~= 'function' then 200 if type(generator) ~= 'function' then
152 error(("Generator for text type '%s' must be a function!"):format(text_type)) 201 error(("Generator for text type '%s' must be a function!"):format(text_type))
153 end 202 end
154 _tabtexts[text_type] = { title=title, desc=description } 203 _reg (text_type, title, description, generator, opt_specgen, opt_noobtip, opt_cli)
155 self:tabposition_insert (text_type)
156 text_gen_funcs[text_type] = generator 204 text_gen_funcs[text_type] = generator
157 specials_gen_funcs[text_type] = opt_specgen
158 dirty_tabs = true
159 end 205 end
160 206
161 -- These two called by tabs_generated_text_OGS 207 -- These two called by tabs_generated_text_OGS
162 -- tabs_OnGroupSelected_func will catch propagated errors 208 -- tabs_OnGroupSelected_func will catch propagated errors
163 function _generate_text (text_type) 209 function _generate_text (text_type)
193 end 239 end
194 end 240 end
195 241
196 -- LOD tab has been clicked on. 242 -- LOD tab has been clicked on.
197 local function _handle_LOD (tabs_container,specials,tabtitle) 243 local function _handle_LOD (tabs_container,specials,tabtitle)
198 -- "tabtitle" here is the name in _taborder, not the colorized string 244 -- "tabtitle" here is the name in taborder, not the colorized string
199 local what = _tabtexts[tabtitle] 245 local what = gui.tabtexts[tabtitle]
200 local addon_index = what.LOD 246 local addon_index = what.LOD
201 local function LOAD() 247 local function LOAD()
202 _tabtexts[tabtitle] = nil 248 gui.tabtexts[tabtitle] = nil
203 addon:tabposition_remove_and_remember (tabtitle) 249 gui:tabposition_remove_and_remember (tabtitle)
204 local loaded, whynot = LoadAddOn(addon_index) 250 local loaded, whynot = LoadAddOn(addon_index)
205 local tabdelta = addon:tabposition_restore() 251 local tabdelta = gui:tabposition_restore()
206 if loaded then 252 if loaded then
207 addon:Print("%s loaded, %d |4tab:tabs; added.", tabtitle, tabdelta) 253 addon:Print("%s loaded, %d |4tab:tabs; added.", tabtitle, tabdelta)
208 else 254 else
209 what.disabled = true 255 what.disabled = true
210 _tabtexts[tabtitle] = what -- restore this for mouseovers 256 gui.tabtexts[tabtitle] = what -- restore this for mouseovers
211 addon:Print("%s could not load (game client reason was '%s').", tabtitle, whynot) 257 addon:Print("%s could not load (game client reason was '%s').", tabtitle, whynot)
212 DisableAddOn(addon_index) 258 DisableAddOn(addon_index)
213 end 259 end
214 dirty_tabs = true 260 dirty_tabs = true
215 return addon:OpenMainDisplayToTab(tabtitle) or addon:BuildMainDisplay() 261 return addon:OpenMainDisplayToTab(tabtitle) or addon:BuildMainDisplay()
241 287
242 -- Add a clickable tab that brings the real module in. Since gui_init has 288 -- Add a clickable tab that brings the real module in. Since gui_init has
243 -- already been called, we flag the dirty bit and let the main building 289 -- already been called, we flag the dirty bit and let the main building
244 -- routine handle it like any other plugin. 290 -- routine handle it like any other plugin.
245 function addon:_gui_add_LOD_tab (tabtitle, folder, addon_index, enabled_p, why_not) 291 function addon:_gui_add_LOD_tab (tabtitle, folder, addon_index, enabled_p, why_not)
246 _tabtexts[tabtitle] = { 292 gui.tabtexts[tabtitle] = {
247 title = ("|cffff0000(%s)|r"):format(tabtitle), 293 title = ("|cffff0000(%s)|r"):format(tabtitle),
248 desc = ("Plugin '|cffff0000%s|r' is not loaded yet. Click the tab to load it now."):format(folder), 294 desc = ("Plugin '|cffff0000%s|r' is not loaded yet. Click the tab to load it now."):format(folder),
249 LOD = addon_index, 295 LOD = addon_index,
250 LOD_enabled = enabled_p, 296 LOD_enabled = enabled_p,
251 LOD_why_not = why_not, 297 LOD_why_not = why_not,
252 } 298 }
253 tabs_OnGroupSelected[tabtitle] = _handle_LOD 299 tabs_OnGroupSelected[tabtitle] = _handle_LOD
254 self:tabposition_insert (tabtitle) 300 gui:tabposition_insert (tabtitle)
255 dirty_tabs = true 301 dirty_tabs = true
302 end
303
304 -- Registering truly arbitrary tab controls, not just text generators.
305 -- (This is slightly out of place, but no more so than the LOD stuff.)
306 -- The arguments are nearly the same as those of :register_text_generator
307 -- but the "generator" function is the full-blown callback and there is
308 -- no "specgen" (since it's handled in the main generator).
309 function addon:register_tab_control (tab_code, title, description,
310 generator, opt_noobtip, opt_cli
311 )
312 if self.NOLOAD then return end
313 if type(generator) ~= 'function' then
314 error(("Generator for tab code '%s' must be a function!"):format(tab_code))
315 end
316 _reg (tab_code, title, description, generator, --[[opt_specgen=]]nil, opt_noobtip, opt_cli)
317 tabs_OnGroupSelected[tab_code] = generator
318 end
319 function addon:register_tab_control_AT_END (...)
320 gui.suppress_taborder = true
321 self:register_tab_control(...)
322 gui.suppress_taborder = nil
256 end 323 end
257 end 324 end
258 325
259 --[[ 326 --[[
260 The g_loot table is populated only with "behavior-relevant" data (names, 327 The g_loot table is populated only with "behavior-relevant" data (names,
679 return f 746 return f
680 end 747 end
681 748
682 749
683 ------ Main GUI Window 750 ------ Main GUI Window
684 local _d -- display when it's open, eoiST when it's not 751 local _d -- display when it's open, nil when it's not
685 local function setstatus(txt) _d:SetStatusText(txt) end 752 local function setstatus(txt) _d:SetStatusText(txt) end
686 local function statusy_OnLeave() setstatus("") end 753 local function statusy_OnLeave() setstatus("") end
687 local tabgroup_tabs 754 local tabgroup_tabs
688 755
689 --[[ 756 --[[
690 Controls for the tabs on the left side of the main display. 757 Controls for the tabs on the left side of the main display.
691 ]] 758 ]]
692 759
693 -- The _tabtexts and _taborder tables have distressingly wide visibility.
694 -- They are used to build the tabgroup_tabs array fed to TabGroup, and for the
695 -- official source of mouseover tab titles, etc. Not completely encapsulated
696 -- because we need to reach in and fiddle too often to be worth it.
697 _tabtexts = {
698 ["eoi"] = {title=[[Loot]], desc=[[Observed loot, plus boss kills and other events of interest]]},
699 ["hist"] = {title=[[History]], desc=[[A short semi-permanent record]]},
700 ["help"] = {title=[[Help]], desc=[[Instructions, reminders, and tips for non-obvious features]]},
701 ["opt"] = {title=[[Options]], desc=[[Options for fine-tuning behavior]]},
702 }
703 _taborder = { "eoi", "hist", "help", "opt" }
704
705 do 760 do
706 local next_insertion_position = 2 -- position in _taborder 761 --local next_insertion_position = 2 -- position in taborder
762 local next_insertion_position = #gui.taborder + 1
707 local removed, saved_offset 763 local removed, saved_offset
708 764
709 function addon:tabposition_insert (tabcode) 765 function gui:tabposition_insert (tabcode)
710 tinsert (_taborder, next_insertion_position, tabcode) 766 tinsert (gui.taborder, next_insertion_position, tabcode)
711 next_insertion_position = next_insertion_position + 1 767 next_insertion_position = next_insertion_position + 1
712 end 768 end
713 769
714 -- These two functions are push/pop pairs, sort of. The first removes 770 -- These two functions are push/pop pairs, sort of. The first removes
715 -- a tab and prepares to insert more tab(s) in its place. The second 771 -- a tab and prepares to insert more tab(s) in its place. The second
716 -- returns the "next tab goes here" marker back to the proper end. (And 772 -- returns the "next tab goes here" marker back to the proper end. (And
717 -- doing all 3 adjustments below at once is amazingly hard to read.) 773 -- doing all 3 adjustments below at once is amazingly hard to read.)
718 function addon:tabposition_remove_and_remember (tabcode) 774 function gui:tabposition_remove_and_remember (tabcode)
719 assert(not removed) -- enforce stack-ish discipline 775 assert(not removed) -- enforce stack-ish discipline
720 for i = 2, #_taborder do 776 for i = 2, #gui.taborder do
721 if _taborder[i] == tabcode then 777 if gui.taborder[i] == tabcode then
722 tremove (_taborder, i) 778 tremove (gui.taborder, i)
723 saved_offset = next_insertion_position - i - 1 779 saved_offset = next_insertion_position - i - 1
724 removed, next_insertion_position = i, i 780 removed, next_insertion_position = i, i
725 return 781 return
726 end 782 end
727 end 783 end
728 error(("'%s' not used as a tab-text code"):format(tabcode)) 784 error(("'%s' not used as a tab-text code"):format(tabcode))
729 end 785 end
730 function addon:tabposition_restore() 786 function gui:tabposition_restore()
731 assert(removed) 787 assert(removed)
732 local count = next_insertion_position - removed 788 local count = next_insertion_position - removed
733 next_insertion_position = next_insertion_position + saved_offset 789 next_insertion_position = next_insertion_position + saved_offset
734 removed, saved_offset = nil, nil 790 removed, saved_offset = nil, nil
735 return count 791 return count
792 end
793
794 function addon:FINISH_SPECIAL_TABS()
795 -- very carefully not touching next_insertion_position
796 for i,v in ipairs(gui.taborder_APPEND) do
797 gui.taborder[#gui.taborder+1] = v
798 end
799 gui.taborder_APPEND = nil
800 self.register_tab_control_AT_END = nil
801 self.FINISH_SPECIAL_TABS = nil
736 end 802 end
737 end 803 end
738 804
739 -- Done at startup, and whenever we've changed the population of tabs. 805 -- Done at startup, and whenever we've changed the population of tabs.
740 function addon:gui_init (loot_pointer, uniques_pointer) 806 function addon:gui_init (loot_pointer, uniques_pointer)
745 window_title = "Ouro Loot " .. self.version 811 window_title = "Ouro Loot " .. self.version
746 -- TabGroup stretches out the tabs to fill the row but only if >75% of the 812 -- TabGroup stretches out the tabs to fill the row but only if >75% of the
747 -- row is already full. It turns out that not doing this looks like ass. 813 -- row is already full. It turns out that not doing this looks like ass.
748 -- If we won't have enough tabs to trigger this on its own, pad out the tab 814 -- If we won't have enough tabs to trigger this on its own, pad out the tab
749 -- titles (not looking quite as nice, ah well) to force it to trigger. 815 -- titles (not looking quite as nice, ah well) to force it to trigger.
750 local fmtstr = #_taborder > 6 and "%s" or " %s " 816 local fmtstr = #gui.taborder > 6 and "%s" or " %s "
751 for i,name in ipairs(_taborder) do 817 for i,name in ipairs(gui.taborder) do
752 tabgroup_tabs[i] = { 818 tabgroup_tabs[i] = {
753 value = name, 819 value = name,
754 text = fmtstr:format(_tabtexts[name].title), 820 text = fmtstr:format(gui.tabtexts[name].title),
755 disabled = _tabtexts[name].disabled, 821 disabled = gui.tabtexts[name].disabled,
756 } 822 }
757 -- By default, tabs are editboxes with generated text 823 -- By default, tabs are editboxes with generated text
758 if not tabs_OnGroupSelected[name] then 824 if not tabs_OnGroupSelected[name] then
759 tabs_OnGroupSelected[name] = tabs_generated_text_OGS 825 tabs_OnGroupSelected[name] = tabs_generated_text_OGS
760 end 826 end
783 849
784 local function dropdownmenu_handler (ddbutton, subfunc, arg) 850 local function dropdownmenu_handler (ddbutton, subfunc, arg)
785 local i = _d and _d.GetUserData and _d:GetUserData("DD index") 851 local i = _d and _d.GetUserData and _d:GetUserData("DD index")
786 if i then 852 if i then
787 subfunc(i,arg) 853 subfunc(i,arg)
788 _d:GetUserData("which ST"):OuroLoot_Refresh(i) 854 gui.which_ST:OuroLoot_Refresh(i)
789 end 855 end
790 end 856 end
791 857
792 local function gen_easymenu_table (initial, list, funcs) 858 local function gen_easymenu_table (initial, list, funcs)
793 for _,tag in ipairs(list) do 859 for _,tag in ipairs(list) do
884 ["Mark as normal"] = function(rowi,disp) 950 ["Mark as normal"] = function(rowi,disp)
885 addon:loot_mark_disposition ("local", rowi, disp) 951 addon:loot_mark_disposition ("local", rowi, disp)
886 end, 952 end,
887 953
888 ["Show only this player"] = function(rowi) 954 ["Show only this player"] = function(rowi)
889 local st = _d:GetUserData("eoiST") 955 local st = assert(gui.eoiST)
890 _d:SetUserData("player filter name", g_loot[rowi].person) 956 _d:SetUserData("player filter name", g_loot[rowi].person)
891 st:SetFilter(_d:GetUserData("player filter by name")) 957 st:SetFilter(_d:GetUserData("player filter by name"))
892 _d:GetUserData("eoi_filter_reset"):SetDisabled(false) 958 _d:GetUserData("eoi_filter_reset"):SetDisabled(false)
893 -- it'd be more futureproof to get the button and call some kind 959 -- it'd be more futureproof to get the button and call some kind
894 -- of :GetText() on it, but no such function is provided by acegui 960 -- of :GetText() on it, but no such function is provided by acegui
896 end, 962 end,
897 963
898 ["Change from 'wipe' to 'kill'"] = function(rowi) 964 ["Change from 'wipe' to 'kill'"] = function(rowi)
899 addon:_mark_boss_kill(rowi) 965 addon:_mark_boss_kill(rowi)
900 -- the fillout function called automatically will start too far down the list 966 -- the fillout function called automatically will start too far down the list
901 _d:GetUserData("eoiST"):OuroLoot_Refresh() 967 gui.eoiST:OuroLoot_Refresh()
902 end, 968 end,
903 969
904 ["Edit note"] = function(rowi) 970 ["Edit note"] = function(rowi)
905 eoi_editcell (rowi, _d:GetUserData("DD cell")) 971 eoi_editcell (rowi, _d:GetUserData("DD cell"))
906 end, 972 end,
1142 1208
1143 function eoi_editcell (row_index, cell_frame) 1209 function eoi_editcell (row_index, cell_frame)
1144 local e = g_loot[row_index] 1210 local e = g_loot[row_index]
1145 if not e then return end -- how the hell could we get this far? 1211 if not e then return end -- how the hell could we get this far?
1146 local celldata = e.cols[3] 1212 local celldata = e.cols[3]
1147 local box = GUI:Create("EditBox") 1213 local box = AceGUI:Create("EditBox")
1148 box:SetText(celldata.value) 1214 box:SetText(celldata.value)
1149 box:SetUserData("old show", box.editbox:GetScript("OnShow")) 1215 box:SetUserData("old show", box.editbox:GetScript("OnShow"))
1150 box:SetUserData("old escape", box.editbox:GetScript("OnEscapePressed")) 1216 box:SetUserData("old escape", box.editbox:GetScript("OnEscapePressed"))
1151 box.editbox:SetScript("OnShow", box.editbox.SetFocus) 1217 box.editbox:SetScript("OnShow", box.editbox.SetFocus)
1152 box.editbox:SetScript("OnEscapePressed", function(_be) 1218 box.editbox:SetScript("OnEscapePressed", function(_be)
1159 e.bcast_from = nil -- things get screwy if this field is still present. sigh. 1225 e.bcast_from = nil -- things get screwy if this field is still present. sigh.
1160 e.extratext_byhand = true 1226 e.extratext_byhand = true
1161 value = value and value:match("^(x%d+)") 1227 value = value and value:match("^(x%d+)")
1162 if value then e.count = value end 1228 if value then e.count = value end
1163 _b:Release() 1229 _b:Release()
1164 return _d:GetUserData("eoiST"):OuroLoot_Refresh(row_index) 1230 return gui.eoiST:OuroLoot_Refresh(row_index)
1165 end) 1231 end)
1166 box:SetCallback("OnRelease", function(_b) 1232 box:SetCallback("OnRelease", function(_b)
1167 _b.editbox:ClearFocus() 1233 _b.editbox:ClearFocus()
1168 _b.editbox:SetScript("OnShow", _b:GetUserData("old show")) 1234 _b.editbox:SetScript("OnShow", _b:GetUserData("old show"))
1169 _b.editbox:SetScript("OnEscapePressed", _b:GetUserData("old escape")) 1235 _b.editbox:SetScript("OnEscapePressed", _b:GetUserData("old escape"))
1269 -- The first time this function is called, we set up a persistent ST 1335 -- The first time this function is called, we set up a persistent ST
1270 -- object and store it. Any other delayed setup work is done, and then 1336 -- object and store it. Any other delayed setup work is done, and then
1271 -- this function replaces itself with a smaller, sleeker, sexier one. 1337 -- this function replaces itself with a smaller, sleeker, sexier one.
1272 -- This function will later be garbage collected. 1338 -- This function will later be garbage collected.
1273 local ST = LibStub("ScrollingTable"):CreateST(eoi_st_cols,eoi_st_displayed_rows,eoi_st_rowheight) 1339 local ST = LibStub("ScrollingTable"):CreateST(eoi_st_cols,eoi_st_displayed_rows,eoi_st_rowheight)
1274 _d:SetUserData("eoiST",ST) 1340 gui.eoiST = assert(ST)
1275 if addon.author_debug then 1341 if addon.author_debug then
1276 _G.OLST = ST 1342 _G.OLST = ST
1277 end 1343 end
1278 1344
1279 if not eoi_st_otherrow_bgcolortable_default then 1345 if not eoi_st_otherrow_bgcolortable_default then
1333 -- so we just reach inside. 1399 -- so we just reach inside.
1334 player_filter_all = ST.Filter 1400 player_filter_all = ST.Filter
1335 1401
1336 -- Now set up the future drawing function... 1402 -- Now set up the future drawing function...
1337 tabs_OnGroupSelected["eoi"] = function(container,specials) 1403 tabs_OnGroupSelected["eoi"] = function(container,specials)
1338 local st_widget = GUI:Create("lib-st") 1404 local st_widget = AceGUI:Create("lib-st")
1339 local st = _d:GetUserData("eoiST") 1405 local st = assert(gui.eoiST)
1340 1406
1341 _d:SetUserData("which ST",st) 1407 gui.which_ST = st
1342 1408
1343 -- This is actually required each time 1409 -- This is actually required each time
1344 _d:SetUserData ("player filter clear", player_filter_all) 1410 _d:SetUserData ("player filter clear", player_filter_all)
1345 _d:SetUserData ("player filter by name", player_filter_by_name) 1411 _d:SetUserData ("player filter by name", player_filter_by_name)
1346 1412
1370 1436
1371 b = mkbutton('eoi_filter_reset', "Reset Player Filter", 1437 b = mkbutton('eoi_filter_reset', "Reset Player Filter",
1372 [[Return to showing complete loot information.]]) 1438 [[Return to showing complete loot information.]])
1373 b:SetFullWidth(true) 1439 b:SetFullWidth(true)
1374 b:SetCallback("OnClick", function (_b) 1440 b:SetCallback("OnClick", function (_b)
1375 local st = _d:GetUserData("eoiST") 1441 gui.eoiST:SetFilter(player_filter_all)
1376 st:SetFilter(player_filter_all)
1377 _b:SetDisabled(true) 1442 _b:SetDisabled(true)
1378 end) 1443 end)
1379 b:SetDisabled(st.Filter == player_filter_all) 1444 b:SetDisabled(st.Filter == player_filter_all)
1380 specials:AddChild(b) 1445 specials:AddChild(b)
1381 1446
1447 -- FIXME iterate over the new raiders table instead
1382 local people = { "<nobody>" } 1448 local people = { "<nobody>" }
1383 for i = 1, GetNumRaidMembers() do 1449 for i = 1, GetNumRaidMembers() do
1384 tinsert(people,(GetRaidRosterInfo(i))) 1450 tinsert(people,(GetRaidRosterInfo(i)))
1385 end 1451 end
1386 table.sort(people) 1452 table.sort(people)
1425 1491
1426 1492
1427 -- Tab 2/3 (generated text) 1493 -- Tab 2/3 (generated text)
1428 function tabs_generated_text_OGS (container, specials, text_kind) 1494 function tabs_generated_text_OGS (container, specials, text_kind)
1429 container:SetLayout("Fill") 1495 container:SetLayout("Fill")
1430 local box = GUI:Create("MultiLineEditBox") 1496 local box = AceGUI:Create("MultiLineEditBox")
1431 box:SetFullWidth(true) 1497 box:SetFullWidth(true)
1432 box:SetFullHeight(true) 1498 box:SetFullHeight(true)
1433 box:SetLabel("Pressing the Escape key while typing will return keystroke control to the usual chat window.") 1499 box:SetLabel("Pressing the Escape key while typing will return keystroke control to the usual chat window.")
1434 box:DisableButton(true) 1500 box:DisableButton(true)
1435 addon:_fill_out_eoi_data(1) 1501 addon:_fill_out_eoi_data(1)
1465 box:SetText("") 1531 box:SetText("")
1466 g_loot[text_kind] = "" 1532 g_loot[text_kind] = ""
1467 g_loot.printed[text_kind] = 0 1533 g_loot.printed[text_kind] = 0
1468 g_generated.last_instance = nil 1534 g_generated.last_instance = nil
1469 g_generated[pos] = nil 1535 g_generated[pos] = nil
1470 addon:Print("'%s' has been regenerated.", _tabtexts[text_kind].title) 1536 addon:Print("'%s' has been regenerated.", gui.tabtexts[text_kind].title)
1471 return addon:redisplay() 1537 return addon:redisplay()
1472 end) 1538 end)
1473 specials:AddChild(w) 1539 specials:AddChild(w)
1474 if addon:is_plugin(text_kind) then 1540 if addon:get_plugin(text_kind) then
1475 local pname = addon:is_plugin(text_kind):GetName() 1541 local pname = addon:get_plugin(text_kind):GetName()
1476 w = mkbutton("Reset SVs & ReloadUI", 1542 w = mkbutton("Reset SVs & ReloadUI",
1477 ([[<DEBUG:> Reset savedvariables for %s plugin back to defaults, and trigger a UI reload.]]):format(pname)) 1543 ([[<DEBUG:> Reset savedvariables for %s plugin back to defaults, and trigger a UI reload.]]):format(pname))
1478 w:SetFullWidth(true) 1544 w:SetFullWidth(true)
1479 w:SetCallback("OnClick", function(_w) 1545 w:SetCallback("OnClick", function(_w)
1480 _G['OuroLoot'..pname..'_opts'] = nil 1546 _G['OuroLoot'..pname..'_opts'] = nil
1514 if numleft then 1580 if numleft then
1515 addon:Print("Removed history entry %s from %s.", 1581 addon:Print("Removed history entry %s from %s.",
1516 h.itemlink, addon:colorize(h.OLwho,h.OLclass)) 1582 h.itemlink, addon:colorize(h.OLwho,h.OLclass))
1517 if numleft < 1 then 1583 if numleft < 1 then
1518 history_filter_who = nil 1584 history_filter_who = nil
1519 --_d:GetUserData("histST"):SetFilter(history_filter_by_recent)
1520 histST:SetFilter(history_filter_by_recent) 1585 histST:SetFilter(history_filter_by_recent)
1521 setstatus(hist_normal_status) 1586 setstatus(hist_normal_status)
1522 end 1587 end
1523 else 1588 else
1524 addon:Print(err) 1589 addon:Print(err)
1661 } 1726 }
1662 1727
1663 -- Tab 4: History (implementation) 1728 -- Tab 4: History (implementation)
1664 tabs_OnGroupSelected["hist"] = function(container,specials) 1729 tabs_OnGroupSelected["hist"] = function(container,specials)
1665 histST = LibStub("ScrollingTable"):CreateST(hist_st_cols,eoi_st_displayed_rows,eoi_st_rowheight) 1730 histST = LibStub("ScrollingTable"):CreateST(hist_st_cols,eoi_st_displayed_rows,eoi_st_rowheight)
1666 _d:SetUserData("histST",histST) 1731 gui.histST = histST
1667 if addon.author_debug then 1732 if addon.author_debug then
1668 _G.OLHST = histST 1733 _G.OLHST = histST
1669 end 1734 end
1670 1735
1671 if not eoi_st_otherrow_bgcolortable_default then 1736 if not eoi_st_otherrow_bgcolortable_default then
1708 histST:OuroLoot_Refresh() 1773 histST:OuroLoot_Refresh()
1709 histST:SetData(addon.history.st) 1774 histST:SetData(addon.history.st)
1710 end 1775 end
1711 1776
1712 tabs_OnGroupSelected["hist"] = function(container,specials) 1777 tabs_OnGroupSelected["hist"] = function(container,specials)
1713 local st_widget = GUI:Create("lib-st") 1778 local st_widget = AceGUI:Create("lib-st")
1714 -- don't need _d:GetUserData("histST") here, as it's already a local 1779 gui.which_ST = histST
1715 _d:SetUserData("which ST",histST)
1716 histST:OuroLoot_Refresh() 1780 histST:OuroLoot_Refresh()
1717 st_widget:WrapST(histST) 1781 st_widget:WrapST(histST)
1718 st_widget.head_offset = 15 1782 st_widget.head_offset = 15
1719 st_widget.tail_offset = 0 1783 st_widget.tail_offset = 0
1720 container:SetLayout("Fill") 1784 container:SetLayout("Fill")
1748 return addon:redisplay() 1812 return addon:redisplay()
1749 end) 1813 end)
1750 specials:AddChild(b) 1814 specials:AddChild(b)
1751 end 1815 end
1752 1816
1753 --[[ b = GUI:Create("Spacer") b:SetFullWidth(true) b:SetHeight(10) specials:AddChild(b) ]] 1817 --[[ b = AceGUI:Create("Spacer") b:SetFullWidth(true) b:SetHeight(10) specials:AddChild(b) ]]
1754 1818
1755 b = mkbutton("Regenerate", 1819 b = mkbutton("Regenerate",
1756 [[Erases all history entries from the displayed realm, and regenerates it from current loot information.]]) 1820 [[Erases all history entries from the displayed realm, and regenerates it from current loot information.]])
1757 b:SetFullWidth(true) 1821 b:SetFullWidth(true)
1758 b:SetDisabled (#addon.history == 0) 1822 b:SetDisabled (#addon.history == 0)
1812 <Left>-click a row to see all history for that player. <Right>-click any row 1876 <Left>-click a row to see all history for that player. <Right>-click any row
1813 to return to showing all players. 1877 to return to showing all players.
1814 1878
1815 <Shift-Left> while over an item link to paste it into chat. <Shift-Right> 1879 <Shift-Left> while over an item link to paste it into chat. <Shift-Right>
1816 any row to display a dropdown menu.]] 1880 any row to display a dropdown menu.]]
1817 -- '/loot hi pla' -> set filter on Playername 1881 -- '/ol hi pla' -> set filter on Playername
1818 tabs_CLI_special["hist"] = function (name) 1882 tabs_CLI_special["hist"] = function (name)
1819 name = '^'..name -- already tolower'd by onslash 1883 name = '^'..name -- already tolower'd by onslash
1820 for _,player in ipairs(addon.history) do 1884 for _,player in ipairs(addon.history) do
1821 if player.name:lower():find(name) then 1885 if player.name:lower():find(name) then
1822 history_filter_who = player.name 1886 history_filter_who = player.name
1823 --_d:GetUserData("histST"):SetFilter(history_filter_by_name)
1824 histST:SetFilter(history_filter_by_name) 1887 histST:SetFilter(history_filter_by_name)
1825 setstatus(hist_name_status) 1888 setstatus(hist_name_status)
1826 break 1889 break
1827 end 1890 end
1828 end 1891 end
1829 -- If nothing found, reset to normal or just leave alone? 1892 -- If nothing found, reset to normal or just leave alone?
1830 end 1893 end
1831 1894
1832 1895
1833 -- Tab 5: Help (content in verbage.lua) 1896 -- Tab 5: Help (content in verbage.lua)
1834 do
1835 local tabs_help_OnGroupSelected_func = function (treeg,event,category)
1836 treeg:ReleaseChildren()
1837 local txt = GUI:Create("Label")
1838 txt:SetFullWidth(true)
1839 txt:SetFontObject(GameFontNormal)--Highlight)
1840 txt:SetText(addon.helptext[category])
1841 local sf = GUI:Create("ScrollFrame")
1842 local sfstat = _d:GetUserData("help tab scroll status") or {}
1843 sf:SetStatusTable(sfstat)
1844 _d:SetUserData("help tab scroll status",sfstat)
1845 sf:SetLayout("Fill")
1846 -- This forces the scrolling area to be bigger than the visible area; else
1847 -- some of the text gets cut off.
1848 sf.content:SetHeight(700)
1849 sf:AddChild(txt)
1850 treeg:AddChild(sf)
1851 if treeg:GetUserData("help restore scroll") then
1852 sfstat = sfstat.scrollvalue
1853 if sfstat then sf:SetScroll(sfstat) end
1854 treeg:SetUserData("help restore scroll", false)
1855 else
1856 sf:SetScroll(0)
1857 end
1858 end
1859 tabs_OnGroupSelected["help"] = function(container,specials)
1860 container:SetLayout("Fill")
1861 local left = GUI:Create("TreeGroup")
1862 local leftstat = _d:GetUserData("help tab select status")
1863 or {treewidth=145}
1864 left:SetStatusTable(leftstat)
1865 _d:SetUserData("help tab select status",leftstat)
1866 left:SetLayout("Fill")
1867 left:SetFullWidth(true)
1868 left:SetFullHeight(true)
1869 left:EnableButtonTooltips(false)
1870 left:SetTree(addon.helptree)
1871 left:SetCallback("OnGroupSelected", tabs_help_OnGroupSelected_func)
1872 container:AddChild(left)
1873 leftstat = leftstat.selected
1874 if leftstat then
1875 left:SetUserData("help restore scroll", true)
1876 left:SelectByValue(leftstat)
1877 else
1878 left:SelectByValue("basic")
1879 end
1880 end
1881 noob_tips["help"] = _markup[[
1882 Every tab across the top also gets its own special buttons here in the lower
1883 right, under the same name as the tab. Some controls do not become visible
1884 until that tab has data to work with.]]
1885 end
1886 1897
1887 1898
1888 -- Tab 6: Options / Advanced 1899 -- Tab 6: Options / Advanced
1889 do 1900 do
1890 -- Local ref to OuroLootSV_opts, which may be reassigned after load. 1901 -- Local ref to OuroLootSV_opts, which may be reassigned after load.
1912 1923
1913 -- Like the first tab, we use a pair of functions; first and repeating. 1924 -- Like the first tab, we use a pair of functions; first and repeating.
1914 local function adv_real (container, specials) 1925 local function adv_real (container, specials)
1915 local grp, w 1926 local grp, w
1916 1927
1917 grp = GUI:Create("InlineGroup") 1928 grp = AceGUI:Create("InlineGroup")
1918 grp:SetLayout("Flow") 1929 grp:SetLayout("Flow")
1919 grp:PauseLayout() 1930 grp:PauseLayout()
1920 grp:SetFullWidth(true) 1931 grp:SetFullWidth(true)
1921 grp:SetTitle("Debugging/Testing Options [not saved across sessions]") 1932 grp:SetTitle("Debugging/Testing Options [not saved across sessions]")
1922 1933
1974 local after = collectgarbage('count') 1985 local after = collectgarbage('count')
1975 addon:Print("Collected %d KB, %d KB still in use by Lua universe.", before-after, after) 1986 addon:Print("Collected %d KB, %d KB still in use by Lua universe.", before-after, after)
1976 end) 1987 end)
1977 grp:AddChild(w) 1988 grp:AddChild(w)
1978 1989
1979 w = GUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(1) grp:AddChild(w) 1990 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(1) grp:AddChild(w)
1980 1991
1981 local simple = GUI:Create("SimpleGroup") 1992 local simple = AceGUI:Create("SimpleGroup")
1982 simple:SetLayout("List") 1993 simple:SetLayout("List")
1983 simple:SetRelativeWidth(0.3) 1994 simple:SetRelativeWidth(0.3)
1984 w = mkbutton("Dropdown", nil, "", [[hovering over Item column only]]) 1995 w = mkbutton("Dropdown", nil, "", [[hovering over Item column only]])
1985 w:SetFullWidth(true) 1996 w:SetFullWidth(true)
1986 w:SetLabel("loot debugging tooltip") 1997 w:SetLabel("loot debugging tooltip")
1993 w:SetCallback("OnValueChanged", function(_w,event,choice) 2004 w:SetCallback("OnValueChanged", function(_w,event,choice)
1994 _do_debugging_tooltip = choice > 1 and choice or nil 2005 _do_debugging_tooltip = choice > 1 and choice or nil
1995 end) 2006 end)
1996 simple:AddChild(w) 2007 simple:AddChild(w)
1997 2008
1998 w = GUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(10) simple:AddChild(w) 2009 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(10) simple:AddChild(w)
1999 2010
2000 w = GUI:Create("CheckBoxSmallLabel") 2011 w = AceGUI:Create("CheckBoxSmallLabel")
2001 w:SetFullWidth(true) 2012 w:SetFullWidth(true)
2002 w:SetType("checkbox") 2013 w:SetType("checkbox")
2003 w:SetLabel("debug toggle --->") 2014 w:SetLabel("debug toggle --->")
2004 w:SetValue(addon.DEBUG_PRINT) 2015 w:SetValue(addon.DEBUG_PRINT)
2005 w:SetCallback("OnValueChanged", function(_w,event,value) 2016 w:SetCallback("OnValueChanged", function(_w,event,value)
2006 addon.DEBUG_PRINT = value 2017 addon.DEBUG_PRINT = value
2007 addon:redisplay() 2018 addon:redisplay()
2008 end) 2019 end)
2009 simple:AddChild(w) 2020 simple:AddChild(w)
2010 w = GUI:Create("CheckBoxSmallLabel") 2021 w = AceGUI:Create("CheckBoxSmallLabel")
2011 w:SetFullWidth(true) 2022 w:SetFullWidth(true)
2012 w:SetType("checkbox") 2023 w:SetType("checkbox")
2013 w:SetLabel("GOP history mode") 2024 w:SetLabel("GOP history mode")
2014 w:SetValue(addon.history_suppress) 2025 w:SetValue(addon.history_suppress)
2015 w:SetCallback("OnValueChanged", function(_w,event,value) addon.history_suppress = value end) 2026 w:SetCallback("OnValueChanged", function(_w,event,value) addon.history_suppress = value end)
2021 addon:_clear_SVs() -- reloads 2032 addon:_clear_SVs() -- reloads
2022 end) 2033 end)
2023 simple:AddChild(w) 2034 simple:AddChild(w)
2024 grp:AddChild(simple) 2035 grp:AddChild(simple)
2025 2036
2026 simple = GUI:Create("SimpleGroup") 2037 simple = AceGUI:Create("SimpleGroup")
2027 simple:SetLayout("List") 2038 simple:SetLayout("List")
2028 simple:SetRelativeWidth(0.5) 2039 simple:SetRelativeWidth(0.5)
2029 for d,v in pairs(addon.debug) do 2040 for d,v in pairs(addon.debug) do
2030 w = GUI:Create("CheckBoxSmallLabel") 2041 w = AceGUI:Create("CheckBoxSmallLabel")
2031 w:SetFullWidth(true) 2042 w:SetFullWidth(true)
2032 w:SetType("checkbox") 2043 w:SetType("checkbox")
2033 w:SetLabel(d) 2044 w:SetLabel(d)
2034 if d == "notraid" then 2045 if d == "notraid" then
2035 w:SetDescription[[Tick this before enabling to make the addon work outside of raid groups]] 2046 w:SetDescription[[Tick this before enabling to make the addon work outside of raid groups]]
2043 w:SetCallback("OnValueChanged", function(_w,event,value) addon.debug[d] = value end) 2054 w:SetCallback("OnValueChanged", function(_w,event,value) addon.debug[d] = value end)
2044 simple:AddChild(w) 2055 simple:AddChild(w)
2045 end 2056 end
2046 grp:AddChild(simple) 2057 grp:AddChild(simple)
2047 2058
2048 simple = GUI:Create("SimpleGroup") 2059 simple = AceGUI:Create("SimpleGroup")
2049 simple:SetLayout("Flow") 2060 simple:SetLayout("Flow")
2050 simple:SetRelativeWidth(0.85) 2061 simple:SetRelativeWidth(0.85)
2051 w = mkbutton("MidS-H", [[not exactly an Easter egg, with sound]]) 2062 w = mkbutton("MidS-H", [[not exactly an Easter egg, with sound]])
2052 w:SetRelativeWidth(0.15) 2063 w:SetRelativeWidth(0.15)
2053 w:SetCallback("OnClick", function() 2064 w:SetCallback("OnClick", function()
2068 simple:AddChild(w) 2079 simple:AddChild(w)
2069 grp:AddChild(simple) 2080 grp:AddChild(simple)
2070 2081
2071 grp:ResumeLayout() 2082 grp:ResumeLayout()
2072 container:AddChild(grp) 2083 container:AddChild(grp)
2073 GUI:ClearFocus() 2084 AceGUI:ClearFocus()
2074 container:SetScroll(1000) -- scrollframe's max value 2085 container:SetScroll(1000) -- scrollframe's max value
2075 end 2086 end
2076 2087
2077 -- Initial lower panel function (unless debug mode is on during load, which 2088 -- Initial lower panel function (unless debug mode is on during load, which
2078 -- means it was almost certainly hardcoded that way, which means it's 2089 -- means it was almost certainly hardcoded that way, which means it's
2080 local adv_lower 2091 local adv_lower
2081 if addon.DEBUG_PRINT then 2092 if addon.DEBUG_PRINT then
2082 adv_lower = adv_real 2093 adv_lower = adv_real
2083 else 2094 else
2084 function adv_lower (container, specials) 2095 function adv_lower (container, specials)
2085 local spacer = GUI:Create("Spacer") 2096 local spacer = AceGUI:Create("Spacer")
2086 spacer:SetFullWidth(true) 2097 spacer:SetFullWidth(true)
2087 spacer:SetHeight(5) 2098 spacer:SetHeight(5)
2088 container:AddChild(spacer) 2099 container:AddChild(spacer)
2089 local speedbump = GUI:Create("InteractiveLabel") 2100 local speedbump = AceGUI:Create("InteractiveLabel")
2090 speedbump:SetFullWidth(true) 2101 speedbump:SetFullWidth(true)
2091 speedbump:SetFontObject(GameFontHighlightLarge) 2102 speedbump:SetFontObject(GameFontHighlightLarge)
2092 speedbump:SetImage[[Interface\DialogFrame\DialogAlertIcon]] 2103 speedbump:SetImage[[Interface\DialogFrame\DialogAlertIcon]]
2093 speedbump:SetImageSize(50,50) 2104 speedbump:SetImageSize(50,50)
2094 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.") 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.")
2095 speedbump:SetCallback("OnClick", function (_sb) 2106 speedbump:SetCallback("OnClick", function (_sb)
2096 adv_lower = adv_real 2107 adv_lower = adv_real
2097 return addon:redisplay() 2108 return addon:redisplay()
2098 end) 2109 end)
2099 container:AddChild(speedbump) 2110 container:AddChild(speedbump)
2100 spacer = GUI:Create("Spacer") 2111 spacer = AceGUI:Create("Spacer")
2101 spacer:SetFullWidth(true) 2112 spacer:SetFullWidth(true)
2102 spacer:SetHeight(5) 2113 spacer:SetHeight(5)
2103 container:AddChild(spacer) 2114 container:AddChild(spacer)
2104 end 2115 end
2105 end 2116 end
2108 opts = OuroLootSV_opts 2119 opts = OuroLootSV_opts
2109 2120
2110 container:SetLayout("Fill") 2121 container:SetLayout("Fill")
2111 local scroll, grp, w 2122 local scroll, grp, w
2112 2123
2113 scroll = GUI:Create("ScrollFrame") 2124 scroll = AceGUI:Create("ScrollFrame")
2114 scroll:SetLayout("Flow") 2125 scroll:SetLayout("Flow")
2115 2126
2116 grp = GUI:Create("InlineGroup") 2127 grp = AceGUI:Create("InlineGroup")
2117 grp:SetLayout("Flow") 2128 grp:SetLayout("Flow")
2118 grp:SetFullWidth(true) 2129 grp:SetFullWidth(true)
2119 grp:SetTitle("User Options [these are saved across sessions]") 2130 grp:SetTitle("User Options [these are saved across sessions]")
2120 2131
2121 -- The relative width fields used to be done to take up less vertical 2132 -- The relative width fields used to be done to take up less vertical
2169 -- prefilling g_uniques with history 2180 -- prefilling g_uniques with history
2170 w = mkoption('precache_history_uniques', "Prescan for faster handling", 0.49, 2181 w = mkoption('precache_history_uniques', "Prescan for faster handling", 0.49,
2171 [[See description under +Help -- Handy Tips -- Prescanning> for instructions.]]) 2182 [[See description under +Help -- Handy Tips -- Prescanning> for instructions.]])
2172 grp:AddChild(w) 2183 grp:AddChild(w)
2173 2184
2174 w = GUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(5) grp:AddChild(w) 2185 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(5) grp:AddChild(w)
2175 2186
2176 -- possible keybindings 2187 -- possible keybindings
2177 do 2188 do
2178 local pair = GUI:Create("InlineGroup") 2189 local pair = AceGUI:Create("InlineGroup")
2179 pair:SetLayout("List") 2190 pair:SetLayout("List")
2180 pair:SetRelativeWidth(0.49) 2191 pair:SetRelativeWidth(0.49)
2181 pair:SetTitle("Keybinding for '/ouroloot'") 2192 pair:SetTitle("Keybinding for '/ouroloot'")
2182 local editbox, checkbox 2193 local editbox, checkbox
2183 editbox = mkbutton("EditBox", nil, opts.keybinding_text, 2194 editbox = mkbutton("EditBox", nil, opts.keybinding_text,
2200 grp:AddChild(pair) 2211 grp:AddChild(pair)
2201 end 2212 end
2202 2213
2203 -- replacement for slashloot 2214 -- replacement for slashloot
2204 do 2215 do
2205 local pair = GUI:Create("InlineGroup") 2216 local pair = AceGUI:Create("InlineGroup")
2206 pair:SetLayout("List") 2217 pair:SetLayout("List")
2207 pair:SetRelativeWidth(0.49) 2218 pair:SetRelativeWidth(0.49)
2208 pair:SetTitle('Synonyms for "/ouroloot"') 2219 pair:SetTitle('Synonyms for "/ouroloot"')
2209 local editbox, checkbox 2220 local editbox, checkbox
2210 editbox = mkbutton("EditBox", nil, opts.slash_synonyms, 2221 editbox = mkbutton("EditBox", nil, opts.slash_synonyms,
2239 grp:AddChild(pair) 2250 grp:AddChild(pair)
2240 end 2251 end
2241 2252
2242 -- chatty disposition/assignment changes 2253 -- chatty disposition/assignment changes
2243 do 2254 do
2244 local chatgroup = GUI:Create("InlineGroup") 2255 local chatgroup = AceGUI:Create("InlineGroup")
2245 chatgroup:SetLayout("List") 2256 chatgroup:SetLayout("List")
2246 chatgroup:SetRelativeWidth(0.49) 2257 chatgroup:SetRelativeWidth(0.49)
2247 chatgroup:SetTitle("Remote Changes Chat") 2258 chatgroup:SetTitle("Remote Changes Chat")
2248 local toggle, editbox 2259 local toggle, editbox
2249 toggle = mkoption('chatty_on_remote_changes', "Be chatty on remote changes", 1, 2260 toggle = mkoption('chatty_on_remote_changes', "Be chatty on remote changes", 1,
2252 opts.chatty_on_remote_changes = value 2263 opts.chatty_on_remote_changes = value
2253 editbox:SetDisabled(not opts.chatty_on_remote_changes) 2264 editbox:SetDisabled(not opts.chatty_on_remote_changes)
2254 end) 2265 end)
2255 toggle:SetFullWidth(true) 2266 toggle:SetFullWidth(true)
2256 chatgroup:AddChild(toggle) 2267 chatgroup:AddChild(toggle)
2257 w = GUI:Create("Label") 2268 w = AceGUI:Create("Label")
2258 w:SetFullWidth(true) 2269 w:SetFullWidth(true)
2259 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.") 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.")
2260 chatgroup:AddChild(w) 2271 chatgroup:AddChild(w)
2261 editbox = mkbutton("EditBox", nil, opts.chatty_on_remote_changes_frame, 2272 editbox = mkbutton("EditBox", nil, opts.chatty_on_remote_changes_frame,
2262 [[1 = default chat frame, 2 = combat log, etc]]) 2273 [[1 = default chat frame, 2 = combat log, etc]])
2290 chatgroup:AddChild(w) 2301 chatgroup:AddChild(w)
2291 grp:AddChild(chatgroup) 2302 grp:AddChild(chatgroup)
2292 end 2303 end
2293 2304
2294 -- boss mod selection 2305 -- boss mod selection
2295 w = GUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(2) grp:AddChild(w) 2306 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(2) grp:AddChild(w)
2296 do 2307 do
2297 local list = {} 2308 local list = {}
2298 local current 2309 local current
2299 for k,v in ipairs(addon.bossmods) do 2310 for k,v in ipairs(addon.bossmods) do
2300 list[k] = v.n 2311 list[k] = v.n
2312 end) 2323 end)
2313 grp:AddChild(w) 2324 grp:AddChild(w)
2314 end 2325 end
2315 2326
2316 -- item filters 2327 -- item filters
2317 w = GUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(2) grp:AddChild(w) 2328 w = AceGUI:Create("Spacer") w:SetFullWidth(true) w:SetHeight(2) grp:AddChild(w)
2318 do 2329 do
2319 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." 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."
2320 local cache_warn, cache_warned = false, false 2331 local cache_warn, cache_warned = false, false
2321 local function do_warning() 2332 local function do_warning()
2322 if cache_warn and not cache_warned then 2333 if cache_warn and not cache_warned then
2341 else 2352 else
2342 cache_warn = true 2353 cache_warn = true
2343 end 2354 end
2344 end 2355 end
2345 2356
2346 w = GUI:Create("EditBoxDropDown") 2357 w = AceGUI:Create("EditBoxDropDown")
2347 w:SetRelativeWidth(0.4) 2358 w:SetRelativeWidth(0.4)
2348 w:SetText("Item filter") 2359 w:SetText("Item filter")
2349 w:SetEditBoxTooltip("Link items which should no longer be tracked.") 2360 w:SetEditBoxTooltip("Link items which should no longer be tracked.")
2350 w:SetList(filterlist) 2361 w:SetList(filterlist)
2351 w:SetCallback("OnTextEnterPressed", function(_w, _, text) 2362 w:SetCallback("OnTextEnterPressed", function(_w, _, text)
2365 addon:Print("No longer filtering out", val_name) 2376 addon:Print("No longer filtering out", val_name)
2366 end) 2377 end)
2367 w:SetCallback("OnDropdownShown",do_warning) 2378 w:SetCallback("OnDropdownShown",do_warning)
2368 grp:AddChild(w) 2379 grp:AddChild(w)
2369 2380
2370 w = GUI:Create("Spacer") 2381 w = AceGUI:Create("Spacer")
2371 w:SetRelativeWidth(0.1) 2382 w:SetRelativeWidth(0.1)
2372 w:SetHeight(2) 2383 w:SetHeight(2)
2373 grp:AddChild(w) 2384 grp:AddChild(w)
2374 2385
2375 w = GUI:Create("EditBoxDropDown") 2386 w = AceGUI:Create("EditBoxDropDown")
2376 w:SetRelativeWidth(0.4) 2387 w:SetRelativeWidth(0.4)
2377 w:SetText("Vault items") 2388 w:SetText("Vault items")
2378 w:SetEditBoxTooltip("Link items which should be automatically marked as guild vault.") 2389 w:SetEditBoxTooltip("Link items which should be automatically marked as guild vault.")
2379 w:SetList(vaultlist) 2390 w:SetList(vaultlist)
2380 w:SetCallback("OnTextEnterPressed", function(_w, _, text) 2391 w:SetCallback("OnTextEnterPressed", function(_w, _, text)
2400 addon.sender_list.sort() 2411 addon.sender_list.sort()
2401 if #addon.sender_list.namesI > 0 then 2412 if #addon.sender_list.namesI > 0 then
2402 local senders = table.concat(addon.sender_list.namesI,'\n') -- sigh 2413 local senders = table.concat(addon.sender_list.namesI,'\n') -- sigh
2403 -- If 39 other people in the raid are running this, the label will 2414 -- If 39 other people in the raid are running this, the label will
2404 -- explode... is it likely enough to care about? No. 2415 -- explode... is it likely enough to care about? No.
2405 w = GUI:Create("Spacer") 2416 w = AceGUI:Create("Spacer")
2406 w:SetFullWidth(true) 2417 w:SetFullWidth(true)
2407 w:SetHeight(20) 2418 w:SetHeight(20)
2408 grp:AddChild(w) 2419 grp:AddChild(w)
2409 w = GUI:Create("Label") 2420 w = AceGUI:Create("Label")
2410 w:SetRelativeWidth(0.4) 2421 w:SetRelativeWidth(0.4)
2411 w:SetText(ITEM_QUALITY_COLORS[3].hex .."Echo from latest ping:|r\n"..senders) 2422 w:SetText(ITEM_QUALITY_COLORS[3].hex .."Echo from latest ping:|r\n"..senders)
2412 grp:AddChild(w) 2423 grp:AddChild(w)
2413 end 2424 end
2414 2425
2450 tabs_OnGroupSelected_func_args[3] = group 2461 tabs_OnGroupSelected_func_args[3] = group
2451 hide_noobtips_frame() 2462 hide_noobtips_frame()
2452 tabs:ReleaseChildren() 2463 tabs:ReleaseChildren()
2453 local spec = tabs:GetUserData("special buttons group") 2464 local spec = tabs:GetUserData("special buttons group")
2454 spec:ReleaseChildren() 2465 spec:ReleaseChildren()
2455 local h = GUI:Create("Heading") 2466 local h = AceGUI:Create("Heading")
2456 h:SetFullWidth(true) 2467 h:SetFullWidth(true)
2457 h:SetText(_tabtexts[group].title) 2468 h:SetText(gui.tabtexts[group].title)
2458 spec:AddChild(h) 2469 spec:AddChild(h)
2459 do 2470 do
2460 addon.sender_list.sort() 2471 addon.sender_list.sort()
2461 local fmt = "Received broadcast data from %d |4player:players;." 2472 local fmt = "Received broadcast data from %d |4player:players;."
2462 if addon.history_suppress then 2473 if addon.history_suppress then
2511 if not label then 2522 if not label then
2512 opt_widget_type, opt_key, label, status = "Button", opt_widget_type, opt_widget_type, opt_key 2523 opt_widget_type, opt_key, label, status = "Button", opt_widget_type, opt_widget_type, opt_key
2513 elseif not status then 2524 elseif not status then
2514 opt_widget_type, opt_key, label, status = "Button", opt_widget_type, opt_key, label 2525 opt_widget_type, opt_key, label, status = "Button", opt_widget_type, opt_key, label
2515 end 2526 end
2516 local button = assert(GUI:Create(opt_widget_type)) 2527 local button = assert(AceGUI:Create(opt_widget_type))
2517 if button.SetText then button:SetText(tostring(label)) end 2528 if button.SetText then button:SetText(tostring(label)) end
2518 status = _markup(status) 2529 status = _markup(status)
2519 button:SetCallback("OnEnter", function() setstatus(status) end) -- maybe factor that closure out 2530 button:SetCallback("OnEnter", function() setstatus(status) end) -- maybe factor that closure out
2520 button:SetCallback("OnLeave", statusy_OnLeave) 2531 button:SetCallback("OnLeave", statusy_OnLeave)
2521 -- retrieval key may be specified as nil if all the parameters are given 2532 -- retrieval key may be specified as nil if all the parameters are given
2544 -- pointers known to be good by now, pass them back in 2555 -- pointers known to be good by now, pass them back in
2545 self:gui_init (g_loot, g_uniques) 2556 self:gui_init (g_loot, g_uniques)
2546 self:zero_printed_fenceposts() 2557 self:zero_printed_fenceposts()
2547 end 2558 end
2548 2559
2549 local display = GUI:Create("Frame") 2560 local display = AceGUI:Create("Frame")
2550 if _d then
2551 display:SetUserData("eoiST",_d) -- warning! warning! kludge detected!
2552 end
2553 _d = display 2561 _d = display
2554 self.display = display 2562 self.display = display
2555 display:SetTitle(window_title) 2563 display:SetTitle(window_title)
2556 display:SetStatusText(self.status_text) 2564 display:SetStatusText(self.status_text)
2557 display:SetLayout("Flow") 2565 display:SetLayout("Flow")
2558 display:SetStatusTable{width=900,height=550} -- default height is 500 2566 display:SetStatusTable{width=900,height=550} -- default height is 500
2559 display:EnableResize(false) 2567 display:EnableResize(false)
2560 display:SetCallback("OnClose", function(_display) 2568 display:SetCallback("OnClose", function(_display)
2561 UIDROPDOWNMENU_SHOW_TIME = prev_fade_time 2569 UIDROPDOWNMENU_SHOW_TIME = prev_fade_time
2562 hide_noobtips_frame() 2570 hide_noobtips_frame()
2563 _d = _display:GetUserData("eoiST") 2571 _d = nil
2564 self.display = nil 2572 self.display = nil
2565 GUI:Release(_display) 2573 AceGUI:Release(_display)
2566 flib.clear() 2574 flib.clear()
2567 collectgarbage() 2575 collectgarbage()
2568 end) 2576 end)
2569 2577
2570 ----- Right-hand panel 2578 ----- Right-hand panel
2571 local rhs_width = 0.20 2579 local rhs_width = 0.20
2572 local control = GUI:Create("SimpleGroup") 2580 local control = AceGUI:Create("SimpleGroup")
2573 control:SetLayout("Flow") 2581 control:SetLayout("Flow")
2574 control:SetRelativeWidth(rhs_width) 2582 control:SetRelativeWidth(rhs_width)
2575 control.alignoffset = 25 2583 control.alignoffset = 25
2576 control:PauseLayout() 2584 control:PauseLayout()
2577 local h,b 2585 local h,b
2578 2586
2579 --- Main --- 2587 --- Main ---
2580 h = GUI:Create("Heading") 2588 h = AceGUI:Create("Heading")
2581 h:SetFullWidth(true) 2589 h:SetFullWidth(true)
2582 h:SetText("Main") 2590 h:SetText("Main")
2583 control:AddChild(h) 2591 control:AddChild(h)
2584 2592
2585 do 2593 do
2623 b:SetCallback("OnClick", function() 2631 b:SetCallback("OnClick", function()
2624 StaticPopup_Show("OUROL_CLEAR").data = self 2632 StaticPopup_Show("OUROL_CLEAR").data = self
2625 end) 2633 end)
2626 control:AddChild(b) 2634 control:AddChild(b)
2627 2635
2628 b = GUI:Create("Spacer") 2636 b = AceGUI:Create("Spacer")
2629 b:SetFullWidth(true) 2637 b:SetFullWidth(true)
2630 b:SetHeight(10) 2638 b:SetHeight(10)
2631 control:AddChild(b) 2639 control:AddChild(b)
2632 2640
2633 --[[ 2641 --[[
2636 saved1 2644 saved1
2637 saved2 2645 saved2
2638 ... 2646 ...
2639 [ Load ] [ Delete ] 2647 [ Load ] [ Delete ]
2640 ]] 2648 ]]
2641 h = GUI:Create("Heading") 2649 h = AceGUI:Create("Heading")
2642 h:SetFullWidth(true) 2650 h:SetFullWidth(true)
2643 h:SetText("Saved Texts") 2651 h:SetText("Saved Texts")
2644 control:AddChild(h) 2652 control:AddChild(h)
2645 b = mkbutton("Save Current As...", 2653 b = mkbutton("Save Current As...",
2646 [[Save forum/attendance/etc texts for later retrieval. Main loot information not included.]]) 2654 [[Save forum/attendance/etc texts for later retrieval. Main loot information not included.]])
2650 _d:Hide() 2658 _d:Hide()
2651 end) 2659 end)
2652 control:AddChild(b) 2660 control:AddChild(b)
2653 2661
2654 do 2662 do
2655 local scontainer = GUI:Create("SimpleGroup") 2663 local scontainer = AceGUI:Create("SimpleGroup")
2656 scontainer:SetFullWidth(true) 2664 scontainer:SetFullWidth(true)
2657 scontainer:SetFullHeight(false) 2665 scontainer:SetFullHeight(false)
2658 scontainer:SetAutoAdjustHeight(false) 2666 scontainer:SetAutoAdjustHeight(false)
2659 scontainer:SetHeight(40) -- no relative height available anymore 2667 scontainer:SetHeight(40) -- no relative height available anymore
2660 scontainer:SetLayout("Fill") 2668 scontainer:SetLayout("Fill")
2661 local scroll = GUI:Create("ScrollFrame") 2669 local scroll = AceGUI:Create("ScrollFrame")
2662 scroll:SetLayout("List") 2670 scroll:SetLayout("List")
2663 local saved = self:check_saved_table(--[[silent_on_empty=]]true) 2671 local saved = self:check_saved_table(--[[silent_on_empty=]]true)
2664 if saved then for i,s in ipairs(saved) do 2672 if saved then for i,s in ipairs(saved) do
2665 local il = GUI:Create("InteractiveLabel") 2673 local il = AceGUI:Create("InteractiveLabel")
2666 il:SetFullWidth(true) 2674 il:SetFullWidth(true)
2667 il:SetText(s.name) 2675 il:SetText(s.name)
2668 il:SetUserData("num",i) 2676 il:SetUserData("num",i)
2669 il:SetHighlight(1,1,1,0.4) 2677 il:SetHighlight(1,1,1,0.4)
2670 local str = ("%s %d entries %s"):format(s.date,s.count,s.name) 2678 local str = ("%s %d entries %s"):format(s.date,s.count,s.name)
2707 self:BuildMainDisplay() 2715 self:BuildMainDisplay()
2708 end) 2716 end)
2709 b:SetDisabled(true) 2717 b:SetDisabled(true)
2710 control:AddChild(b) 2718 control:AddChild(b)
2711 2719
2712 b = GUI:Create("Spacer") 2720 b = AceGUI:Create("Spacer")
2713 b:SetFullWidth(true) 2721 b:SetFullWidth(true)
2714 b:SetHeight(10) 2722 b:SetHeight(10)
2715 control:AddChild(b) 2723 control:AddChild(b)
2716 2724
2717 -- Other stuff on right-hand side 2725 -- Other stuff on right-hand side
2718 local tab_specials = GUI:Create("SimpleGroup") 2726 local tab_specials = AceGUI:Create("SimpleGroup")
2719 tab_specials:SetLayout("Flow") 2727 tab_specials:SetLayout("Flow")
2720 tab_specials:SetFullWidth(true) 2728 tab_specials:SetFullWidth(true)
2721 control:AddChild(tab_specials) 2729 control:AddChild(tab_specials)
2722 control:ResumeLayout() 2730 control:ResumeLayout()
2723 2731
2724 ----- Left-hand group 2732 ----- Left-hand group
2725 local tabs = GUI:Create("TabGroup") 2733 local tabs = AceGUI:Create("TabGroup")
2726 tabs:SetLayout("Flow") 2734 tabs:SetLayout("Flow")
2727 tabs.alignoffset = 25 2735 tabs.alignoffset = 25
2728 local titletext_orig_fo = tabs.titletext:GetFontObject() 2736 local titletext_orig_fo = tabs.titletext:GetFontObject()
2729 tabs.titletext:SetFontObject(GameFontNormalSmall) 2737 tabs.titletext:SetFontObject(GameFontNormalSmall)
2730 tabs:SetCallback("OnRelease", function(_tabs) 2738 tabs:SetCallback("OnRelease", function(_tabs)
2733 tabs:SetRelativeWidth(0.99-rhs_width) 2741 tabs:SetRelativeWidth(0.99-rhs_width)
2734 tabs:SetFullHeight(true) 2742 tabs:SetFullHeight(true)
2735 tabs:SetTabs(tabgroup_tabs) 2743 tabs:SetTabs(tabgroup_tabs)
2736 tabs:SetCallback("OnGroupSelected", tabs_OnGroupSelected_func) 2744 tabs:SetCallback("OnGroupSelected", tabs_OnGroupSelected_func)
2737 tabs:SetCallback("OnTabEnter", function(_tabs,event,value,tab) 2745 tabs:SetCallback("OnTabEnter", function(_tabs,event,value,tab)
2738 setstatus(_tabtexts[value].desc) 2746 setstatus(gui.tabtexts[value].desc)
2739 end) 2747 end)
2740 tabs:SetCallback("OnTabLeave", statusy_OnLeave) 2748 tabs:SetCallback("OnTabLeave", statusy_OnLeave)
2741 tabs:SetUserData("special buttons group",tab_specials) 2749 tabs:SetUserData("special buttons group",tab_specials)
2742 tabs:SelectTab((opt_tabselect and #opt_tabselect>0) 2750 tabs:SelectTab((opt_tabselect and #opt_tabselect>0)
2743 and opt_tabselect or "eoi") 2751 and opt_tabselect or "eoi")
2747 2755
2748 display:Show() -- without this, only appears every *other* function call 2756 display:Show() -- without this, only appears every *other* function call
2749 return display 2757 return display
2750 end 2758 end
2751 2759
2760 -- Searches tab titles from left to right.
2752 function addon:OpenMainDisplayToTab (text, opt_arg) 2761 function addon:OpenMainDisplayToTab (text, opt_arg)
2753 text = '^'..text:lower() 2762 text = '^'..text:lower()
2754 for tab,v in pairs(_tabtexts) do 2763 for _,tab in ipairs(gui.taborder) do
2755 if v.title:lower():find(text) then 2764 local v = gui.tabtexts[tab]
2765 if v and v.title:lower():find(text) then
2756 self:BuildMainDisplay(tab) 2766 self:BuildMainDisplay(tab)
2757 if opt_arg and tabs_CLI_special[tab] then 2767 if opt_arg and tabs_CLI_special[tab] then
2758 tabs_CLI_special[tab](opt_arg) 2768 tabs_CLI_special[tab](opt_arg)
2759 end 2769 end
2760 return true 2770 return true
2945 raidersnap = data.yes_snap or {}, 2955 raidersnap = data.yes_snap or {},
2946 } 2956 }
2947 local entry = tremove(g_loot,boss_index) 2957 local entry = tremove(g_loot,boss_index)
2948 tinsert(g_loot,data.rowindex,entry) 2958 tinsert(g_loot,data.rowindex,entry)
2949 addon:_mark_boss_kill(data.rowindex) 2959 addon:_mark_boss_kill(data.rowindex)
2950 data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.rowindex) 2960 gui.eoiST:OuroLoot_Refresh(data.rowindex)
2951 dialog.data = nil -- free up memory 2961 dialog.data = nil -- free up memory
2952 addon:Print("Inserted %s %s at entry %d.", data.kind, data.name, data.rowindex) 2962 addon:Print("Inserted %s %s at entry %d.", data.kind, data.name, data.rowindex)
2953 return 2963 return
2954 end 2964 end
2955 2965
3110 button2 = CANCEL, 3120 button2 = CANCEL,
3111 hasEditBox = true, 3121 hasEditBox = true,
3112 OnAccept = function(dialog, data) 3122 OnAccept = function(dialog, data)
3113 local name = dialog.usertext --editBox:GetText() 3123 local name = dialog.usertext --editBox:GetText()
3114 addon:reassign_loot ("local", data.index, name) 3124 addon:reassign_loot ("local", data.index, name)
3115 data.display:GetUserData("eoiST"):OuroLoot_Refresh(data.index) 3125 gui.eoiST:OuroLoot_Refresh(data.index)
3116 end, 3126 end,
3117 } 3127 }
3118 3128
3119 StaticPopupDialogs["OUROL_SAVE_SAVEAS"] = flib.StaticPopup{ 3129 StaticPopupDialogs["OUROL_SAVE_SAVEAS"] = flib.StaticPopup{
3120 text = "Enter a name for the loot collection:", 3130 text = "Enter a name for the loot collection:",