Thread Tools Display Modes
10-30-09, 11:38 PM   #1
Unkn
Premium Member
 
Unkn's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 258
Slash commands for different layouts

I have been trying and failing at this, so I figured I would ask the oUF community. I have created different layouts for different toons. One healing, one tanking/dps. At the moment they are saved to different oUF layouts and I'm just logging and enabling the correct one for what I need. Though now I've got a prot/holy pali and this is begining to get very annoying.

What I'd like to do is create a slash command that will disable one and turn on the other. Anyone have any ideas? Any help would be appreciated.
  Reply With Quote
10-30-09, 11:58 PM   #2
MidgetMage55
Grinch!
 
MidgetMage55's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,498
You can always use an addon like ampere to enable/disable addons from in-game without logging. All it will require is a ui reload which it has a button for. Its available in tekkub's addon section.
__________________

I think Hong Kong Phooey was a ninja AND a pirate. That was just too much awesome. - Yhor
  Reply With Quote
10-31-09, 01:27 AM   #3
Freebaser
A Molten Kobold Bandit
 
Freebaser's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 135
Try Reflux
  Reply With Quote
10-31-09, 01:42 AM   #4
MidgetMage55
Grinch!
 
MidgetMage55's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,498
The issue with reflux in this case is that its not a matter of profile but completely different addons. Each oUF layout is a separate addon all together so reflux wont be able to do anything with it.

Granted you can use an addon that has addon profiles (i think acp comes to mind here) but now your using 2 addons to do the job of one for only turning one layout on and one off at any given time. though the advantage is you can set this to a macro if you like and now its a simple keystroke and your layout changes. Though in both cases (reflux and ampere) there is a ui reload.
__________________

I think Hong Kong Phooey was a ninja AND a pirate. That was just too much awesome. - Yhor
  Reply With Quote
10-31-09, 03:32 AM   #5
wurmfood
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 122
You're not really going to find a way to do it without a reload. I suppose you could add something like this at the beginning of your layout, though it may not work (not sure if talent info is loaded at the time):

(if GetNumTalentGroups(false, false) == 2 and GetActiveTalentGroup(false, false) == 1 ) then return end

This, for example, will effectively abort loading that layout if you are in your primary spec.

Again, though, I don't know if talent info is loaded that early, so it may not work. If it doesn't, I'd suggest either OptionHouse or AddonControlPanel to be able to switch between them without having to log out, only reload the UI.
  Reply With Quote
10-31-09, 03:38 AM   #6
Unkn
Premium Member
 
Unkn's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 258
Thanks for all the ideas.

Its not a reload that I have problems with at the present. That I could handle. Its logging out, switching on the right layout and back in, then end of fight doing it all again. >.< Faction Champions fight comes to mind. Or Hodir. Any of those things where I'm healing instead of tanking. I'll try out what's been suggested and see how it works for me.
  Reply With Quote
10-31-09, 04:12 AM   #7
Monolit
A Black Drake
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 81
There are 2 ways of doing what you want that I can think of:
make an addon or just add those lines to some addon:

method 1:

Code:
SlashCmdList["DISABLE_ADDON"] = function(s) DisableAddOn(s) print(s, format("|cffd36b6b disabled.  Reload UI is required.")) end
SLASH_DISABLE_ADDON1 = "/dis" 

SlashCmdList["ENABLE_ADDON"] = function(s) EnableAddOn(s) print(s, format("|cfff07100 enabled. Reload UI is required.")) end
SLASH_ENABLE_ADDON1 = "/en"   -- 

SlashCmdList['RELOADUI'] = function() ReloadUI() end
SLASH_RELOADUI1 = '/rl'
then create macros like this:
Code:
/dis oUF_LayoutX
/dis some_crap_addon_you_dont_need
/en oUF_LayoutY
/en some_superuseful_addon_just_showing_the_idea
/rl

method 2:
Code:
SlashCmdList['RELOADUI'] = function() ReloadUI() end
SLASH_RELOADUI1 = '/rl'

SlashCmdList["ENABLE_SETONE"] = function() 
EnableAddOn("some_useless_addon1")
EnableAddOn("can_be_your_unused_oUF_layout")
EnableAddOn("or_anything_really")
print(format("Modules are enabled, reload UI for changes to take place")) end
SLASH_ENABLE_SETONE1 = "/set1on"

