Skip to content

Commit 1124a67

Browse files
Timclaude
andcommitted
Add Classic Era and Cata Classic API compatibility
- Add C_ActionBar.GetSpell fallback using GetActionInfo for versions without modern API - Add C_ActionBar.IsAssistedCombatAction check to prevent errors on Classic - Add fallback text for HUD_EDIT_MODE_COLLAPSE/EXPAND_OPTIONS global strings - Extract editmodeui.blp for arrow textures in Classic versions Fixes Lua errors on Classic Era (1.15.8) and Cata Classic (5.5.3). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1fe2995 commit 1124a67

3 files changed

Lines changed: 34 additions & 6 deletions

File tree

Core.lua

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ local API_COMPAT = {
1414
has_modern_spellbook = (C_SpellBook and C_SpellBook.GetNumSpellBookSkillLines ~= nil),
1515
has_legacy_spell_api = (_G.GetSpellBookItemInfo ~= nil and _G.GetNumSpellTabs ~= nil),
1616
has_assisted_combat = (C_AssistedCombat and C_AssistedCombat.IsAvailable ~= nil),
17+
has_actionbar_getspell = (C_ActionBar and C_ActionBar.GetSpell ~= nil),
1718
}
1819
addon.api_compat = API_COMPAT
1920

@@ -1563,6 +1564,11 @@ end
15631564
function addon:update_assisted_combat_indicator(button, slot)
15641565
if not slot then return end
15651566

1567+
-- Assisted Combat only exists in Retail & Anniversary
1568+
if not C_ActionBar or not C_ActionBar.IsAssistedCombatAction then
1569+
return
1570+
end
1571+
15661572
local isAssistedCombat = C_ActionBar.IsAssistedCombatAction(slot)
15671573

15681574
if isAssistedCombat then
@@ -1588,6 +1594,20 @@ function addon:update_assisted_combat_indicator(button, slot)
15881594
end
15891595
end
15901596

1597+
-- Get spell ID from action slot (version-compatible)
1598+
-- Retail & Anniversary have C_ActionBar.GetSpell, Cata Classic & Classic Era don't
1599+
local function GetSpellFromActionSlot(slot)
1600+
if API_COMPAT.has_actionbar_getspell then
1601+
return C_ActionBar.GetSpell(slot)
1602+
else
1603+
local actionType, actionID = GetActionInfo(slot)
1604+
if actionType == "spell" then
1605+
return actionID
1606+
end
1607+
end
1608+
return nil
1609+
end
1610+
15911611
-- Handles processing for ACTIONBUTTON
15921612
function addon:process_actionbutton_slot(slot, button)
15931613
if not slot then return end
@@ -1605,7 +1625,7 @@ function addon:process_actionbutton_slot(slot, button)
16051625
button.icon:Show()
16061626

16071627
-- Store the spell ID if the action contains a spell
1608-
local spellID = C_ActionBar.GetSpell(adjusted_slot)
1628+
local spellID = GetSpellFromActionSlot(adjusted_slot)
16091629
if spellID then
16101630
button.spellid = spellID
16111631
end
@@ -1671,7 +1691,7 @@ function addon:process_multiactionbar_slot(bar, bar_button, button)
16711691
button.icon:Show()
16721692

16731693
-- Store the spell ID if the action contains a spell
1674-
local spellID = C_ActionBar.GetSpell(slot)
1694+
local spellID = GetSpellFromActionSlot(slot)
16751695
if spellID then
16761696
button.spellid = spellID
16771697
end

Frames/Controls.lua

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,18 +537,26 @@ function addon:create_controls()
537537
end
538538
end
539539

540+
-- Fallback text for Classic versions that don't have these global strings
541+
-- Inline texture format: |Tpath:height:width:xoffset:yoffset:texWidth:texHeight:left:right:top:bottom|t
542+
-- EditModeUI.blp is 32x256, arrows are at pixel coords calculated from AtlasInfo
543+
local ARROW_UP = "|TInterface\\AddOns\\KeyUI\\Media\\Atlas\\editmodeui:11:16:0:3:32:256:1:17:158:169|t"
544+
local ARROW_DOWN = "|TInterface\\AddOns\\KeyUI\\Media\\Atlas\\editmodeui:11:16:0:-7:32:256:1:17:145:156|t"
545+
local COLLAPSE_TEXT = HUD_EDIT_MODE_COLLAPSE_OPTIONS or ("Collapse options " .. ARROW_UP)
546+
local EXPAND_TEXT = HUD_EDIT_MODE_EXPAND_OPTIONS or ("Expand options " .. ARROW_DOWN)
547+
540548
-- Function to toggle the controls_expanded value
541549
local function toggle_controls_expanded()
542550
keyui_settings.controls_expanded = not keyui_settings.controls_expanded
543551

544552
-- Update the expander text and controls visibility based on the new state
545553
if keyui_settings.controls_expanded then
546-
controls_frame.expander_text:SetText(HUD_EDIT_MODE_COLLAPSE_OPTIONS)
554+
controls_frame.expander_text:SetText(COLLAPSE_TEXT)
547555
controls_frame:SetHeight(350)
548556
set_controls_visibility(true)
549557
controls_frame.expander_text:SetPoint("CENTER", controls_frame, "BOTTOM", 0, 30)
550558
else
551-
controls_frame.expander_text:SetText(HUD_EDIT_MODE_EXPAND_OPTIONS)
559+
controls_frame.expander_text:SetText(EXPAND_TEXT)
552560
controls_frame:SetHeight(200)
553561
set_controls_visibility(false)
554562
controls_frame.expander_text:SetPoint("CENTER", controls_frame, "BOTTOM", 0, 30)
@@ -560,9 +568,9 @@ function addon:create_controls()
560568

561569
-- Set the text based on controls_expanded value
562570
if keyui_settings.controls_expanded then
563-
controls_frame.expander_text:SetText(HUD_EDIT_MODE_COLLAPSE_OPTIONS)
571+
controls_frame.expander_text:SetText(COLLAPSE_TEXT)
564572
else
565-
controls_frame.expander_text:SetText(HUD_EDIT_MODE_EXPAND_OPTIONS)
573+
controls_frame.expander_text:SetText(EXPAND_TEXT)
566574
end
567575

568576
controls_frame.expander_text:SetFont(addon:GetFont(), addon:GetFontSize(1.0))

Media/Atlas/editmodeui.blp

33.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)