Skip to content

Commit

Permalink
Merge pull request #219 from bpapuni/master
Browse files Browse the repository at this point in the history
Updated for 11.0 The War Within
  • Loading branch information
Sellorio authored Jul 24, 2024
2 parents a370358 + 1163535 commit 41bdfef
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 44 deletions.
2 changes: 1 addition & 1 deletion MegaMacro.toc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Interface: 100206
## Interface: 110000
## Title: Mega Macro
## Author: Sellorio
## Version: 1.0.0
Expand Down
41 changes: 23 additions & 18 deletions src/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ MacroLimits = {
PerClassCount = 30,
PerSpecializationCount = 30,
-- limit: 18 character specific macro slots
PerCharacterCount = 18,
PerCharacterCount = 30,
PerCharacterSpecializationCount = 0,
InactiveCount = 160,
MaxGlobalMacros = 120,
MaxCharacterMacros = 18
MaxCharacterMacros = 30
}

MacroIndexOffsets = {
Expand Down Expand Up @@ -42,20 +42,25 @@ PetActionTextures = {

MegaMacroTexture = 134400
MegaMacroActiveStanceTexture = 136116
MegaMacroCodeMaxLength = 1023
MegaMacroCodeMaxLength = 255
MegaMacroCodeMaxLengthForNative = 250
HighestMaxMacroCount = math.max(MacroLimits.GlobalCount, MacroLimits.PerClassCount, MacroLimits.PerSpecializationCount, MacroLimits.PerCharacterCount, MacroLimits.PerCharacterSpecializationCount)

MegaMacroInfoFunctions = {
Spell = {
GetCooldown = GetSpellCooldown,
GetCount = GetSpellCount,
GetCharges = function(spellId) return GetSpellCharges(spellId) end,
IsUsable = IsUsableSpell,
GetCooldown = function(abilityId)
local spellCooldownInfo = C_Spell.GetSpellCooldown(abilityId);
if spellCooldownInfo then
return spellCooldownInfo.startTime, spellCooldownInfo.duration, spellCooldownInfo.isEnabled, spellCooldownInfo.modRate;
end
end,
GetCount = C_Spell.GetSpellCastCount,
GetCharges = function(spellId) return C_Spell.GetSpellCharges(spellId) end,
IsUsable = C_Spell.IsSpellUsable,
IsInRange = function(spellId, target)
local spellIndex = FindSpellBookSlotBySpellID(spellId)
if spellIndex then
local result = IsSpellInRange(spellIndex, "spell", target)
local result = C_Spell.IsSpellInRange(spellIndex, "spell", target)

if result == nil then
return nil
Expand All @@ -64,27 +69,27 @@ MegaMacroInfoFunctions = {
end
end
end,
IsCurrent = IsCurrentSpell,
IsCurrent = C_Spell.IsCurrentSpell,
IsEquipped = function(_) return false end,
IsAutoRepeat = IsAutoRepeatSpell,
IsAutoRepeat = C_Spell.IsAutoRepeatSpell,
IsLocked = C_LevelLink.IsSpellLocked,
GetLossOfControlCooldown = GetSpellLossOfControlCooldown,
GetLossOfControlCooldown = C_Spell.GetSpellLossOfControlCooldown,
IsOverlayed = IsSpellOverlayed
},
Item = {
GetCooldown = GetItemCooldown,
GetCount = function(itemId) return GetItemCount(itemId, false, true) end,
GetCooldown = C_Item.GetItemCooldown,
GetCount = function(itemId) return C_Item.GetItemCount(itemId, false, true) end,
GetCharges = function(_) return 0, 0, -1, 0, 1 end, -- charges, maxCharges, chargeStart, chargeDuration, chargeModRate
IsUsable = function(itemId) return IsUsableItem(itemId), false end,
IsUsable = function(itemId) return C_Item.IsUsableItem(itemId), false end,
IsInRange = function(itemId)
if GetItemInfo(itemId) then
if C_Item.GetItemInfo(itemId) then
return function(unit)
return IsItemInRange(itemId, unit)
return C_Item.IsItemInRange(itemId, unit)
end
end
end,
IsCurrent = IsCurrentItem,
IsEquipped = function(itemId) return IsEquippedItem(itemId) end,
IsCurrent = C_Item.IsCurrentItem,
IsEquipped = function(itemId) return C_Item.IsEquippedItem(itemId) end,
IsAutoRepeat = function(_) return false end,
IsLocked = function(_) return false end,
GetLossOfControlCooldown = function(_) return -1, 0 end,
Expand Down
15 changes: 5 additions & 10 deletions src/engine/mega-macro-action-bar-engine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ For developer refererence, these are the features of an action bar button:

local LibActionButton = nil
local ActionBarSystem = nil -- Blizzard or LAB or Dominos
local BlizzardActionBars = { "Action", "MultiBarBottomLeft", "MultiBarBottomRight", "MultiBarRight", "MultiBarLeft" }
local BlizzardActionBars = { "Action", "MultiBarBottomLeft", "MultiBarBottomRight", "MultiBarRight", "MultiBarLeft", "MultiBar5", "MultiBar6", "MultiBar7" }

local rangeTimer = 5
local updateRange = false
Expand Down Expand Up @@ -190,7 +190,7 @@ local function UpdateCount(button, functions, abilityId)
local countLabel = button.Count
local count = functions.GetCount(abilityId)

local isNonEquippableItem = functions == MegaMacroInfoFunctions.Item and not IsEquippableItem(abilityId)
local isNonEquippableItem = functions == MegaMacroInfoFunctions.Item and not C_Item.IsEquippableItem(abilityId)
local isNonItemWithCount = functions ~= MegaMacroInfoFunctions.Item and count and count > 0

if isNonEquippableItem or isNonItemWithCount then
Expand Down Expand Up @@ -235,6 +235,8 @@ end

local function UpdateRange(button, functions, abilityId, target)
local valid = functions.IsInRange(abilityId, target)
-- local valid = IsSpellInRange(spellName, target) or IsItemInRange(abilityId, target)
-- local valid = true
local checksRange = (valid ~= nil);
local inRange = checksRange and valid;
rangeTimer = 1;
Expand Down Expand Up @@ -278,10 +280,6 @@ local function UpdateRange(button, functions, abilityId, target)
end

local function UpdateActionBar(button, macroId)
if MegaMacroConfig['UseNativeActionBar'] then
return
end

local data = MegaMacroIconEvaluator.GetCachedData(macroId)
local functions = MegaMacroInfoFunctions.Unknown

Expand Down Expand Up @@ -316,9 +314,6 @@ local function UpdateActionBar(button, macroId)
end

local function ResetActionBar(button)
if MegaMacroConfig['UseNativeActionBar'] then
return
end
button:SetChecked(false)
button.Count:SetText("")
button.Border:Hide() -- reset eqipped border
Expand Down Expand Up @@ -397,7 +392,7 @@ end
function MegaMacroActionBarEngine.OnUpdate(elapsed)
UpdateRangeTimer(elapsed)

local focus = GetMouseFocus()
local focus = GetMouseFoci()[1]
local iterator = ForEachBlizzardActionButton

if ActionBarSystem == "LAB" then
Expand Down
12 changes: 8 additions & 4 deletions src/engine/mega-macro-icon-evaluator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,28 @@ local function GetAbilityData(ability)
if slotId then
local itemId = GetInventoryItemID("player", slotId)
if itemId then
local itemName, _, _, _, _, _, _, _, _, itemTexture = GetItemInfo(itemId)
local itemName, _, _, _, _, _, _, _, _, itemTexture = C_Item.GetItemInfo(itemId)
return "item", itemId, itemName, itemTexture
else
return "unknown", nil, nil, MegaMacroTexture
end
else
local spellName, _, texture, _, _, _, spellId = GetSpellInfo(ability)
local spellInfo = C_Spell.GetSpellInfo(ability)
if (spellInfo == nil) then
return
end
local spellName, _, texture, _, _, _, spellId = spellInfo.name, nil, spellInfo.iconID, spellInfo.castTime, spellInfo.minRange, spellInfo.maxRange, spellInfo.spellID
if spellId then
local shapeshiftFormIndex = GetShapeshiftForm()
local isActiveStance = shapeshiftFormIndex and shapeshiftFormIndex > 0 and spellId == select(4, GetShapeshiftFormInfo(shapeshiftFormIndex))
return "spell", spellId, spellName, isActiveStance and MegaMacroActiveStanceTexture or texture
end

local itemId
itemId, _, _, _, texture = GetItemInfoInstant(ability)
itemId, _, _, _, texture = C_Item.GetItemInfoInstant(ability)
if texture then
if C_ToyBox.GetToyInfo(itemId) then
spellName, spellId = GetItemSpell(itemId)
spellName, spellId = C_Item.GetItemSpell(itemId)
if spellId then
return "spell", spellId, spellName, texture
end
Expand Down
1 change: 1 addition & 0 deletions src/engine/parsing/conditions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ end

local Conditionals = {
actionbar = NoModifier,
advflyable = NoModifier,
bar = NumberModifier,
bonusbar = NumberModifier,
btn = MouseButtonModifier,
Expand Down
9 changes: 8 additions & 1 deletion src/engine/parsing/parsing-functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ local function ParseResult(parsingContext, length, colour)
end
local text = string.sub(parsingContext.Code, parsingContext.Index, parsingContext.Index + length - 1)
parsingContext.Index = parsingContext.Index + length
return colour and "|c"..colour..text.."|r" or text

if parsingContext.Index > 256 then
local validText = #text - (parsingContext.Index - 256) >= 1 and text:sub(1, #text - (parsingContext.Index - 256)) or ""
local overflowText = #validText > 0 and text:sub(#text - (parsingContext.Index - 257)) or text
return validText .. "|c"..GetMegaMacroParsingColourData().Error..overflowText.."|r"
else
return colour and "|c"..colour..text.."|r" or text
end
end

function GetMegaMacroParsingFunctions()
Expand Down
5 changes: 4 additions & 1 deletion src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,7 @@ f:SetScript("OnEvent", function(self, event)
end
end)

MegaMacro_RegisterShiftClicks()
MegaMacro_RegisterShiftClicks()

tinsert(UISpecialFrames, "MegaMacro_Frame")
UIPanelWindows["MegaMacro_Frame"] = nil
18 changes: 13 additions & 5 deletions src/mega-macro-icon-navigator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@ local function GetDefaultIconList()
-- We need to avoid adding duplicate spellIDs from the spellbook tabs for your other specs.
local activeIcons = {};

for i = 1, GetNumSpellTabs() do
local tab, tabTex, offset, numSpells, _ = GetSpellTabInfo(i);
for i = 1, C_SpellBook.GetNumSpellBookSkillLines() do
local skillLine = C_SpellBook.GetSpellBookSkillLineInfo(i)
local tab = skillLine.name
local tabTex = skillLine.iconID
local offset = skillLine.itemIndexOffset
local numSpells = skillLine.numSpellBookItems
offset = offset + 1;
local tabEnd = offset + numSpells;
for j = offset, tabEnd - 1 do
--to get spell info by slot, you have to pass in a pet argument
local spellType, ID = GetSpellBookItemInfo(j, "player");
local spellType, ID = C_SpellBook.GetSpellBookItemType(j, Enum.SpellBookSpellBank.Player);
if (spellType ~= "FUTURESPELL") then
local fileID = GetSpellBookItemTexture(j, "player");
local fileID = C_SpellBook.GetSpellBookItemTexture(j, Enum.SpellBookSpellBank.Player);
if (fileID) then
activeIcons[fileID] = true;
end
Expand Down Expand Up @@ -86,7 +90,11 @@ function MegaMacroIconNavigator.OnUpdate()
if IconLoadingStarted and not IconLoadingFinished then
for _=1, FetchesPerFrame do
CurrentSpellId = CurrentSpellId + 1
local name, _, icon, _, _, _, spellId = GetSpellInfo(CurrentSpellId)
local spellInfo = C_Spell.GetSpellInfo(CurrentSpellId)
if (spellInfo == nil) then
return
end
local name, _, icon, _, _, _, spellId = spellInfo.name, nil, spellInfo.iconID, spellInfo.castTime, spellInfo.minRange, spellInfo.maxRange, spellInfo.spellID

if icon == 136243 then
-- 136243 is the a gear icon, we can ignore those spells (courtesy of WeakAuras)
Expand Down
10 changes: 6 additions & 4 deletions src/windows/mega-macro.window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ local function InitializeTabs()
MegaMacro_FrameTab4:SetText(playerName)
MegaMacro_FrameTab5:SetText("Inactive")
MegaMacro_FrameTab6:SetText("Config")

if MegaMacroCachedSpecialization == '' then
MegaMacro_FrameTab3:SetText("Locked")
MegaMacro_FrameTab3:Disable()
Expand Down Expand Up @@ -285,7 +285,7 @@ local function DeleteMegaMacro()
end

local function UpdateTooltipIfButtonIsHovered(updatedMacroId)
local mouseFocus = GetMouseFocus()
local mouseFocus = GetMouseFoci()[1]

if mouseFocus then
local focusFrame = mouseFocus:GetName()
Expand Down Expand Up @@ -501,7 +501,7 @@ function MegaMacro_FrameTab_OnClick(self)
MegaMacro_FrameTab_ShowConfig()
return
end

SelectedScope = scope
SelectedTabIndex = tabIndex

Expand Down Expand Up @@ -630,7 +630,9 @@ function MegaMacro_TextBox_TextChanged(self)
MegaMacro_FrameText:GetNumLetters(),
MegaMacroCodeMaxLength)
-- Set color of text based on length
if MegaMacro_FrameText:GetNumLetters() > MegaMacroCodeMaxLengthForNative then
if MegaMacro_FrameText:GetNumLetters() > MegaMacroCodeMaxLength then
MegaMacro_FrameCharLimitText:SetTextColor(1, 0.267, 0.267)
elseif MegaMacro_FrameText:GetNumLetters() > MegaMacroCodeMaxLengthForNative then
MegaMacro_FrameCharLimitText:SetTextColor(1, 0.85, 0)
else
MegaMacro_FrameCharLimitText:SetTextColor(1,1,1) --0.2, 0.867, 1.0
Expand Down

0 comments on commit 41bdfef

Please sign in to comment.