Comparer les révisions

...

17 Révisions

Auteur SHA1 Message Date
Albirew 05c592f66f updated with latest fixes from Sunnova 2021-07-26 22:13:56 +02:00
Albirew 176330e352 removed regression 2021-05-25 19:18:40 +02:00
Albirew 199fd9cd09 update for classic BC 2021-05-24 18:34:34 +02:00
Albirew 4763a6c340 Merge branch 'master' of https://git.dess.ga/Albirew/ButtonForge-classic 2021-02-20 14:13:48 +01:00
Albirew 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
Albirew 00bf15fb7b Merge branch 'original'
also removed advanced "create bonus bar" button since non-existant in classic
2021-01-30 17:15:42 +01:00
Albirew d42e06d3de release 1.0.3 2021-01-30 15:10:55 +01:00
Albirew 183479263c Merged Release 1.0.2 into master
also fixed destroy bar sound
2020-12-29 17:34:25 +01:00
Albirew 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
Albirew fabebbfe11 release 1.0.2 2020-12-15 05:05:07 +01:00
Albirew 3b450b1daa fixed last forgotten line from renaming 2020-11-26 15:53:29 +01:00
Albirew 58a8ef7de9 update to 1.0.1 2020-11-26 02:32:29 +01:00
Albirew 9da175d295 update to 1.0.0 2020-11-26 02:31:28 +01:00
15 fichiers modifiés avec 705 ajouts et 120 suppressions

