WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   configuring to switch between 2 layouts (https://www.wowinterface.com/forums/showthread.php?t=38973)

barbol12 02-17-11 06:44 PM

configuring to switch between 2 layouts
 
hello, i got a raid frame layout, 5 columns at 5 per column.. other words a 25man raid.. can also make it a 40man....

now what i am trying to do, is be able to type in a ingame config... to bring up a static popup that loads the 40man layout, and another static popup to load 25man...... basically to have two different layouts(positions and ofcourse 2 different # of columns) heres the configurations that i have so far.

this is the config file(seperate from lua, but enable to load with my ouf addon) it works fine upthrough showing the staticpopups. but doesnt change the raid layouts.
lua Code:
  1. local addon, ns = ...
  2. local cfg = CreateFrame("Frame")
  3.  
  4. ....... BLAH BLAH...... BLAH BLAH.... NOT IMPORTANT TO RAID STUFF.....
  5.  
  6. local function raidsmall()
  7.  
  8. if (cfg.raidbig == nil) then cfg.raidbig = {} end
  9.  
  10. cfg.raidbig = {}
  11. cfg.raidsmall = true
  12.  
  13. end
  14.  
  15. local function raidbig()
  16.  
  17. if (cfg.raidsmall == nil) then cfg.raidsmall = {} end
  18.  
  19. cfg.raidsmall = {}
  20. cfg.raidbig = true
  21.  
  22. end
  23.  
  24.  
  25.  
  26.  
  27. StaticPopupDialogs["BARBOLUI_RAIDSMALL"] = {
  28.     text = "Do you wish to set the raid layout to 25-man?",
  29.     button1 = YES,
  30.     button2 = NO,
  31.     OnAccept = function(self)
  32.         raidsmall();
  33.         ReloadUI();
  34.     end,
  35.     timeout = 0,
  36.     whileDead = 1,
  37.     hideOnEscape = 1
  38. }
  39.  
  40. StaticPopupDialogs["BARBOLUI_RAIDBIG"] = {
  41.     text = "Do you wish to set the raid layout to 40-man?",
  42.     button1 = YES,
  43.     button2 = NO,
  44.     OnAccept = function(self)
  45.         raidbig();
  46.         ReloadUI();
  47.     end,
  48.     timeout = 0,
  49.     whileDead = 1,
  50.     hideOnEscape = 1
  51. }
  52.  
  53.  
  54. SLASH_RAIDSMALL1 = "/Barbol25"
  55. SlashCmdList["RAIDSMALL"] = function() StaticPopup_Show("BARBOLUI_RAIDSMALL") end
  56.  
  57.  
  58. SLASH_RAIDBIG1 = "/Barbol40"
  59. SlashCmdList["RAIDBIG"] = function() StaticPopup_Show("BARBOLUI_RAIDBIG") end
  60.  
  61. ns.cfg = cfg

here is the ouf portion needed... for raid frame to make the layout positions work.
lua Code:
  1. if cfg.raidsmall then
  2.    
  3.     local raid = oUF:SpawnHeader("oUF_Raid", nil, 'solo,party,raid10,raid25,raid40',
  4.         'showRaid', true,  
  5.         'showPlayer', true,
  6.         'showSolo', true,
  7.         'showParty', false,
  8.         'xoffset', 0,
  9.         'yOffset', -3,
  10.         'groupFilter', "1,2,3,4,5,6,7,8",
  11.         'groupingOrder', "1,2,3,4,5,6,7,8",
  12.         'groupBy', "GROUP",
  13.         'maxColumns', 5,
  14.         'unitsPerColumn', 5,
  15.         'columnSpacing', 3,
  16.         'point', "TOP",
  17.         'columnAnchorPoint', "LEFT"
  18.     )
  19.        
  20.     raid:SetPoint("CENTER", 0, 0)
  21.    
  22.    
  23.     elseif cfg.raidbig then
  24.    
  25.     local raid = oUF:SpawnHeader("oUF_Raid", nil, 'solo,party,raid10,raid25,raid40',
  26.         'showRaid', true,  
  27.         'showPlayer', true,
  28.         'showSolo', true,
  29.         'showParty', false,
  30.         'xoffset', 0,
  31.         'yOffset', -3,
  32.         'groupFilter', "1,2,3,4,5,6,7,8",
  33.         'groupingOrder', "1,2,3,4,5,6,7,8",
  34.         'groupBy', "GROUP",
  35.         'maxColumns', 8,
  36.         'unitsPerColumn', 5,
  37.         'columnSpacing', 3,
  38.         'point', "TOP",
  39.         'columnAnchorPoint', "LEFT"
  40.     )
  41.        
  42.     raid:SetPoint("LEFT", 0, 0)
  43. end

anyone know how to make this work/ fix my stuff???

Akkorian 02-17-11 09:21 PM

Hi barbol,

Here’s the problem:

Code:

cfg.raidbig = {}
cfg.raidsmall = true

When you check if cfg.raidsmall then, you’re only asking if cfg.raidsmall isn’t nil, so the check still passes if cfg.raidsmall is a table. Set the one you don’t want to nil or false instead of an empty table.

You could check if cfg.raidsmall == true then instead, but since you don’t really need a table, there isn’t really any point in making one. Tables take up more memory than boolean values.


All times are GMT -6. The time now is 11:36 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI