Mercurial > wow > ouroloot
comparison gui.lua @ 49:fd3dd12f96ce
Handle text generation modules being LoadOnDemand. lib-st widget to v5 to fix handling multiple live ST instances.
author | Farmbuyer of US-Kilrogg <farmbuyer@gmail.com> |
---|---|
date | Sun, 29 Jan 2012 03:38:30 +0000 |
parents | 1070a14cfee4 |
children | 857aea8ae33d |
comparison
equal
deleted
inserted
replaced
48:22db12e97313 | 49:fd3dd12f96ce |
---|---|
54 | 54 |
55 -- En masse forward decls of symbols defined inside local blocks | 55 -- En masse forward decls of symbols defined inside local blocks |
56 local _generate_text, _populate_text_specials | 56 local _generate_text, _populate_text_specials |
57 local _tabtexts, _taborder -- filled out in gui block scope | 57 local _tabtexts, _taborder -- filled out in gui block scope |
58 | 58 |
59 --[[ | |
60 This is a table of callback functions, each responsible for drawing a tab | |
61 into the container passed in the first argument. Special-purpose buttons | |
62 can optionally be created (mkbutton) and added to the container in the second | |
63 argument. | |
64 ]] | |
65 local tabs_OnGroupSelected = {} | |
66 local mkbutton | |
67 local tabs_OnGroupSelected_func, tabs_generated_text_OGS | |
68 | |
59 -- Working around this bug: | 69 -- Working around this bug: |
60 -- http://forums.wowace.com/showpost.php?p=295202&postcount=31 | 70 -- http://forums.wowace.com/showpost.php?p=295202&postcount=31 |
61 do | 71 do |
62 local function fix_frame_level (level, ...) | 72 local function fix_frame_level (level, ...) |
63 for i = 1, select("#", ...) do | 73 for i = 1, select("#", ...) do |
139 end | 149 end |
140 function _populate_text_specials (editbox, specials, mkb, text_type) | 150 function _populate_text_specials (editbox, specials, mkb, text_type) |
141 local f = specials_gen_funcs[text_type] | 151 local f = specials_gen_funcs[text_type] |
142 if not f then return end | 152 if not f then return end |
143 pcall (f, text_type, editbox, specials, mkb) | 153 pcall (f, text_type, editbox, specials, mkb) |
154 end | |
155 | |
156 -- LOD tab has been clicked on. | |
157 local function _handle_LOD (tabs_container,specials,tabtitle) | |
158 local what = _tabtexts[tabtitle] | |
159 local addon_index = what.LOD | |
160 local loaded_at = what.loaded_at | |
161 local real_nip = next_insertion_position | |
162 local function LOAD() | |
163 _tabtexts[tabtitle] = nil | |
164 tremove (_taborder, loaded_at) | |
165 next_insertion_position = loaded_at | |
166 local loaded, whynot = LoadAddOn(addon_index) | |
167 if loaded then | |
168 addon:Print(tabtitle, "loaded.") | |
169 else | |
170 what.disabled = true | |
171 _tabtexts[tabtitle] = what -- restore this for mouseovers | |
172 addon:Print("%s could not load (game client reason was '%s').", tabtitle, whynot) | |
173 DisableAddOn(addon_index) | |
174 end | |
175 next_insertion_position = real_nip | |
176 dirty_tabs = true | |
177 addon:BuildMainDisplay() | |
178 end | |
179 addon.display:Hide() | |
180 if what.LOD_enabled then | |
181 -- totally loadable, go for it | |
182 LOAD() | |
183 else | |
184 -- was disabled at addons menu | |
185 StaticPopupDialogs["OUROL_LOD_DISABLED"] = flib.StaticPopup{ | |
186 text = tabtitle.." was disabled at the character loading screen. Do you want to enable it?", | |
187 button1 = YES, | |
188 button2 = NO, | |
189 OnAccept = function() | |
190 EnableAddOn(addon_index) | |
191 LOAD() | |
192 end, | |
193 OnCancel = function() | |
194 addon:BuildMainDisplay() | |
195 end, | |
196 OnHide = function() | |
197 StaticPopupDialogs["OUROL_LOD_DISABLED"] = nil | |
198 end, | |
199 } | |
200 StaticPopup_Show("OUROL_LOD_DISABLED") | |
201 end | |
202 end | |
203 | |
204 -- Add a clickable tab that brings the real module in. Since gui_init has | |
205 -- already been called, we flag the dirty bit and let the main building | |
206 -- routine handle it like any other plugin. | |
207 function addon:_gui_add_LOD_tab (tabtitle, folder, addon_index, enabled_p, why_not) | |
208 _tabtexts[tabtitle] = { | |
209 title = tabtitle, | |
210 desc = ("'%s' is not loaded yet. Click the tab to load it now."):format(folder), | |
211 LOD = addon_index, | |
212 LOD_enabled = enabled_p, | |
213 LOD_why_not = why_not, | |
214 loaded_at = next_insertion_position, | |
215 } | |
216 tabs_OnGroupSelected[tabtitle] = _handle_LOD | |
217 tinsert (_taborder, next_insertion_position, tabtitle) | |
218 next_insertion_position = next_insertion_position + 1 | |
219 dirty_tabs = true | |
144 end | 220 end |
145 end | 221 end |
146 | 222 |
147 --[[ | 223 --[[ |
148 The g_loot table is populated only with "behavior-relevant" data (names, | 224 The g_loot table is populated only with "behavior-relevant" data (names, |
345 } | 421 } |
346 --if addon.author_debug then | 422 --if addon.author_debug then |
347 _taborder = { "eoi", "hist", "help", "opt" } | 423 _taborder = { "eoi", "hist", "help", "opt" } |
348 --else _taborder = { "eoi", "help", "opt" } end | 424 --else _taborder = { "eoi", "help", "opt" } end |
349 | 425 |
350 --[[ | |
351 This is a table of callback functions, each responsible for drawing a tab | |
352 into the container passed in the first argument. Special-purpose buttons | |
353 can optionally be created (mkbutton) and added to the container in the second | |
354 argument. | |
355 ]] | |
356 local tabs_OnGroupSelected = {} | |
357 local mkbutton | |
358 local tabs_OnGroupSelected_func, tabs_generated_text_OGS | |
359 | |
360 function addon:gui_init (loot_pointer) | 426 function addon:gui_init (loot_pointer) |
361 g_loot = loot_pointer | 427 g_loot = loot_pointer |
362 g_generated = nil | 428 g_generated = nil |
363 tabgroup_tabs = {} | 429 tabgroup_tabs = {} |
364 window_title = "Ouro Loot " .. self.revision | 430 window_title = "Ouro Loot " .. self.revision |
365 -- TabGroup stretches out the tabs to fill the row but only if >75% of the | 431 -- TabGroup stretches out the tabs to fill the row but only if >75% of the |
366 -- row is already full. It turns out that not doing this looks like ass. | 432 -- row is already full. It turns out that not doing this looks like ass. |
367 -- If we won't have enough tabs to trigger this on its own, pad out the tab | 433 -- If we won't have enough tabs to trigger this on its own, pad out the tab |
368 -- titles (not looking quite as nice, ah well) to force it to trigger. | 434 -- titles (not looking quite as nice, ah well) to force it to trigger. |
369 local fmtstr = #_taborder > 6 and "%s" or " %s " | 435 local fmtstr = #_taborder > 6 and "%s" or " %s " |
370 for _,v in ipairs(_taborder) do | 436 for i,name in ipairs(_taborder) do |
371 tinsert (tabgroup_tabs, {value=v, text=fmtstr:format(_tabtexts[v].title)}) | 437 tabgroup_tabs[i] = { |
438 value = name, | |
439 text = fmtstr:format(_tabtexts[name].title), | |
440 disabled = _tabtexts[name].disabled, | |
441 } | |
372 -- By default, tabs are editboxes with generated text | 442 -- By default, tabs are editboxes with generated text |
373 if not tabs_OnGroupSelected[v] then | 443 if not tabs_OnGroupSelected[name] then |
374 tabs_OnGroupSelected[v] = tabs_generated_text_OGS | 444 tabs_OnGroupSelected[name] = tabs_generated_text_OGS |
375 end | 445 end |
376 end | 446 end |
377 dirty_tabs = nil | 447 dirty_tabs = nil |
378 end | 448 end |
379 | 449 |
1998 | 2068 |
1999 ----- Left-hand group | 2069 ----- Left-hand group |
2000 local tabs = GUI:Create("TabGroup") | 2070 local tabs = GUI:Create("TabGroup") |
2001 tabs:SetLayout("Flow") | 2071 tabs:SetLayout("Flow") |
2002 tabs.alignoffset = 25 | 2072 tabs.alignoffset = 25 |
2003 tabs.titletext:SetFontObject(GameFontNormalSmall) -- XXX | 2073 local titletext_orig_fo = tabs.titletext:GetFontObject() |
2074 tabs.titletext:SetFontObject(GameFontNormalSmall) | |
2075 tabs:SetCallback("OnRelease", function(_tabs) | |
2076 tabs.titletext:SetFontObject(titletext_orig_fo) | |
2077 end) | |
2004 do | 2078 do |
2005 self.sender_list.sort() | 2079 self.sender_list.sort() |
2006 tabs.titletext:SetFormattedText("Received broadcast data from %d |4player:players;.", | 2080 tabs.titletext:SetFormattedText("Received broadcast data from %d |4player:players;.", |
2007 self.sender_list.activeI) | 2081 self.sender_list.activeI) |
2008 end | 2082 end |