comparison gui.lua @ 148:113dd7c86222

Update how LoadOnDemand modules are treated for 6.0. Blizzard API change, different return values. Adds finer-grained handling. Users who don't want to see a module at all can disable the module's "addon", and then later restore it from OL's option tab.
author Farmbuyer of US-Kilrogg <farmbuyer@gmail.com>
date Wed, 07 Jan 2015 17:37:43 -0500
parents e4bfe7a8b1c9
children df0ca8ed1aff
comparison
equal deleted inserted replaced
147:e1a90e398231 148:113dd7c86222
298 if loaded then 298 if loaded then
299 addon:Print("%s loaded, %d |4tab:tabs; added.", tabtitle, tabdelta) 299 addon:Print("%s loaded, %d |4tab:tabs; added.", tabtitle, tabdelta)
300 else 300 else
301 what.disabled = true 301 what.disabled = true
302 gui.tabtexts[tabtitle] = what -- restore this for mouseovers 302 gui.tabtexts[tabtitle] = what -- restore this for mouseovers
303 addon:Print("%s could not load (game client reason was '%s').", tabtitle, whynot) 303 addon:Print("%s could not load and will be disabled (game client reason was '%s').", tabtitle, whynot)
304 DisableAddOn(addon_index) 304 DisableAddOn(addon_index)
305 end 305 end
306 dirty_tabs = true 306 dirty_tabs = true
307 return addon:OpenMainDisplayToTab(tabtitle) or addon:BuildMainDisplay() 307 return addon:OpenMainDisplayToTab(tabtitle) or addon:BuildMainDisplay()
308 end 308 end
309 addon.display:Hide() 309 addon.display:Hide()
310 if what.LOD_enabled then 310 if what.LOD_enabled then
311 -- totally loadable, go for it 311 -- totally loadable, go for it
312 LOAD() 312 LOAD()
313 else 313 else
314 -- was disabled at addons menu 314 -- probably was disabled at addons menu
315 StaticPopupDialogs["OUROL_LOD_DISABLED"] = flib.StaticPopup{ 315 StaticPopupDialogs["OUROL_LOD_DISABLED"] = flib.StaticPopup{
316 text = tabtitle.." was disabled at the character selection screen. Do you want to enable it?", 316 text = [[%s is marked "%s". Do you want to enable and load it?]],
317 button1 = YES, 317 button1 = YES,
318 button2 = NO, 318 button2 = NO,
319 OnAccept = function() 319 OnAccept = function()
320 EnableAddOn(addon_index) 320 EnableAddOn(addon_index)
321 LOAD() 321 LOAD()
325 end, 325 end,
326 OnHide = function() 326 OnHide = function()
327 StaticPopupDialogs["OUROL_LOD_DISABLED"] = nil 327 StaticPopupDialogs["OUROL_LOD_DISABLED"] = nil
328 end, 328 end,
329 } 329 }
330 StaticPopup_Show("OUROL_LOD_DISABLED") 330 StaticPopup_Show ("OUROL_LOD_DISABLED", tabtitle, _G['ADDON_' .. what.LOD_why_not])
331 end 331 end
332 end 332 end
333 333
334 -- Add a clickable tab that brings the real module in. Since gui_init has 334 -- Add a clickable tab that brings the real module in. Since gui_init has
335 -- already been called, we flag the dirty bit and let the main building 335 -- already been called, we flag the dirty bit and let the main building
343 LOD_why_not = why_not, 343 LOD_why_not = why_not,
344 } 344 }
345 tabs_OnGroupSelected[tabtitle] = _handle_LOD 345 tabs_OnGroupSelected[tabtitle] = _handle_LOD
346 gui:tabposition_insert (tabtitle) 346 gui:tabposition_insert (tabtitle)
347 dirty_tabs = true 347 dirty_tabs = true
348 end
349
350 -- Called when the "include disabled plugins" option box is toggled on.
351 function addon:_gui_add_disabled_LOD_tabs()
352 while self._disabled_LOD_modules and #self._disabled_LOD_modules > 0 do
353 local t = tremove(self._disabled_LOD_modules)
354 self:_gui_add_LOD_tab (t.tabtitle, t.folder, t.addon_index, false, 'DISABLED')
355 end
356
357 self._disabled_LOD_modules = nil
358 self._gui_add_disabled_LOD_tabs = flib.nullfunc
348 end 359 end
349 360
350 -- Registering truly arbitrary tab controls, not just text generators. 361 -- Registering truly arbitrary tab controls, not just text generators.
351 -- (This is slightly out of place, but no more so than the LOD stuff.) 362 -- (This is slightly out of place, but no more so than the LOD stuff.)
352 -- The arguments are nearly the same as those of :register_text_generator 363 -- The arguments are nearly the same as those of :register_text_generator