SlashCmdList["DISABLE_SET_ONE"] = function() 
DisableAddOn("some_useless_addon1")
DisableAddOn("can_be_your_unused_oUF_layout")
DisableAddOn("or_anything_really")
print(format("Modules are disabled, reload UI for changes to take place")) end
SLASH_DISABLE_SET_ONE1 = "/set1off"
This not very efficient code wise, but if you use this method - you don't need to create any macros, just type /set1on to enable required addons or /set1off to disable them (reloading UI is still required, which is /rl in that case). You can create as many of those "sets" as you want.

Last edited by Monolit : 10-31-09 at 04:15 AM.
  Reply With Quote
10-31-09, 07:47 AM   #8
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
If you want to change your own layout via slash commands try this.

First you need to add a SavedVariables command to yout TOC file.

Example TOC
Code:
## Interface: 30200
## Author: yyy
## Title: myTestLayout
## Notes: yyy
## SavedVariablesPerCharacter: myTestLayoutVariables

myTestLayout.lua
Now you need to add slash commands and a default setting to your layout.

Example LUA
Code:
  
  --load the savedvariables data
  myTestLayoutVariables = myTestLayoutVariables or {}
  
  --the default layout if none is set
  local default_layout = 1 
  
  ------------------------------------------------------
  -- / SET UP DEFAULT VALUES / --
  ------------------------------------------------------

  local function load_default()
    if(not myTestLayoutVariables.layout) then 
      myTestLayoutVariables.layout = default_layout 
    end
  end
  
  ------------------------------------------------------
  -- / FUNCTIONS / --
  ------------------------------------------------------
  
  --local function dosth()
    --DEFAULT_CHAT_FRAME:AddMessage("Hello World!")
  --end
  
  local function CreatePlayerStyle1(self, unit)
    --do this
  end
  
  local function CreatePlayerStyle2(self, unit)
    --do that
  end

  ------------------------------------------------------
  -- / INIT LAYOUT / --
  ------------------------------------------------------
  
  local function init_layout()  
    if myTestLayoutVariables.layout == 2 then
      oUF:RegisterStyle("oUF_D3Orbs2_player", CreatePlayerStyle1)
      oUF:SetActiveStyle("oUF_D3Orbs2_player")
      oUF:Spawn("player", "oUF_D3Orbs2_PlayerFrame"):SetPoint("CENTER",0,0)  
    else
      oUF:RegisterStyle("oUF_D3Orbs2_player", CreatePlayerStyle2)
      oUF:SetActiveStyle("oUF_D3Orbs2_player")
      oUF:Spawn("player", "oUF_D3Orbs2_PlayerFrame"):SetPoint("CENTER",0,0)      
    end  
  end  
  
  ------------------------------------------------------
  -- / SLASH FUNC / --
  ------------------------------------------------------
  
  local function SlashCmd(cmd)    
    --getlayout
    if (cmd:match"getlayout") then
      am("Currently the layout is set to: "..myTestLayoutVariables.layout)
    --setlayout
    elseif (cmd:match"setlayout") then
      local a,b = strfind(cmd, " ");
      if b then
        local c = strsub(cmd, b+1)
        if tonumber(c) then
            am("Layout is set to: "..c)
            myTestLayoutVariables.layout = tonumber(c)
            am("Type in /reload to see the changes.")
            --reload_interface()
        else
          am("No number value.")
        end
      else
        am("No value found.")
      end  
    else
      am("commands...")
      am("\/mtl setlayout NUMBER (tell me the layout number)")
      am("\/mtl getlayout (tells you the set layout number)")
    end    
  end  
  
  ------------------------------------------------------
  -- / LOAD THE **** / --
  ------------------------------------------------------  

  local a = CreateFrame"Frame"
  a:RegisterEvent("VARIABLES_LOADED")
  a:SetScript("OnEvent", function(self)
    self:UnregisterEvent("VARIABLES_LOADED")
    self:SetScript("OnEvent", nil)    
    SlashCmdList["mtl"] = SlashCmd;
    SLASH_jexp1 = "/mtl";
    --load the default 
    load_default()
    --init the layout
    init_layout()
  end)
The last function calls everything.
It is available after the Variables have been loaded, thus the event.
First the default value gets checked, then the layout will be initialized.

Now you have a new slash command
Code:
/mtl setlayout 2
Hope you get it.

You could do it without the savedvariables but the the layout would use the default setting on every loadup.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 10-31-09 at 07:54 AM.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Slash commands for different layouts


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off