From 256890528dc5f3dcf936106d1fb585f27ba04a51 Mon Sep 17 00:00:00 2001 From: Jim Whitehead Date: Sat, 26 Jul 2014 17:10:21 +0200 Subject: [PATCH] Updates for WoD - Handle 1nil change for Region:IsEnabled() - Update TOC version --- AddonCore.lua | 15 +++++++++++++++ BindConfig.lua | 2 +- Clique.toc | 2 +- Clique.xml | 2 +- OptionsPanel.lua | 15 ++++++++------- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/AddonCore.lua b/AddonCore.lua index a765133..6de3696 100755 --- a/AddonCore.lua +++ b/AddonCore.lua @@ -52,6 +52,21 @@ if EMERGENCY_DEBUG then end --[[------------------------------------------------------------------------- +-- API compatibility support +-------------------------------------------------------------------------]]-- + +-- Returns true if the API value is true-ish (handles old 1/nil returns) +function addon:APIIsTrue(val, ...) + if type(val) == "boolean" then + return val + elseif type(val) == "number" then + return val == 1 + else + return false + end +end + +--[[------------------------------------------------------------------------- -- Print/Printf support -------------------------------------------------------------------------]]-- diff --git a/BindConfig.lua b/BindConfig.lua index 988de8c..d08eb07 100755 --- a/BindConfig.lua +++ b/BindConfig.lua @@ -148,7 +148,7 @@ function CliqueConfig:EnableSpellbookButtons() if self.spellbookButtons then for idx, button in ipairs(self.spellbookButtons) do - if enabled and button.spellbutton:IsEnabled() == 1 then + if enabled and addon:APIIsTrue(button.spellbutton:IsEnabled()) then button:Show() else button:Hide() diff --git a/Clique.toc b/Clique.toc index cafc65b..d7fa293 100755 --- a/Clique.toc +++ b/Clique.toc @@ -1,4 +1,4 @@ -## Interface: 50400 +## Interface: 60000 ## Title: Clique ## Author: Cladhaire ## Version: @project-version@ diff --git a/Clique.xml b/Clique.xml index cde147d..4b93364 100755 --- a/Clique.xml +++ b/Clique.xml @@ -88,7 +88,7 @@ local parent = self:GetParent() - if parent:IsEnabled() == 1 then + if Clique:APIIsTrue(parent:IsEnabled()) then SpellButton_OnEnter(parent) else self:GetHighlightTexture():Hide() diff --git a/OptionsPanel.lua b/OptionsPanel.lua index 5bf9dba..c692b6e 100755 --- a/OptionsPanel.lua +++ b/OptionsPanel.lua @@ -159,13 +159,14 @@ StaticPopupDialogs["CLIQUE_NEW_PROFILE"] = { _G[self:GetName().."EditBox"]:SetFocus(); end, EditBoxOnEnterPressed = function(self) - if (_G[self:GetParent():GetName().."Button1"]:IsEnabled() == 1) then - local base = self:GetParent():GetName() - local editbox = _G[base .. "EditBox"] - local profileName = editbox:GetText() - addon.db:SetProfile(profileName) - end - self:GetParent():Hide(); + local button = _G[self:GetParent():GetName().."Button1"] + if addon:APIIsTrue(button:IsEnabled()) then + local base = self:GetParent():GetName() + local editbox = _G[base .. "EditBox"] + local profileName = editbox:GetText() + addon.db:SetProfile(profileName) + end + self:GetParent():Hide(); end, EditBoxOnTextChanged = function (self) local editBox = _G[self:GetParent():GetName().."EditBox"]; -- 1.7.9.5