diff --git a/Clique.lua b/Clique.lua index 57f66d7..5405744 100644 --- a/Clique.lua +++ b/Clique.lua @@ -37,7 +37,7 @@ function Clique:Enable() [L.CLICKSET_OOC] = {}, } } - + self.db = self:InitializeDB("CliqueDB", self.defaults) self.profile = self.db.profile @@ -59,6 +59,33 @@ function Clique:Enable() Clique:OptionsOnLoad() Clique:EnableFrames() + -- Define a state header for forms + self.stateheader = CreateFrame("Frame", "CliqueStateHeader", UIParent, "SecureStateDriverTemplate") + self.stateheader:SetAttribute("statemap-stance-0", "s0") + self.stateheader:SetAttribute("statemap-stance-1", "s1") + self.stateheader:SetAttribute("statemap-stance-2", "s2") + self.stateheader:SetAttribute("statemap-stance-3", "s3") + self.stateheader:SetAttribute("statemap-stance-4", "s4") + self.stateheader:SetAttribute("statemap-stance-5", "s5") + + --PlayerFrame:SetAttribute("shift-statebutton1", "s0:s0;s1:s1;s2:s2;s3:s3;s4:s4;s5:s5") +--[[ + PlayerFrame:SetAttribute("shift-unit-s1", "player") + PlayerFrame:SetAttribute("shift-type-s1", "spell") + PlayerFrame:SetAttribute("shift-spell-s1", "Enrage") + + PlayerFrame:SetAttribute("shift-unit1", "player") + PlayerFrame:SetAttribute("shift-type1", "spell") + PlayerFrame:SetAttribute("shift-spell1", "Rejuvenation") + + PlayerFrame:SetAttribute("alt-type1", "spell") + PlayerFrame:SetAttribute("alt-spell1", "Attack") +--]] + + -- Register for LEARNED_SPELL_IN_TAB + self:RegisterEvent("LEARNED_SPELL_IN_TAB") + self:LEARNED_SPELL_IN_TAB() + -- Run the OOC script if we need to Clique:CombatUnlock() @@ -72,6 +99,36 @@ function Clique:Enable() hooksecurefunc("CreateFrame", raidFunc) end +function Clique:LEARNED_SPELL_IN_TAB() + local forms = { + [L.DIRE_BEAR_FORM] = L.CLICKSET_BEARFORM, + [L.BEAR_FORM] = L.CLICKSET_BEARFORM, + [L.AQUATIC_FORM] = L.CLICKSET_AQUATICFORM, + [L.CAT_FORM] = L.CLICKSET_CATFORM, + [L.TRAVEL_FORM] = L.CLICKSET_TRAVELFORM, + [L.MOONKIN_FORM] = L.CLICKSET_MOONKINFORM, + [L.TREEOFLIFE] = L.CLICKSET_TREEOFLIFE, + [L.STEALTH] = L.CLICKSET_STEALTHED, + [L.BATTLESTANCE] = L.CLICKSET_BATTLESTANCE, + [L.DEFENSIVESTANCE] = L.CLICKSET_DEFENSIVESTANCE, + [L.BERSERKERSTANCE] = L.CLICKSET_BERSERKERSTANCE, + [L.SHADOWFORM] = L.CLICKSET_SHADOWFORM, + } + self.forms = forms + local profile = self.defaults.profile + + local offset,num = select(3, GetSpellTabInfo(GetNumSpellTabs())) + local num = num + offset + + for i=1,num do + local name = GetSpellName(i, BOOKTYPE_SPELL) + if forms[name] then + profile[name] = profile[name] or {} + self.profile[name] = self.profile[name] or {} + end + end +end + function Clique:EnableFrames() local tbl = { PlayerFrame, @@ -210,7 +267,6 @@ function Clique:RegisterFrame(frame) end function Clique:ProfileChanged(new) - for name,set in pairs(self.profile) do for modifier,entry in pairs(set) do self:DeleteAction(entry) @@ -225,8 +281,6 @@ function Clique:ProfileChanged(new) CliqueDropDownProfile:Hide() CliqueDropDownProfile:Show() - self:Print("Profile changed to '%s'", new) - for frame in pairs(ClickCastFrames) do self:RegisterFrame(frame) end diff --git a/CliqueOptions.lua b/CliqueOptions.lua index 7d5f278..8e1bac9 100644 --- a/CliqueOptions.lua +++ b/CliqueOptions.lua @@ -1010,12 +1010,22 @@ function Clique:DropDownProfile_Initialize() func = click_func } UIDropDownMenu_AddButton(info) + + info = { + text = "Delete Profile", + value = -2, + func = click_func + } + UIDropDownMenu_AddButton(info) end function Clique:DropDownProfile_OnClick() if this.value == -1 then StaticPopup_Show("CLIQUE_NEW_PROFILE") return + elseif this.value == -2 then + StaticPopup_Show("CLIQUE_DELETE_PROFILE") + return end UIDropDownMenu_SetSelectedValue(CliqueDropDownProfile, this.value) @@ -1273,3 +1283,50 @@ StaticPopupDialogs["CLIQUE_NEW_PROFILE"] = { ClearCursor(); end } + +StaticPopupDialogs["CLIQUE_DELETE_PROFILE"] = { + text = TEXT("Enter the name of a profile you'd like to delete"), + button1 = TEXT(OKAY), + button2 = TEXT(CANCEL), + OnAccept = function() + Clique:DeleteProfile(getglobal(this:GetName().."EditBox"):GetText()) + Clique:DropDownProfile_OnShow() + end, + timeout = 0, + whileDead = 1, + exclusive = 1, + showAlert = 1, + hideOnEscape = 1, + hasEditBox = 1, + maxLetters = 32, + OnShow = function() + getglobal(this:GetName().."Button1"):Disable(); + getglobal(this:GetName().."EditBox"):SetFocus(); + end, + OnHide = function() + if ( ChatFrameEditBox:IsVisible() ) then + ChatFrameEditBox:SetFocus(); + end + getglobal(this:GetName().."EditBox"):SetText(""); + end, + EditBoxOnEnterPressed = function() + if ( getglobal(this:GetParent():GetName().."Button1"):IsEnabled() == 1 ) then + Clique:DeleteProfile(this:GetText()) + Clique:DropDownProfile_OnShow() + this:GetParent():Hide(); + end + end, + EditBoxOnTextChanged = function () + local editBox = getglobal(this:GetParent():GetName().."EditBox"); + local txt = editBox:GetText() + if Clique.db.profiles[txt] then + getglobal(this:GetParent():GetName().."Button1"):Enable(); + else + getglobal(this:GetParent():GetName().."Button1"):Disable(); + end + end, + EditBoxOnEscapePressed = function() + this:GetParent():Hide(); + ClearCursor(); + end +} diff --git a/Localization.en.lua b/Localization.en.lua index 91b0903..05d6072 100644 --- a/Localization.en.lua +++ b/Localization.en.lua @@ -16,6 +16,30 @@ local L = Clique.Locals L.CLICKSET_HARMFUL = "Harmful actions" L.CLICKSET_HELPFUL = "Helpful actions" L.CLICKSET_OOC = "Out of Combat" + L.CLICKSET_BEARFORM = "Bear Form" + L.CLICKSET_CATFORM = "Cat Form" + L.CLICKSET_AQUATICFORM = "Aquatic Form" + L.CLICKSET_TRAVELFORM = "Travel Form" + L.CLICKSET_MOONKINFORM = "Moonkin Form" + L.CLICKSET_TREEOFLIFE = "Tree of Life Form" + L.CLICKSET_SHADOWFORM = "Shadowform" + L.CLICKSET_STEALTHED = "Stealthed" + L.CLICKSET_BATTLESTANCE = "Battle Stance" + L.CLICKSET_DEFENSIVESTANCE = "Defensive Stance" + L.CLICKSET_BERSERKERSTANCE = "Berserker Stance" + + L.BEAR_FORM = "Bear Form" + L.DIRE_BEAR_FORM = "Dire Bear Form" + L.CAT_FORM = "Cat Form" + L.AQUATIC_FORM = "Aquatic Form" + L.TRAVEL_FORM = "Travel Form" + L.TREEOFLIFE = "Tree of Life" + L.MOONKIN_FORM = "Moonkin Form" + L.STEALTH = "Stealth" + L.SHADOWFORM = "Shadowform" + L.BATTLESTANCE = "Battle Stance" + L.DEFENSIVESTANCE = "Defensive Stance" + L.BERSERKERSTANCE = "Berserker Stance" L.BINDING_NOT_DEFINED = "Binding not defined"