41
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]]-- --[[Background Layer, this will contain all controls and is used in resizing]]--
local Background = CreateFrame("FRAME", nil, ControlFrame); local Background = CreateFrame("FRAME", nil, ControlFrame);
Mixin(Background, BackdropTemplateMixin)
Background:SetSize(1, 1); Background:SetSize(1, 1);
Background:SetPoint("TOPLEFT", ControlFrame, "TOPLEFT"); 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}}); 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]]-- --[[Label Frame]]--
local LabelFrame = CreateFrame("FRAME", nil, ControlFrame); local LabelFrame = CreateFrame("FRAME", nil, ControlFrame);
Mixin(LabelFrame, BackdropTemplateMixin)
LabelFrame:SetSize(1, 1); 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: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); LabelFrame:SetBackdropColor(0, 0, 0, 1);
@ -534,8 +536,7 @@ function Bar:Configure(BarSave)
self:SetAlpha(BarSave["Alpha"]); self:SetAlpha(BarSave["Alpha"]);
self:SetGUI(BarSave["GUI"]); self:SetGUI(BarSave["GUI"]);
-- Uncomment this once Clamp insets are working again self.ControlFrame:SetClampedToScreen(true);
--self.ControlFrame:SetClampedToScreen(true);
end end
--[[ --[[
@ -562,6 +563,27 @@ function Bar:GetPosition()
return self.BarSave["Left"], self.BarSave["Top"], self.BarSave["Left"]..", "..self.BarSave["Top"]; return self.BarSave["Left"], self.BarSave["Top"], self.BarSave["Left"]..", "..self.BarSave["Top"];
end 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) function Bar:SetScale(Scale, NoCheck)
Scale = (Scale or 0) + 0; Scale = (Scale or 0) + 0;
if (Scale <= 0) then 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"]); 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); table.insert(self.Buttons, i, NewButton);
NewButton.Widget:SetPoint("TOPLEFT", self.ButtonFrame, "TOPLEFT", (c-1) * self.BSize, (1-r) * self.BSize); 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
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"]); local NewButton = Util.NewButton(BFrame, ButtonSave, self.BarSave["ButtonsLocked"], self.BarSave["TooltipsOn"], self.BarSave["MacroText"], self.BarSave["KeyBindText"]);
table.insert(Buttons, i, NewButton); table.insert(Buttons, i, NewButton);
NewButton.Widget:SetPoint("TOPLEFT", BFrame, "TOPLEFT", (c-1) * self.BSize, (1-r) * self.BSize); 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
end end
self.Cols = Cols; self.Cols = Cols;
@ -679,7 +709,11 @@ function Bar:SetNumButtons(Cols, Rows)
local ButtonSave = {}; local ButtonSave = {};
local NewButton = Util.NewButton(BFrame, ButtonSave, self.BarSave["ButtonsLocked"], self.BarSave["TooltipsOn"], self.BarSave["MacroText"], self.BarSave["KeyBindText"]); local NewButton = Util.NewButton(BFrame, ButtonSave, self.BarSave["ButtonsLocked"], self.BarSave["TooltipsOn"], self.BarSave["MacroText"], self.BarSave["KeyBindText"]);
table.insert(Buttons, i, NewButton); table.insert(Buttons, i, NewButton);
NewButton.Widget:SetPoint("TOPLEFT", BFrame, "TOPLEFT", (c-1) * self.BSize, (1-r) * self.BSize); 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
end end
self.Rows = Rows; self.Rows = Rows;
@ -1105,6 +1139,7 @@ end
--]] --]]
function Bar:DestroyBar() function Bar:DestroyBar()
if (not InCombatLockdown()) then if (not InCombatLockdown()) then
PlaySoundFile("sound/spells/meltoretarget.ogg"); --PlaySoundFile(569366)
Util.DeallocateBar(self); Util.DeallocateBar(self);
end end
UILib.ToggleDestroyBarMode(true); 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 --]] --[[ Set the individual types of actions including obtained any extra data they may need --]]
function Button:SetCommandSpell(Id) 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); local NameRank = Util.GetFullSpellName(Name, Rank);
self:SetCommandExplicitSpell(Id, NameRank, Name, Book); self:SetCommandExplicitSpell(Id, NameRank, Name, Book);
end 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) --]] --[[ 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) function Button:SetEnvSpell(Id, NameRank, Name, Book, IsTalent)
self.UpdateTexture = Button.Empty; self.UpdateTexture = Button.UpdateTextureSpell;
self.UpdateChecked = Button.UpdateCheckedSpell; self.UpdateChecked = Button.UpdateCheckedSpell;
self.UpdateEquipped = Button.Empty; self.UpdateEquipped = Button.Empty;
self.UpdateCooldown = Button.UpdateCooldownSpell; self.UpdateCooldown = Button.UpdateCooldownSpell;
@ -1136,7 +1136,7 @@ function Button:SetAttributes(Type, Value)
self.Widget:SetAttribute("spell", Value); self.Widget:SetAttribute("spell", Value);
elseif (Type == "customaction") then elseif (Type == "customaction") then
CustomAction.SetAttributes(Value, self.Widget); CustomAction.SetAttributes(Value, self.Widget);
end end
end end
@ -1230,7 +1230,9 @@ function Button:TranslateMacro()
self.CompanionIndex = CompanionID; self.CompanionIndex = CompanionID;
end end
self.SpellName = SpellName; 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.SpellId = SpellId;
self.MacroMode = "spell"; self.MacroMode = "spell";
else else
@ -1275,6 +1277,27 @@ function Button:UnitBuffBySpell(unit, spell)
return nil; return nil;
end; 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() function Button:UpdateTextureWispSpell()
--BFA fix: UnitBuff can no longer be called with the spell name as a param --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?? 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 end
function Button:UpdateTextureBonusAction() function Button:UpdateTextureBonusAction()
local action = self.Widget:GetAttribute("action"); local action = self.Widget:GetAttribute("action");
if (HasOverrideActionBar() or HasVehicleActionBar()) then if (HasOverrideActionBar()) then
local Texture = GetActionTexture(action); local Texture = GetActionTexture(action);
if (not Texture) then if (not Texture) then
self.WIcon:SetTexture(Const.ImagesDir.."Bonus"..self.BonusActionId); self.WIcon:SetTexture(Const.ImagesDir.."Bonus"..self.BonusActionId);
@ -1386,7 +1409,7 @@ function Button:UpdateCheckedCompanion()
end end
function Button:UpdateCheckedBonusAction() function Button:UpdateCheckedBonusAction()
local action = self.Widget:GetAttribute("action"); 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); self.Widget:SetChecked(true);
else else
self.Widget:SetChecked(false); self.Widget:SetChecked(false);
@ -1397,6 +1420,8 @@ function Button:UpdateCheckedCustomAction()
end end
--[[--------------------------------------------------------------------------------------- --[[---------------------------------------------------------------------------------------
Equipped functions Equipped functions
-----------------------------------------------------------------------------------------]] -----------------------------------------------------------------------------------------]]
@ -1469,7 +1494,7 @@ function Button:UpdateCooldownCompanion()
--as of 5.0.4 doesn't appear to exist anymore?! --as of 5.0.4 doesn't appear to exist anymore?!
end end
function Button:UpdateCooldownBonusAction() function Button:UpdateCooldownBonusAction()
if (HasOverrideActionBar() or HasVehicleActionBar()) then if (HasOverrideActionBar()) then
local action = self.Widget:GetAttribute("action"); local action = self.Widget:GetAttribute("action");
Util.CooldownFrame_SetTimer(self.WCooldown, GetActionCooldown(action)); Util.CooldownFrame_SetTimer(self.WCooldown, GetActionCooldown(action));
else else
@ -1478,6 +1503,7 @@ function Button:UpdateCooldownBonusAction()
end end
--[[------------------------------------------------------------------------------------- --[[-------------------------------------------------------------------------------------
Usable Functions Usable Functions
---------------------------------------------------------------------------------------]] ---------------------------------------------------------------------------------------]]
@ -1537,7 +1563,7 @@ end
function Button:UpdateUsableBonusAction() function Button:UpdateUsableBonusAction()
local action = self.Widget:GetAttribute("action"); local action = self.Widget:GetAttribute("action");
local IsUsable, NotEnoughMana = IsUsableAction(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.WIcon:SetVertexColor(1.0, 1.0, 1.0);
self.WNormalTexture:SetVertexColor(1.0, 1.0, 1.0); self.WNormalTexture:SetVertexColor(1.0, 1.0, 1.0);
elseif (NotEnoughMana) then elseif (NotEnoughMana) then
@ -1575,8 +1601,8 @@ function Button:UpdateTextCountSpell()
self.WCount:SetText(count); self.WCount:SetText(count);
return; return;
end end
local charges = GetSpellCharges(self.SpellNameRank); local charges, maxCharges = GetSpellCharges(self.SpellNameRank);
if (charges ~= nil) then if (charges ~= nil and maxCharges ~= 1) then
self.WCount:SetText(charges); self.WCount:SetText(charges);
return; return;
end end
@ -1607,7 +1633,7 @@ function Button:UpdateTextCountMacro()
end end
function Button:UpdateTextCountBonusAction() function Button:UpdateTextCountBonusAction()
local action = self.Widget:GetAttribute("action"); 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)); self.WCount:SetText(GetActionCount(action));
else else
self.WCount:SetText(""); self.WCount:SetText("");
@ -1697,7 +1723,7 @@ end
function Button:UpdateTooltipBonusAction() function Button:UpdateTooltipBonusAction()
self = self.ParentButton or self; --This is a sneaky cheat incase the widget was used to get here... self = self.ParentButton or self; --This is a sneaky cheat incase the widget was used to get here...
local action = self.Widget:GetAttribute("action"); local action = self.Widget:GetAttribute("action");
if (HasOverrideActionBar() or HasVehicleActionBar()) then if (HasOverrideActionBar()) then
GameTooltip:SetAction(action); GameTooltip:SetAction(action);
else else
GameTooltip:SetText(self.Tooltip, nil, nil, nil, nil, 1); GameTooltip:SetText(self.Tooltip, nil, nil, nil, nil, 1);
@ -1718,6 +1744,8 @@ function Button:UpdateTooltipCustomAction()
end end
--[[--------------------------------------------------------------------- --[[---------------------------------------------------------------------
Cursor functions Cursor functions
-----------------------------------------------------------------------]] -----------------------------------------------------------------------]]
@ -1750,6 +1778,8 @@ function Button:GetCursorCustomAction()
end end
--[[------------------------------------------------------------------------ --[[------------------------------------------------------------------------
Flash functions Flash functions
--------------------------------------------------------------------------]] --------------------------------------------------------------------------]]
@ -1774,7 +1804,7 @@ function Button:UpdateFlashMacro()
end end
function Button:UpdateFlashBonusAction() function Button:UpdateFlashBonusAction()
local action = self.Widget:GetAttribute("action"); 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 if (not self.FlashOn) then
self:AddToFlash(); self:AddToFlash();
end end
@ -1839,7 +1869,7 @@ function Button:UpdateRangeTimerMacro()
end end
function Button:UpdateRangeTimerBonusAction() function Button:UpdateRangeTimerBonusAction()
local action = self.Widget:GetAttribute("action"); 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 if (not self.RangeTimerOn) then
self:AddToRangeTimer(); self:AddToRangeTimer();
end end
@ -2006,7 +2036,8 @@ function Button:PromoteSpell()
end end
--[[ --[[
if (self.Mode == "spell") then 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 (Name) then
if (Util.LookupNewSpellIndex(Name.."("..Rank..")")) 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 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 -- Update arrow
Widget.FlyoutArrow:Show(); Widget.FlyoutArrow:Show();
Widget.FlyoutArrow:ClearAllPoints(); Widget.FlyoutArrow:ClearAllPoints();
--if (self:GetParent() == MultiBarRight or self:GetParent() == MultiBarLeft) then local direction = self.Widget:GetAttribute("flyoutDirection");
--self.FlyoutArrow:SetPoint("LEFT", self, "LEFT", -arrowDistance, 0); if (direction == "LEFT") then
--SetClampedTextureRotation(self.FlyoutArrow, 270); Widget.FlyoutArrow:SetPoint("LEFT", Widget, "LEFT", -arrowDistance, 0);
--else 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); Widget.FlyoutArrow:SetPoint("TOP", Widget, "TOP", 0, arrowDistance);
SetClampedTextureRotation(Widget.FlyoutArrow, 0); SetClampedTextureRotation(Widget.FlyoutArrow, 0);
--end end
else else
Widget.FlyoutBorder:Hide(); Widget.FlyoutBorder:Hide();
Widget.FlyoutBorderShadow:Hide(); Widget.FlyoutBorderShadow:Hide();

Voir le fichier

@ -1,8 +1,8 @@
## Interface: 11305 ## Interface: 20501
## Title: Button Forge (Classic) ## 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 ## 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.4
## Author: Massiner of Nathrezim
## SavedVariables: ButtonForgeGlobalSettings, ButtonForgeGlobalProfiles, ButtonForgeGlobalBackup ## SavedVariables: ButtonForgeGlobalSettings, ButtonForgeGlobalProfiles, ButtonForgeGlobalBackup
## SavedVariablesPerCharacter: ButtonForgeSave ## SavedVariablesPerCharacter: ButtonForgeSave
## OptionalDeps: Masque ## OptionalDeps: Masque

Voir le fichier

@ -9,8 +9,8 @@
local Const = BFConst; local Const = BFConst;
Const.SUMMON_RANDOM_FAVORITE_MOUNT_SPELL = 150544; Const.SUMMON_RANDOM_FAVORITE_MOUNT_SPELL = 150544;
Const.SUMMON_RANDOM_FAVORITE_MOUNT_ID = 268435455; Const.SUMMON_RANDOM_FAVORITE_MOUNT_ID = 268435455;
Const.Version = 0.9; Const.Version = 1.0;
Const.VersionMinor = 50; Const.VersionMinor = 0.5;
Const.MAX_ACCOUNT_MACROS = 120; Const.MAX_ACCOUNT_MACROS = 120;
Const.ButtonNaming = "ButtonForge" Const.ButtonNaming = "ButtonForge"
Const.ButtonSeq = 1; --This value will increment (so not technically a const...) Const.ButtonSeq = 1; --This value will increment (so not technically a const...)
@ -54,6 +54,11 @@ Const.ThresholdHSnapSq = 10 * 10;
Const.ThresholdHPressureSq = 20 * 20; Const.ThresholdHPressureSq = 20 * 20;
Const.StealthSpellIds = {};
Const.StealthSpellIds[1784] = 1; -- Stealth
Const.StealthSpellIds[5215] = 1; -- Prowl
Const.WispSpellIds = {}; Const.WispSpellIds = {};
Const.WispSpellIds[19746] = 1; --Concentration Aura Const.WispSpellIds[19746] = 1; --Concentration Aura
Const.WispSpellIds[32223] = 1; --Crusader Aura Const.WispSpellIds[32223] = 1; --Crusader Aura
@ -90,15 +95,17 @@ Const.DarkOrange = "ffEE5500";
Const.SlashCommands = {}; Const.SlashCommands = {};
Const.SlashCommands["-bar"] = {params = "^%s*(..-)%s*$", group = "bar"}; Const.SlashCommands["-bar"] = {params = "^%s*(..-)%s*$", group = "bar"};
Const.SlashCommands["-list"] = {params = "^()$", incompat = {"ALL"}};
Const.SlashCommands["-macrotext"] = {params = "bool", group = "bar"}; Const.SlashCommands["-macrotext"] = {params = "bool", group = "bar"};
Const.SlashCommands["-keybindtext"] = {params = "bool", group = "bar"}; Const.SlashCommands["-keybindtext"] = {params = "bool", group = "bar"};
Const.SlashCommands["-tooltips"] = {params = "bool", group = "bar"}; Const.SlashCommands["-tooltips"] = {params = "bool", group = "bar"};
Const.SlashCommands["-emptybuttons"] = {params = "bool", group = "bar"}; Const.SlashCommands["-emptybuttons"] = {params = "bool", group = "bar"};
Const.SlashCommands["-lockbuttons"] = {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["-scale"] = {params = "^%s*(%d*%.?%d+)%s*$", group = "bar"};
Const.SlashCommands["-rows"] = {params = "^%s*(%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 = {"-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 = {"-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["-gap"] = {params = "^%s*(%d*%.?%d+)%s*$", group = "bar"};
Const.SlashCommands["-enabled"] = {params = "bool", group = "bar"}; Const.SlashCommands["-enabled"] = {params = "bool", group = "bar"};
Const.SlashCommands["-info"] = {params = "^()$", group = "bar", requires = {"-bar"}}; Const.SlashCommands["-info"] = {params = "^()$", group = "bar", requires = {"-bar"}};

Voir le fichier

@ -1,18 +1,18 @@
--[[ --[[
Author: Alternator (Massiner of Nathrezim) Author: Alternator (Massiner of Nathrezim)
Copyright 2010 Copyright 2010
Notes: Notes:
]] ]]
BFLocales = {}; BFLocales = {};
BFConst = {}; BFConst = {};
BFUtil = {}; BFUtil = {};
BFUILib = {}; BFUILib = {};
BFButton = {}; BFButton = {};
BFBar = {}; BFBar = {};
BFCustomAction = {}; BFCustomAction = {};
ButtonForge_API1 = {}; ButtonForge_API1 = {};
ButtonForgeSave = {}; ButtonForgeSave = {};
@ -20,3 +20,4 @@ ButtonForgeSave = {};
ButtonForgeGlobalSettings = {}; ButtonForgeGlobalSettings = {};
ButtonForgeGlobalProfiles = {}; ButtonForgeGlobalProfiles = {};
ButtonForgeGlobalBackup = {}; 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) 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 self.AddonLoaded = true; --Before setting up is complete we also need to have spell, and macro data available
elseif (Event == "PLAYER_ENTERING_WORLD") then elseif (Event == "PLAYER_ENTERING_WORLD") then
Util.CacheSpellBookRanks() -- TBC Fix 2021/06/17
Util.CacheCompanions(); Util.CacheCompanions();
Util.CacheSpellIndexes(); Util.CacheSpellIndexes();
Util.CachePetSpellIndexes(); Util.CachePetSpellIndexes();
@ -455,6 +456,13 @@ function Misc:OnEvent(Event, ...)
-- self.TalentSwap = true; -- self.TalentSwap = true;
-- self:SetScript("OnUpdate", self.OnUpdate); -- 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 elseif (Event == "PLAYER_REGEN_DISABLED") then
Util.PreCombatStateUpdate(); Util.PreCombatStateUpdate();

Voir le fichier

@ -36,6 +36,9 @@
BFKeyBinder.OnInputBindingOverlay("MOUSEWHEELDOWN"); BFKeyBinder.OnInputBindingOverlay("MOUSEWHEELDOWN");
end end
</OnMouseWheel> </OnMouseWheel>
<OnGamePadButtonDown>
BFKeyBinder.OnInputBindingOverlay(button);
</OnGamePadButtonDown>
</Scripts> </Scripts>
</Frame> </Frame>

Voir le fichier

@ -88,6 +88,7 @@ Locale["SlashHelpFormatted"] =
"Valid slash commands: |c"..Const.LightBlue.."/buttonforge|r, |c"..Const.LightBlue.."/bufo|r\n".. "Valid slash commands: |c"..Const.LightBlue.."/buttonforge|r, |c"..Const.LightBlue.."/bufo|r\n"..
"Valid switches:\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.."-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.."-rename <new name>|r\n"..
"|c"..Const.LightBlue.."-rows <number>|r\n".. "|c"..Const.LightBlue.."-rows <number>|r\n"..
"|c"..Const.LightBlue.."-cols <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.."-tooltips <on/off>|r\n"..
"|c"..Const.LightBlue.."-emptybuttons <on/off>|r\n".. "|c"..Const.LightBlue.."-emptybuttons <on/off>|r\n"..
"|c"..Const.LightBlue.."-lockbuttons <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.."-macrotext <on/off>|r\n"..
"|c"..Const.LightBlue.."-keybindtext <on/off>|r\n".. "|c"..Const.LightBlue.."-keybindtext <on/off>|r\n"..
"|c"..Const.LightBlue.."-hidespec1 <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["SlashCommandRequired"] = "<COMMANDA> requires <COMMANDB> to also be specified";
Locale["SlashCommandIncompatible"] = "<COMMANDA> is incompatible with <COMMANDB>"; Locale["SlashCommandIncompatible"] = "<COMMANDA> is incompatible with <COMMANDB>";
Locale["SlashCommandAlone"] = "<COMMANDA> cannot be used with other commands"; 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"] = Locale["SlashBarNameRequired"] =
[[ButtonForge slash command failed: [[ButtonForge slash command failed:

Voir le fichier

@ -144,6 +144,18 @@ Notes:
#### Enable Right Click Self Cast #### Enable Right Click Self Cast
This can be done using the Right Click Self Cast button. 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 ## F.A.Q

Voir le fichier

@ -2,7 +2,7 @@
<Script file="UILibLayers.lua"/> <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> <Anchors>
<Anchor point="TOPLEFT" relativeTo="UIParent" relativePoint="TOPLEFT"> <Anchor point="TOPLEFT" relativeTo="UIParent" relativePoint="TOPLEFT">
<Offset> <Offset>

Voir le fichier

@ -10,11 +10,13 @@ local UILib = BFUILib;
local Const = BFConst; local Const = BFConst;
local VertLine = CreateFrame("FRAME", nil, UIParent); 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()); VertLine:SetWidth(Const.VLineThickness / UIParent:GetScale());
local HorizLine = CreateFrame("FRAME", nil, UIParent); 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()); HorizLine:SetHeight(Const.HLineThickness / UIParent:GetScale());

Voir le fichier

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

Voir le fichier

@ -4,6 +4,9 @@
<Frame name="BFToolbar" parent="BFConfigureLayer" enablemouse="true" movable="true"> <Frame name="BFToolbar" parent="BFConfigureLayer" enablemouse="true" movable="true">
<!--<FrameSkin skinid="dcb143e1-a4ab-4e7c-b934-1efa40101d21" frameid="2d508883-59c2-4f83-ae10-27aaad48391b" />--> <!--<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> <Scripts>
<OnMouseDown> <OnMouseDown>
self:StartMoving(); self:StartMoving();
@ -119,41 +122,6 @@
</Scripts> </Scripts>
</CheckButton> </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 --> <!-- Destroy Bar, this button toggles destroy bar mode -->
<CheckButton name="$parentDestroyBar" inherits="ActionButtonTemplate"> <CheckButton name="$parentDestroyBar" inherits="ActionButtonTemplate">
<Anchors> <Anchors>

337
Util.lua
Voir le fichier

@ -105,7 +105,7 @@ function Util.UpdateSavedData()
------The following section updates the per character saved data------ ------The following section updates the per character saved data------
--Need to allocate save structure --Need to allocate save structure
if (not ButtonForgeSave or ButtonForgeSave["Version"] == nil ) then if (not ButtonForgeSave or ButtonForgeSave["Version"] == nil) then
--Swap v0.9.0 / v0.9.1 / v0.9.2 users to the new save structure --Swap v0.9.0 / v0.9.1 / v0.9.2 users to the new save structure
ButtonForgeSave = {}; ButtonForgeSave = {};
ButtonForgeSave["ConfigureMode"] = true; ButtonForgeSave["ConfigureMode"] = true;
@ -168,6 +168,12 @@ function Util.UpdateSavedData()
DEFAULT_CHAT_FRAME:AddMessage(Util.GetLocaleString("UpgradedChatMsg").."v0.9.22", .5, 1, 0, 1); DEFAULT_CHAT_FRAME:AddMessage(Util.GetLocaleString("UpgradedChatMsg").."v0.9.22", .5, 1, 0, 1);
end 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 -- v0.9.34 update
if (ButtonForgeSave["Version"] == 0.9 and ButtonForgeSave["VersionMinor"] < 34) then if (ButtonForgeSave["Version"] == 0.9 and ButtonForgeSave["VersionMinor"] < 34) then
for i = 1, #ButtonForgeSave.Bars do for i = 1, #ButtonForgeSave.Bars do
@ -420,8 +426,6 @@ function Util.Load()
Util.StartMacroCheckDelay(); Util.StartMacroCheckDelay();
Util.RefreshOnUpdateFunction(); 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"); collectgarbage("collect");
Util.CallbackEvent("INITIALISED"); Util.CallbackEvent("INITIALISED");
end end
@ -1184,7 +1188,10 @@ function Util.SlashShowMessageByLine(Message)
end end
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 PreparedCommands = {};
local Command, Params; local Command, Params;
local Count = 0; local Count = 0;
@ -1192,6 +1199,9 @@ function SlashCmdList.BUTTONFORGE(msg, editbox)
for Token, Space in string.gmatch(msg, '([^%s]+)([%s]*)') do for Token, Space in string.gmatch(msg, '([^%s]+)([%s]*)') do
if (Const.SlashCommands[strlower(Token)]) then if (Const.SlashCommands[strlower(Token)]) then
if (Command) then if (Command) then
if (FirstCommand == nil) then
FirstCommand = Command;
end;
Count = Count + 1; Count = Count + 1;
--PreparedCommands["Count"] = Count; --PreparedCommands["Count"] = Count;
PreparedCommands[Command] = Util.ProcessSlashCommandParams(Command, Params); PreparedCommands[Command] = Util.ProcessSlashCommandParams(Command, Params);
@ -1225,7 +1235,7 @@ function SlashCmdList.BUTTONFORGE(msg, editbox)
-- 2. A rules required's must be present -- 2. A rules required's must be present
-- 3. A rules exclusions must not be present -- 3. A rules exclusions must not be present
local Group; local Group;
local FirstCommand;
for k, v in pairs(Commands) do for k, v in pairs(Commands) do
FirstCommand = FirstCommand or k; FirstCommand = FirstCommand or k;
if (Group ~= nil and Group ~= Const.SlashCommands[k].group) then 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; local Requires = Const.SlashCommands[k].requires;
if (Requires) then 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 for k1, v1 in pairs(Requires) do
if (Commands[v1] == nil) then table.insert(RequiresInfo,v1);
-- Missing a required command if (Commands[v1] ~= nil) then
DEFAULT_CHAT_FRAME:AddMessage(string.gsub(string.gsub(Util.GetLocaleString("SlashCommandRequired"), "<COMMANDA>", k), "<COMMANDB>", v1), .5, 1, 0, 1); RequiresValid = true;
return;
end end
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 end
local Incompat = Const.SlashCommands[k].incompat; local Incompat = Const.SlashCommands[k].incompat;
@ -1282,10 +1299,21 @@ function SlashCmdList.BUTTONFORGE(msg, editbox)
BarName = Commands["-bar"][1]; BarName = Commands["-bar"][1];
elseif (Commands["-destroybar"]) then elseif (Commands["-destroybar"]) then
BarName = Commands["-destroybar"][1]; BarName = Commands["-destroybar"][1];
end end
local barFound = false;
for i = 1, #Bars do for i = 1, #Bars do
if ((not BarName) or strlower(BarName) == strlower(Bars[i].BarSave["Label"])) then if ((not BarName) or strlower(BarName) == strlower(Bars[i].BarSave["Label"])) then
Util.ApplySlashCommands(Commands, Bars[i]); 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 end
end end
@ -1309,6 +1337,17 @@ function Util.ApplySlashCommands(Commands, Bar)
end end
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 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 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 if (Commands["-destroybar"]) then
Util.DeallocateBar(Bar); Util.DeallocateBar(Bar);
@ -1333,6 +1372,10 @@ function Util.ApplySlashCommands(Commands, Bar)
if (Commands["-lockbuttons"]) then if (Commands["-lockbuttons"]) then
Bar:SetButtonsLocked(Commands["-lockbuttons"][1]); Bar:SetButtonsLocked(Commands["-lockbuttons"][1]);
end end
if (Commands["-flyout"]) then
Bar:SetFlyoutDirection(Commands["-flyout"][1]);
end
if (Commands["-scale"]) then if (Commands["-scale"]) then
Bar:SetScale(tonumber(Commands["-scale"][1])); Bar:SetScale(tonumber(Commands["-scale"][1]));
@ -1377,7 +1420,7 @@ function Util.ApplySlashCommands(Commands, Bar)
if (Commands["-hideoverridebar"]) then if (Commands["-hideoverridebar"]) then
Bar:SetHBonusBar(Commands["-hideoverridebar"][1]); Bar:SetHBonusBar(Commands["-hideoverridebar"][1]);
end end
if (Commands["-vismacro"]) then if (Commands["-vismacro"]) then
Bar:SetVD(Commands["-vismacro"][1]); Bar:SetVD(Commands["-vismacro"][1]);
end end
@ -1508,7 +1551,13 @@ function Util.SetCursor(Command, Data, Subvalue, Subsubvalue)
UILib.StopDraggingIcon(); UILib.StopDraggingIcon();
-- SpellFlyout:Hide(); -- SpellFlyout:Hide();
if (Command == "spell") then if (Command == "spell") then
PickupSpell(Subsubvalue); -- 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 elseif (Command == "item") then
PickupItem(Data); PickupItem(Data);
elseif (Command == "macro") then elseif (Command == "macro") then
@ -1533,7 +1582,7 @@ function Util.SetCursor(Command, Data, Subvalue, Subsubvalue)
page = 14; page = 14;
end end
local Texture = GetActionTexture(Data + ((page - 1) * 12)); 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); UILib.StartDraggingIcon(Texture, 23, 23, "bonusaction", Data);
else else
UILib.StartDraggingIcon(Const.ImagesDir.."Bonus"..Data, 23, 23, "bonusaction", Data); UILib.StartDraggingIcon(Const.ImagesDir.."Bonus"..Data, 23, 23, "bonusaction", Data);
@ -1638,7 +1687,7 @@ end
-------------------------------------------]] -------------------------------------------]]
function Util.GetFullSpellName(Name, Rank) function Util.GetFullSpellName(Name, Rank)
--BFA fix: GetSpellInfo now returns a nil for the rank. That's passed in here --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 if (Rank) then
Rank = "("..Rank..")"; Rank = "("..Rank..")";
else else
@ -1697,8 +1746,8 @@ function Util.CacheSpellIndexes()
for i = total, 1, -1 do for i = total, 1, -1 do
ItemType, Id = GetSpellBookItemInfo(i, BOOKTYPE_SPELL); ItemType, Id = GetSpellBookItemInfo(i, BOOKTYPE_SPELL);
--local Name, Rank, Icon, PowerCost, IsFunnel, PowerType = GetSpellInfo(i, BOOKTYPE_SPELL); -- local Name, Rank, Icon, castTime, minRange, maxRange, spellId = GetSpellInfo(i, BOOKTYPE_SPELL);
local Name, Rank, Icon, PowerCost, IsFunnel, PowerType = GetSpellInfo(Id); local Name, Rank, Icon, castTime, minRange, maxRange, spellId = Util.GetSpellInfo(Id); -- TBC Fix 2021/06/18
local NameRank = Util.GetFullSpellName(Name, Rank); local NameRank = Util.GetFullSpellName(Name, Rank);
if (ItemType == "SPELL") then if (ItemType == "SPELL") then
NewSI[NameRank] = i; NewSI[NameRank] = i;
@ -1732,21 +1781,16 @@ end
function Util.CachePetSpellIndexes() function Util.CachePetSpellIndexes()
local i = 1; local i = 1;
local NewPSI = {}; local NewPSI = {};
--Util.NewPetSpellIndex = {};
while true do while true do
local NameRank = Util.GetFullSpellName(GetSpellInfo(i, BOOKTYPE_PET)); local spellName, spellSubName = GetSpellBookItemName(i, BOOKTYPE_PET)
if (not NameRank) then if not spellName then
break; do break end
end end
--if (not Util.PetSpellIndex[NameRank]) then NewPSI[spellName] = i;
-- Util.NewPetSpellIndex[NameRanl] = i; i = i + 1
--end
NewPSI[NameRank] = i;
i = i + 1;
end end
Util.PetSpellIndex = NewPSI; Util.PetSpellIndex = NewPSI;
end end
function Util.LookupSpellIndex(NameRank) function Util.LookupSpellIndex(NameRank)
@ -1845,13 +1889,15 @@ function Util.CacheCompanions()
end]] end]]
Util.Mounts = {}; Util.Mounts = {};
-- for i, mountID in pairs(C_MountJournal.GetMountIDs()) do --[[
-- local creatureName, spellID = C_MountJournal.GetMountInfoByID(mountID); for i, mountID in pairs(C_MountJournal.GetMountIDs()) do
-- if (not creatureName) then local creatureName, spellID = C_MountJournal.GetMountInfoByID(mountID);
-- return; if (not creatureName) then
-- end return;
-- Util.Mounts[spellID] = mountID; end
-- end Util.Mounts[spellID] = mountID;
end
Util.CompanionsCached = true;]]
end end
function Util.LookupCompanion(Name) function Util.LookupCompanion(Name)
@ -2351,7 +2397,9 @@ function Util.GetButtonActionInfo2(ButtonName)
--]] --]]
if (Button.Mode == "spell") then 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; return "spell", Button.SpellName, Rank, Button.SpellId, Util.LookupSpellIndex(Button.SpellNameRank), Button.SpellBook;
elseif (Button.Mode == "item") then elseif (Button.Mode == "item") then
return "item", Button.ItemId, Button.ItemName; return "item", Button.ItemId, Button.ItemName;
@ -2510,6 +2558,223 @@ function Util.LookupEquipmentSetIndex(EquipmentSetID)
end end
end end
return nil; return nil;
end 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