1
0
Bifurcation 0

Comparer les révisions

...

19 commits

Auteur SHA1 Message Date
05c592f66f updated with latest fixes from Sunnova 2021-07-26 22:13:56 +02:00
176330e352 removed regression 2021-05-25 19:18:40 +02:00
199fd9cd09 update for classic BC 2021-05-24 18:34:34 +02:00
4763a6c340 Merge branch 'master' of https://git.dess.ga/Albirew/ButtonForge-classic 2021-02-20 14:13:48 +01:00
7fbbf2f98d fixed issue 70
https://www.curseforge.com/wow/addons/button-forge/issues/70
2021-02-20 14:13:01 +01:00
Albirew
813a26859a Mise à jour de 'README.md' 2021-02-20 11:24:09 +00:00
Albirew
e6d11fcdc6 added some slash commands 2021-02-20 11:23:18 +00:00
00bf15fb7b Merge branch 'original'
also removed advanced "create bonus bar" button since non-existant in classic
2021-01-30 17:15:42 +01:00
d42e06d3de release 1.0.3 2021-01-30 15:10:55 +01:00
183479263c Merged Release 1.0.2 into master
also fixed destroy bar sound
2020-12-29 17:34:25 +01:00
89fad344be ToC bump 2020-12-29 15:41:40 +01:00
Albirew
2bd6ddb1d2 fixed #8 part.2 2020-12-23 02:11:38 +00:00
Albirew
09c0b23576 fixed #8 2020-12-23 02:04:12 +00:00
fabebbfe11 release 1.0.2 2020-12-15 05:05:07 +01:00
3b450b1daa fixed last forgotten line from renaming 2020-11-26 15:53:29 +01:00
74105a9d11 removed classic from name and ToC bump
fork got it's place in addon team
2020-11-26 03:13:24 +01:00
58a8ef7de9 update to 1.0.1 2020-11-26 02:32:29 +01:00
9da175d295 update to 1.0.0 2020-11-26 02:31:28 +01:00
d46c9fcf1c Bump ToC to 1.13.3 2019-12-14 00:43:59 +01:00
15 fichiers modifiés avec 708 ajouts et 123 suppressions

39
Bar.lua
Voir le fichier

@ -142,6 +142,7 @@ function Bar.New(BarSave)
--[[Background Layer, this will contain all controls and is used in resizing]]--
local Background = CreateFrame("FRAME", nil, ControlFrame);
Mixin(Background, BackdropTemplateMixin)
Background:SetSize(1, 1);
Background:SetPoint("TOPLEFT", ControlFrame, "TOPLEFT");
Background:SetBackdrop({bgFile = Const.ImagesDir.."Backdrop.tga", edgeFile = "Interface/Tooltips/UI-Tooltip-Border", tile = true, tileSize = 16, edgeSize = 16, insets = {left=3, right=3, bottom=3, top=3}});
@ -183,6 +184,7 @@ function Bar.New(BarSave)
--[[Label Frame]]--
local LabelFrame = CreateFrame("FRAME", nil, ControlFrame);
Mixin(LabelFrame, BackdropTemplateMixin)
LabelFrame:SetSize(1, 1);
LabelFrame:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", edgeFile = "Interface/Tooltips/UI-Tooltip-Border", tile = true, tileSize = 16, edgeSize = 8, insets = {left=1.5, right=1.5, bottom=1.5, top=1.5}});
LabelFrame:SetBackdropColor(0, 0, 0, 1);
@ -534,8 +536,7 @@ function Bar:Configure(BarSave)
self:SetAlpha(BarSave["Alpha"]);
self:SetGUI(BarSave["GUI"]);
-- Uncomment this once Clamp insets are working again
--self.ControlFrame:SetClampedToScreen(true);
self.ControlFrame:SetClampedToScreen(true);
end
--[[
@ -562,6 +563,27 @@ function Bar:GetPosition()
return self.BarSave["Left"], self.BarSave["Top"], self.BarSave["Left"]..", "..self.BarSave["Top"];
end
function Bar:SetFlyoutDirection(Direction)
local flyoutDirection = "UP"; -- default
if (Direction == "left" or Direction == "LEFT") then
flyoutDirection = "LEFT";
elseif (Direction == "right" or Direction == "RIGHT") then
flyoutDirection = "RIGHT";
elseif (Direction == "down" or Direction == "DOWN") then
flyoutDirection = "DOWN";
end
self.BarSave["FlyoutDirection"] = flyoutDirection;
for r = 1, self.Rows do
for c = 1, self.Cols do
local i = (r-1) * self.Cols + c;
self.Buttons[i].Widget:SetAttribute("flyoutDirection", flyoutDirection);
self.Buttons[i]:UpdateFlyout();
end
end
end
function Bar:SetScale(Scale, NoCheck)
Scale = (Scale or 0) + 0;
if (Scale <= 0) then
@ -605,6 +627,10 @@ function Bar:SetButtonsFromSave()
local NewButton = Util.NewButton(self.ButtonFrame, self.BarSave["Buttons"][i], self.BarSave["ButtonsLocked"], self.BarSave["TooltipsOn"], self.BarSave["MacroText"], self.BarSave["KeyBindText"]);
table.insert(self.Buttons, i, NewButton);
NewButton.Widget:SetPoint("TOPLEFT", self.ButtonFrame, "TOPLEFT", (c-1) * self.BSize, (1-r) * self.BSize);
if (self.BarSave["FlyoutDirection"]) then
NewButton.Widget:SetAttribute("flyoutDirection", self.BarSave["FlyoutDirection"]);
NewButton:UpdateFlyout();
end
end
end
@ -668,6 +694,10 @@ function Bar:SetNumButtons(Cols, Rows)
local NewButton = Util.NewButton(BFrame, ButtonSave, self.BarSave["ButtonsLocked"], self.BarSave["TooltipsOn"], self.BarSave["MacroText"], self.BarSave["KeyBindText"]);
table.insert(Buttons, i, NewButton);
NewButton.Widget:SetPoint("TOPLEFT", BFrame, "TOPLEFT", (c-1) * self.BSize, (1-r) * self.BSize);
if (self.BarSave["FlyoutDirection"]) then
NewButton.Widget:SetAttribute("flyoutDirection", self.BarSave["FlyoutDirection"]);
NewButton:UpdateFlyout();
end
end
end
self.Cols = Cols;
@ -680,6 +710,10 @@ function Bar:SetNumButtons(Cols, Rows)
local NewButton = Util.NewButton(BFrame, ButtonSave, self.BarSave["ButtonsLocked"], self.BarSave["TooltipsOn"], self.BarSave["MacroText"], self.BarSave["KeyBindText"]);
table.insert(Buttons, i, NewButton);
NewButton.Widget:SetPoint("TOPLEFT", BFrame, "TOPLEFT", (c-1) * self.BSize, (1-r) * self.BSize);
if (self.BarSave["FlyoutDirection"]) then
NewButton.Widget:SetAttribute("flyoutDirection", self.BarSave["FlyoutDirection"]);
NewButton:UpdateFlyout();
end
end
end
self.Rows = Rows;
@ -1105,6 +1139,7 @@ end
--]]
function Bar:DestroyBar()
if (not InCombatLockdown()) then
PlaySoundFile("sound/spells/meltoretarget.ogg"); --PlaySoundFile(569366)
Util.DeallocateBar(self);
end
UILib.ToggleDestroyBarMode(true);

Voir le fichier

