From 8af21646fa390c2be0cd3fc776112e764806a84b Mon Sep 17 00:00:00 2001 From: Ahmil Jilani Date: Tue, 16 Dec 2008 14:46:00 -0500 Subject: [PATCH] 1.3.1 --- SuperDuperMacro/SuperDuperMacro.lua | 175 ++++++++++++++++++----------------- SuperDuperMacro/SuperDuperMacro.toc | 2 +- SuperDuperMacro/sdm Readme.txt | 14 +-- 3 files changed, 97 insertions(+), 94 deletions(-) diff --git a/SuperDuperMacro/SuperDuperMacro.lua b/SuperDuperMacro/SuperDuperMacro.lua index 748ab73..71928c8 100644 --- a/SuperDuperMacro/SuperDuperMacro.lua +++ b/SuperDuperMacro/SuperDuperMacro.lua @@ -1,6 +1,6 @@ -function sdm_SlashHandler(command) +function sdm_SlashHandler(command) if command=="" then - sdm_editFrame:Show() + sdm_editFrame:Show() elseif command=="load" then sdm_DoAllMacros() elseif command:sub(1,4)=="run " then sdm_RunScript(command:sub(5,command:len())) @@ -20,29 +20,29 @@ function sdm_MakeMacroFrame(name, text) 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) + local macroIndex = sdm_GetMacroIndex(ID) + if macroIndex then + EditMacro(macroIndex, name, nil, text, 1, perCharacter) else CreateMacro(name, 1, text, perCharacter, 1) end end -function sdm_GetSdmID(macroID) - local thisMacroText=GetMacroBody(macroID) +function sdm_GetSdmID(macroIndex) + local thisMacroText=GetMacroBody(macroIndex) 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_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 "\n/click [btn:5]"..nextName.." Button5;[btn:4]"..nextName.." Button4;[btn:3]"..nextName.." MiddleButton;[btn:2]"..nextName.." RightButton;"..nextName end @@ -59,14 +59,14 @@ function sdm_UpdateCurrentEdit(setTo) else sdm_currentEdit = 0 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 + 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, ID) frameNum=1 @@ -152,7 +152,7 @@ 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={} @@ -176,24 +176,24 @@ EventFrame:SetScript("OnEvent", function () 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 macrosToDelete = {} local iIsPerCharacter=false - for i=1,54 do + for i=1,54 do if i==37 then iIsPerCharacter=true end thisID=sdm_GetSdmID(i) - if thisID then + if thisID then local IDUsedBy = sdm_IsIDUsed(thisID) if foundOne[thisID] then - table.insert(macrosToDelete, i) + 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 + 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 @@ -203,28 +203,29 @@ EventFrame:SetScript("OnEvent", function () 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 + 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 strings[i]==nil then strings[i]="0" end + local indexOfPeriod=(strings[i]):find("%.") if indexOfPeriod==nil then numbers[i]=strings[i] strings[i]=nil @@ -267,30 +268,30 @@ function sdm_MenuFrameButtonClicked() sdm_editFrame_menuFrame_numberInput:SetText("") sdm_editFrame_menuFrame_numberInput:ClearFocus() end -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_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 - sdm_editFrame_editScrollFrame_text:ClearFocus() + else + sdm_editFrame_editScrollFrame_text:ClearFocus() StaticPopupDialogs["SDM_CONFIRM"] = { text = "Do you want to save your changes to \""..sdm_macros[sdm_currentEdit].name.."\"?", button1 = "Save", --left button @@ -305,19 +306,19 @@ function sdm_SaveConfirmationBox(postponed) } StaticPopup_Show("SDM_CONFIRM"):SetPoint("CENTER", "sdm_editFrame", "CENTER") end -end +end function sdm_ShowMacroEditText(index) if sdm_currentEdit==0 then textToShow="" else textToShow=sdm_macros[index].text end - sdm_editFrame_editScrollFrame_text:SetText(textToShow) + sdm_editFrame_editScrollFrame_text:SetText(textToShow) end function sdm_DeleteMacro(num) - if sdm_currentEdit==0 then return end + if num==0 then return end if sdm_macros[num].type=="b" then - DeleteMacro(sdm_macros[num].name) + DeleteMacro(sdm_GetMacroIndex(sdm_macros[num].ID)) end for i=num, getn(sdm_macros) do sdm_macros[i]=sdm_macros[i+1] @@ -327,15 +328,8 @@ function sdm_DeleteMacro(num) end function sdm_GetCurrentLink() if sdm_currentEdit==0 then return end - 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) + if sdm_macros[sdm_currentEdit].type=="b" then + PickupMacro(sdm_GetMacroIndex(sdm_macros[sdm_currentEdit].ID)) 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 @@ -352,8 +346,8 @@ end function sdm_SaveCurrent() if sdm_currentEdit==0 then return end sdm_macros[sdm_currentEdit].text=sdm_editFrame_editScrollFrame_text:GetText() - sdm_DoAllMacros() - sdm_saveButtonEnabled=0 + sdm_DoAllMacros() + sdm_saveButtonEnabled=0 sdm_editFrame_saveButton:Disable() end function sdm_CreateButtonClicked() @@ -370,6 +364,13 @@ function sdm_CreateButtonClicked() type="s" end perCharacter = sdm_newFrame_charspecRadio:GetChecked() + if not perChar and GetMacroInfo(36) then + DEFAULT_CHAT_FRAME:AddMessage("SDM: You already have 36 global macros.") + return + elseif perCharacter and GetMacroInfo(54) then + DEFAULT_CHAT_FRAME:AddMessage("SDM: You already have 18 character-specific macros.") + return + end 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..")") @@ -384,11 +385,11 @@ function sdm_CreateNew(type, name, perCharacter) 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." + 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." + sdm_macros[sdm_currentEdit].text="# Enter macro text here." end if perCharacter then sdm_macros[sdm_currentEdit].character={name=UnitName("player"), server=GetRealmName()} diff --git a/SuperDuperMacro/SuperDuperMacro.toc b/SuperDuperMacro/SuperDuperMacro.toc index 0e6464c..5767d75 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.3 +## Version: 1.3.1 ## SavedVariables: sdm_macros, sdm_version SuperDuperMacro.xml SuperDuperMacro.lua \ No newline at end of file diff --git a/SuperDuperMacro/sdm Readme.txt b/SuperDuperMacro/sdm Readme.txt index a678831..16985c1 100644 --- a/SuperDuperMacro/sdm Readme.txt +++ b/SuperDuperMacro/sdm Readme.txt @@ -1,5 +1,5 @@ Super Duper Macro -version 1.3 +version 1.3.1 by hypehuman Open the interface by typing /sdm @@ -7,16 +7,14 @@ 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 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") +¥ button macros ("b") can be placed on your action bar because they tie themselves to a regular macro. Therefore, you can only make a limited number of these (36 global and 36 character-specific for each character). To set an icon for a button macro, use the regular macro interface (/macro). +¥ floating macros ("f"), do not have buttons, and are accessed by /click. You can make as many of these as you want. +¥ You can also make lua 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: ¥ Clickable menu of macros ¥ 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! @@ -28,6 +26,10 @@ Special thanks to: Change Log +1.3.1 (12/16/08) +¥ÊFixed an occasional bug with the "Get Link" and "Delete" buttons +¥ Blocked you from attempting to make more button macros than the standard macro interface can hold + 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"). -- 1.7.9.5