From e9175d8c651d625918fdcc222534a4cdd70a7793 Mon Sep 17 00:00:00 2001 From: Ahmil Jilani Date: Mon, 15 Dec 2008 20:55:00 -0500 Subject: [PATCH] 1.3 --- SuperDuperMacro/SuperDuperMacro.lua | 374 +++++++++++++++++++++------- SuperDuperMacro/SuperDuperMacro.toc | 2 +- SuperDuperMacro/SuperDuperMacro.xml | 462 +++++++++++++++++++---------------- SuperDuperMacro/sdm Readme.txt | 42 +++- 4 files changed, 578 insertions(+), 302 deletions(-) diff --git a/SuperDuperMacro/SuperDuperMacro.lua b/SuperDuperMacro/SuperDuperMacro.lua index 6dc41e0..748ab73 100644 --- a/SuperDuperMacro/SuperDuperMacro.lua +++ b/SuperDuperMacro/SuperDuperMacro.lua @@ -1,10 +1,10 @@ -function sdm_SlashHandler(command) - if command=="load" then sdm_DoAllMacros() - elseif command=="" then - sdm_editFrame:Show() - sdm_updateCurrentEdit() - sdm_showMacroEditText(sdm_currentEdit) - else ChatFrame1:AddMessage("sdm did not recognize the command \""..command.."\"") +function sdm_SlashHandler(command) + if command=="" then + sdm_editFrame:Show() + elseif command=="load" then sdm_DoAllMacros() + elseif command:sub(1,4)=="run " then + sdm_RunScript(command:sub(5,command:len())) + else DEFAULT_CHAT_FRAME:AddMessage("sdm did not recognize the command \""..command.."\"") end end SlashCmdList["SUPERDUPERMACRO"] = sdm_SlashHandler; @@ -15,22 +15,38 @@ function sdm_MakeMacroFrame(name, text) temp:SetAttribute('type', 'macro') temp:SetAttribute('macrotext', text) -- GetClickFrame(name) --This line is just to fix a taint issue from a Blizzard bug (fixed in 3.0) --- ChatFrame1:AddMessage("Creating frame \""..name.."\" with macrotext\n\""..text.."\"\n(length "..string.len(text)..")") - if string.len(text)>sdm_charLimit then ChatFrame1:AddMessage("The following line is "..(string.len(text)-sdm_charLimit).." characters too long:\n"..text) end -end -function sdm_MakeBlizzardMacro(name, text, perCharacter) --- ChatFrame1:AddMessage("Creating macro \""..name.."\" with text\n\""..text.."\"\n(length "..string.len(text)..")") - index=GetMacroIndexByName(name) - if index==0 then - CreateMacro(name, 1, text, perCharacter) +-- DEFAULT_CHAT_FRAME:AddMessage("Creating frame \""..name.."\" with macrotext\n\""..text.."\"\n(length "..string.len(text)..")") + if string.len(text)>sdm_charLimit then DEFAULT_CHAT_FRAME:AddMessage("The following line is "..(string.len(text)-sdm_charLimit).." characters too long:\n"..text) end +end +function sdm_MakeBlizzardMacro(ID, name, text, perCharacter) +-- DEFAULT_CHAT_FRAME:AddMessage("Creating macro \""..name.."\" with text\n\""..text.."\"\n(length "..string.len(text)..")") + local index = nil + local macrosToDelete = {} + for i=1,54 do + thisID=sdm_GetSdmID(i) + if thisID==ID then + index=i + break + end + end + if index then + EditMacro(index, name, nil, text, 1, perCharacter) else - EditMacro(index, name, nil, text, perCharacter) + CreateMacro(name, 1, text, perCharacter, 1) + end +end +function sdm_GetSdmID(macroID) + local thisMacroText=GetMacroBody(macroID) + if thisMacroText and thisMacroText:sub(1,4)=="#sdm" then + return tonumber(thisMacroText:sub(5,thisMacroText:find("\n")-1)) + else + return nil end end function sdm_GetLinkText(nextName) return "\n/click [btn:5]"..nextName.." Button5;[btn:4]"..nextName.." Button4;[btn:3]"..nextName.." MiddleButton;[btn:2]"..nextName.." RightButton;"..nextName end -function sdm_updateCurrentEdit(setTo) +function sdm_UpdateCurrentEdit(setTo) if setTo then sdm_currentEdit = setTo end if getn(sdm_macros)>0 then if not sdm_currentEdit or sdm_currentEdit<1 then @@ -38,16 +54,26 @@ function sdm_updateCurrentEdit(setTo) elseif sdm_currentEdit > getn(sdm_macros) then sdm_currentEdit = getn(sdm_macros) end - sdm_editFrameMenuFrame_current:SetPoint("TOPLEFT", sdm_editFrameMenuFrame_macroInfo, "TOPLEFT", -10, -sdm_currentEdit*12+6) - sdm_editFrameMenuFrame_current:Show() + sdm_editFrame_menuFrame_current:SetPoint("TOPLEFT", sdm_editFrame_menuFrame_macroInfo, "TOPLEFT", -10, -sdm_currentEdit*12+6) + sdm_editFrame_menuFrame_current:Show() else sdm_currentEdit = 0 - sdm_editFrameMenuFrame_current:Hide() - end + sdm_editFrame_menuFrame_current:Hide() + end + if sdm_currentEdit==0 then + sdm_editFrame_deleteButton:Disable() + sdm_editFrame_getLinkButton:Disable() + else + sdm_editFrame_deleteButton:Enable() + sdm_editFrame_getLinkButton:Enable() + end end -function sdm_SetUpMacro(type, number, name, text, perCharacter) +function sdm_SetUpMacro(type, number, name, text, perCharacter, ID) frameNum=1 linkText=sdm_GetLinkText("s"..number.."_"..(frameNum+1)) + if type=="b" then + text="#sdm"..ID.."\n"..text + end charsLeft=string.len(text) thisFrameText="" frameName=name @@ -60,7 +86,7 @@ function sdm_SetUpMacro(type, number, name, text, perCharacter) else if string.len(thisFrameText)+string.len(line)+string.len(linkText)+1>sdm_charLimit then if sdm_charLimit==255 then - sdm_MakeBlizzardMacro(frameName, thisFrameText..linkText, perCharacter) + sdm_MakeBlizzardMacro(ID, frameName, thisFrameText..linkText, perCharacter) sdm_charLimit=1023 else sdm_MakeMacroFrame(frameName, thisFrameText..linkText) @@ -69,7 +95,7 @@ function sdm_SetUpMacro(type, number, name, text, perCharacter) frameName="s"..number.."_"..frameNum linkText=sdm_GetLinkText("s"..number.."_"..(frameNum+1)) charsLeft=charsLeft-string.len(thisFrameText)-1 - -- ChatFrame1:AddMessage("new charsLeft: "..charsLeft) + -- DEFAULT_CHAT_FRAME:AddMessage("new charsLeft: "..charsLeft) thisFrameText=line else if thisFrameText ~= "" then thisFrameText = thisFrameText.."\n" end @@ -78,7 +104,7 @@ function sdm_SetUpMacro(type, number, name, text, perCharacter) end end if sdm_charLimit==255 then - sdm_MakeBlizzardMacro(frameName, thisFrameText, perCharacter) + sdm_MakeBlizzardMacro(ID, frameName, thisFrameText, perCharacter) sdm_charLimit=1023 else sdm_MakeMacroFrame(frameName, thisFrameText) @@ -95,7 +121,7 @@ function sdm_SetUpMacro(type, number, name, text, perCharacter) frameName="s"..number.."_"..frameNum linkText=sdm_GetLinkText("s"..number.."_"..(frameNum+1)) charsLeft=charsLeft-string.len(thisFrameText)-1 - -- ChatFrame1:AddMessage("new charsLeft: "..charsLeft) + -- DEFAULT_CHAT_FRAME:AddMessage("new charsLeft: "..charsLeft) thisFrameText=line else if thisFrameText ~= "" then thisFrameText = thisFrameText.."\n" end @@ -109,138 +135,304 @@ end function sdm_DoAllMacros() infoString="" for i=1,getn(sdm_macros) do - perChar=(sdm_macros[i][4]~=nil) - if (not perChar) or (sdm_macros[i][4]==UnitName("player") and sdm_macros[i][5]==GetRealmName()) then - sdm_SetUpMacro(sdm_macros[i][1], i, sdm_macros[i][2], sdm_macros[i][3], perChar) + perChar=(sdm_macros[i].character~=nil) + if (not perChar) or (sdm_macros[i].character.name==UnitName("player") and sdm_macros[i].character.server==GetRealmName()) then + sdm_SetUpMacro(sdm_macros[i].type, i, sdm_macros[i].name, sdm_macros[i].text, perChar, sdm_macros[i].ID) end - infoString=infoString..i..": \""..sdm_macros[i][2].."\" type "..sdm_macros[i][1] - if perChar then infoString=infoString.." ("..sdm_macros[i][4].." of "..sdm_macros[i][5]..")" end + infoString=infoString..i..": \""..sdm_macros[i].name.."\" type "..sdm_macros[i].type + if perChar then infoString=infoString.." ("..sdm_macros[i].character.name.." of "..sdm_macros[i].character.server..")" end infoString=infoString.."\n" - end - sdm_editFrameMenuFrame_macroInfo:SetText(infoString) - sdm_updateCurrentEdit() + end + sdm_editFrame_menuFrame_macroInfo:SetText(infoString) + sdm_UpdateCurrentEdit() end sdm_globalsLoaded=0 local EventFrame = CreateFrame("Frame") EventFrame:RegisterEvent("VARIABLES_LOADED") EventFrame:RegisterEvent("UPDATE_MACROS") +EventFrame:RegisterEvent("ADDON_LOADED") EventFrame:SetScript("OnEvent", function () - if event=="VARIABLES_LOADED" then + if event=="VARIABLES_LOADED" then + EventFrame:UnregisterEvent("VARIABLES_LOADED") + if sdm_macros==nil then + sdm_macros={} + elseif sdm_CompareVersions(sdm_version,"1.3")==2 then + sdm_oldMacros=sdm_macros + sdm_macros={} + local ID=1 + for i=1,getn(sdm_oldMacros) do + sdm_macros[i]={type=sdm_oldMacros[i][1], name=sdm_oldMacros[i][2], text=sdm_oldMacros[i][3]} + if sdm_oldMacros[i][4] then + sdm_macros[i].character={name=sdm_oldMacros[i][4], server=sdm_oldMacros[i][5]} + end + if sdm_oldMacros[i][1]=="b" then + sdm_macros[i].ID=ID + ID=ID+1 + end + end + end sdm_version=GetAddOnMetadata("SuperDuperMacro", "Version") --the version of this addon - if sdm_macros==nil then sdm_macros={} end elseif event=="UPDATE_MACROS" then if sdm_globalsLoaded~=nil and sdm_globalsLoaded<3 then sdm_globalsLoaded=sdm_globalsLoaded+1 elseif sdm_globalsLoaded==3 then - sdm_globalsLoaded=nil + sdm_globalsLoaded=nil + EventFrame:UnregisterEvent("UPDATE_MACROS") + local foundOne = {} + local macrosToDelete = {} + local iIsPerCharacter=false + for i=1,54 do + if i==37 then iIsPerCharacter=true end + thisID=sdm_GetSdmID(i) + if thisID then + local IDUsedBy = sdm_IsIDUsed(thisID) + if foundOne[thisID] then + table.insert(macrosToDelete, i) + elseif not IDUsedBy then + table.insert(macrosToDelete, i) + foundOne[thisID]=1 + elseif (sdm_macros[IDUsedBy].character~=nil)~=iIsPerCharacter then --if the macro is in the wrong spot based on perCharacter + table.insert(macrosToDelete, i) + else + foundOne[thisID]=1 + end + end + end + for i=getn(macrosToDelete),1,-1 do + DEFAULT_CHAT_FRAME:AddMessage("SDM: Deleting extraneous macro "..macrosToDelete[i]..": "..GetMacroInfo(macrosToDelete[i])) + DeleteMacro(macrosToDelete[i]) + end sdm_DoAllMacros() + end + elseif event=="ADDON_LOADED" then + if arg1=="Blizzard_MacroUI" then + EventFrame:UnregisterEvent("ADDON_LOADED") + local 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_editFrame:Show() end) + select(6, MacroFrame:GetRegions()):SetPoint("TOP",MacroFrame, "TOP", 76, -17) -- Move the text "Create Macros" 76 units to the right. end end end) -sdm_charLimit=1023 --the number of characters allowed per frame +sdm_charLimit=1023 --the number of characters allowed per frame +sdm_saveButtonEnabled=0 +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 + local indexOfPeriod=strings[i]:find("%.") + if indexOfPeriod==nil then + numbers[i]=strings[i] + strings[i]=nil + else + numbers[i]=strings[i]:sub(1, indexOfPeriod-1) + strings[i] = strings[i]:sub(indexOfPeriod+1, strings[i]:len()) + end + numbers[i] = tonumber(numbers[i]) + end + if numbers[1] > numbers[2] then + return 1 + elseif numbers[2] > numbers[1] then + return 2 + elseif strings[1]==nil and strings[2]==nil then + return 0 + end + end +end function sdm_About() DEFAULT_CHAT_FRAME:AddMessage("Super Duper Macro by hypehuman. Version "..sdm_version..". Check for updates at www.wowinterface.com") end function sdm_MenuFrameButtonClicked() - if this:GetName()=="sdm_editFrameMenuFrame_NewButton" then + if this:GetName()=="sdm_editFrame_menuFrame_newButton" then sdm_newFrame:Show() sdm_newFrame_input:SetFocus() - elseif this:GetName()=="sdm_editFrameDeleteButton" then - sdm_deleteMacro(sdm_currentEdit) - sdm_updateCurrentEdit() - elseif this:GetName()=="sdm_editFrameMenuFrame_SelectButton" then - local input=sdm_editFrameMenuFrame_numberInput:GetText() + elseif this:GetName()=="sdm_editFrame_deleteButton" then + sdm_DeleteMacro(sdm_currentEdit) + sdm_UpdateCurrentEdit() + elseif this:GetName()=="sdm_editFrame_menuFrame_selectButton" then + local input=sdm_editFrame_menuFrame_numberInput:GetText() local numberFromInput = tonumber(string.format("%d", tonumber(input) or 0)) local entry = nil if tostring(numberFromInput) == input and numberFromInput>0 and numberFromInput<=getn(sdm_macros) then entry = numberFromInput end if entry then - sdm_saveConfirmationBox("sdm_updateCurrentEdit("..entry..") sdm_showMacroEditText(sdm_currentEdit)") + sdm_SaveConfirmationBox("sdm_UpdateCurrentEdit("..entry..") sdm_ShowMacroEditText(sdm_currentEdit)") end end - sdm_editFrameMenuFrame_numberInput:SetText("") - sdm_editFrameMenuFrame_numberInput:ClearFocus() + sdm_editFrame_menuFrame_numberInput:SetText("") + sdm_editFrame_menuFrame_numberInput:ClearFocus() end -function sdm_saveConfirmationBox(postponed) - if sdm_currentEdit==0 or sdm_macros[sdm_currentEdit][3]==sdm_editFrameEditScrollFrameText:GetText() then +function sdm_freezeEditFrame() + sdm_descendants = {sdm_editFrame:GetChildren()} + sdm_mouseStates = {} + local i=1 + for i,v in ipairs(sdm_descendants) do + --table.insert(sdm_descendants, v:GetChildren()) -- this doesn't work (I was trying to put all the returns of GetChildren into the table), so I put in the next three lines instead + for j,w in ipairs({v:GetChildren()}) do + table.insert(sdm_descendants, w) + end + sdm_mouseStates[i] = v:IsMouseEnabled() + v:EnableMouse(false) + i=i+1 + end +end +function sdm_thawEditFrame() + for i,v in ipairs(sdm_descendants) do + v:EnableMouse(sdm_mouseStates[i]) + end +end +function sdm_SaveConfirmationBox(postponed) + if sdm_currentEdit==0 or sdm_macros[sdm_currentEdit].text==sdm_editFrame_editScrollFrame_text:GetText() then RunScript(postponed) - else + else + sdm_editFrame_editScrollFrame_text:ClearFocus() StaticPopupDialogs["SDM_CONFIRM"] = { - text = "Do you want to save your changes to \""..sdm_macros[sdm_currentEdit][2].."\"?", + text = "Do you want to save your changes to \""..sdm_macros[sdm_currentEdit].name.."\"?", button1 = "Save", --left button button3 = "Don't Save", --middle button button2 = "Cancel", -- right button - OnAccept = function() sdm_saveCurrent() RunScript(postponed) end, --button1 (left) + OnAccept = function() sdm_SaveCurrent() RunScript(postponed) end, --button1 (left) OnAlt = function() RunScript(postponed) end, --button3 (middle) --OnCancel = , --button2 (right) - --OnShow = function() sdm_editFrame:SetAttribute("enableMouse", "false") end, --These two lines are doing nothing for some reason - --OnHide = function() sdm_editFrame:SetAttribute("enableMouse", "true") end, + OnShow = sdm_freezeEditFrame, + OnHide = sdm_thawEditFrame, timeout = 0 } StaticPopup_Show("SDM_CONFIRM"):SetPoint("CENTER", "sdm_editFrame", "CENTER") end -end -function sdm_showMacroEditText(index) +end +function sdm_ShowMacroEditText(index) if sdm_currentEdit==0 then textToShow="" else - textToShow=sdm_macros[index][3] + textToShow=sdm_macros[index].text end - sdm_editFrameEditScrollFrameText:SetText(textToShow) + sdm_editFrame_editScrollFrame_text:SetText(textToShow) end -function sdm_deleteMacro(num) +function sdm_DeleteMacro(num) if sdm_currentEdit==0 then return end - if sdm_macros[num][1]=="b" then - DeleteMacro(sdm_macros[num][2]) + if sdm_macros[num].type=="b" then + DeleteMacro(sdm_macros[num].name) end for i=num, getn(sdm_macros) do sdm_macros[i]=sdm_macros[i+1] end sdm_DoAllMacros() - sdm_showMacroEditText(sdm_currentEdit) + sdm_ShowMacroEditText(sdm_currentEdit) end -function sdm_getCurrentLink() +function sdm_GetCurrentLink() if sdm_currentEdit==0 then return end - if sdm_macros[sdm_currentEdit][1]=="b" then - PickupMacro(sdm_macros[sdm_currentEdit][2]) - elseif sdm_macros[sdm_currentEdit][1]=="f" then - DEFAULT_CHAT_FRAME:AddMessage("To link to this macro, use \"/click "..sdm_macros[sdm_currentEdit][2].."\"") + if sdm_macros[sdm_currentEdit].type=="b" then + local MacroID = nil + for i=1,54 do + if sdm_GetSdmID(i)==sdm_macros[sdm_currentEdit].ID then + MacroID=i + break + end + end + PickupMacro(MacroID) + elseif sdm_macros[sdm_currentEdit].type=="f" then + DEFAULT_CHAT_FRAME:AddMessage("To run this macro, use \"/click "..sdm_macros[sdm_currentEdit].name.."\".") + elseif sdm_macros[sdm_currentEdit].type=="s" then + DEFAULT_CHAT_FRAME:AddMessage("To run this script, use \"/sdm run "..sdm_macros[sdm_currentEdit].name.."\" or use the function \"sdm_RunScript("..sdm_macros[sdm_currentEdit].name..")\".") end end -function sdm_revertCurrent() +function sdm_RevertCurrent() if sdm_currentEdit==0 then return end - if sdm_macros[sdm_currentEdit][3]==nil or sdm_macros[sdm_currentEdit][3]=="" then sdm_macros[sdm_currentEdit][3]="# Enter macro text here." end - sdm_editFrameEditScrollFrameText:SetText(sdm_macros[sdm_currentEdit][3]) + sdm_editFrame_editScrollFrame_text:SetText(sdm_macros[sdm_currentEdit].text) end function sdm_Quit() - sdm_saveConfirmationBox("sdm_editFrame:Hide()") + sdm_SaveConfirmationBox("sdm_editFrame:Hide() sdm_newFrame:Hide()") end -function sdm_saveCurrent() +function sdm_SaveCurrent() if sdm_currentEdit==0 then return end - sdm_macros[sdm_currentEdit][3]=sdm_editFrameEditScrollFrameText:GetText() - sdm_DoAllMacros() + sdm_macros[sdm_currentEdit].text=sdm_editFrame_editScrollFrame_text:GetText() + sdm_DoAllMacros() + sdm_saveButtonEnabled=0 + sdm_editFrame_saveButton:Disable() end -function sdm_createButtonClicked() - if sdm_newFrame_input:GetText()=="" then return end - sdm_saveConfirmationBox("sdm_createButtonConfirmed()") +function sdm_CreateButtonClicked() + local name = sdm_newFrame_input:GetText() + if name=="" then + return + end + local type = nil + if sdm_newFrame_buttonRadio:GetChecked() then + type="b" + elseif sdm_newFrame_floatingRadio:GetChecked() then + type="f" + elseif sdm_newFrame_scriptRadio:GetChecked() then + type="s" + end + perCharacter = sdm_newFrame_charspecRadio:GetChecked() + local conflict = sdm_DoesNameConflict(name, type, perCharacter) + if conflict then + DEFAULT_CHAT_FRAME:AddMessage("SDM: You may not have more than one of that type with the same name per character. (Conflicts with #"..conflict..")") + return + end + sdm_SaveConfirmationBox("sdm_CreateNew(\""..type.."\", \""..name.."\", "..(perCharacter or "nil")..")") end -function sdm_createButtonConfirmed() +function sdm_CreateNew(type, name, perCharacter) table.insert(sdm_macros, {}) - sdm_updateCurrentEdit(getn(sdm_macros)) - if sdm_newFrame_RadioButton1:GetChecked() then - sdm_macros[sdm_currentEdit][1]="b" - elseif sdm_newFrame_RadioButton2:GetChecked() then - sdm_macros[sdm_currentEdit][1]="f" - end - sdm_macros[sdm_currentEdit][2]=sdm_newFrame_input:GetText() - sdm_macros[sdm_currentEdit][3]="# Enter macro text here." - if sdm_newFrame_RadioButton4:GetChecked() then - sdm_macros[sdm_currentEdit][4]=UnitName("player") - sdm_macros[sdm_currentEdit][5]=GetRealmName() + sdm_UpdateCurrentEdit(getn(sdm_macros)) + sdm_macros[sdm_currentEdit].type=type + if type=="b" then + sdm_macros[sdm_currentEdit].ID=sdm_FindUnusedID() + end + sdm_macros[sdm_currentEdit].name=sdm_newFrame_input:GetText() + if type=="s" then + sdm_macros[sdm_currentEdit].text="-- Enter lua commands here." + else + sdm_macros[sdm_currentEdit].text="# Enter macro text here." + end + if perCharacter then + sdm_macros[sdm_currentEdit].character={name=UnitName("player"), server=GetRealmName()} end sdm_newFrame:Hide() sdm_DoAllMacros() - sdm_showMacroEditText(sdm_currentEdit) + sdm_ShowMacroEditText(sdm_currentEdit) +end +function sdm_FindUnusedID() + local attempt = 0 + repeat + attempt=attempt+1 + until not sdm_IsIDUsed(attempt) + return attempt end ---sdm_macros is a table of tables. Each table in it is three elements long, representing the type, name, text [, name, and realm] of each macro. Type can be "b" for button macros or "f" for ones that don't have macro buttons, but instead just float invisibly and respond to /click \ No newline at end of file +function sdm_IsIDUsed(num) -- returns the index of the macro + for i=1,getn(sdm_macros) do + if sdm_macros[i].type=="b" and sdm_macros[i].ID==num then + return i + end + end + return nil +end +function sdm_RunScript(name) + local index = nil + for i=1,getn(sdm_macros) do + if sdm_macros[i].type=="s" and sdm_macros[i].name==name then + index=i + break + end + end + if index then + RunScript(sdm_macros[index].text) + else + DEFAULT_CHAT_FRAME:AddMessage("SDM could not find a script named \""..name.."\".") + end +end +function sdm_DoesNameConflict(name, type, perCharacter) --returns a conflict if we find a macro of the same type and name that can be seen for this same character. Button macros never conflict. + if type=="f" or type=="s" then + for i=1,getn(sdm_macros) do + if sdm_macros[i].type==type and sdm_macros[i].name==name and ((not perCharacter) or (not sdm_macros[i].character) or (sdm_macros[i].character.name==UnitName("player") and sdm_macros[i].character.server==GetRealmName())) then + return i + end + end + end + return nil +end \ No newline at end of file diff --git a/SuperDuperMacro/SuperDuperMacro.toc b/SuperDuperMacro/SuperDuperMacro.toc index 869ab1d..0e6464c 100644 --- a/SuperDuperMacro/SuperDuperMacro.toc +++ b/SuperDuperMacro/SuperDuperMacro.toc @@ -2,7 +2,7 @@ ## Title : Super Duper Macro ## Notes: This AddOn allows users to make incredibly long macros. ## Author: hypehuman -## Version: 1.2 +## Version: 1.3 ## SavedVariables: sdm_macros, sdm_version SuperDuperMacro.xml SuperDuperMacro.lua \ No newline at end of file diff --git a/SuperDuperMacro/SuperDuperMacro.xml b/SuperDuperMacro/SuperDuperMacro.xml index 44b8754..36cc810 100644 --- a/SuperDuperMacro/SuperDuperMacro.xml +++ b/SuperDuperMacro/SuperDuperMacro.xml @@ -73,15 +73,15 @@ - + - - + + @@ -110,59 +110,60 @@ - + - - - - - - + + + + - + self:ClearFocus() + + sdm_editFrame_menuFrame_selectButton:Click() + - - - - - - + - + @@ -228,12 +241,25 @@ - + self:ClearFocus() + + self:Insert(" ") + + + sdm_saveButtonEnabled=-2 + sdm_editFrame_saveButton:Disable() + + + sdm_saveButtonEnabled=sdm_saveButtonEnabled+1 + if sdm_saveButtonEnabled>0 then + sdm_editFrame_saveButton:Enable() + end + @@ -244,175 +270,203 @@ this:StartMoving(); this:StopMovingOrSizing(); this:StopMovingOrSizing(); - this:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", 0, -104); + + this:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", 0, -104) + sdm_UpdateCurrentEdit() + sdm_ShowMacroEditText(sdm_currentEdit) + - - - - + + + - - - + + - + - - - - + + + - - - + + - + - - - - - - - - - - - - - - - - - - - - - - - sdm_newFrame_RadioButton1:SetChecked(1) - - - sdm_newFrame_RadioButton1:SetChecked(1) - sdm_newFrame_RadioButton2:SetChecked(nil) - - - - - - - - - - - - - - - - - - - - sdm_newFrame_RadioButton2:SetChecked(1) - sdm_newFrame_RadioButton1:SetChecked(nil) - - - - - - - - - - - - - - - - - - - - - - - - sdm_newFrame_RadioButton3:SetChecked(1) - - - sdm_newFrame_RadioButton3:SetChecked(1) - sdm_newFrame_RadioButton4:SetChecked(nil) - - - - - - - - - - - - - - - - - - - - sdm_newFrame_RadioButton4:SetChecked(1) - sdm_newFrame_RadioButton3:SetChecked(nil) - - - - - - - - - - - - - - - - - - - - - - - - - - - self:ClearFocus() - - - - + diff --git a/SuperDuperMacro/sdm Readme.txt b/SuperDuperMacro/sdm Readme.txt index 88632ae..a678831 100644 --- a/SuperDuperMacro/sdm Readme.txt +++ b/SuperDuperMacro/sdm Readme.txt @@ -1,20 +1,50 @@ Super Duper Macro -version 1.2 +version 1.3 by hypehuman Open the interface by typing /sdm This addon allows you to create macros beyond the 255-character limit, and even beyond the 1023-character macrotext limit. However, no individual line in a macro may be more than about 1000 characters. The number of lines is virtually unlimited. -This mod allows you to make two types of macros: button macros ("b"), which modify regular macro, allowing you to place it on your action bar, and floating macros ("f"), which do not have buttons, are accessed by /click, and are limitless in number. To set an icon for a button macro, use the regular macro interface (/macro). +This mod allows you to make two types of macros: +¥ button macros ("b"), which create standard macros that link to them, allowing you to place them on your action bar. You can only create as many of these as Blizzard normally allows. +¥ floating macros ("f"), which do not have buttons, are accessed by /click, and are limitless in number. To set an icon for a button macro, use the regular macro interface (/macro). + +You can also make scripts ("s") of unlimited length that you can call using "/sdm run " or via sdm_RunScript("name") I haven't yet made the interface as pretty as I'd like (I'm just learning xml), and I haven't put in all the error handling features that I want to. Some of them are: -¥ There is no warning if you create two macros with the same name, so please don't do that. If you make one with the same name as an existing macro, it will overwrite it. If you attempt to make more with the same name, it will act erratically. -¥ Gray out certain buttons when appropriate ¥ Clickable menu of macros -¥ Add interface for putting in long scripts (basically just strings to be called with RunScript()) +¥ Add the ability to change button-macro icons from within the SDM interface (currently you have to switch over to the regular macro window to do this) +¥ÊHandle cases in which the number of standard macros exceeds its limit Over the next few weeks, I'm going to be updating the interface and adding features. If anyone has an idea, please let me know on wowinterface.com, or add it yourself and upload it :) I haven't gotten a lot of feedback on this addon, but I know people have been using it. So please let me know what you like about it and what you don't! -Special thanks to the creators of Behaviors, from which I shamelessly copied many UI elements. \ No newline at end of file +Special thanks to: +¥ SuperMacro, which inspired the idea for this addon. +¥ Behaviors, from which I shamelessly copied many UI elements. + + + +Change Log + +1.3 (12/15/08) +¥ You can now use the addon to store long scripts and call them via a function or slash command. +¥ SDM now keeps track of the button macros it creates, and deletes orphaned ones upon login. If you are upgrading from a previous version, you can delete the old button macros that SDM created (the text of the new ones all start with "#sdm"). +¥ Because of this, SDM will no longer ever replace your macros, and their names do not need to be unique at all. Floating macros and Scripts still have some restrictions on naming, you will get a warning it you try to violate them. +¥ Added many UI improvements to make working with the addon more intuitive: + Ð Pressing tab will now add four spaces + Ð Pressing enter will now be equivalent to the appropriate button click + - Moved some buttons around to more appropriate places + - Added buttons that link between the regular macro window and the SDM window + Ð Buttons will now "gray out" when appropriate + Ð The SDM window will now become unresponsive during confirmation dialogs + +1.2 (12/13/08) +Fixed a bug that caused major problems when there were no macros in the list. + +1.1 (12/12/08) +More UI improvements. Some UI elements are still placeholders. + +1.0 (11/13/08) +just two minor updates in code to make it 3.0-ready. More UI improvements to come! \ No newline at end of file -- 1.7.9.5