From bec043c2940f8889c79db1e681c4faf7855cee53 Mon Sep 17 00:00:00 2001 From: Jim Whitehead Date: Fri, 27 Jan 2017 09:29:00 +0100 Subject: [PATCH] Add a /clique profile command This makes it possible to change profiles without navigating the GUI. --- Clique.lua | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/Clique.lua b/Clique.lua index 2f2cdfc..4c6b30c 100755 --- a/Clique.lua +++ b/Clique.lua @@ -1034,11 +1034,35 @@ function addon:BLACKLIST_CHANGED() self:ApplyAttributes() end +local contains = function(arr, value) + for idx, key in ipairs(arr) do + if key == value then + return true + end + end + return false +end + SLASH_CLIQUE1 = "/clique" SlashCmdList["CLIQUE"] = function(msg, editbox) - if SpellBookFrame:IsVisible() then - CliqueConfig:ShowWithSpellBook() + local profile = (msg or ""):match("^profile (.+)$") + if profile then + if InCombatLockdown() then + addon:Printf("Cannot change profiles while in combat lockdown") + else + local availableProfiles = addon.db:GetProfiles({}) + if contains(availableProfiles, profile) then + addon:Printf("Switching to profile '%s'", profile) + addon.db:SetProfile(profile) + else + addon:Printf("Cannot find profile '%s'", profile) + end + end else - ShowUIPanel(CliqueConfig) + if SpellBookFrame:IsVisible() then + CliqueConfig:ShowWithSpellBook() + else + ShowUIPanel(CliqueConfig) + end end end -- 1.7.9.5