@ -573,7 +573,7 @@ end
--[[ Set the individual types of actions including obtained any extra data they may need --]]
function Button:SetCommandSpell(Id)
local Name, Rank = GetSpellInfo(Id);
local Name, Rank = Util.GetSpellInfo(Id); -- TBC Fix 2021/06/18
local NameRank = Util.GetFullSpellName(Name, Rank);
self:SetCommandExplicitSpell(Id, NameRank, Name, Book);
end
@ -663,7 +663,7 @@ end
--[[ The following functions will configure the button to operate correctly for the specific type of action (these functions must be able to handle the player not knowing spells/macros etc) --]]
function Button:SetEnvSpell(Id, NameRank, Name, Book, IsTalent)
self.UpdateTexture = Button.Empty;
self.UpdateTexture = Button.UpdateTextureSpell;
self.UpdateChecked = Button.UpdateCheckedSpell;
self.UpdateEquipped = Button.Empty;
self.UpdateCooldown = Button.UpdateCooldownSpell;
@ -1230,7 +1230,9 @@ function Button:TranslateMacro()
self.CompanionIndex = CompanionID;
end
self.SpellName = SpellName;
self.SpellNameRank = GetSpellInfo(SpellName); --BFA fix: Cache is indexed by name and the old function returned the ID
-- self.SpellNameRank = GetSpellInfo(SpellName); --BFA fix: Cache is indexed by name and the old function returned the ID
local Rank = Util.GetSpellRank(SpellId) -- TBC Fix 2021/06/17
self.SpellNameRank = Util.GetFullSpellName(SpellName, Rank); -- TBC Fix 2021/06/17
self.SpellId = SpellId;
self.MacroMode = "spell";
else
@ -1275,6 +1277,27 @@ function Button:UnitBuffBySpell(unit, spell)
return nil;
end;
function Button:UpdateTextureSpell()
local spellHasBuffActive = false;
for i=1,40 do
local spellId = select(10, UnitBuff("player", i));
if spellId then
if spellId == self.SpellId then
spellHasBuffActive = true;
break;
end
else
-- no more buffs
break;
end;
end;
if (spellHasBuffActive == true and Const.StealthSpellIds[self.SpellId] ~= nil) then
self.WIcon:SetTexture("Interface/Icons/Spell_Nature_Invisibilty");
else
self.WIcon:SetTexture(self.Texture);
end
end
function Button:UpdateTextureWispSpell()
--BFA fix: UnitBuff can no longer be called with the spell name as a param
if (self.UnitBuffBySpell("player", self.SpellName)) then --NOTE: This en-US, hopefully it will be fine for other locales as well??
@ -1288,7 +1311,7 @@ function Button:UpdateTextureMacro()
end
function Button:UpdateTextureBonusAction()
local action = self.Widget:GetAttribute("action");
if (HasOverrideActionBar() or HasVehicleActionBar()) then
if (HasOverrideActionBar()) then
local Texture = GetActionTexture(action);
if (not Texture) then
self.WIcon:SetTexture(Const.ImagesDir.."Bonus"..self.BonusActionId);
@ -1386,7 +1409,7 @@ function Button:UpdateCheckedCompanion()
end
function Button:UpdateCheckedBonusAction()
local action = self.Widget:GetAttribute("action");
if ((HasOverrideActionBar() or HasVehicleActionBar()) and (IsCurrentAction(action) or IsAutoRepeatAction(action))) then
if ((HasOverrideActionBar()) and (IsCurrentAction(action) or IsAutoRepeatAction(action))) then
self.Widget:SetChecked(true);
else
self.Widget:SetChecked(false);
@ -1397,6 +1420,8 @@ function Button:UpdateCheckedCustomAction()
end
--[[---------------------------------------------------------------------------------------
Equipped functions
-----------------------------------------------------------------------------------------]]
@ -1469,7 +1494,7 @@ function Button:UpdateCooldownCompanion()
--as of 5.0.4 doesn't appear to exist anymore?!
end
function Button:UpdateCooldownBonusAction()
if (HasOverrideActionBar() or HasVehicleActionBar()) then
if (HasOverrideActionBar()) then
local action = self.Widget:GetAttribute("action");
Util.CooldownFrame_SetTimer(self.WCooldown, GetActionCooldown(action));
else
@ -1478,6 +1503,7 @@ function Button:UpdateCooldownBonusAction()
end
--[[-------------------------------------------------------------------------------------
Usable Functions
---------------------------------------------------------------------------------------]]
@ -1537,7 +1563,7 @@ end
function Button:UpdateUsableBonusAction()
local action = self.Widget:GetAttribute("action");
local IsUsable, NotEnoughMana = IsUsableAction(action);
if (IsUsable or (HasOverrideActionBar() == nil and HasVehicleActionBar() == nil)) then
if (IsUsable or (HasOverrideActionBar() == nil)) then
self.WIcon:SetVertexColor(1.0, 1.0, 1.0);
self.WNormalTexture:SetVertexColor(1.0, 1.0, 1.0);
elseif (NotEnoughMana) then
@ -1575,8 +1601,8 @@ function Button:UpdateTextCountSpell()
self.WCount:SetText(count);
return;
end
local charges = GetSpellCharges(self.SpellNameRank);
if (charges ~= nil) then
local charges, maxCharges = GetSpellCharges(self.SpellNameRank);
if (charges ~= nil and maxCharges ~= 1) then
self.WCount:SetText(charges);
return;
end
@ -1607,7 +1633,7 @@ function Button:UpdateTextCountMacro()
end
function Button:UpdateTextCountBonusAction()
local action = self.Widget:GetAttribute("action");
if ((HasOverrideActionBar() or HasVehicleActionBar()) and (IsConsumableAction(action) or IsStackableAction(action))) then
if ((HasOverrideActionBar()) and (IsConsumableAction(action) or IsStackableAction(action))) then
self.WCount:SetText(GetActionCount(action));
else
self.WCount:SetText("");
@ -1697,7 +1723,7 @@ end
function Button:UpdateTooltipBonusAction()
self = self.ParentButton or self; --This is a sneaky cheat incase the widget was used to get here...
local action = self.Widget:GetAttribute("action");
if (HasOverrideActionBar() or HasVehicleActionBar()) then
if (HasOverrideActionBar()) then
GameTooltip:SetAction(action);
else
GameTooltip:SetText(self.Tooltip, nil, nil, nil, nil, 1);
@ -1718,6 +1744,8 @@ function Button:UpdateTooltipCustomAction()
end
--[[---------------------------------------------------------------------
Cursor functions
-----------------------------------------------------------------------]]
@ -1750,6 +1778,8 @@ function Button:GetCursorCustomAction()
end
--[[------------------------------------------------------------------------
Flash functions
--------------------------------------------------------------------------]]
@ -1774,7 +1804,7 @@ function Button:UpdateFlashMacro()
end
function Button:UpdateFlashBonusAction()
local action = self.Widget:GetAttribute("action");
if ((HasOverrideActionBar() or HasVehicleActionBar()) and ((IsAttackAction(action) and IsCurrentAction(action)) or IsAutoRepeatAction(action))) then
if ((HasOverrideActionBar()) and ((IsAttackAction(action) and IsCurrentAction(action)) or IsAutoRepeatAction(action))) then
if (not self.FlashOn) then
self:AddToFlash();
end
@ -1839,7 +1869,7 @@ function Button:UpdateRangeTimerMacro()
end
function Button:UpdateRangeTimerBonusAction()
local action = self.Widget:GetAttribute("action");
if ((HasOverrideActionBar() or HasVehicleActionBar()) and IsActionInRange(action)) then
if ((HasOverrideActionBar()) and IsActionInRange(action)) then
if (not self.RangeTimerOn) then
self:AddToRangeTimer();
end
@ -2006,7 +2036,8 @@ function Button:PromoteSpell()
end
--[[
if (self.Mode == "spell") then
local Name, Rank = GetSpellInfo(self.SpellName); --This will actually retrieve for the highest rank of the spell
-- local Name, Rank = GetSpellInfo(self.SpellName); --This will actually retrieve for the highest rank of the spell
local Name, Rank = Util.GetSpellInfo(self.SpellName) -- TBC Fix 2021/06/18
if (Name) then
if (Util.LookupNewSpellIndex(Name.."("..Rank..")")) then
if (strfind(Rank, Util.GetLocaleString("SpellRank"), 1, true) and strfind(self.SpellNameRank, Util.GetLocaleString("SpellRank"), 1, true)) then
@ -2090,13 +2121,20 @@ function Button:UpdateFlyout()
-- Update arrow
Widget.FlyoutArrow:Show();
Widget.FlyoutArrow:ClearAllPoints();
--if (self:GetParent() == MultiBarRight or self:GetParent() == MultiBarLeft) then
--self.FlyoutArrow:SetPoint("LEFT", self, "LEFT", -arrowDistance, 0);
--SetClampedTextureRotation(self.FlyoutArrow, 270);
--else
local direction = self.Widget:GetAttribute("flyoutDirection");
if (direction == "LEFT") then
Widget.FlyoutArrow:SetPoint("LEFT", Widget, "LEFT", -arrowDistance, 0);
SetClampedTextureRotation(Widget.FlyoutArrow, 270);
elseif (direction == "RIGHT") then
Widget.FlyoutArrow:SetPoint("RIGHT", Widget, "RIGHT", arrowDistance, 0);
SetClampedTextureRotation(Widget.FlyoutArrow, 90);
elseif (direction == "DOWN") then
Widget.FlyoutArrow:SetPoint("BOTTOM", Widget, "BOTTOM", 0, -arrowDistance);
SetClampedTextureRotation(Widget.FlyoutArrow, 180);
else
Widget.FlyoutArrow:SetPoint("TOP", Widget, "TOP", 0, arrowDistance);
SetClampedTextureRotation(Widget.FlyoutArrow, 0);
--end
end
else
Widget.FlyoutBorder:Hide();
Widget.FlyoutBorderShadow:Hide();

Voir le fichier

@ -1,8 +1,8 @@
## Interface: 11302
## Title: Button Forge Classic
## Interface: 20501
## Title: Button Forge |cff69f0d1(Classic-TBC)|r
## Version: 1.0.5-classic-TBC
## Author: Massiner of Nathrezim, Albirew
## Notes: Add as many or few extra Action Bars and Buttons to your user interface to complement the standard (or other) Action Bars
## Version: 0.9.50.3
## Author: Massiner of Nathrezim
## SavedVariables: ButtonForgeGlobalSettings, ButtonForgeGlobalProfiles, ButtonForgeGlobalBackup
## SavedVariablesPerCharacter: ButtonForgeSave
## OptionalDeps: Masque

Voir le fichier

@ -9,8 +9,8 @@
local Const = BFConst;
Const.SUMMON_RANDOM_FAVORITE_MOUNT_SPELL = 150544;
Const.SUMMON_RANDOM_FAVORITE_MOUNT_ID = 268435455;
Const.Version = 0.9;
Const.VersionMinor = 50;
Const.Version = 1.0;
Const.VersionMinor = 0.5;
Const.MAX_ACCOUNT_MACROS = 120;
Const.ButtonNaming = "ButtonForge"
Const.ButtonSeq = 1; --This value will increment (so not technically a const...)
@ -34,7 +34,7 @@ Const.KeyBindOverlayColor = {0.3, 0.7, 0.1, 0.4};
Const.BarBackdrop = {0.1, 0.1, 0.4, 0.85};
Const.BonusBarBackdrop = {0.1, 0.5, 0.1, 0.85};
Const.IconDragOverlayColor = {0.0, 0.1, 0.3, 0.0};
Const.ImagesDir = "Interface\\AddOns\\ButtonForge-classic\\Images\\";
Const.ImagesDir = "Interface\\AddOns\\ButtonForge\\Images\\";
Const.SlashNumLines = 4; --Num of lines to show before breaking the message up
Const.DisableAutoAlignAgainstDefaultBars = false; --Set to true and reload UI in order to not check the Blizzard bars when performing auto-alignment, this probably isn't needed but just in case
@ -54,6 +54,11 @@ Const.ThresholdHSnapSq = 10 * 10;
Const.ThresholdHPressureSq = 20 * 20;
Const.StealthSpellIds = {};
Const.StealthSpellIds[1784] = 1; -- Stealth
Const.StealthSpellIds[5215] = 1; -- Prowl
Const.WispSpellIds = {};
Const.WispSpellIds[19746] = 1; --Concentration Aura
Const.WispSpellIds[32223] = 1; --Crusader Aura
@ -90,15 +95,17 @@ Const.DarkOrange = "ffEE5500";
Const.SlashCommands = {};
Const.SlashCommands["-bar"] = {params = "^%s*(..-)%s*$", group = "bar"};
Const.SlashCommands["-list"] = {params = "^()$", incompat = {"ALL"}};
Const.SlashCommands["-macrotext"] = {params = "bool", group = "bar"};
Const.SlashCommands["-keybindtext"] = {params = "bool", group = "bar"};
Const.SlashCommands["-tooltips"] = {params = "bool", group = "bar"};
Const.SlashCommands["-emptybuttons"] = {params = "bool", group = "bar"};
Const.SlashCommands["-lockbuttons"] = {params = "bool", group = "bar"};
Const.SlashCommands["-flyout"] = {params = "^%s*(..-)%s*$", group = "bar"};
Const.SlashCommands["-scale"] = {params = "^%s*(%d*%.?%d+)%s*$", group = "bar"};
Const.SlashCommands["-rows"] = {params = "^%s*(%d+)%s*$", group = "bar", requires = {"-bar"}};
Const.SlashCommands["-cols"] = {params = "^%s*(%d+)%s*$", group = "bar", requires = {"-bar"}};
Const.SlashCommands["-coords"] = {params = "^%s*(%d*%.?%d+)%s*,?%s*(%d*%.?%d+)%s*$", group = "bar", requires = {"-bar"}};
Const.SlashCommands["-rows"] = {params = "^%s*(%d+)%s*$", group = "bar", requires = {"-createbar", "-bar"}};
Const.SlashCommands["-cols"] = {params = "^%s*(%d+)%s*$", group = "bar", requires = {"-createbar", "-bar"}};
Const.SlashCommands["-coords"] = {params = "^%s*(%d*%.?%d+)%s*,?%s*(%d*%.?%d+)%s*$", group = "bar", requires = {"-createbar", "-bar"}};
Const.SlashCommands["-gap"] = {params = "^%s*(%d*%.?%d+)%s*$", group = "bar"};
Const.SlashCommands["-enabled"] = {params = "bool", group = "bar"};
Const.SlashCommands["-info"] = {params = "^()$", group = "bar", requires = {"-bar"}};

Voir le fichier

@ -20,3 +20,4 @@ ButtonForgeSave = {};
ButtonForgeGlobalSettings = {};
ButtonForgeGlobalProfiles = {};
ButtonForgeGlobalBackup = {};

247
DumpSpells.lua Fichier normal
Voir le fichier

@ -0,0 +1,247 @@
local _G = getfenv(0)
local addon, L = ...;
DS_Color1 = "|cff3399ff"
DS_Color2 = "|cff1eff00"
DS_Loaded = false
DS_pName = UnitName("player")
DS_pClass = UnitClass("player")
local function myprint(msg)
if msg ~= nil then
msg = tostring(msg)
print(DS_Color1..addon..": "..DS_Color2..msg)
return
end
end
local function DS_PadiSpellId(t)
if strlen(t) == 2 then
tnum = "0000"..t
return tnum
elseif strlen(t) == 3 then
tnum = "000"..t
return tnum
elseif strlen(t) == 4 then
tnum = "00"..t
return tnum
elseif strlen(t) == 5 then
tnum = "0"..t
return tnum
end
return t
end
function Init_DS_Tables()
-- known spells
if DS_kSpellsTable == nil then DS_kSpellsTable = {} end
if DS_kSpellsTable2 == nil then DS_kSpellsTable2 = {} end
if DS_kSpellsTable3 == nil then DS_kSpellsTable3 = {} end
if DS_ktblSpellNames == nil then DS_ktblSpellNames = {} end
if DS_kSpellsRank == nil then DS_kSpellsRank = {} end
if DS_ktblSpellCount == nil then DS_ktblSpellCount = {} end
DS_kSpellsTable[DS_pName] = {}
DS_kSpellsTable2[DS_pName] = {}
DS_kSpellsTable3[DS_pName] = {}
DS_ktblSpellNames[DS_pName] = {}
DS_kSpellsRank[DS_pName] = {}
DS_ktblSpellCount[DS_pName] = 0
-- all spells not pet
if DS_aSpellsTable == nil then DS_aSpellsTable = {} end
if DS_aSpellsTable2 == nil then DS_aSpellsTable2 = {} end
if DS_atblSpellNames == nil then DS_atblSpellNames = {} end
if DS_aSpellsRank == nil then DS_aSpellsRank = {} end
if DS_atblSpellCount == nil then DS_atblSpellCount = {} end
DS_aSpellsTable[DS_pName] = {}
DS_aSpellsTable2[DS_pName] = {}
DS_atblSpellNames[DS_pName] = {}
DS_aSpellsRank[DS_pName] = {}
DS_atblSpellCount[DS_pName] = 0
end
-- RegisterEvents
local DS_Eventframe = CreateFrame("FRAME")
DS_Eventframe:RegisterEvent("ADDON_LOADED")
DS_Eventframe:RegisterEvent("PLAYER_LOGIN")
local function DS_OnEvent(self, event, arg1, ...)
if event == "ADDON_LOADED" and arg1 == addon then
myprint("Addon_Loaded")
DS_Loaded = true
self:UnregisterEvent("ADDON_LOADED")
end
if event == "PLAYER_LOGIN" and DS_Loaded then
myprint("Player_Loaded")
myprint("Current Player :"..DS_pName)
myprint("Current Class :"..DS_pClass)
DS_GetSpellBook()
DS_Eventframe:UnregisterEvent("PLAYER_LOGIN")
end
end
DS_Eventframe:SetScript("OnEvent", DS_OnEvent)
-- Parse player's spellbook and build a list of available spells
function DS_GetSpellBook()
Init_DS_Tables()
-- known spells for character
local i = 0
local iIndex = 0
local iSpellId = 0
local old_iSpellId = 0
local txt_iSpellId = ""
for i = 1, GetNumSpellTabs() do
local _, _, offset, numSlots = GetSpellTabInfo(i)
for iIndex = offset, offset+numSlots do
local slotType, iSpellId = GetSpellBookItemInfo(iIndex, BOOKTYPE_SPELL)
if slotType == "SPELL" then
local slotName = GetSpellBookItemName(iIndex, "spell")
local spellName = GetSpellInfo(slotName)
if (spellName) then
txt_iSpellId = DS_PadiSpellId(tostring(iSpellId))
-- make sure iSpellId has not been seen
if not DS_kSpellsRank[DS_pName][iSpellId] then
DS_kSpellsRank[DS_pName][iSpellId] = 0
DS_ktblSpellNames[DS_pName][spellName] = spellName
if old_iSpellId ~= iSpellId then
old_iSpellId = iSpellId
DS_ktblSpellCount[DS_pName] = DS_ktblSpellCount[DS_pName] + 1
DS_kSpellsTable2[DS_pName][DS_ktblSpellCount[DS_pName]] = DS_pClass..", known, "..spellName..", "..txt_iSpellId
DS_kSpellsTable[DS_pName][DS_ktblSpellCount[DS_pName]] = { DS_pClass, "known", spellName, txt_iSpellId, 0 }
end
end
end
end
end -- for
end -- for
-- all non pet spells for character
local i = 0
local iIndex = 0
local iSpellId = 0
local old_iSpellId = 0
local txt_iSpellId = ""
for i = 1, GetNumSpellTabs() do
local _, _, offset, numSlots = GetSpellTabInfo(i)
for iIndex = offset, offset+numSlots do
local slotType, iSpellId = GetSpellBookItemInfo(iIndex, BOOKTYPE_SPELL)
if slotType == "SPELL" or slotType == "FUTURESPELL" then
local slotName = GetSpellBookItemName(iIndex, "spell")
local spellName = GetSpellInfo(slotName)
if (spellName) then
txt_iSpellId = DS_PadiSpellId(tostring(iSpellId))
-- make sure iSpellId has not been seen
if not DS_aSpellsRank[DS_pName][iSpellId] then
DS_aSpellsRank[DS_pName][iSpellId] = 0
DS_atblSpellNames[DS_pName][spellName] = spellName
if old_iSpellId ~= iSpellId then
old_iSpellId = iSpellId
DS_atblSpellCount[DS_pName] = DS_atblSpellCount[DS_pName] + 1
DS_aSpellsTable2[DS_pName][DS_atblSpellCount[DS_pName]] = DS_pClass..", all, "..spellName..", "..txt_iSpellId
DS_aSpellsTable[DS_pName][DS_atblSpellCount[DS_pName]] = { DS_pClass, "all", spellName, txt_iSpellId, 0 }
end
end
end
end
end -- for
end -- for
table.sort({DS_aSpellsTable[DS_pName]})
table.sort(DS_aSpellsTable2[DS_pName])
table.sort({DS_kSpellsTable[DS_pName]})
table.sort(DS_kSpellsTable2[DS_pName])
local spellRank = 0
local findinstr = ""
local findinstr2 = ""
-- known entries
for spellName, _ in pairs(DS_ktblSpellNames[DS_pName]) do
spellRank = 0
for loop = 1, DS_ktblSpellCount[DS_pName] do
findinstr = DS_kSpellsTable2[DS_pName][loop]
if string.match(findinstr, spellName) then
spellRank = spellRank + 1
DS_kSpellsTable2[DS_pName][loop] = findinstr..", Rank-"..spellRank
findinstr2 = DS_kSpellsTable2[DS_pName][loop]
for loop2 = 1, DS_ktblSpellCount[DS_pName] do
txt_iSpellId = DS_kSpellsTable[DS_pName][loop2][4]
if string.match(findinstr2,txt_iSpellId) then
DS_kSpellsTable[DS_pName][loop2][5] = spellRank
DS_kSpellsRank[DS_pName][tonumber(txt_iSpellId)] = spellRank
end
end
end
end
end
-- build table3
for loop = 1, DS_atblSpellCount[DS_pName] do
spellName = DS_kSpellsTable[DS_pName][loop][3]
iSpellId = tonumber(DS_kSpellsTable[DS_pName][loop][4])
if DS_kSpellsTable3[DS_pName][spellName] == nil then
DS_kSpellsTable3[DS_pName][spellName] = {}
end
table.insert(DS_kSpellsTable3[DS_pName][spellName], iSpellId)
end
-- test getting spellid for a rank
-- spellName = "Healing Touch"
-- r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14 = unpack(DS_kSpellsTable3[DS_pName][spellName])
-- myprint("Spell is: "..spellName..", Max Ranks for this spell is: "..#DS_kSpellsTable3[DS_pName][spellName]..", Rank 10 spellId is: "..r10)
-- all entries
for spellName, _ in pairs(DS_atblSpellNames[DS_pName]) do
spellRank = 0
for loop = 1, DS_atblSpellCount[DS_pName] do
findinstr = DS_aSpellsTable2[DS_pName][loop]
if string.match(findinstr, spellName) then
spellRank = spellRank + 1
DS_aSpellsTable2[DS_pName][loop] = findinstr..", Rank-"..spellRank
findinstr2 = DS_aSpellsTable2[DS_pName][loop]
for loop2 = 1, DS_atblSpellCount[DS_pName] do
txt_iSpellId = DS_aSpellsTable[DS_pName][loop2][4]
if string.match(findinstr2,txt_iSpellId) then
DS_aSpellsTable[DS_pName][loop2][5] = spellRank
DS_aSpellsRank[DS_pName][tonumber(txt_iSpellId)] = spellRank
end
end
end
end
end
end

Voir le fichier

@ -224,10 +224,11 @@ STOP_AUTOREPEAT_SPELL
function Full:InitialOnEvent(Event, Arg1)
if (Event == "ADDON_LOADED" and Arg1 == "ButtonForge-classic") then
if (Event == "ADDON_LOADED" and Arg1 == "ButtonForge") then
self.AddonLoaded = true; --Before setting up is complete we also need to have spell, and macro data available
elseif (Event == "PLAYER_ENTERING_WORLD") then
Util.CacheSpellBookRanks() -- TBC Fix 2021/06/17
Util.CacheCompanions();
Util.CacheSpellIndexes();
Util.CachePetSpellIndexes();
@ -455,6 +456,13 @@ function Misc:OnEvent(Event, ...)
-- self.TalentSwap = true;
-- self:SetScript("OnUpdate", self.OnUpdate);
-- elseif (Event == "COMPANION_LEARNED") then
-- Util.CacheCompanions();
-- Util.RefreshCompanions();
-- elseif (Event == "EQUIPMENT_SETS_CHANGED") then
-- Util.RefreshEquipmentSets();
elseif (Event == "PLAYER_REGEN_DISABLED") then
Util.PreCombatStateUpdate();

Voir le fichier

@ -36,6 +36,9 @@
BFKeyBinder.OnInputBindingOverlay("MOUSEWHEELDOWN");
end
</OnMouseWheel>
<OnGamePadButtonDown>
BFKeyBinder.OnInputBindingOverlay(button);
</OnGamePadButtonDown>
</Scripts>
</Frame>
@ -99,7 +102,7 @@
</Offset>
</Shadow>
</FontString>
<Texture parentKey="ToggleBorder" file="Interface\AddOns\ButtonForge-classic\Images\ToggleBorder.tga">
<Texture parentKey="ToggleBorder" file="Interface\AddOns\ButtonForge\Images\ToggleBorder.tga">
<Size>
<AbsDimension x="26" y="26" />
</Size>

Voir le fichier

@ -88,6 +88,7 @@ Locale["SlashHelpFormatted"] =
"Valid slash commands: |c"..Const.LightBlue.."/buttonforge|r, |c"..Const.LightBlue.."/bufo|r\n"..
"Valid switches:\n"..
"|c"..Const.LightBlue.."-bar <bar name>|r (the bar to apply changes to, or if not set then all bars)\n"..
"|c"..Const.LightBlue.."-list|r\n"..
"|c"..Const.LightBlue.."-rename <new name>|r\n"..
"|c"..Const.LightBlue.."-rows <number>|r\n"..
"|c"..Const.LightBlue.."-cols <number>|r\n"..
@ -97,6 +98,7 @@ Locale["SlashHelpFormatted"] =
"|c"..Const.LightBlue.."-tooltips <on/off>|r\n"..
"|c"..Const.LightBlue.."-emptybuttons <on/off>|r\n"..
"|c"..Const.LightBlue.."-lockbuttons <on/off>|r\n"..
"|c"..Const.LightBlue.."-flyout <up/down/left/right>|r\n"..
"|c"..Const.LightBlue.."-macrotext <on/off>|r\n"..
"|c"..Const.LightBlue.."-keybindtext <on/off>|r\n"..
"|c"..Const.LightBlue.."-hidespec1 <on/off>|r\n"..
@ -134,6 +136,8 @@ Locale["SlashHelpFormatted"] =
Locale["SlashCommandRequired"] = "<COMMANDA> requires <COMMANDB> to also be specified";
Locale["SlashCommandIncompatible"] = "<COMMANDA> is incompatible with <COMMANDB>";
Locale["SlashCommandAlone"] = "<COMMANDA> cannot be used with other commands";
Locale["SlashListBarWithLabel"] = "- <LABEL> |c"..Const.LightBlue.." Examples: /bufo -bar <LABEL> -info";
Locale["SlashListBarWithIndex"] = "- <LABEL> (No label set, use Index) |c"..Const.LightBlue.." Examples: /bufo -bar <LABEL> -info";
Locale["SlashBarNameRequired"] =
[[ButtonForge slash command failed:

Voir le fichier

@ -144,6 +144,18 @@ Notes:
#### Enable Right Click Self Cast
This can be done using the Right Click Self Cast button.
#### Some slash commands
`/bufo saveprofile <profile name>`
`/bufo loadprofile <profile name>`
`/bufo loadprofiletemplate <profile name>` (load the bar layout but not the actions on the buttons)
`/bufo undoprofile` (reverts to how things were before you ran loadprofile)
`/bufo deleteprofile <profile name>`
`/bufo listprofiles`
## F.A.Q

Voir le fichier

@ -2,7 +2,7 @@
<Script file="UILibLayers.lua"/>
<Frame name="BFOverlay" enablemouse="true" hidden="true" virtual="true">
<Frame name="BFOverlay" mixin="BackdropTemplateMixin" enablemouse="true" hidden="true" virtual="true">
<Anchors>
<Anchor point="TOPLEFT" relativeTo="UIParent" relativePoint="TOPLEFT">
<Offset>

Voir le fichier

@ -10,11 +10,13 @@ local UILib = BFUILib;
local Const = BFConst;
local VertLine = CreateFrame("FRAME", nil, UIParent);
VertLine:SetBackdrop({bgFile = Const.ImagesDir.."VertLine.tga", edgeFile = nil, tile = false, tileSize = 1, edgeSize = 0, insets = {left=0, right=0, bottom=0, top=0}});
Mixin(VertLine, BackdropTemplateMixin)
VertLine:SetBackdrop({bgFile = Const.ImagesDir.."VertLine.tga", edgeFile = nil, tile = false, tileSize = 1, edgeSize = 1, insets = {left=0, right=0, bottom=0, top=0}});
VertLine:SetWidth(Const.VLineThickness / UIParent:GetScale());
local HorizLine = CreateFrame("FRAME", nil, UIParent);
HorizLine:SetBackdrop({bgFile = Const.ImagesDir.."HorizontalLine.tga", edgeFile = nil, tile = false, tileSize = 1, edgeSize = 0, insets = {left=0, right=0, bottom=0, top=0}});
Mixin(HorizLine, BackdropTemplateMixin)
HorizLine:SetBackdrop({bgFile = Const.ImagesDir.."HorizontalLine.tga", edgeFile = nil, tile = false, tileSize = 1, edgeSize = 1, insets = {left=0, right=0, bottom=0, top=0}});
HorizLine:SetHeight(Const.HLineThickness / UIParent:GetScale());

Voir le fichier

@ -16,7 +16,6 @@ function UILib.ToggleCreateBarMode(ForceOff)
if (BFCreateBarOverlay:IsShown() or ForceOff) then
BFCreateBarOverlay:Hide();
BFToolbarCreateBar:SetChecked(false);
BFToolbarCreateBonusBar:SetChecked(false);
UILib.CreateBarMode = false;
UILib.CreateBonusBarMode = false;
SetCursor(nil);
@ -40,14 +39,12 @@ function UILib.ToggleCreateBonusBarMode(ForceOff)
if (BFCreateBarOverlay:IsShown() or ForceOff) then
BFCreateBarOverlay:Hide();
BFToolbarCreateBar:SetChecked(false);
BFToolbarCreateBonusBar:SetChecked(false);
UILib.CreateBarMode = false;
UILib.CreateBonusBarMode = false;
SetCursor(nil);
elseif (not InCombatLockdown()) then
UILib.CreateBonusBarMode = true;
BFCreateBarOverlay:Show();
BFToolbarCreateBonusBar:SetChecked(true);
SetCursor("REPAIRNPC_CURSOR");
end
EventFull.RefreshButtons = true;
@ -83,14 +80,12 @@ function UILib.ToggleAdvancedTools()
BFToolbarAdvanced:SetChecked(false);
ButtonForgeSave.AdvancedMode = false;
BFToolbar:SetSize(216, 88);
BFToolbarCreateBonusBar:Hide();
BFToolbarRightClickSelfCast:Hide();
else
BFAdvancedToolsLayer:Show();
BFToolbarAdvanced:SetChecked(true);
ButtonForgeSave.AdvancedMode = true;
BFToolbar:SetSize(216, 116);
BFToolbarCreateBonusBar:Show();
BFToolbarRightClickSelfCast:Show();
end
EventFull.RefreshButtons = true;

Voir le fichier

@ -4,6 +4,9 @@
<Frame name="BFToolbar" parent="BFConfigureLayer" enablemouse="true" movable="true">
<!--<FrameSkin skinid="dcb143e1-a4ab-4e7c-b934-1efa40101d21" frameid="2d508883-59c2-4f83-ae10-27aaad48391b" />-->
<KeyValues>
<KeyValue key="backdropInfo" value="BACKDROP_DIALOG_32_32" type="global"/>
</KeyValues>
<Scripts>
<OnMouseDown>
self:StartMoving();
@ -48,7 +51,7 @@
</Anchors>
<TexCoords left="0.2" right="0.8" top="0" bottom="0.6" />
</Texture>
<Texture name="$parentToggleBorder" file="Interface\AddOns\ButtonForge-classic\Images\ToggleBorder.tga">
<Texture name="$parentToggleBorder" file="Interface\AddOns\ButtonForge\Images\ToggleBorder.tga">
<Size>
<AbsDimension x="26" y="26" />
</Size>
@ -119,41 +122,6 @@
</Scripts>
</CheckButton>
<!-- Create Bonus Bar, This button toggles create bonus bar mode -->
<CheckButton name="$parentCreateBonusBar" inherits="ActionButtonTemplate" hidden="true">
<Anchors>
<Anchor point="TOPLEFT">
<Offset>
<AbsDimension x="20" y="-74" />
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
_G[self:GetName().."Icon"]:SetTexture(BFConst.ImagesDir.."CreateBonusBar.tga");
self:RegisterForDrag("LeftButton", "RightButton");
self.Tooltip = BFUtil.GetLocaleString("CreateBonusBarTooltip");
self:SetScale(0.66);
self:ClearAllPoints();
self:SetPoint("TOPLEFT", self:GetParent(), "TOPLEFT", 20 / 0.66, -74 / 0.66);
</OnLoad>
<OnClick>
-- Toggle CreateBar Mode
BFUILib.ToggleCreateBonusBarMode();
</OnClick>
<OnDragStart>
BFCustomAction.SetCursor("createbonusbarmode");
</OnDragStart>
<OnEnter>
GameTooltip:SetOwner(self:GetParent(), "ANCHOR_TOPLEFT");
GameTooltip:SetText(self.Tooltip, nil, nil, nil, nil, 1);
</OnEnter>
<OnLeave>
GameTooltip_Hide();
</OnLeave>
</Scripts>
</CheckButton>
<!-- Destroy Bar, this button toggles destroy bar mode -->
<CheckButton name="$parentDestroyBar" inherits="ActionButtonTemplate">
<Anchors>

327
Util.lua
Voir le fichier

@ -168,6 +168,12 @@ function Util.UpdateSavedData()
DEFAULT_CHAT_FRAME:AddMessage(Util.GetLocaleString("UpgradedChatMsg").."v0.9.22", .5, 1, 0, 1);
end
--v0.9.25 update
if (ButtonForgeSave["Version"] == 0.9 and ButtonForgeSave["VersionMinor"] < 25) then
ButtonForgeSave["VersionMinor"] = 25;
DEFAULT_CHAT_FRAME:AddMessage(Util.GetLocaleString("UpgradedChatMsg").."v0.9.25", .5, 1, 0, 1);
end
-- v0.9.34 update
if (ButtonForgeSave["Version"] == 0.9 and ButtonForgeSave["VersionMinor"] < 34) then
for i = 1, #ButtonForgeSave.Bars do
@ -420,8 +426,6 @@ function Util.Load()
Util.StartMacroCheckDelay();
Util.RefreshOnUpdateFunction();
SLASH_BUTTONFORGE1 = Util.GetLocaleString("SlashButtonForge1"); -- = "/buttonforge"; --these two identifiers probably shouldn't change, but if need be they can be?!
SLASH_BUTTONFORGE2 = Util.GetLocaleString("SlashButtonForge2"); -- = "/bufo";
collectgarbage("collect");
Util.CallbackEvent("INITIALISED");
end
@ -1184,7 +1188,10 @@ function Util.SlashShowMessageByLine(Message)
end
end
function SlashCmdList.BUTTONFORGE(msg, editbox)
SLASH_BUTTONFORGE1 = Util.GetLocaleString("SlashButtonForge1"); -- = "/buttonforge"; --these two identifiers probably shouldn't change, but if need be they can be?!
SLASH_BUTTONFORGE2 = Util.GetLocaleString("SlashButtonForge2"); -- = "/bufo";
SlashCmdList["BUTTONFORGE"] = function(msg, editbox)
local FirstCommand;
local PreparedCommands = {};
local Command, Params;
local Count = 0;
@ -1192,6 +1199,9 @@ function SlashCmdList.BUTTONFORGE(msg, editbox)
for Token, Space in string.gmatch(msg, '([^%s]+)([%s]*)') do
if (Const.SlashCommands[strlower(Token)]) then
if (Command) then
if (FirstCommand == nil) then
FirstCommand = Command;
end;
Count = Count + 1;
--PreparedCommands["Count"] = Count;
PreparedCommands[Command] = Util.ProcessSlashCommandParams(Command, Params);
@ -1225,7 +1235,7 @@ function SlashCmdList.BUTTONFORGE(msg, editbox)
-- 2. A rules required's must be present
-- 3. A rules exclusions must not be present
local Group;
local FirstCommand;
for k, v in pairs(Commands) do
FirstCommand = FirstCommand or k;
if (Group ~= nil and Group ~= Const.SlashCommands[k].group) then
@ -1237,13 +1247,20 @@ function SlashCmdList.BUTTONFORGE(msg, editbox)
local Requires = Const.SlashCommands[k].requires;
if (Requires) then
local RequiresValid = false;
local RequiresInfo = {};
-- make sure we have at least one of the requirements
for k1, v1 in pairs(Requires) do
if (Commands[v1] == nil) then
-- Missing a required command
DEFAULT_CHAT_FRAME:AddMessage(string.gsub(string.gsub(Util.GetLocaleString("SlashCommandRequired"), "<COMMANDA>", k), "<COMMANDB>", v1), .5, 1, 0, 1);
return;
table.insert(RequiresInfo,v1);
if (Commands[v1] ~= nil) then
RequiresValid = true;
end
end
if (RequiresValid == false) then
-- Missing a required command
DEFAULT_CHAT_FRAME:AddMessage(string.gsub(string.gsub(Util.GetLocaleString("SlashCommandRequired"), "<COMMANDA>", k), "<COMMANDB>", table.concat(RequiresInfo, " or ")), .5, 1, 0, 1);
return;
end
end
local Incompat = Const.SlashCommands[k].incompat;
@ -1283,9 +1300,20 @@ function SlashCmdList.BUTTONFORGE(msg, editbox)
elseif (Commands["-destroybar"]) then
BarName = Commands["-destroybar"][1];
end
local barFound = false;
for i = 1, #Bars do
if ((not BarName) or strlower(BarName) == strlower(Bars[i].BarSave["Label"])) then
Util.ApplySlashCommands(Commands, Bars[i]);
barFound = true;
end
end
-- bar name not found, check with Index
if ( barFound == false ) then
for i = 1, #Bars do
if ( tonumber(BarName) == i ) then
Util.ApplySlashCommands(Commands, Bars[i]);
barFound = true;
end
end
end
end
@ -1310,6 +1338,17 @@ function Util.ApplySlashCommands(Commands, Bar)
Commands["-rename"] = Commands["-createbar"]; --this could arguably work by having an empty param to createbar but I think it will feel more natural to require a name with this command
end
if (Commands["-list"]) then
local Bars = Util.ActiveBars;
for i = 1, #Bars do
local label = string.gsub(Util.GetLocaleString("SlashListBarWithLabel"), "<LABEL>", Bars[i].BarSave["Label"]);
if (Bars[i].BarSave["Label"] == "") then
label = string.gsub(Util.GetLocaleString("SlashListBarWithIndex"), "<LABEL>", i);
end
DEFAULT_CHAT_FRAME:AddMessage(label, .5, 1, 0, 1);
end
end
if (Commands["-destroybar"]) then
Util.DeallocateBar(Bar);
end
@ -1334,6 +1373,10 @@ function Util.ApplySlashCommands(Commands, Bar)
Bar:SetButtonsLocked(Commands["-lockbuttons"][1]);
end
if (Commands["-flyout"]) then
Bar:SetFlyoutDirection(Commands["-flyout"][1]);
end
if (Commands["-scale"]) then
Bar:SetScale(tonumber(Commands["-scale"][1]));
end
@ -1508,7 +1551,13 @@ function Util.SetCursor(Command, Data, Subvalue, Subsubvalue)
UILib.StopDraggingIcon();
-- SpellFlyout:Hide();
if (Command == "spell") then
-- pet spell or not
local name = GetSpellInfo(Subsubvalue);
if ( Util.PetSpellIndex[name] ) then
PickupSpellBookItem(Util.PetSpellIndex[name], BOOKTYPE_PET);
else
PickupSpell(Subsubvalue);
end;
elseif (Command == "item") then
PickupItem(Data);
elseif (Command == "macro") then
@ -1533,7 +1582,7 @@ function Util.SetCursor(Command, Data, Subvalue, Subsubvalue)
page = 14;
end
local Texture = GetActionTexture(Data + ((page - 1) * 12));
if (Texture and (HasOverrideActionBar() or HasVehicleActionBar())) then
if (Texture and (HasOverrideActionBar())) then
UILib.StartDraggingIcon(Texture, 23, 23, "bonusaction", Data);
else
UILib.StartDraggingIcon(Const.ImagesDir.."Bonus"..Data, 23, 23, "bonusaction", Data);
@ -1638,7 +1687,7 @@ end
-------------------------------------------]]
function Util.GetFullSpellName(Name, Rank)
--BFA fix: GetSpellInfo now returns a nil for the rank. That's passed in here
--So we check to make sure ranx exists or only pass back the name itself.
--So we check to make sure rank exists or only pass back the name itself.
if (Rank) then
Rank = "("..Rank..")";
else
@ -1697,8 +1746,8 @@ function Util.CacheSpellIndexes()
for i = total, 1, -1 do
ItemType, Id = GetSpellBookItemInfo(i, BOOKTYPE_SPELL);
--local Name, Rank, Icon, PowerCost, IsFunnel, PowerType = GetSpellInfo(i, BOOKTYPE_SPELL);
local Name, Rank, Icon, PowerCost, IsFunnel, PowerType = GetSpellInfo(Id);
-- local Name, Rank, Icon, castTime, minRange, maxRange, spellId = GetSpellInfo(i, BOOKTYPE_SPELL);
local Name, Rank, Icon, castTime, minRange, maxRange, spellId = Util.GetSpellInfo(Id); -- TBC Fix 2021/06/18
local NameRank = Util.GetFullSpellName(Name, Rank);
if (ItemType == "SPELL") then
NewSI[NameRank] = i;
@ -1732,21 +1781,16 @@ end
function Util.CachePetSpellIndexes()
local i = 1;
local NewPSI = {};
--Util.NewPetSpellIndex = {};
while true do
local NameRank = Util.GetFullSpellName(GetSpellInfo(i, BOOKTYPE_PET));
if (not NameRank) then
break;
local spellName, spellSubName = GetSpellBookItemName(i, BOOKTYPE_PET)
if not spellName then
do break end
end
--if (not Util.PetSpellIndex[NameRank]) then
-- Util.NewPetSpellIndex[NameRanl] = i;
--end
NewPSI[NameRank] = i;
i = i + 1;
NewPSI[spellName] = i;
i = i + 1
end
Util.PetSpellIndex = NewPSI;
end
function Util.LookupSpellIndex(NameRank)
@ -1845,13 +1889,15 @@ function Util.CacheCompanions()
end]]
Util.Mounts = {};
-- for i, mountID in pairs(C_MountJournal.GetMountIDs()) do
-- local creatureName, spellID = C_MountJournal.GetMountInfoByID(mountID);
-- if (not creatureName) then
-- return;
-- end
-- Util.Mounts[spellID] = mountID;
-- end
--[[
for i, mountID in pairs(C_MountJournal.GetMountIDs()) do
local creatureName, spellID = C_MountJournal.GetMountInfoByID(mountID);
if (not creatureName) then
return;
end
Util.Mounts[spellID] = mountID;
end
Util.CompanionsCached = true;]]
end
function Util.LookupCompanion(Name)
@ -2351,7 +2397,9 @@ function Util.GetButtonActionInfo2(ButtonName)
--]]
if (Button.Mode == "spell") then
local Rank = select(2, GetSpellInfo(Button.SpellId));
-- local Rank = select(2, GetSpellInfo(Button.SpellId));
local Rank = select(2, Util.GetSpellInfo(Button.SpellId)); -- TBC Fix 2021/06/18
return "spell", Button.SpellName, Rank, Button.SpellId, Util.LookupSpellIndex(Button.SpellNameRank), Button.SpellBook;
elseif (Button.Mode == "item") then
return "item", Button.ItemId, Button.ItemName;
@ -2510,6 +2558,223 @@ function Util.LookupEquipmentSetIndex(EquipmentSetID)
end
end
return nil;
end
-- TBC Fix new functions for ranks 06/17/2021
function Util.InitCacheSpellBookRanksVars()
BF_PlayerName = UnitName("player")
BF_ClassName = UnitClass("player")
-- table of spellnames, spellIds and spellranks
BF_kwnSpellsTable = {}
BF_kwnSpellsTable[BF_PlayerName] = {}
-- used to build spellranks using string.find, sorted by spellname, spellid
BF_kwnSpellsTableVis = {}
BF_kwnSpellsTableVis[BF_PlayerName] = {}
-- for looped, each time spellname found, rank is bumped up
BF_kwntblSpellNames = {}
BF_kwntblSpellNames[BF_PlayerName] = {}
-- stores rank for each spellId found
BF_kwnSpellsRank = {}
BF_kwnSpellsRank[BF_PlayerName] = {}
-- stores spellId for max rank for spellname
BF_kwnSpellsTableR = {}
BF_kwnSpellsTableR[BF_PlayerName] = {}
-- total known spells found
BF_kwntblSpellCount = {}
BF_kwntblSpellCount[BF_PlayerName] = 0
end
-- spellId converted to text and padded for sorting
function Util.PadiSpellId(t)
if strlen(t) == 2 then
tnum = "0000"..t
return tnum
elseif strlen(t) == 3 then
tnum = "000"..t
return tnum
elseif strlen(t) == 4 then
tnum = "00"..t
return tnum
elseif strlen(t) == 5 then
tnum = "0"..t
return tnum
end
return t
end
-- Parse player's spellbook and build a list of available spells
function Util.CacheSpellBookRanks()
Util.InitCacheSpellBookRanksVars() -- reset known spells for character
local i = 0
local iIndex = 0
local iSpellId = 0
local old_iSpellId = 0
local txt_iSpellId = ""
for i = 1, GetNumSpellTabs() do
local _, _, offset, numSlots = GetSpellTabInfo(i)
for iIndex = offset, offset+numSlots do
local slotType, iSpellId = GetSpellBookItemInfo(iIndex, BOOKTYPE_SPELL)
if slotType == "SPELL" then
local slotName = GetSpellBookItemName(iIndex, "spell")
local spellName = GetSpellInfo(slotName)
if (spellName) then
txt_iSpellId = Util.PadiSpellId(tostring(iSpellId))
-- make sure iSpellId has not been seen
if not BF_kwnSpellsRank[BF_PlayerName][iSpellId] then
BF_kwnSpellsRank[BF_PlayerName][iSpellId] = 0
BF_kwntblSpellNames[BF_PlayerName][spellName] = spellName
if old_iSpellId ~= iSpellId then
old_iSpellId = iSpellId
BF_kwntblSpellCount[BF_PlayerName] = BF_kwntblSpellCount[BF_PlayerName] + 1
BF_kwnSpellsTable[BF_PlayerName][BF_kwntblSpellCount[BF_PlayerName]] = { BF_ClassName, "known", spellName, txt_iSpellId, 0 }
BF_kwnSpellsTableVis[BF_PlayerName][BF_kwntblSpellCount[BF_PlayerName]] = BF_ClassName..", known, "..spellName..", "..txt_iSpellId
end
end
end
end
end -- for
end -- for
table.sort({BF_kwnSpellsTable[BF_PlayerName]})
table.sort(BF_kwnSpellsTableVis[BF_PlayerName])
local spellRank = 0
local tstr = ""
-- known entries, spellranks for each spellId
for spellName, _ in pairs(BF_kwntblSpellNames[BF_PlayerName]) do
spellRank = 0
for loop = 1, BF_kwntblSpellCount[BF_PlayerName] do
tstr = BF_kwnSpellsTableVis[BF_PlayerName][loop]
if string.match(tstr, spellName) then
spellRank = spellRank + 1
BF_kwnSpellsTableVis[BF_PlayerName][loop] = tstr..", Rank-"..spellRank
tstr2 = BF_kwnSpellsTableVis[BF_PlayerName][loop]
for loop2 = 1, BF_kwntblSpellCount[BF_PlayerName] do
txt_iSpellId = BF_kwnSpellsTable[BF_PlayerName][loop2][4]
if string.match(tstr2,txt_iSpellId) then
BF_kwnSpellsTable[BF_PlayerName][loop2][5] = spellRank
BF_kwnSpellsRank[BF_PlayerName][tonumber(txt_iSpellId)] = spellRank
end
end
end
end
end
-- build spell maxrank table
for loop = 1, BF_kwntblSpellCount[BF_PlayerName] do
spellName = BF_kwnSpellsTable[BF_PlayerName][loop][3]
iSpellId = tonumber(BF_kwnSpellsTable[BF_PlayerName][loop][4])
if BF_kwnSpellsTableR[BF_PlayerName][spellName] == nil then
BF_kwnSpellsTableR[BF_PlayerName][spellName] = {}
end
table.insert(BF_kwnSpellsTableR[BF_PlayerName][spellName], iSpellId)
end
end
--[[ example to find max rank for spellId
if BF_kwnSpellsTableR[BF_PlayerName][spellName] ~= nil then
maxrank = #BF_kwnSpellsTableR[BF_PlayerName][spellName]
findSpellId = BF_kwnSpellsTableR[BF_PlayerName][spellName][maxrank]
return
end
]]
-- return highest rank for spellname
function Util.GetMaxSpellRank(spellname)
-- print("Function Util.GetMaxSpellRank(spellname) :"..spellname)
local Rank = 1
if BF_kwnSpellsRank[BF_PlayerName][spellname] ~= nil then
Rank = #BF_kwnSpellsRank[BF_PlayerName][spellname]
-- print("Function Util.GetMaxSpellRank(spellname) :"..spellname..", Max Rank found :"..Rank)
return Rank
end
-- print("Function Util.GetMaxSpellRank(spellname) :"..spellname..", Max Rank not found")
return Rank
end
-- return rank for spellId
function Util.GetSpellRank(Id)
-- print("Function Util.GetSpellRank(Id) :"..Id)
local Rank = 1
if BF_kwnSpellsRank[BF_PlayerName][Id] ~= nil then
Rank = BF_kwnSpellsRank[BF_PlayerName][Id]
-- print("Function Util.GetSpellRank(Id) :"..Id..", Rank found :"..Rank)
return Rank
end
-- print("Function Util.GetSpellRank(Id) :"..Id..", Rank not found")
return Rank
end
-- our wrapper for GetSpellInfo() 06/18/2021
function Util.GetSpellInfo(sName, spellId_or_Rank)
local rank = 1
-- Util.GetSpellInfo("Thorns",3) -- example: return info for spell thorns, rank 3 spellId
if (type(sName) ~= "number" and type(spellId_or_Rank) == "number") then -- spellname and looking for spellid of rank
sRank = spellId_or_Rank
rank = sRank
if BF_kwnSpellsTableR[BF_PlayerName][sName] ~= nil then
if BF_kwnSpellsTableR[BF_PlayerName][sName][sRank] ~= nil then
spellId = BF_kwnSpellsTableR[BF_PlayerName][sName][sRank]
local name, _, icon, castTime, minRange, maxRange, spellId = GetSpellInfo(spellId);
return name,rank,icon,castTime,minRange,maxRange,spellId
end
end
-- rank not found in BF_kwnSpellsTableR, this should not happen
rank = 0
local name, _, icon, castTime, minRange, maxRange, spellId = GetSpellInfo(sName);
return name,rank,icon,castTime,minRange,maxRange,spellId
-- Util.GetSpellInfo("Thorns") -- example: return info for spellId for highest rank known for Thorns
elseif type(sName) ~= "number" then -- spellname only, return spellId for max rank
if BF_kwnSpellsTableR[BF_PlayerName][sName] ~= nil then
maxrank = #BF_kwnSpellsTableR[BF_PlayerName][sName]
Id = BF_kwnSpellsTableR[BF_PlayerName][sName][maxrank]
local name, _, icon, castTime, minRange, maxRange, spellId = GetSpellInfo(Id);
return name,maxrank,icon,castTime,minRange,maxRange,Id
end
-- rank not found in BF_kwnSpellsTableR, this should not happen
rank = 0
local name, _, icon, castTime, minRange, maxRange, spellId = GetSpellInfo(sName);
return name,rank,icon,castTime,minRange,maxRange,spellId
-- Util.GetSpellInfo(9910) -- example: return info for spellId
elseif type(sName) == "number" then -- spellId passed, not spell name, don't bother with sRank here
Id = sName
local name, _, icon, castTime, minRange, maxRange, spellId = GetSpellInfo(Id);
rank = Util.GetSpellRank(Id)
if spellId ~= Id then
print("Error in Util.GetSpellInfo, spellid mismatch "..spellId.." should match "..Id)
end
return name,rank,icon,castTime,minRange,maxRange,Id
end
print("Error in Util.GetSpellInfo, params match didn't happen")
local name, _, icon, castTime, minRange, maxRange, spellId = GetSpellInfo(sName);
return name, 0
end