From 7c389ec0d984ad7e48ed313ccb832f52ccd8364c Mon Sep 17 00:00:00 2001 From: Ahmil Jilani Date: Fri, 4 Nov 2011 15:46:00 -0400 Subject: [PATCH] 2.2 --- SuperDuperMacro/SDM-Icon.tga | Bin 0 -> 16428 bytes SuperDuperMacro/SuperDuperMacro.lua | 532 ---------- SuperDuperMacro/SuperDuperMacro.toc | 7 +- SuperDuperMacro/SuperDuperMacro.xml | 1337 ------------------------ SuperDuperMacro/SuperDuperMacro_Core.lua | 564 +++++++++++ SuperDuperMacro/SuperDuperMacro_Frames.lua | 97 ++ SuperDuperMacro/SuperDuperMacro_Frames.xml | 1338 +++++++++++++++++++++++++ SuperDuperMacro/SuperDuperMacro_Interface.lua | 348 +++++-- SuperDuperMacro/SuperDuperMacro_Sharing.lua | 4 +- SuperDuperMacro/sdm Readme.txt | 7 + 10 files changed, 2250 insertions(+), 1984 deletions(-) create mode 100644 SuperDuperMacro/SDM-Icon.tga delete mode 100644 SuperDuperMacro/SuperDuperMacro.lua delete mode 100644 SuperDuperMacro/SuperDuperMacro.xml create mode 100644 SuperDuperMacro/SuperDuperMacro_Core.lua create mode 100644 SuperDuperMacro/SuperDuperMacro_Frames.lua create mode 100644 SuperDuperMacro/SuperDuperMacro_Frames.xml diff --git a/SuperDuperMacro/SDM-Icon.tga b/SuperDuperMacro/SDM-Icon.tga new file mode 100644 index 0000000000000000000000000000000000000000..17dbeabc412ec4969a8149054904c1391033a24e GIT binary patch literal 16428 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 S!-odHjt#qe8GJn*mH!5LQ*jgk literal 0 HcmV?d00001 diff --git a/SuperDuperMacro/SuperDuperMacro.lua b/SuperDuperMacro/SuperDuperMacro.lua deleted file mode 100644 index 3f128aa..0000000 --- a/SuperDuperMacro/SuperDuperMacro.lua +++ /dev/null @@ -1,532 +0,0 @@ -sdm_printPrefix = "|cffff7700Super Duper Macro|r - " -sdm_countUpdateMacrosEvents=0 -sdm_validChars = {1,2,3,4,5,6,7,8,11,12,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255} -sdm_thisChar = {name=UnitName("player"), realm=GetRealmName()} -sdm_doAfterCombat={} --a collection of strings that will be run as scripts when combat ends - -function sdm_SlashHandler(command) - if command=="" then - if sdm_mainFrame:IsShown() then - sdm_Quit() - else - sdm_mainFrame:Show() - end - elseif command:sub(1,4):lower()=="run " then - sdm_RunScript(command:sub(5)) - else - print(sdm_printPrefix.."SDM did not recognize the command \""..command.."\"") - end -end -SlashCmdList["SUPERDUPERMACRO"] = sdm_SlashHandler; -SLASH_SUPERDUPERMACRO1 = "/sdm"; - -sdm_eventFrame = CreateFrame("Frame") -sdm_eventFrame:RegisterEvent("VARIABLES_LOADED") -sdm_eventFrame:RegisterEvent("UPDATE_MACROS") -sdm_eventFrame:RegisterEvent("ADDON_LOADED") -sdm_eventFrame:RegisterEvent("CHAT_MSG_ADDON") -sdm_eventFrame:SetScript("OnEvent", function (self, event, ...) - if event=="VARIABLES_LOADED" then - local oldVersion = sdm_version - sdm_version=GetAddOnMetadata("SuperDuperMacro", "Version") --the version of this addon - sdm_eventFrame:UnregisterEvent("VARIABLES_LOADED") - if (not sdm_macros) then - sdm_macros={} --type tokens: "b": button macro. "f": floating macro. "s": scripts. "c": containers (folders) - elseif sdm_CompareVersions(oldVersion,"1.6.1")==2 then - if sdm_CompareVersions(oldVersion,"1.6")==2 then - if sdm_CompareVersions(oldVersion,"1.3")==2 then - --when updating from before 1.3: - local oldMacros=sdm_macros - sdm_macros={} - local ID=1 - for i,v in ipairs(oldMacros) do - sdm_macros[i]={type=v[1], name=v[2], text=v[3]} - if v[4] then - sdm_macros[i].character={name=v[4], server=v[5]} - end - if v[1]=="b" then - sdm_macros[i].ID=ID - ID=ID+1 - end - end - end - --when updating from before 1.6: - local attempt, found - for i,v in pairs(sdm_macros) do - if (not v.ID) then - attempt = 0 - while true do --keep going until we find an unused ID - found = nil - for _,v in pairs(sdm_macros) do - if v.ID==attempt then - found=1 - break - end - end - if not found then - break - end - attempt = attempt+1 - end - v.ID=attempt - end - if v.character then - v.character.realm=v.character.server - v.character.server=nil - end - v.icon=1 - if v.hideName then - v.buttonName=" " - v.hideName=nil - end - if sdm_ContainsIllegalChars(v.name) then - v.name = ""..v.ID - elseif sdm_DoesNameConflict(v.name, v.type, v.character, i) then - v.name = v.name..""..v.ID - end - end - end - --when updating from before 1.6.1: - for i,v in pairs(sdm_macros) do - if v.buttonName=="" then - v.buttonName=" " - end - end - end - --Saving strips away numeric keys. Now we have to put the macros back into their proper indices. - local savedMacros = sdm_macros - sdm_macros = {} - for _,v in pairs(savedMacros) do - sdm_macros[v.ID]=v - end - if sdm_mainContents==nil then - sdm_ResetContainers() - end - sdm_iconSize=sdm_iconSize or 36 - if not sdm_listFilters then - sdm_listFilters={b=true, f=true, s=true, global=true} - sdm_listFilters["true"]=true - sdm_listFilters["false"]=true - end - sdm_mainFrame_iconSizeSlider:SetValue(sdm_iconSize) - sdm_mainFrame_iconSizeSlider:SetScript("OnValueChanged", function(self) sdm_iconSize = self:GetValue() sdm_UpdateList() end) - sdm_SelectItem(nil) --We want to start with no macro selected - elseif event=="UPDATE_MACROS" then - sdm_countUpdateMacrosEvents=sdm_countUpdateMacrosEvents+1 - if sdm_countUpdateMacrosEvents==2 then - sdm_eventFrame:UnregisterEvent("UPDATE_MACROS") - local killOnSight = {} - local macrosToDelete = {} - local iIsPerCharacter=false - local thisID, mTab - for i=1,54 do --Check each macro to see if it's been orphaned by a previous installation of SDM. - if i==37 then iIsPerCharacter=true end - thisID = sdm_GetSdmID(i) - mTab = sdm_macros[thisID] - if thisID then --if the macro was created by SDM... - if killOnSight[thisID] then --if this ID is marked as kill-on-sight, kill it. - table.insert(macrosToDelete, i) - elseif (not mTab) or mTab.type~="b" or (not sdm_UsedByThisChar(mTab)) then --if this ID is not in use by this character as a button macro, kill it and mark this ID as KoS - table.insert(macrosToDelete, i) - killOnSight[thisID]=1 - elseif (mTab.character~=nil)~=iIsPerCharacter then --if the macro is in the wrong spot based on perCharacter, kill it, but give it a chance to find one in the right spot. - table.insert(macrosToDelete, i) - else --This macro is good and should be here. Kill any duplicates. - killOnSight[thisID]=1 - end - end - end - for i=getn(macrosToDelete),1,-1 do - print(sdm_printPrefix.."Deleting extraneous macro "..macrosToDelete[i]..": "..GetMacroInfo(macrosToDelete[i])) - DeleteMacro(macrosToDelete[i]) - end - for i,v in pairs(sdm_macros) do - if sdm_UsedByThisChar(sdm_macros[i]) then - sdm_SetUpMacro(sdm_macros[i]) - end - end - end - elseif event=="ADDON_LOADED" then - local addonName = ...; - if addonName=="Blizzard_MacroUI" then - sdm_DefaultMacroFrameLoaded() - end - elseif event=="PLAYER_REGEN_ENABLED" then - sdm_eventFrame:UnregisterEvent("PLAYER_REGEN_ENABLED") - for _,luaText in ipairs(sdm_doAfterCombat) do - RunScript(luaText) - end - sdm_doAfterCombat={} - print(sdm_printPrefix.."Your macros are now up to date.") - elseif event=="CHAT_MSG_ADDON" then - sdm_InterpretAddonMessage(...) - end -end) - -function sdm_MakeMacroFrame(name, text) - sdm_DoOrQueue("local temp = getglobal("..sdm_Stringer(name)..") or CreateFrame(\"Button\", "..sdm_Stringer(name)..", nil, \"SecureActionButtonTemplate\")\ - temp:SetAttribute(\'type\', \'macro\')\ - temp:SetAttribute(\'macrotext\', "..sdm_Stringer(text)..")") - if string.len(text)>1023 then print(sdm_printPrefix.."The following line is "..(string.len(text)-1023).." characters too long:\n"..text) end -end - -function sdm_MakeBlizzardMacro(ID, name, icon, text, perCharacter) - sdm_DoOrQueue("local macroIndex = sdm_GetMacroIndex("..sdm_Stringer(ID)..")\ - if macroIndex then\ - EditMacro(macroIndex, "..sdm_Stringer(name)..", "..sdm_Stringer(icon)..", "..sdm_Stringer(text)..", 1, "..sdm_Stringer(perCharacter)..")\ - else\ - CreateMacro("..sdm_Stringer(name)..", "..sdm_Stringer(icon or 1)..", "..sdm_Stringer(text)..", "..sdm_Stringer(perCharacter)..", 1)\ - end") -end - -function sdm_GetSdmID(macroIndex) - local thisMacroText=GetMacroBody(macroIndex) - if thisMacroText and thisMacroText:sub(1,4)=="#sdm" then - return sdm_charsToNum(thisMacroText:sub(5,thisMacroText:find("\n")-1)) - else - return nil - end -end - -function sdm_GetMacroIndex(sdmID) - for i=1,54 do - if sdm_GetSdmID(i)==sdmID then - return i - end - end - return nil -end - -function sdm_GetLinkText(nextName) - return "/click [btn:5]"..nextName.." Button5;[btn:4]"..nextName.." Button4;[btn:3]"..nextName.." MiddleButton;[btn:2]"..nextName.." RightButton;"..nextName -end - -function sdm_SetUpMacro(mTab) - local type = mTab.type - if type~="b" and type~="f" then - return - end - local text = mTab.text - local perCharacter = mTab.character~=nil - local ID = mTab.ID - local icon = mTab.icon - local charLimit = 255 - if type=="b" then - text="#sdm"..sdm_numToChars(ID).."\n"..text - end - local nextFrameName = "sdh"..sdm_numToChars(ID) - local frameText - if text:len()<=charLimit then - frameText = text - else - frameText = "" - local linkText = "\n"..sdm_GetLinkText(nextFrameName) - for line in text:gmatch("[^\r\n]+") do - if line~="" then - if frameText~="" then --if this is not the first line of the frame, we need to add a carriage return before it. - line="\n"..line - end - if frameText:len()+line:len()+linkText:len() > charLimit then --adding this line would be too much, so just add the link and be done with it. (note that this line does NOT get removed from the master text) - frameText = frameText..linkText - break - end - frameText = frameText..line - end - text=text:sub((text:find("\n") or text:len())+1) --remove the line from the text - end - end - sdm_SetUpMacroFrames(nextFrameName, text, 1) - if type=="b" then - sdm_MakeBlizzardMacro(ID, (mTab.buttonName or mTab.name), icon, frameText, perCharacter) - sdm_MakeMacroFrame("sdb_"..mTab.name, frameText) - elseif type=="f" then - sdm_MakeMacroFrame("sdf_"..mTab.name, frameText) - end -end - -function sdm_SetUpMacroFrames(clickerName, text, currentLayer) --returns the frame to be clicked - local currentFrame=1 - local frameText="" - local nextLayerText="" - for line in text:gmatch("[^\r\n]+") do - if line~="" then - if frameText~="" then --if this is not the first line of the frame, we need to add a carriage return before it. - line="\n"..line - end - if (frameText:len()+line:len() > 1023) then --adding this line would be too much, so finish this frame and move on to the next. - sdm_MakeMacroFrame(clickerName.."_"..currentLayer.."_"..currentFrame, frameText) - if nextLayerText~="" then nextLayerText= nextLayerText.."\n" end - nextLayerText = nextLayerText..sdm_GetLinkText(clickerName.."_"..currentLayer.."_"..currentFrame) - frameText = "" - currentFrame = currentFrame+1 - end - frameText = frameText..line - end - text=text:sub((text:find("\n") or text:len())+1) --remove the line from the text - end - if currentFrame==1 then - return sdm_MakeMacroFrame(clickerName, frameText) - else - sdm_MakeMacroFrame(clickerName.."_"..currentLayer.."_"..currentFrame, frameText) --repeated from above; just finishing off this frame - nextLayerText = nextLayerText.."\n"..sdm_GetLinkText(clickerName.."_"..currentLayer.."_"..currentFrame) - return sdm_SetUpMacroFrames(clickerName, nextLayerText, currentLayer+1) - end -end - -function sdm_CreateCancelButtonPressed() - sdm_newFrame:Hide() - if sdm_receiving then - sdm_CancelReceive() - end -end - -function sdm_DoOrQueue(luaText) --If player is not in combat, runs the command. Otherwise, queues it up to be executed when combat is dropped. - if InCombatLockdown() then - sdm_eventFrame:RegisterEvent("PLAYER_REGEN_ENABLED") - print(sdm_printPrefix.."Changes to macros will not take effect until combat ends.") - table.insert(sdm_doAfterCombat, luaText) - else - RunScript(luaText) - end -end - -function sdm_Stringer(var) --converts a variable to a string for purposes of putting it in a string for RunScript(). Strings are formatted as quoted strings, other vars are converted to strings. - if type(var)=="string" then - return string.format("%q", var) - else - return tostring(var) - end -end - -function sdm_CompareVersions(firstString, secondString) --returns 1 if the first is bigger, 2 if the second is bigger, and 0 if they are equal. - local strings = {firstString, secondString} - local numbers = {} - while 1 do - for i=1, 2 do - if (not strings[i]) then strings[i]="0" end - local indexOfPeriod=(strings[i]):find("%.") - if (not indexOfPeriod) then - numbers[i]=strings[i] - strings[i]=nil - else - numbers[i]=strings[i]:sub(1, indexOfPeriod-1) - strings[i] = strings[i]:sub(indexOfPeriod+1) - end - numbers[i] = tonumber(numbers[i]) - end - if numbers[1] > numbers[2] then - return 1 - elseif numbers[2] > numbers[1] then - return 2 - elseif (not strings[1]) and (not strings[2]) then - return 0 - end - end -end - -function sdm_Edit(mTab, text) - mTab.text=text - sdm_SetUpMacro(mTab) - sdm_mainFrame_saveButton:Disable() -end - -function sdm_CheckCreationSafety(type, name, character) --returns the mTab of the new macro, or nil if creation failed - if name=="" then - print(sdm_printPrefix.."Invalid name") - return false - end - if (type=="b" or type=="f") and sdm_ContainsIllegalChars(name, true) then - return false - end - if (not character) and GetMacroInfo(36) then - print(sdm_printPrefix.."You already have 36 global macros.") - return false - elseif character and character.name==sdm_thisChar.name and character.realm==sdm_thisChar.realm and GetMacroInfo(54) then - print(sdm_printPrefix.."You already have 18 character-specific macros.") - return false - end - local conflict = sdm_DoesNameConflict(name, type, character, nil, true) - if conflict then - return false - end - return true -end - -function sdm_GetEmptySlot() -- returns the lowest unused index in sdm_macros - local result = 0 - while sdm_macros[result] do --keep going until we find an empty slot - result = result+1 - end - return result -end - -function sdm_CreateNew(type, name, character) --returns the mTab of the new macro - local mTab = {} - mTab.ID = sdm_GetEmptySlot() - while sdm_macros[mTab.ID] do --keep going until we find an empty slot - mTab.ID = mTab.ID+1 - end - sdm_macros[mTab.ID]=mTab - mTab.type=type - mTab.name=name - if type=="c" then - mTab.open = true - mTab.contents = {} - else - mTab.icon=1 - if sdm_receiving and sdm_receiving.text then - mTab.text=sdm_receiving.text - mTab.icon=sdm_receiving.icon - SendAddonMessage("SDM recDone", "", "WHISPER", sdm_receiving.playerName) - sdm_EndReceiving("|cff44ff00Saved|r") - else - if type=="s" then - mTab.text="-- Enter lua commands here." - elseif type=="b" or type=="f" then - mTab.text="# Enter macro text here." - else --this shouldn't happen - mTab.text="" - end - end - mTab.character=character - sdm_SetUpMacro(mTab) - end - sdm_ChangeContainer(mTab, nil) - return mTab -end - -function sdm_UpgradeMacro() -- Upgrades the currently selected standard macro to a Super Duper macro - if InCombatLockdown() then - print(sdm_printPrefix.."You can't upgrade a macro during combat.") - return - end - local index = MacroFrame.selectedMacro - if index==nil then - print(sdm_printPrefix.."You must select a standard macro first.") - return - end - local name, texture = GetMacroInfo(index) - local character - if index > 36 then - character = sdm_thisChar - end - local safe = sdm_CheckCreationSafety("b", name, character) - if not safe then - return -- the creation failed - end - MacroSaveButton:Click() - local body = GetMacroBody(index) - EditMacro(index, nil, nil, "#sdm"..sdm_numToChars(sdm_GetEmptySlot()).."\n#placeholder") -- let SDM know that this is the macro to edit - local iconIndex = 1 - for iii = 1,GetNumMacroIcons() do - if GetMacroIconInfo(iii) == texture then -- find out if there's a more efficient way of getting this. This must be done AFTER the macro body is cleared, or the question mark could show up as something else. - iconIndex = iii - break - end - end - local newMacro = sdm_CreateNew("b", name, character) - newMacro.icon = iconIndex - sdm_Edit(newMacro, body) - MacroFrame_linkToSDM:Click() -- show the SDM frame - sdm_SelectItem(newMacro.ID) -- select the newly upgraded macro - MacroFrame.selectedMacro = nil -- deselect the macro in the standard macro frame -end - -function sdm_RunScript(name) - local luaText = nil - for i,v in pairs(sdm_macros) do - if v.type=="s" and v.name==name and sdm_UsedByThisChar(v) then - luaText=v.text - break - end - end - if luaText then - RunScript(luaText) - else - print(sdm_printPrefix.."SDM could not find a script named \""..name.."\".") - end -end - -function sdm_DoesNameConflict(name, type, char, ignoring, printWarning) --returns a conflict if we find a macro of the same type and name that can be seen for a given character. If no character is passed, we it's assumed to be global. If we are passed , we will skip that particular macro index while checking. - for i,v in pairs(sdm_macros) do - if v.type~="c" and i~=ignoring and v.type==type and v.name==name and ((not char) or (not sdm_macros[i].character) or (char.name==sdm_macros[i].character.name and char.realm==sdm_macros[i].character.realm)) then --If they're the same name and type, we can only return false if they're both specific to different characters. - if printWarning then - print(sdm_printPrefix.."You may not have more than one of the same type with the same name (unless they are specific to different characters).") - end - return i - end - end -end - -function sdm_ContainsIllegalChars(s, printWarning) --s is the string to evaluate, printWarning is a boolean - local b, found - for i=1,s:len() do - b = s:byte(i) - found = false - for _,v in ipairs(sdm_validChars) do - if b==v then - found=true - break - end - end - if not found then - local badChar = s:sub(i,i) - if printWarning then - print(sdm_printPrefix.."You may not use the character \""..badChar.."\" in the name. If this is a button macro, you might be able to use that character in the name displayed on the button (click \"Change Name/Icon\").") - end - return badChar - end - end -end - -function sdm_UsedByThisChar(mTab) --returns true if the macro is global or specific to this character. Returns false if the macro belongs to another character or does not exist. - if not mTab then - return false - end - return (not mTab.character or (mTab.character.name==sdm_thisChar.name and mTab.character.realm==sdm_thisChar.realm)) -end - -function sdm_numToChars(num) --converts a number into a string (with maximum compression) - local base = getn(sdm_validChars) --the counting system we're working in. sdm_validChars[1] is the digit for 0, [2] is the digit for 1, and so on. - local place=0 --the power on the base that you multiply by the digit to get the value (0 is the ones place) - while num >= math.pow(base, place+1) do - place=place+1 - end - local chars="" - local count=0 - local digit - local value - while place>=0 do - digit=base - while digit>0 do - digit=digit-1 - value = digit*math.pow(base, place) - if count+value<=num then - break - end - end - count=count+value - chars=chars..string.format("%c",sdm_validChars[digit+1]) - place=place-1 - end - if count~=num then return nil end --this should never happen - return chars -end - -function sdm_charsToNum(chars) --converts characters back into a number - local base = getn(sdm_validChars) - local num = 0 - local found - for i=1,chars:len() do - found = false - for j,v in ipairs(sdm_validChars) do - if chars:byte(i)==v then - num = num + (j-1)*math.pow(base, (chars:len()-i)) - found = true - break - end - end - if not found then return nil end --this shouldn't happen unless we give bad chars - end - return num -end \ No newline at end of file diff --git a/SuperDuperMacro/SuperDuperMacro.toc b/SuperDuperMacro/SuperDuperMacro.toc index 6d03e67..c7d9217 100644 --- a/SuperDuperMacro/SuperDuperMacro.toc +++ b/SuperDuperMacro/SuperDuperMacro.toc @@ -2,9 +2,10 @@ ## Title : Super Duper Macro ## Notes: Enables creation of incredibly long macros. ## Author: hypehuman -## Version: 2.1 +## Version: 2.2 ## SavedVariables: sdm_version, sdm_listFilters, sdm_iconSize, sdm_mainContents, sdm_macros -SuperDuperMacro.lua +SuperDuperMacro_Core.lua SuperDuperMacro_Interface.lua SuperDuperMacro_Sharing.lua -SuperDuperMacro.xml \ No newline at end of file +SuperDuperMacro_Frames.xml +SuperDuperMacro_Frames.lua \ No newline at end of file diff --git a/SuperDuperMacro/SuperDuperMacro.xml b/SuperDuperMacro/SuperDuperMacro.xml deleted file mode 100644 index ca0fe7f..0000000 --- a/SuperDuperMacro/SuperDuperMacro.xml +++ /dev/null @@ -1,1337 +0,0 @@ - - - - - self.TimeSinceLastUpdate=0 - - sdm_OnUpdate(self, elapsed); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sdm_CharDropdownLoaded(self); - - - - - - - - - - - - - - - - - - - - - - - - - - - sdm_TypeDropdownLoaded(self); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - self:ClearFocus() - - - self:Insert(" ") - - - sdm_mainFrame_saveButton:Disable() - sdm_textChanged=-2 - - - if sdm_textChanged then - sdm_textChanged=sdm_textChanged+1 - if sdm_textChanged>0 then - sdm_mainFrame_saveButton:Enable() - end - end - - - - - - - - - - - - - - - - - - - - - - - - self:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b) - self:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - self:StartMoving(); - self:StopMovingOrSizing(); - self:StopMovingOrSizing(); - - PlaySound "igCharacterInfoOpen" - self:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", 0, -104) - sdm_currentlyPlacing=nil - sdm_UpdateList() - - - PlaySound "igCharacterInfoClose" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - self:SetChecked(1) - _,outline,_,fill,text = self:GetRegions() - outline:SetVertexColor(sdm_GetColor("b")) - fill:SetVertexColor(sdm_GetColor("b")) - text:SetTextColor(sdm_GetColor("b")) - - - self:SetChecked(1) - sdm_newFrame_floatingRadio:SetChecked(nil) - sdm_newFrame_scriptRadio:SetChecked(nil) - - - - - - - - - - - - - - - - - self:SetTextColor(sdm_GetColor("f")) - - - - - - - - _,outline,_,fill,text = self:GetRegions() - outline:SetVertexColor(sdm_GetColor("f")) - fill:SetVertexColor(sdm_GetColor("f")) - text:SetTextColor(sdm_GetColor("f")) - - - sdm_newFrame_buttonRadio:SetChecked(nil) - self:SetChecked(1) - sdm_newFrame_scriptRadio:SetChecked(nil) - - - - - - - - - - - - - - - - - self:SetTextColor(sdm_GetColor("s")) - - - - - - - - _,outline,_,fill,text = self:GetRegions() - outline:SetVertexColor(sdm_GetColor("s")) - fill:SetVertexColor(sdm_GetColor("s")) - text:SetTextColor(sdm_GetColor("s")) - - - sdm_newFrame_buttonRadio:SetChecked(nil) - sdm_newFrame_floatingRadio:SetChecked(nil) - self:SetChecked(1) - - - - - - - - - - - - - - - - - - - - - - - - self:SetChecked(1) - - - self:SetChecked(1) - sdm_newFrame_charspecRadio:SetChecked(nil) - - - - - - - - - - - - - - - - - - - - self:SetChecked(1) - sdm_newFrame_globalRadio:SetChecked(nil) - - - - - - - - - - - - - - - - - - - - - - - - - - - - self:ClearFocus() - - - sdm_newFrame_createButton:Click() - - - - - - - - sdm_mainFrame:StartMoving(); - sdm_mainFrame:StopMovingOrSizing(); - sdm_mainFrame:StopMovingOrSizing(); - - sdm_AddToExclusiveGroup(self, "centerwindows") - - - UIFrameFlashStop(sdm_newFrame_createButton_flash) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - self:ClearFocus() - - - sdm_newFolderFrame_createButton:Click() - - - - - - - - sdm_mainFrame:StartMoving(); - sdm_mainFrame:StopMovingOrSizing(); - sdm_mainFrame:StopMovingOrSizing(); - - sdm_AddToExclusiveGroup(self, "centerwindows") - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - self:ClearFocus() - - - sdm_ChangeIconOkayed() - - - - - - - sdm_AddToExclusiveGroup(self, "centerwindows") - - - sdm_OnShow_changeIconFrame(self, sdm_macros[sdm_currentEdit]) - - - sdm_OnHide_changeIconFrame(self) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - self:SetChecked(1) - - - self:SetChecked(1) - sdm_sendReceiveFrame_sendRaidRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendBattlegroundRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendGuildRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendTargetRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendArbitraryRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendInput:ClearFocus() - - - - - - - - - - - - - - - - - - - - sdm_sendReceiveFrame_sendPartyRadio:SetChecked(nil) - self:SetChecked(1) - sdm_sendReceiveFrame_sendBattlegroundRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendGuildRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendTargetRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendArbitraryRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendInput:ClearFocus() - - - - - - - - - - - - - - - - - - - - sdm_sendReceiveFrame_sendPartyRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendRaidRadio:SetChecked(nil) - self:SetChecked(1) - sdm_sendReceiveFrame_sendGuildRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendTargetRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendArbitraryRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendInput:ClearFocus() - - - - - - - - - - - - - - - - - - - - sdm_sendReceiveFrame_sendPartyRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendRaidRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendBattlegroundRadio:SetChecked(nil) - self:SetChecked(1) - sdm_sendReceiveFrame_sendTargetRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendArbitraryRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendInput:ClearFocus() - - - - - - - - - - - - - - - - - - - - sdm_sendReceiveFrame_sendPartyRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendRaidRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendBattlegroundRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendGuildRadio:SetChecked(nil) - self:SetChecked(1) - sdm_sendReceiveFrame_sendArbitraryRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendInput:ClearFocus() - - - - - - - - - - - - - - - - - - - - sdm_sendReceiveFrame_sendInput:SetFocus() - - - - - - - - - - - - - - - self:ClearFocus() - - - sdm_sendReceiveFrame_sendButton:Click() - - - sdm_sendReceiveFrame_sendPartyRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendRaidRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendBattlegroundRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendGuildRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendTargetRadio:SetChecked(nil) - sdm_sendReceiveFrame_sendArbitraryRadio:SetChecked(1) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - self:SetChecked(1) - - - self:SetChecked(1) - sdm_sendReceiveFrame_receiveArbitraryRadio:SetChecked(nil) - sdm_sendReceiveFrame_receiveInput:ClearFocus() - - - - - - - - - - - - - - - - - - - - sdm_sendReceiveFrame_receiveInput:SetFocus() - - - - - - - - - - - - - - - self:ClearFocus() - - - sdm_sendReceiveFrame_receiveButton:Click() - - - sdm_sendReceiveFrame_receiveTargetRadio:SetChecked(nil) - sdm_sendReceiveFrame_receiveArbitraryRadio:SetChecked(1) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - sdm_mainFrame:StartMoving(); - sdm_mainFrame:StopMovingOrSizing(); - sdm_mainFrame:StopMovingOrSizing(); - - if (not sdm_sending) then - sdm_sendReceiveFrame_sendBar_statusBar:SetValue(0) - sdm_sendReceiveFrame_sendBar_statusBar_text:SetText("") - end - if (not sdm_receiving) then - sdm_sendReceiveFrame_receiveBar_statusBar:SetValue(0) - sdm_sendReceiveFrame_receiveBar_statusBar_text:SetText("") - end - - - - \ No newline at end of file diff --git a/SuperDuperMacro/SuperDuperMacro_Core.lua b/SuperDuperMacro/SuperDuperMacro_Core.lua new file mode 100644 index 0000000..0578bf5 --- /dev/null +++ b/SuperDuperMacro/SuperDuperMacro_Core.lua @@ -0,0 +1,564 @@ +sdm_printPrefix = "|cffff7700Super Duper Macro|r - " +sdm_countUpdateMacrosEvents=0 +sdm_validChars = {1,2,3,4,5,6,7,8,11,12,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255} +sdm_thisChar = {name=UnitName("player"), realm=GetRealmName()} +sdm_doAfterCombat={} --a collection of strings that will be run as scripts when combat ends + +function sdm_SlashHandler(command) + if command=="" then + if sdm_mainFrame:IsShown() then + sdm_Quit() + else + sdm_mainFrame:Show() + end + elseif command:sub(1,4):lower()=="run " then + sdm_RunScript(command:sub(5)) + else + print(sdm_printPrefix.."SDM did not recognize the command \""..command.."\"") + end +end +SlashCmdList["SUPERDUPERMACRO"] = sdm_SlashHandler; +SLASH_SUPERDUPERMACRO1 = "/sdm"; + +sdm_eventFrame = CreateFrame("Frame") +sdm_eventFrame:RegisterEvent("VARIABLES_LOADED") +sdm_eventFrame:RegisterEvent("UPDATE_MACROS") +sdm_eventFrame:RegisterEvent("CHAT_MSG_ADDON") +sdm_eventFrame:SetScript("OnEvent", function (self, event, ...) + if event=="VARIABLES_LOADED" then + local oldVersion = sdm_version + sdm_version=GetAddOnMetadata("SuperDuperMacro", "Version") --the version of this addon + sdm_eventFrame:UnregisterEvent(event) + if (not sdm_macros) then + sdm_macros={} --type tokens: "b": button macro. "f": floating macro. "s": scripts. "c": containers (folders) + elseif sdm_CompareVersions(oldVersion,"2.2")==2 then + if sdm_CompareVersions(oldVersion,"1.6.1")==2 then + if sdm_CompareVersions(oldVersion,"1.6")==2 then -- Hopefully nobody is upgrading from a version this old. If they are, they should download 2.1 and run that once before upgrading to 2.2. + sdm_macros={} + end + --when updating from before 1.6.1: + for i,v in pairs(sdm_macros) do + if v.buttonName=="" then + v.buttonName=" " + end + end + end + --when updating from before 2.2: + for i,v in pairs(sdm_macros) do + if v.character then + v.characters = {v.character} + v.character = nil + end + end + end + --Saving strips away numeric keys. Now we have to put the macros back into their proper indices. + local savedMacros = sdm_macros + sdm_macros = {} + for _,v in pairs(savedMacros) do + sdm_macros[v.ID]=v + end + if sdm_mainContents==nil then + sdm_ResetContainers() + end + sdm_iconSize=sdm_iconSize or 36 + if not sdm_listFilters then + sdm_listFilters={b=true, f=true, s=true, global=true} + sdm_listFilters["true"]=true + sdm_listFilters["false"]=true + end + sdm_mainFrame_iconSizeSlider:SetValue(sdm_iconSize) + sdm_mainFrame_iconSizeSlider:SetScript("OnValueChanged", function(self) sdm_iconSize = self:GetValue() sdm_UpdateList() end) + sdm_SelectItem(nil) --We want to start with no macro selected + elseif event=="UPDATE_MACROS" then + sdm_countUpdateMacrosEvents=sdm_countUpdateMacrosEvents+1 + if sdm_countUpdateMacrosEvents==2 then + sdm_eventFrame:UnregisterEvent(event) + local killOnSight = {} + local macrosToDelete = {} + local iIsPerCharacter=false + local thisID, mTab + for i=1,54 do --Check each macro to see if it's been orphaned by a previous installation of SDM. + if i==37 then iIsPerCharacter=true end + thisID = sdm_GetSdmID(i) + mTab = sdm_macros[thisID] + if thisID then --if the macro was created by SDM... + if killOnSight[thisID] then --if this ID is marked as kill-on-sight, kill it. + table.insert(macrosToDelete, i) + elseif (not mTab) or mTab.type~="b" or (not sdm_UsedByThisChar(mTab)) then --if this ID is not in use by this character as a button macro, kill it and mark this ID as KoS + table.insert(macrosToDelete, i) + killOnSight[thisID]=1 + elseif (mTab.characters~=nil)~=iIsPerCharacter then --if the macro is in the wrong spot based on perCharacter, kill it, but give it a chance to find one in the right spot. + table.insert(macrosToDelete, i) + else --This macro is good and should be here. Kill any duplicates. + killOnSight[thisID]=1 + end + end + end + for i=getn(macrosToDelete),1,-1 do -- we delete in descending order so that the indices don't get messed up while we're deleting, which would cause us to delete the wrong macros + print(sdm_printPrefix.."Deleting extraneous macro "..macrosToDelete[i]..": "..GetMacroInfo(macrosToDelete[i])) + DeleteMacro(macrosToDelete[i]) + end + for i,v in pairs(sdm_macros) do + if sdm_UsedByThisChar(sdm_macros[i]) then + sdm_SetUpMacro(sdm_macros[i]) + end + end + end + elseif event=="ADDON_LOADED" then + local addonName = ...; + if addonName=="Blizzard_MacroUI" then + sdm_eventFrame:UnregisterEvent(event) + sdm_DefaultMacroFrameLoaded() + end + elseif event=="PLAYER_REGEN_ENABLED" then + sdm_eventFrame:UnregisterEvent(event) + for _,luaText in ipairs(sdm_doAfterCombat) do + RunScript(luaText) + end + sdm_doAfterCombat={} + print(sdm_printPrefix.."Your macros are now up to date.") + elseif event=="CHAT_MSG_ADDON" then + sdm_InterpretAddonMessage(...) + end +end) + +function sdm_MakeMacroFrame(name, text) + sdm_DoOrQueue("local temp = getglobal("..sdm_Stringer(name)..") or CreateFrame(\"Button\", "..sdm_Stringer(name)..", nil, \"SecureActionButtonTemplate\")\ + temp:SetAttribute(\'type\', \'macro\')\ + temp:SetAttribute(\'macrotext\', "..sdm_Stringer(text)..")") + if string.len(text)>1023 then print(sdm_printPrefix.."The following line is "..(string.len(text)-1023).." characters too long:\n"..text) end +end + +function sdm_MakeBlizzardMacro(ID, name, icon, text, perCharacter) + sdm_DoOrQueue("local macroIndex = sdm_GetMacroIndex("..sdm_Stringer(ID)..")\ + if macroIndex then\ + EditMacro(macroIndex, "..sdm_Stringer(name)..", "..sdm_Stringer(icon)..", "..sdm_Stringer(text)..", 1, "..sdm_Stringer(perCharacter)..")\ + else\ + CreateMacro("..sdm_Stringer(name)..", "..sdm_Stringer(icon or 1)..", "..sdm_Stringer(text)..", "..sdm_Stringer(perCharacter)..", 1)\ + end") +end + +function sdm_GetSdmID(macroIndex) + local thisMacroText=GetMacroBody(macroIndex) + if thisMacroText and thisMacroText:sub(1,4)=="#sdm" then + return sdm_charsToNum(thisMacroText:sub(5,thisMacroText:find("\n")-1)) + else + return nil + end +end + +function sdm_GetMacroIndex(sdmID) + for i=1,54 do + if sdm_GetSdmID(i)==sdmID then + return i + end + end + return nil +end + +function sdm_GetLinkText(nextName) + return "/click [btn:5]"..nextName.." Button5;[btn:4]"..nextName.." Button4;[btn:3]"..nextName.." MiddleButton;[btn:2]"..nextName.." RightButton;"..nextName +end + +function sdm_SetUpMacro(mTab) + local type = mTab.type + if type~="b" and type~="f" then + return + end + local text = mTab.text + local perCharacter = mTab.characters~=nil + local ID = mTab.ID + local icon = mTab.icon + local charLimit = 255 + if type=="b" then + text="#sdm"..sdm_numToChars(ID).."\n"..text + end + local nextFrameName = "sdh"..sdm_numToChars(ID) + local frameText + if text:len()<=charLimit then + frameText = text + else + frameText = "" + local linkText = "\n"..sdm_GetLinkText(nextFrameName) + for line in text:gmatch("[^\r\n]+") do + if line~="" then + if frameText~="" then --if this is not the first line of the frame, we need to add a carriage return before it. + line="\n"..line + end + if frameText:len()+line:len()+linkText:len() > charLimit then --adding this line would be too much, so just add the link and be done with it. (note that this line does NOT get removed from the master text) + frameText = frameText..linkText + break + end + frameText = frameText..line + end + text=text:sub((text:find("\n") or text:len())+1) --remove the line from the text + end + end + sdm_SetUpMacroFrames(nextFrameName, text, 1) + if type=="b" then + sdm_MakeBlizzardMacro(ID, (mTab.buttonName or mTab.name), icon, frameText, perCharacter) + sdm_MakeMacroFrame("sdb_"..mTab.name, frameText) + elseif type=="f" then + sdm_MakeMacroFrame("sdf_"..mTab.name, frameText) + end +end + +function sdm_UnSetUpMacro(mTab) + if sdm_UsedByThisChar(mTab) and (mTab.type=="b" or mTab.type=="f") then + sdm_DoOrQueue("getglobal("..sdm_Stringer("sd"..mTab.type.."_"..mTab.name).."):SetAttribute(\"type\", nil)") + if mTab.type=="b" then + sdm_DoOrQueue("DeleteMacro(sdm_GetMacroIndex("..sdm_Stringer(mTab.ID).."))") + end + end +end + +function sdm_SetUpMacroFrames(clickerName, text, currentLayer) --returns the frame to be clicked + local currentFrame=1 + local frameText="" + local nextLayerText="" + for line in text:gmatch("[^\r\n]+") do + if line~="" then + if frameText~="" then --if this is not the first line of the frame, we need to add a carriage return before it. + line="\n"..line + end + if (frameText:len()+line:len() > 1023) then --adding this line would be too much, so finish this frame and move on to the next. + sdm_MakeMacroFrame(clickerName.."_"..currentLayer.."_"..currentFrame, frameText) + if nextLayerText~="" then nextLayerText= nextLayerText.."\n" end + nextLayerText = nextLayerText..sdm_GetLinkText(clickerName.."_"..currentLayer.."_"..currentFrame) + frameText = "" + currentFrame = currentFrame+1 + end + frameText = frameText..line + end + text=text:sub((text:find("\n") or text:len())+1) --remove the line from the text + end + if currentFrame==1 then + return sdm_MakeMacroFrame(clickerName, frameText) + else + sdm_MakeMacroFrame(clickerName.."_"..currentLayer.."_"..currentFrame, frameText) --repeated from above; just finishing off this frame + nextLayerText = nextLayerText.."\n"..sdm_GetLinkText(clickerName.."_"..currentLayer.."_"..currentFrame) + return sdm_SetUpMacroFrames(clickerName, nextLayerText, currentLayer+1) + end +end + +function sdm_CreateCancelButtonPressed() + sdm_newFrame:Hide() + if sdm_receiving then + sdm_CancelReceive() + end +end + +function sdm_DoOrQueue(luaText) --If player is not in combat, runs the command. Otherwise, queues it up to be executed when combat is dropped. + if InCombatLockdown() then + sdm_eventFrame:RegisterEvent("PLAYER_REGEN_ENABLED") + print(sdm_printPrefix.."Changes to macros will not take effect until combat ends.") + table.insert(sdm_doAfterCombat, luaText) + else + RunScript(luaText) + end +end + +function sdm_Stringer(var) --converts a variable to a string for purposes of putting it in a string for RunScript(). Strings are formatted as quoted strings, other vars are converted to strings. + if type(var)=="string" then + return string.format("%q", var) + else + return tostring(var) + end +end + +function sdm_CompareVersions(firstString, secondString) --returns 1 if the first is bigger, 2 if the second is bigger, and 0 if they are equal. + local strings = {firstString or '0', secondString or '0'} + local numbers = {} + while 1 do + for i=1, 2 do + if (not strings[i]) then strings[i]="0" end + local indexOfPeriod=(strings[i]):find("%.") + if (not indexOfPeriod) then + numbers[i]=strings[i] + strings[i]=nil + else + numbers[i]=strings[i]:sub(1, indexOfPeriod-1) + strings[i] = strings[i]:sub(indexOfPeriod+1) + end + numbers[i] = tonumber(numbers[i]) + end + if numbers[1] > numbers[2] then + return 1 + elseif numbers[2] > numbers[1] then + return 2 + elseif (not strings[1]) and (not strings[2]) then + return 0 + end + end +end + +function sdm_Edit(mTab, text) + mTab.text=text + sdm_SetUpMacro(mTab) + sdm_mainFrame_saveButton:Disable() +end + +function sdm_CheckCreationSafety(type, name, character) --returns the mTab of the new macro, or nil if creation failed + if name=="" then + print(sdm_printPrefix.."Invalid name") + return false + end + if (type=="b" or type=="f") and sdm_ContainsIllegalChars(name, true) then + return false + end + if (not character) and GetMacroInfo(36) then + print(sdm_printPrefix.."You already have 36 global macros.") + return false + elseif character and character.name==sdm_thisChar.name and character.realm==sdm_thisChar.realm and GetMacroInfo(54) then + print(sdm_printPrefix.."You already have 18 character-specific macros.") + return false + end + local conflict = sdm_DoesNameConflict(name, type, {character}, nil, true) + if conflict then + return false + end + return true +end + +function sdm_GetEmptySlot() -- returns the lowest unused index in sdm_macros + local result = 0 + while sdm_macros[result] do --keep going until we find an empty slot + result = result+1 + end + return result +end + +function sdm_CreateNew(type, name, character) --returns the mTab of the new macro + local mTab = {} + mTab.ID = sdm_GetEmptySlot() + while sdm_macros[mTab.ID] do --keep going until we find an empty slot + mTab.ID = mTab.ID+1 + end + sdm_macros[mTab.ID]=mTab + mTab.type=type + mTab.name=name + if type=="c" then + mTab.open = true + mTab.contents = {} + else + mTab.icon=1 + if sdm_receiving and sdm_receiving.text then + mTab.text=sdm_receiving.text + mTab.icon=sdm_receiving.icon + SendAddonMessage("SDM recDone", "", "WHISPER", sdm_receiving.playerName) + sdm_EndReceiving("|cff44ff00Saved|r") + elseif sdm_saveAsText then + mTab.text = sdm_saveAsText + mTab.icon = sdm_saveAsIcon + sdm_saveAsText = nil + sdm_saveAsIcon = nil + else + if type=="s" then + mTab.text="-- Enter lua commands here." + elseif type=="b" or type=="f" then + mTab.text="# Enter macro text here." + else --this shouldn't happen + mTab.text="" + end + end + if character then + mTab.characters = {character} + end + sdm_SetUpMacro(mTab) + end + sdm_ChangeContainer(mTab, nil) + return mTab +end + +function sdm_UpgradeMacro(index) -- Upgrades the given standard macro to a Super Duper macro + if InCombatLockdown() then + print(sdm_printPrefix.."You can't upgrade a macro during combat.") + return + end + local name = GetMacroInfo(index) + local character + if index > 36 then + character = sdm_thisChar + end + local safe = sdm_CheckCreationSafety("b", name, character) + if not safe then + return -- the creation failed + end + local body = GetMacroBody(index) + EditMacro(index, nil, nil, "#sdm"..sdm_numToChars(sdm_GetEmptySlot()).."\n#placeholder") -- let SDM know that this is the macro to edit + local _, texture = GetMacroInfo(index) -- This must be done AFTER the macro body is edited, or the question mark could show up as something else. + local iconIndex = 1 + for iii = 1,GetNumMacroIcons() do + if GetMacroIconInfo(iii) == texture then + iconIndex = iii + break + end + end + local newMacro = sdm_CreateNew("b", name, character) + newMacro.icon = iconIndex + sdm_Edit(newMacro, body) + return newMacro +end + +-- Converts the given button macro into a standard macro +function sdm_DowngradeMacro(mTab) + if InCombatLockdown() then + print(sdm_printPrefix.."You can't downgrade a macro during combat.") + return + end + if mTab.type ~= "b" then -- only button macros can be downgraded + return + end + local index = sdm_GetMacroIndex(mTab.ID) + -- remove the #sdm header from the standard macro, which also makes it so that sdm_ChangeContainer won't delete the standard macro + EditMacro(index, nil, nil, mTab.text) + sdm_ChangeContainer(mTab, false) -- remove the macro from the SDM database + return index +end + +-- if the mTab is character-specific, adds the given character to it +function sdm_AddCharacter(mTab, character) + if mTab.characters==nil then -- If this is global, it should stay that way. The user should select "Save As" if they want to make it character-specific. + return + end + table.insert(mTab.characters, character) +end + +-- removes the given character from the mTab +function sdm_RemoveCharacter(mTab, character) + if mTab.characters==nil then + return + end + for iii,savedChar in pairs(mTab.characters) do + if savedChar.name==character.name and savedChar.realm==character.realm then + table.remove(mTab.characters, iii) + return + end + end +end + +function sdm_RunScript(name) + local luaText = nil + for i,v in pairs(sdm_macros) do + if v.type=="s" and v.name==name and sdm_UsedByThisChar(v) then + luaText=v.text + break + end + end + if luaText then + RunScript(luaText) + else + print(sdm_printPrefix.."SDM could not find a script named \""..name.."\".") + end +end + +--returns a conflict if we find a macro of the same type and name that can be seen for a given character. If no character is passed, we it's assumed to be global. If we are passed , we will skip that particular macro index while checking. +function sdm_DoesNameConflict(name, type, chars, ignoring, printWarning) + local conflict + for i,v in pairs(sdm_macros) do + if v.type~="c" and i~=ignoring and v.type==type and v.name==name then -- the type and name are the same. Let's see if they are used by the same characters... + conflict = false + if ((not chars) or (not sdm_macros[i].characters)) then -- one or both of them is global, meaning that it is used by all characters. + conflict = true + else + for _,char in pairs(chars) do + if sdm_UsedBy(v,char) then -- they are both specific to the same character + conflict = true + break + end + end + end + if conflict then + if printWarning then + print(sdm_printPrefix.."You may not have more than one of the same type with the same name (unless they are specific to different characters).") + end + return i + end + end + end +end + +function sdm_ContainsIllegalChars(s, printWarning) --s is the string to evaluate, printWarning is a boolean + local b, found + for i=1,s:len() do + b = s:byte(i) + found = false + for _,v in ipairs(sdm_validChars) do + if b==v then + found=true + break + end + end + if not found then + local badChar = s:sub(i,i) + if printWarning then + print(sdm_printPrefix.."You may not use the character \""..badChar.."\" in the name. If this is a button macro, you might be able to use that character in the name displayed on the button (click \"Change Name/Icon\").") + end + return badChar + end + end +end + +function sdm_UsedBy(mTab, char) --returns true if the macro is global or is specific to the given character. Otherwise returns false. + if mTab==nil then + return false + end + if mTab.characters==nil then + return true + end + for _,storedChar in pairs(mTab.characters) do + if storedChar.name==char.name and storedChar.realm==char.realm then + return true + end + end + return false +end + +function sdm_UsedByThisChar(mTab) + return sdm_UsedBy(mTab,sdm_thisChar) +end + +function sdm_numToChars(num) --converts a number into a string (with maximum compression) + local base = getn(sdm_validChars) --the counting system we're working in. sdm_validChars[1] is the digit for 0, [2] is the digit for 1, and so on. + local place=0 --the power on the base that you multiply by the digit to get the value (0 is the ones place) + while num >= math.pow(base, place+1) do + place=place+1 + end + local chars="" + local count=0 + local digit + local value + while place>=0 do + digit=base + while digit>0 do + digit=digit-1 + value = digit*math.pow(base, place) + if count+value<=num then + break + end + end + count=count+value + chars=chars..string.format("%c",sdm_validChars[digit+1]) + place=place-1 + end + if count~=num then return nil end --this should never happen + return chars +end + +function sdm_charsToNum(chars) --converts characters back into a number + local base = getn(sdm_validChars) + local num = 0 + local found + for i=1,chars:len() do + found = false + for j,v in ipairs(sdm_validChars) do + if chars:byte(i)==v then + num = num + (j-1)*math.pow(base, (chars:len()-i)) + found = true + break + end + end + if not found then return nil end --this shouldn't happen unless we give bad chars + end + return num +end \ No newline at end of file diff --git a/SuperDuperMacro/SuperDuperMacro_Frames.lua b/SuperDuperMacro/SuperDuperMacro_Frames.lua new file mode 100644 index 0000000..7394c1d --- /dev/null +++ b/SuperDuperMacro/SuperDuperMacro_Frames.lua @@ -0,0 +1,97 @@ +local f + +f = CreateFrame("Button", "$parent_saveAsButton", sdm_mainFrame, "UIPanelButtonTemplate") +f:SetPoint("TOPLEFT", sdm_mainFrame_saveButton, "BOTTOMLEFT") +f:SetPoint("RIGHT", sdm_mainFrame_saveButton) +f:SetHeight(sdm_mainFrame_saveButton:GetHeight()) +f:SetText("Save As...") +f:SetScript("OnClick", sdm_SaveAsButtonClicked) +sdm_SetTooltip(f, "Saves a copy of the current item. You may change the type, or make it global or character-specific.") + +f = CreateFrame("Button", "$parent_downgradeButton", sdm_mainFrame, "UIPanelButtonTemplate") +f:SetPoint("TOPLEFT", sdm_mainFrame_deleteButton, "BOTTOMLEFT") +f:SetPoint("RIGHT", sdm_mainFrame_deleteButton) +f:SetHeight(sdm_mainFrame_deleteButton:GetHeight()) +f:SetText("Downgrade") +f:SetScript("OnClick", sdm_DowngradeButtonClicked) +sdm_SetTooltip(f, "Turns this macro into a default macro. Anything over 255 characters will be lost.") + +f = CreateFrame("Button", "$parent_claimButton", sdm_mainFrame, "UIPanelButtonTemplate") +f:SetPoint("TOPLEFT", sdm_mainFrame_getLinkButton, "BOTTOMLEFT") +f:SetPoint("RIGHT", sdm_mainFrame_getLinkButton) +f:SetHeight(sdm_mainFrame_getLinkButton:GetHeight()) +f:SetText("Claim") +f:SetScript("OnClick", sdm_ClaimButtonClicked) +sdm_SetTooltip(f, "Did you know that character-specific items can belong to multiple characters? Click this button to claim this item for your current character.") + +f = CreateFrame("Button", "$parent_disownButton", sdm_mainFrame, "UIPanelButtonTemplate") +f:SetAllPoints(sdm_mainFrame_claimButton) +f:SetText("Disown") +f:SetScript("OnClick", sdm_DisownButtonClicked) +sdm_SetTooltip(f, "Removes this item from your current character's list. Other characters will still be able to use it.") + +function sdm_CreateDefaultMacroFrameButtons() + local f + + --Create the button that links from the default macro frame to the SDM frame + f = CreateFrame("Button", "$parent_linkToSDM", MacroFrame, "UIPanelButtonTemplate") + f:SetWidth(150) + f:SetHeight(19) + f:SetPoint("TOPLEFT", 68, -14) + f:SetText("Super Duper Macro") + f:SetScript("OnClick", function() + HideUIPanel(MacroFrame) + sdm_mainFrame:Show() + end) + sdm_SetTooltip(f, "Open Super Duper Macro, an advanced macro interface that lets you create longer macros") + + --Create the button that turns a regular macro into a Super Duper macro + f = CreateFrame("Button", "$parent_convertToSuper", MacroFrame, "UIPanelButtonTemplate") + f:SetPoint("TOPLEFT", MacroDeleteButton, "TOPRIGHT") + f:SetPoint("BOTTOMRIGHT", MacroNewButton, "BOTTOMLEFT") + f:SetText("Upgrade! ") + local t = f:CreateTexture() + margin = 0.25 * f:GetHeight() + t:SetPoint("TOPRIGHT", f, "TOPRIGHT", -margin, -margin) + t:SetPoint("BOTTOM", f, "BOTTOM", 0, margin) + t:SetWidth(t:GetHeight()) + t:SetTexture("Interface\\AddOns\\SuperDuperMacro\\SDM-Icon.tga") + local t2 = f:CreateTexture(nil, "OVERLAY") + t2:SetTexture(t:GetTexture()) + t2:SetAllPoints(t) + local t3 = f:CreateTexture(nil, "HIGHLIGHT") + t3:SetTexture(t:GetTexture()) + t3:SetAllPoints(t) + f:SetScript("OnClick", sdm_UpgradeButtonClicked) + sdm_SetTooltip(f, "Turn the current macro into a Super Duper Macro, allowing you to make it longer") + + -- The following three frames are only showed when SDM's "Change Name/Icon" button is clicked. Clicking this button hijack's the default MacroPopupFrame and modifies it to our needs. + + -- Create the "Different name on button" checkbox + f = CreateFrame("CheckButton", "$parent_buttonTextCheckBox", MacroPopupFrame, "UICheckButtonTemplate") + f:SetWidth(20) + f:SetHeight(20) + f:SetPoint("TOPLEFT", 25, -18) + f:SetScript("OnClick", function() + sdm_buttonTextCheckBoxClicked(MacroPopupFrame_buttonTextCheckBox:GetChecked()==1) + end) + f:Hide() + + -- Create the "Cancel" button + f = CreateFrame("Button", "$parent_sdmCancelButton", MacroPopupFrame, "UIPanelButtonTemplate") + f:SetWidth(78) + f:SetHeight(22) + f:SetPoint("BOTTOMRIGHT", -11, 13) + f:SetText(CANCEL) + f:SetScript("OnClick", function() + sdm_changeIconFrame:Hide() + end) + + -- Create the "Okay" button + f = CreateFrame("Button", "$parent_sdmOkayButton", MacroPopupFrame, "UIPanelButtonTemplate") + f:SetWidth(78) + f:SetHeight(22) + f:SetPoint("RIGHT", MacroPopupCancelButton, "LEFT", -2, 0) + f:SetText(OKAY) + f:SetScript("OnClick", sdm_ChangeIconOkayed) +end \ No newline at end of file diff --git a/SuperDuperMacro/SuperDuperMacro_Frames.xml b/SuperDuperMacro/SuperDuperMacro_Frames.xml new file mode 100644 index 0000000..a09ed3d --- /dev/null +++ b/SuperDuperMacro/SuperDuperMacro_Frames.xml @@ -0,0 +1,1338 @@ + + + + + self.TimeSinceLastUpdate=0 + + sdm_OnUpdate(self, elapsed); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + sdm_CharDropdownLoaded(self); + + + + + + + + + + + + + + + + + + + + + + + + + + + sdm_TypeDropdownLoaded(self); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + self:ClearFocus() + + + self:Insert(" ") + + + sdm_mainFrame_saveButton:Disable() + sdm_textChanged=-2 + + + if sdm_textChanged then + sdm_textChanged=sdm_textChanged+1 + if sdm_textChanged>0 then + sdm_mainFrame_saveButton:Enable() + end + end + + + + + + + + + + + + + + + + + + + + + + + + self:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b) + self:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + sdm_StartMove(); + sdm_StopMove(); + sdm_StopMove(); + + PlaySound "igCharacterInfoOpen" + self:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", 0, -104) + sdm_currentlyPlacing=nil + sdm_UpdateList() + + + PlaySound "igCharacterInfoClose"; + sdm_StopMove() + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + self:SetChecked(1) + _,outline,_,fill,text = self:GetRegions() + outline:SetVertexColor(sdm_GetColor("b")) + fill:SetVertexColor(sdm_GetColor("b")) + text:SetTextColor(sdm_GetColor("b")) + + + self:SetChecked(1) + sdm_newFrame_floatingRadio:SetChecked(nil) + sdm_newFrame_scriptRadio:SetChecked(nil) + + + + + + + + + + + + + + + + + self:SetTextColor(sdm_GetColor("f")) + + + + + + + + _,outline,_,fill,text = self:GetRegions() + outline:SetVertexColor(sdm_GetColor("f")) + fill:SetVertexColor(sdm_GetColor("f")) + text:SetTextColor(sdm_GetColor("f")) + + + sdm_newFrame_buttonRadio:SetChecked(nil) + self:SetChecked(1) + sdm_newFrame_scriptRadio:SetChecked(nil) + + + + + + + + + + + + + + + + + self:SetTextColor(sdm_GetColor("s")) + + + + + + + + _,outline,_,fill,text = self:GetRegions() + outline:SetVertexColor(sdm_GetColor("s")) + fill:SetVertexColor(sdm_GetColor("s")) + text:SetTextColor(sdm_GetColor("s")) + + + sdm_newFrame_buttonRadio:SetChecked(nil) + sdm_newFrame_floatingRadio:SetChecked(nil) + self:SetChecked(1) + + + + + + + + + + + + + + + + + + + + + + + + self:SetChecked(1) + + + self:SetChecked(1) + sdm_newFrame_charspecRadio:SetChecked(nil) + + + + + + + + + + + + + + + + + + + + self:SetChecked(1) + sdm_newFrame_globalRadio:SetChecked(nil) + + + + + + + + + + + + + + + + + + + + + + + + + + + + self:ClearFocus() + + + sdm_newFrame_createButton:Click() + + + + + + + + sdm_StartMove(); + sdm_StopMove(); + sdm_StopMove(); + + sdm_AddToExclusiveGroup(self, "centerwindows") + + + UIFrameFlashStop(sdm_newFrame_createButton_flash) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + self:ClearFocus() + + + sdm_newFolderFrame_createButton:Click() + + + + + + + + sdm_StartMove(); + sdm_StopMove(); + sdm_StopMove(); + + sdm_AddToExclusiveGroup(self, "centerwindows") + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + self:ClearFocus() + + + sdm_ChangeIconOkayed() + + + + + + + sdm_AddToExclusiveGroup(self, "centerwindows") + + + sdm_OnShow_changeIconFrame(self, sdm_macros[sdm_currentEdit]) + + + sdm_OnHide_changeIconFrame(self) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + self:SetChecked(1) + + + self:SetChecked(1) + sdm_sendReceiveFrame_sendRaidRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendBattlegroundRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendGuildRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendTargetRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendArbitraryRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendInput:ClearFocus() + + + + + + + + + + + + + + + + + + + + sdm_sendReceiveFrame_sendPartyRadio:SetChecked(nil) + self:SetChecked(1) + sdm_sendReceiveFrame_sendBattlegroundRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendGuildRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendTargetRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendArbitraryRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendInput:ClearFocus() + + + + + + + + + + + + + + + + + + + + sdm_sendReceiveFrame_sendPartyRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendRaidRadio:SetChecked(nil) + self:SetChecked(1) + sdm_sendReceiveFrame_sendGuildRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendTargetRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendArbitraryRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendInput:ClearFocus() + + + + + + + + + + + + + + + + + + + + sdm_sendReceiveFrame_sendPartyRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendRaidRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendBattlegroundRadio:SetChecked(nil) + self:SetChecked(1) + sdm_sendReceiveFrame_sendTargetRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendArbitraryRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendInput:ClearFocus() + + + + + + + + + + + + + + + + + + + + sdm_sendReceiveFrame_sendPartyRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendRaidRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendBattlegroundRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendGuildRadio:SetChecked(nil) + self:SetChecked(1) + sdm_sendReceiveFrame_sendArbitraryRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendInput:ClearFocus() + + + + + + + + + + + + + + + + + + + + sdm_sendReceiveFrame_sendInput:SetFocus() + + + + + + + + + + + + + + + self:ClearFocus() + + + sdm_sendReceiveFrame_sendButton:Click() + + + sdm_sendReceiveFrame_sendPartyRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendRaidRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendBattlegroundRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendGuildRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendTargetRadio:SetChecked(nil) + sdm_sendReceiveFrame_sendArbitraryRadio:SetChecked(1) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + self:SetChecked(1) + + + self:SetChecked(1) + sdm_sendReceiveFrame_receiveArbitraryRadio:SetChecked(nil) + sdm_sendReceiveFrame_receiveInput:ClearFocus() + + + + + + + + + + + + + + + + + + + + sdm_sendReceiveFrame_receiveInput:SetFocus() + + + + + + + + + + + + + + + self:ClearFocus() + + + sdm_sendReceiveFrame_receiveButton:Click() + + + sdm_sendReceiveFrame_receiveTargetRadio:SetChecked(nil) + sdm_sendReceiveFrame_receiveArbitraryRadio:SetChecked(1) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + sdm_StartMove(); + sdm_StopMove(); + sdm_StopMove(); + + if (not sdm_sending) then + sdm_sendReceiveFrame_sendBar_statusBar:SetValue(0) + sdm_sendReceiveFrame_sendBar_statusBar_text:SetText("") + end + if (not sdm_receiving) then + sdm_sendReceiveFrame_receiveBar_statusBar:SetValue(0) + sdm_sendReceiveFrame_receiveBar_statusBar_text:SetText("") + end + + + + \ No newline at end of file diff --git a/SuperDuperMacro/SuperDuperMacro_Interface.lua b/SuperDuperMacro/SuperDuperMacro_Interface.lua index 1434f4e..c048166 100644 --- a/SuperDuperMacro/SuperDuperMacro_Interface.lua +++ b/SuperDuperMacro/SuperDuperMacro_Interface.lua @@ -1,3 +1,5 @@ +--[[ Interface-related Functions ]]-- + function sdm_About() print(sdm_printPrefix.."by hypehuman. Version "..sdm_version..". Check for updates at www.wowinterface.com") end @@ -29,7 +31,7 @@ function sdm_InitializeTypeDropdown() info.func = sdm_FilterButtonClicked; info.checked = sdm_listFilters[info.value]; info.keepShownOnClick = 1; - UIDropDownMenu_AddButton(info); + UIDropDownMenu_AddButton(info); end end @@ -60,11 +62,105 @@ function sdm_NewButtonClicked() sdm_SaveConfirmationBox("sdm_SelectItem(nil) sdm_newFrame:Show() sdm_newFrame_input:SetFocus()") end +function sdm_SaveAsButtonClicked() + local saved = sdm_macros[sdm_currentEdit] + sdm_saveAsText = sdm_mainFrame_editScrollFrame_text:GetText() -- we'll save this text into the new one, but leave the old one unsaved. + sdm_saveAsIcon = saved.icon + sdm_newFrame:Show() + sdm_newFrame_input:SetFocus() + sdm_newFrame_input:SetText(saved.name) + if saved.type=="b" then + sdm_newFrame_buttonRadio:Click() + elseif saved.type=="f" then + sdm_newFrame_floatingRadio:Click() + elseif saved.type=="s" then + sdm_newFrame_scriptRadio:Click() + end + if saved.characters then + sdm_newFrame_charspecRadio:Click() + else + sdm_newFrame_globalRadio:Click() + end +end + function sdm_DeleteButtonClicked() sdm_ChangeContainer(sdm_macros[sdm_currentEdit], false) sdm_SelectItem(nil) end +function sdm_ClaimButtonClicked() + sdm_AddCharacter(sdm_macros[sdm_currentEdit], sdm_thisChar) + sdm_SetUpMacro(sdm_macros[sdm_currentEdit]) + sdm_UpdateCurrentTitle() + sdm_UpdateList() + sdm_UpdateClaimDisownButtons() +end + +function sdm_DisownButtonClicked() + sdm_UnSetUpMacro(sdm_macros[sdm_currentEdit]) + sdm_RemoveCharacter(sdm_macros[sdm_currentEdit], sdm_thisChar) + sdm_UpdateCurrentTitle() + sdm_UpdateList() + sdm_UpdateClaimDisownButtons() +end + +function sdm_UpgradeButtonClicked() + local index = MacroFrame.selectedMacro + if index==nil then + print(sdm_printPrefix.."You must select a standard macro first.") + return + end + MacroSaveButton:Click() + local newMacro = sdm_UpgradeMacro(index) + if newMacro==nil then + return + end + MacroFrame_linkToSDM:Click() -- show the SDM frame + sdm_SelectItem(newMacro.ID) -- select the newly upgraded macro + MacroFrame.selectedMacro = nil -- deselect the macro in the standard macro frame +end + +function sdm_DowngradeButtonClicked() + sdm_mainFrame_saveButton:Click() + local index = sdm_DowngradeMacro(sdm_macros[sdm_currentEdit]) + if index==nil then + return + end + sdm_SelectItem(nil) -- deselect the macro in the SDM frame + sdm_mainFrame_linkToMacroFrame:Click() -- show the standard macro frame + local buttonName = "MacroButton" + if index<=36 then -- global macro + MacroFrameTab1:Click() + buttonName = buttonName..index + else -- character-specific macro + MacroFrameTab2:Click() + buttonName = buttonName..(index-36) + end + getglobal(buttonName):Click() -- select the newly downgraded macro +end + +function sdm_OnEnterTippedButton(self) + GameTooltip:SetOwner(self, "ANCHOR_RIGHT") + GameTooltip:SetText(self.tooltipText, nil, nil, nil, nil, true) + GameTooltip:Show() +end + +function sdm_OnLeaveTippedButton() + GameTooltip_Hide() +end + +-- if text is provided, sets up the button to show a tooltip when moused over. Otherwise, removes the tooltip. +function sdm_SetTooltip(self, text) + if text then + self.tooltipText = text + self:SetScript("OnEnter", sdm_OnEnterTippedButton) + self:SetScript("OnLeave", sdm_OnLeaveTippedButton) + else + self:SetScript("OnEnter", nil) + self:SetScript("OnLeave", nil) + end +end + function sdm_ListItemClicked(self, button) local mTab = sdm_macros[self.index] if button=="RightButton" then @@ -95,39 +191,66 @@ function sdm_SelectItem(newCurrentEdit) else sdm_currentEdit = nil end - if (not sdm_currentEdit) then + local mTab = sdm_macros[sdm_currentEdit] + if (not mTab) then sdm_mainFrame_deleteButton:Disable() sdm_mainFrame_getLinkButton:Disable() sdm_mainFrame_changeIconButton:Disable() sdm_mainFrame_editScrollFrame:Hide() sdm_mainFrame_saveButton:Disable() + sdm_mainFrame_saveAsButton:Disable() + sdm_mainFrame_downgradeButton:Disable() sdm_sendReceiveFrame_sendButton:Disable() sdm_containerInstructions:Hide() - sdm_currentTitle:Hide() else sdm_mainFrame_editScrollFrame_text:ClearFocus() sdm_mainFrame_deleteButton:Enable() sdm_mainFrame_changeIconButton:Enable() - if sdm_macros[sdm_currentEdit].type=="c" then + if mTab.type=="c" then sdm_mainFrame_editScrollFrame:Hide() sdm_containerInstructions:Show() sdm_mainFrame_getLinkButton:Disable() + sdm_mainFrame_saveAsButton:Disable() else sdm_mainFrame_editScrollFrame:Show() sdm_containerInstructions:Hide() sdm_mainFrame_getLinkButton:Enable() + sdm_mainFrame_saveAsButton:Enable() + if mTab.type=="b" and sdm_UsedByThisChar(mTab) then + sdm_mainFrame_downgradeButton:Enable() + else + sdm_mainFrame_downgradeButton:Disable() + end end - sdm_mainFrame_editScrollFrame_text:SetText(sdm_macros[sdm_currentEdit].text or "") + sdm_mainFrame_editScrollFrame_text:SetText(mTab.text or "") sdm_mainFrame_saveButton:Disable() if not sdm_sending then sdm_sendReceiveFrame_sendButton:Enable() end - sdm_currentTitle:SetText(sdm_GetColor(sdm_macros[sdm_currentEdit].type, sdm_GetTitle(sdm_macros[sdm_currentEdit]))) - sdm_currentTitle:Show() end + sdm_UpdateClaimDisownButtons() + sdm_UpdateCurrentTitle() sdm_UpdateList() end +function sdm_UpdateClaimDisownButtons() + local mTab = sdm_macros[sdm_currentEdit] + if mTab and mTab.characters then + sdm_mainFrame_claimButton:Enable() + sdm_mainFrame_disownButton:Enable() + else + sdm_mainFrame_claimButton:Disable() + sdm_mainFrame_disownButton:Disable() + end + if sdm_UsedByThisChar(mTab) then + sdm_mainFrame_claimButton:Hide() + sdm_mainFrame_disownButton:Show() + else + sdm_mainFrame_claimButton:Show() + sdm_mainFrame_disownButton:Hide() + end +end + function sdm_ResetContainers() --Deletes all folders and places all items into the main list sdm_mainContents={} for i,v in pairs(sdm_macros) do @@ -167,13 +290,8 @@ function sdm_ChangeContainer(mTab, newContainer) --removes the mTab from its cur sdm_macros[ID].container=mTab.container sdm_SortedInsert(prevContents, sdm_macros[ID]) end - elseif sdm_UsedByThisChar(mTab) then - if type=="b" or type=="f" then - sdm_DoOrQueue("getglobal("..sdm_Stringer("sd"..type.."_"..mTab.name).."):SetAttribute(\"type\", nil)") - if type=="b" then - sdm_DoOrQueue("DeleteMacro(sdm_GetMacroIndex("..sdm_Stringer(mTab.ID).."))") - end - end + else + sdm_UnSetUpMacro(mTab) end sdm_macros[mTab.ID]=nil else --move mTab into newContainer @@ -208,17 +326,27 @@ end function sdm_IsAtLeast(one, two, i) --sees if the first mTab is greater than or equal to the second. This is used for sorting them in the list. i=i or 1 local var - if i==1 then - var=function(mTab) return mTab.name:upper() end - elseif i==2 then - var=function(mTab) return mTab.name end - elseif i==3 then - var=function(mTab) return mTab.type end - elseif i==4 then - var=function(mTab) if mTab.character then return mTab.character.name end return string.format('%c', 1) end - elseif i==5 then - var=function(mTab) if mTab.character then return mTab.character.realm end return string.format('%c', 1) end - else + if i==1 then -- first sort by case-insensitive name + var=function(mTab) + return mTab.name:upper() + end + elseif i==2 then -- if the case-insensitive names are the same, sort by case-sensitive name + var=function(mTab) + return mTab.name + end + elseif i==3 then -- if the case-sensitive names are the same, sort by type (folder, button, floating, script) + var=function(mTab) + return mTab.type + end + elseif i==4 then -- if the types are the same, sort by global/percharacter + var=function(mTab) + if mTab.characters then + return "1" + else + return "0" + end + end + else -- If they are both global or both percharacter, the macros are equivalent. return true end if var(one) > var(two) then @@ -290,6 +418,7 @@ function sdm_UpdateList() else listItem.icon:SetTexture("Interface\\Buttons\\UI-PlusButton-UP") end + sdm_SetTooltip(listItem, "Alt-click for folder options") else if mTab.icon==1 then if mTab.type=="b" and sdm_UsedByThisChar(mTab) then @@ -341,14 +470,50 @@ function sdm_UpdateList() end end +function sdm_UpdateCurrentTitle() + local mTab = sdm_macros[sdm_currentEdit] + if mTab then + sdm_currentTitle:Show() + sdm_currentTitle:SetText(sdm_GetColoredTitle(mTab)) + else + sdm_currentTitle:Hide() + end +end + function sdm_GetTitle(mTab) -- the title that will be displayed in the list local result = mTab.name - if mTab.character then - result=result..sdm_GetColor(tostring(mTab.character.name..mTab.character.realm==sdm_thisChar.name..sdm_thisChar.realm), " ("..mTab.character.name.." of "..mTab.character.realm..")") + if mTab.characters then + local lightTxt, darkTxt + if sdm_UsedByThisChar(mTab) then + lightTxt = " "..sdm_thisChar.name.." of "..sdm_thisChar.realm + lightTxt = sdm_GetColor("true", lightTxt) + else + if mTab.characters[1] == nil then -- this item is character-specific, but it has not been claimed by any characters. + darkTxt = " disowned" + else + darkTxt = " "..mTab.characters[1].name.." of "..mTab.characters[1].realm + end + end + if mTab.characters[2] then + darkTxt = (darkTxt or "").." and others" + end + if lightTxt then + lightTxt = sdm_GetColor("true", lightTxt) + result = result..lightTxt + end + if darkTxt then + darkTxt = sdm_GetColor("false", darkTxt) + result = result..darkTxt + end end return result end +function sdm_GetColoredTitle(mTab) + local title = sdm_GetTitle(mTab) + return sdm_GetColor(mTab.type, title) +end + function sdm_AddFolderContents(mTabs, offsets, contents, offset) --Populates mTabs with the elements of contents and all its subfolders. Populates offsets with the amount of indentation for each item. for i,ID in ipairs(contents) do local mTab = sdm_macros[ID] @@ -363,16 +528,16 @@ function sdm_AddFolderContents(mTabs, offsets, contents, offset) --Populates mTa end function sdm_IncludeInList(mTab) --checks the filters to see if the item should be in the scrolling list - if mTab.type=="c" then + if mTab.type=="c" then -- always show folders (aka containers) return true end - if not sdm_listFilters[mTab.type] then + if not sdm_listFilters[mTab.type] then -- if this item's type is not included in the filter, don't show it! return false end - if not mTab.character then + if not mTab.characters then -- if this item is global and globals are not included in the filter, don't show it! return sdm_listFilters["global"] end - return sdm_listFilters[tostring(mTab.character.name..mTab.character.realm==sdm_thisChar.name..sdm_thisChar.realm)] + return sdm_listFilters[tostring(sdm_UsedByThisChar(mTab))] -- take care of this character's and other character's items end function sdm_MakeTextWhite(listItem) @@ -507,7 +672,7 @@ function sdm_ChangeIconOkayed() return end if (mTab.type=="b" or mTab.type=="f") and sdm_ContainsIllegalChars(nameInputted, true) then return end - if sdm_DoesNameConflict(nameInputted, mTab.type, mTab.character, sdm_currentEdit, true) then + if sdm_DoesNameConflict(nameInputted, mTab.type, mTab.characters, sdm_currentEdit, true) then return end local oldName = mTab.name @@ -538,7 +703,7 @@ function sdm_ChangeIconOkayed() sdm_MakeBlizzardMacro(mTab.ID, (mTab.buttonName or mTab.name), mTab.icon) end end - sdm_currentTitle:SetText(sdm_GetColor(sdm_macros[sdm_currentEdit].type, sdm_GetTitle(sdm_macros[sdm_currentEdit]))) + sdm_UpdateCurrentTitle() sdm_UpdateList() end @@ -704,7 +869,9 @@ function sdm_ExclusiveWindowShown(f) --when a window in the group is shown, disa button:Disable() end end - sdm_listLocked=true --this should only apply to the "centerwindows" group, but right now that's all there is. + if f.exclusiveGroupKey=="centerwindows" then + sdm_listLocked = true + end end function sdm_ExclusiveWindowHidden(f) --reenable the buttons. @@ -715,80 +882,36 @@ function sdm_ExclusiveWindowHidden(f) --reenable the buttons. end end t.isEnabled=nil - sdm_listLocked=false --this should only apply to the "centerwindows" group, but right now that's all there is. + if f.exclusiveGroupKey=="centerwindows" then + sdm_listLocked = false + end +end + +function sdm_StartMove() + if not sdm_mainFrameIsMoving then + sdm_mainFrameIsMoving = true + sdm_mainFrame:StartMoving() + end +end + +function sdm_StopMove() + if sdm_mainFrameIsMoving then + sdm_mainFrameIsMoving = false + sdm_mainFrame:StopMovingOrSizing() + end end function sdm_DefaultMacroFrameLoaded() - sdm_eventFrame:UnregisterEvent("ADDON_LOADED") sdm_macroUILoaded=true select(6, MacroFrame:GetRegions()):SetPoint("TOP",MacroFrame, "TOP", 76, -17) -- Move the text "Create Macros" 76 units to the right. - local f - - --Create the button that links from the default macro frame to the SDM frame - f = CreateFrame("Button", "$parent_linkToSDM", MacroFrame, "UIPanelButtonTemplate") - f:SetWidth(150) - f:SetHeight(19) - f:SetPoint("TOPLEFT", 68, -14) - f:SetText("Super Duper Macro") - f:SetScript("OnClick", function() - HideUIPanel(MacroFrame) - sdm_mainFrame:Show() - end) - - --Create the button that turns a regular macro into a Super Duper macro - f = CreateFrame("Button", "$parent_convertToSuper", MacroFrame, "UIPanelButtonTemplate") - f:SetPoint("TOPLEFT", MacroDeleteButton, "TOPRIGHT") - f:SetPoint("BOTTOMRIGHT", MacroNewButton, "BOTTOMLEFT") - f:SetText("Upgrade! ") - local t = f:CreateTexture() - margin = 0.25 * f:GetHeight() - t:SetPoint("TOPRIGHT", f, "TOPRIGHT", -margin, -margin) - t:SetPoint("BOTTOM", f, "BOTTOM", 0, margin) - t:SetWidth(t:GetHeight()) - t:SetTexture("Interface\\MacroFrame\\MacroFrame-Icon") - local t2 = f:CreateTexture(nil, "OVERLAY") - t2:SetTexture(t:GetTexture()) - t2:SetAllPoints(t) - local t3 = f:CreateTexture(nil, "HIGHLIGHT") - t3:SetTexture(t:GetTexture()) - t3:SetAllPoints(t) - f:SetScript("OnClick", function() - if MacroFrame.selectedMacro then - sdm_UpgradeMacro(MacroFrame.selectedMacro) - end - end) - - f = CreateFrame("CheckButton", "$parent_buttonTextCheckBox", MacroPopupFrame, "UICheckButtonTemplate") - f:SetWidth(20) - f:SetHeight(20) - f:SetPoint("TOPLEFT", 25, -18) - f:SetScript("OnClick", function() - sdm_buttonTextCheckBoxClicked(MacroPopupFrame_buttonTextCheckBox:GetChecked()==1) - end) - f:Hide() - - f = CreateFrame("Button", "$parent_sdmCancelButton", MacroPopupFrame, "UIPanelButtonTemplate") - f:SetWidth(78) - f:SetHeight(22) - f:SetPoint("BOTTOMRIGHT", -11, 13) - f:SetText(CANCEL) - f:SetScript("OnClick", function() - sdm_changeIconFrame:Hide() - end) - - f = CreateFrame("Button", "$parent_sdmOkayButton", MacroPopupFrame, "UIPanelButtonTemplate") - f:SetWidth(78) - f:SetHeight(22) - f:SetPoint("RIGHT", MacroPopupCancelButton, "LEFT", -2, 0) - f:SetText(OKAY) - f:SetScript("OnClick", sdm_ChangeIconOkayed) + sdm_CreateDefaultMacroFrameButtons() hooksecurefunc("MacroFrame_Update", function() --This function prevents the user from messing with macros created by SDM. local selectedIsSDM = nil local globalTab = (MacroFrame.macroBase==0) --Is this the global tab or the character-specific tab? for i,v in pairs(sdm_macros) do - if v.type=="b" and sdm_UsedByThisChar(v) and ((globalTab and (not v.character)) or ((not globalTab) and v.character and v.character.name==sdm_thisChar.name and v.character.realm==sdm_thisChar.realm)) then + if v.type=="b" and sdm_UsedByThisChar(v) and ((globalTab and v.characters==nil) or ((not globalTab) and v.characters)) then -- if this item is supposed to have a macro in this tab local index = sdm_GetMacroIndex(v.ID) local prefix = "MacroButton"..index-MacroFrame.macroBase if index == MacroFrame.selectedMacro then --The currently selected macro is a SDM macro. Deselect it for now, then later select another one. @@ -798,7 +921,7 @@ function sdm_DefaultMacroFrameLoaded() MacroFrame_HideDetails() end _G[prefix]:Disable() - _G[prefix.."Icon"]:SetTexture("Interface\\MacroFrame\\MacroFrame-Icon") + _G[prefix.."Icon"]:SetTexture("Interface\\AddOns\\SuperDuperMacro\\SDM-Icon.tga") _G[prefix.."Name"]:SetText("SDM") end end @@ -816,6 +939,21 @@ function sdm_DefaultMacroFrameLoaded() end) end +--[[ Interface-related Variables ]]-- + +sdm_iconSpacing=5/36 +sdm_listLocked=false --if this is true, clicking on a macro in the SDM list will not select it. +if (IsAddOnLoaded("Blizzard_MacroUI")) then + sdm_macroUILoaded=true --the default macro UI, which normally loads when you type /macro + sdm_DefaultMacroFrameLoaded() +else + sdm_macroUILoaded=false --the default macro UI, which normally loads when you type /macro + sdm_eventFrame:RegisterEvent("ADDON_LOADED") +end +sdm_unusedListItems={} +sdm_listItems,sdm_unusedListItems[true],sdm_unusedListItems[false]={},{},{} +sdm_listItemPrefix = "sdm_mainFrame_macrosScroll_macroList_listItem" + sdm_containerInstructionsString = [[ Left-click on a folder to open or close it. @@ -830,16 +968,4 @@ Deleting a folder will move all of its contents into its parent folder. To bring up these instructions and folder options, alt-click on a folder in the list. -]] - -sdm_iconSpacing=5/36 -sdm_listLocked=false --if this is true, clicking on a macro in the SDM list will do nothing. -if (IsAddOnLoaded("Blizzard_MacroUI")) then - sdm_macroUILoaded=true --the default macro UI, which normally loads when you type /macro - sdm_DefaultMacroFrameLoaded() -else - sdm_macroUILoaded=false --the default macro UI, which normally loads when you type /macro -end -sdm_unusedListItems={} -sdm_listItems,sdm_unusedListItems[true],sdm_unusedListItems[false]={},{},{} -sdm_listItemPrefix = "sdm_mainFrame_macrosScroll_macroList_listItem" \ No newline at end of file +]] \ No newline at end of file diff --git a/SuperDuperMacro/SuperDuperMacro_Sharing.lua b/SuperDuperMacro/SuperDuperMacro_Sharing.lua index 9e966ea..df6057f 100644 --- a/SuperDuperMacro/SuperDuperMacro_Sharing.lua +++ b/SuperDuperMacro/SuperDuperMacro_Sharing.lua @@ -5,7 +5,7 @@ function sdm_SendMacro(mTab, chan, tar) end local perCharacter=nil --make the string that will be split up and sent. It consists of a bunch of values separated by commas. They are, in order: the version the sender is running, the minimum version the receiver must have, the type of macro, the index of the icon, the perCharacter status ("" or "nil"), the length of the name, the length of the text, the name, and the text. There is no comma between the name and the text. - local textToSend = sdm_version..","..sdm_minVersion..","..mTab.type..","..tostring(mTab.icon)..","..tostring(mTab.character)..","..mTab.name:len()..","..mTab.text:len()..","..mTab.name..mTab.text + local textToSend = sdm_version..","..sdm_minVersion..","..mTab.type..","..tostring(mTab.icon)..","..tostring(mTab.characters)..","..mTab.name:len()..","..mTab.text:len()..","..mTab.name..mTab.text local pref = "SDM send1" -- if the prefix ends in "send1", it's the first line. If it ends in "send2", it's any line after the first. local lineLen = 254 - pref:len() local linesToSend={} @@ -94,6 +94,8 @@ function sdm_WaitForMacro(name) sdm_newFrame_globalRadio:Disable() sdm_newFrame_charspecRadio:Disable() sdm_newFrame_createButton:Disable() + sdm_saveAsText = nil + sdm_saveAsIcon = nil end function sdm_InterpretAddonMessage(...) diff --git a/SuperDuperMacro/sdm Readme.txt b/SuperDuperMacro/sdm Readme.txt index 603f7d6..06817b1 100644 --- a/SuperDuperMacro/sdm Readme.txt +++ b/SuperDuperMacro/sdm Readme.txt @@ -25,6 +25,13 @@ Special thanks to: Change Log +2.2 (11/4/11) +ナUpgraded macros will now appropriately change their icons based on the macro code (unless an icon other than the Question Mark icon was selected). If you upgraded a macro with version 2.1, you will need to manually change the icon to the Question Mark icon. +ナAdded a "Downgrade" button that converts a Super Duper macro into a standard macro +ナAdded a "Claim"/"Disown" button that allows you to have a single character-specific macro or script that applies to multiple characters +ナAdded a "Save As..." button that allows you to save an existing macro as a different type or character. For example, you can save a button macro as a floating macro if you want to free up a macro slot. +ナSeveral UI improvements; more to come! + 2.1 (10/19/11) ナAdded an "Upgrade" button to the standard macro frame, allowing you to convert a standard macro into a Super Duper macro ナRemoved an overbearing version-checking system -- 1.7.9.5