Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset buffs, not UI settings on new releases #54

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 58 additions & 65 deletions SmartBuff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
-- Version/Release info, bump these as needed:
-- Bump .toc file and optionally update notes in localization.en.lua

SMARTBUFF_DATE = "011124"; -- EU Date
SMARTBUFF_VERSION = "r31." .. SMARTBUFF_DATE;
-- Update the NR below to force full reload of SB_Data on first login
-- Bump on major logic or buff changes only
SMARTBUFF_VERSIONNR = 110005;
SMARTBUFF_DATE = "151124"; -- EU Date
SMARTBUFF_VERSION = "r32." .. SMARTBUFF_DATE;
-- Update the NR below to force reload of SB_Buffs on first login
SMARTBUFF_VERSIONNR = 110006;
-- End of version info

SMARTBUFF_TITLE = "SmartBuff";
Expand Down Expand Up @@ -181,7 +180,7 @@ local sounds = sharedMedia:HashTable("sound")

local DebugChatFrame = DEFAULT_CHAT_FRAME;

-- Popup
-- Popup reset all data
StaticPopupDialogs["SMARTBUFF_DATA_PURGE"] = {
text = SMARTBUFF_OFT_PURGE_DATA,
button1 = SMARTBUFF_OFT_YES,
Expand All @@ -192,6 +191,17 @@ StaticPopupDialogs["SMARTBUFF_DATA_PURGE"] = {
hideOnEscape = 1
}

-- Popup reset buffs
StaticPopupDialogs["SMARTBUFF_BUFFS_PURGE"] = {
text = SMARTBUFF_OFT_PURGE_BUFFS,
button1 = SMARTBUFF_OFT_YES,
button2 = SMARTBUFF_OFT_NO,
OnAccept = function() SMARTBUFF_ResetBuffs() end,
timeout = 0,
whileDead = 1,
hideOnEscape = 1
}

-- Popup to reloadui
StaticPopupDialogs["SMARTBUFF_GUI_RELOAD"] = {
text = SMARTBUFF_OFT_REQ_RELOAD,
Expand Down Expand Up @@ -514,9 +524,9 @@ function SMARTBUFF_OnEvent(self, event, ...)
if (event == "PLAYER_ENTERING_WORLD" and isInit and O.Toggle) then
isSetZone = true;
tStartZone = GetTime();

-- elseif (event == "PLAYER_ENTERING_WORLD" and isLoaded and isPlayer and not isInit and not InCombatLockdown()) then
-- SMARTBUFF_Options_Init(self);
end
if (event == "PLAYER_ENTERING_WORLD" and isLoaded and isPlayer and not isInit and not InCombatLockdown()) then
SMARTBUFF_Options_Init(self);
end
elseif (event == "ADDON_LOADED" and arg1 == SMARTBUFF_TITLE) then
isLoaded = true;
Expand Down Expand Up @@ -623,30 +633,6 @@ function SMARTBUFF_OnEvent(self, event, ...)
if (UnitAffectingCombat("player") and (arg1 == "player" or string.find(arg1, "^party") or string.find(arg1, "^raid"))) then
isSyncReq = true;
end

-- checks if aspect of cheetah or pack is active and cancel it if someone gets dazed
if (sPlayerClass == "HUNTER" and O.AntiDaze and (arg1 == "player" or string.find(arg1, "^party") or string.find(arg1, "^raid") or string.find(arg1, "pet"))) then
local _, stuntex = C_Spell.GetSpellTexture(1604); --get Dazed icon
if (SMARTBUFF_IsDebuffTexture(arg1, stuntex)) then
buff = nil;
if (arg1 == "player" and SMARTBUFF_CheckBuff(arg1, SMARTBUFF_AOTC)) then
buff = SMARTBUFF_AOTC;
elseif (SMARTBUFF_CheckBuff(arg1, SMARTBUFF_AOTP, true)) then
buff = SMARTBUFF_AOTP;
end
if (buff) then
if (O.ToggleAutoSplash and not SmartBuffOptionsFrame:IsVisible()) then
SmartBuffSplashFrame:Clear();
SmartBuffSplashFrame:SetTimeVisible(1);
SmartBuffSplashFrame:AddMessage("!!! CANCEL " .. buff .. " !!!", O.ColSplashFont.r, O.ColSplashFont.g,
O.ColSplashFont.b, 1.0);
end
if (O.ToggleAutoChat) then
SMARTBUFF_AddMsgWarn("!!! CANCEL " .. buff .. " !!!", true);
end
end
end
end
end

if (event == "UI_ERROR_MESSAGE") then
Expand Down Expand Up @@ -1040,6 +1026,7 @@ end

-- Set the buff array
function SMARTBUFF_SetBuffs()
if (InCombatLockdown()) then return end
if (B == nil) then return; end

local n = 1;
Expand Down Expand Up @@ -1540,13 +1527,15 @@ function SMARTBUFF_SyncBuffTimers()
rbTime = 0;
buffS = cBuffs[i].BuffS;

-- TOCHECK
rbTime = B[CS()][ct][buffS].RBTime;
if (rbTime <= 0) then
rbTime = O.RebuffTimer;
-- CHECK FOR NOT NIL; possible overkill with double check
if (B[CS()][ct][buffS] ~= nil) and (B[CS()][ct][buffS].RBTime ~= nil) then
rbTime = B[CS()][ct][buffS].RBTime;
if (rbTime <= 0) then
rbTime = O.RebuffTimer;
end
end

if (buffS and B[CS()][ct][buffS].EnableS and cBuffs[i].IDS ~= nil and cBuffs[i].DurationS > 0) then
if (buffS and (B[CS()][ct][buffS] ~= nil) and B[CS()][ct][buffS].EnableS and cBuffs[i].IDS ~= nil and cBuffs[i].DurationS > 0) then
if (cBuffs[i].Type ~= SMARTBUFF_CONST_SELF or (cBuffs[i].Type == SMARTBUFF_CONST_SELF and SMARTBUFF_IsPlayer(unit))) then
SMARTBUFF_SyncBuffTimer(unit, unit, cBuffs[i]);
end
Expand Down Expand Up @@ -3050,7 +3039,6 @@ function SMARTBUFF_Options_Init(self)
if (O.BuffInCities == nil) then O.BuffInCities = true; end
if (O.LinkSelfBuffCheck == nil) then O.LinkSelfBuffCheck = true; end
if (O.LinkGrpBuffCheck == nil) then O.LinkGrpBuffCheck = true; end
if (O.AntiDaze == nil) then O.AntiDaze = true; end

if (O.ScrollWheel ~= nil and O.ScrollWheelUp == nil) then O.ScrollWheelUp = O.ScrollWheel; end
if (O.ScrollWheel ~= nil and O.ScrollWheelDown == nil) then O.ScrollWheelDown = O.ScrollWheel; end
Expand Down Expand Up @@ -3180,15 +3168,16 @@ function SMARTBUFF_Options_Init(self)
end
end

-- major version changes are backwards incompatible by definition, so trigger a RESET ALL
-- Do a reset of buff data on changes
O.VersionNr = O.VersionNr or SMARTBUFF_VERSIONNR -- don't reset if O.VersionNr == nil
if O.VersionNr < SMARTBUFF_VERSIONNR then
if (O.VersionNr ~= SMARTBUFF_VERSIONNR) then
O.VersionNr = SMARTBUFF_VERSIONNR;
StaticPopup_Show("SMARTBUFF_DATA_PURGE");
SMARTBUFF_SetBuffs();
StaticPopup_Show("SMARTBUFF_BUFFS_PURGE");
SMARTBUFF_SetTemplate()
InitBuffOrder(true);
SMARTBUFF_AddMsg("Upgraded SmartBuff to " .. SMARTBUFF_VERSION, true);
end
SMARTBUFF_AddMsg("Upgraded SmartBuff to " .. SMARTBUFF_VERSION);
-- TODO: Bring back major reset of everything but also there's a UI button still to do it

if (SMARTBUFF_OptionsGlobal == nil) then
SMARTBUFF_OptionsGlobal = {};
Expand All @@ -3203,6 +3192,7 @@ function SMARTBUFF_Options_Init(self)

if (OG.FirstStart ~= SMARTBUFF_VERSION) then
SMARTBUFF_OptionsFrame_Open(true);
OG.FirstStart = SMARTBUFF_VERSION;
if (OG.Tutorial == nil) then
OG.Tutorial = SMARTBUFF_VERSIONNR;
SMARTBUFF_ToggleTutorial();
Expand Down Expand Up @@ -3239,12 +3229,22 @@ function SMARTBUFF_InitActionButtonPos()
--print(format("x = %.0f, y = %.0f", O.ActionBtnX, O.ActionBtnY));
end

-- Reset all options, buffs and window position
function SMARTBUFF_ResetAll()
wipe(SMARTBUFF_Buffs);
wipe(SMARTBUFF_Options);
ReloadUI();
end

-- Reset only buffs. Useful for upgrades, keep UI options
-- Don't reload UI. Since buffs are after reset
function SMARTBUFF_ResetBuffs()
wipe(SMARTBUFF_Buffs);
SMARTBUFF_SetTemplate()
InitBuffOrder(true);
SMARTBUFF_OptionsFrame_Close(true)
end

function SMARTBUFF_SetButtonPos(self)
local x, y = self:GetLeft(), self:GetTop() - UIParent:GetHeight();
O.ActionBtnX = x;
Expand Down Expand Up @@ -3472,10 +3472,6 @@ function SMARTBUFF_OLinkGrpBuffCheck()
O.LinkGrpBuffCheck = not O.LinkGrpBuffCheck;
end

function SMARTBUFF_OAntiDaze()
O.AntiDaze = not O.AntiDaze;
end

function SMARTBUFF_OScrollWheelUp()
O.ScrollWheelUp = not O.ScrollWheelUp;
isKeyUpChanged = true;
Expand Down Expand Up @@ -3527,6 +3523,9 @@ function SMARTBUFF_OSelfFirst()
end

function SMARTBUFF_OToggleBuff(s, i)
if (cBuffs[i] == nil) then
return
end
local bs = GetBuffSettings(cBuffs[i].BuffS);
if (bs == nil) then
return;
Expand Down Expand Up @@ -3568,11 +3567,6 @@ function SMARTBUFF_OptionsFrame_Toggle()
SmartBuff_PlayerSetup:Hide();
end
SmartBuffOptionsFrame:Hide();
-- if we were a new build then request a reloadui.
if (OG.FirstStart ~= SMARTBUFF_VERSION) then
OG.FirstStart = SMARTBUFF_VERSION;
StaticPopup_Show("SMARTBUFF_GUI_RELOAD");
end
else
SmartBuffOptionsCredits_lblText:SetText(SMARTBUFF_CREDITS);
SmartBuffOptionsFrame:Show();
Expand All @@ -3589,6 +3583,13 @@ function SMARTBUFF_OptionsFrame_Open(force)
end
end

function SMARTBUFF_OptionsFrame_Close(force)
if (not isInit) then return; end
if (SmartBuffOptionsFrame:IsVisible() or force) then
SmartBuffOptionsFrame:Hide();
end
end

function SmartBuff_BuffSetup_Show(i)
local icon1 = cBuffs[i].IconS;
local icon2 = cBuffs[i].IconG;
Expand Down Expand Up @@ -3848,7 +3849,6 @@ function SMARTBUFF_Options_OnShow()
SmartBuffOptionsFrame_cbInShapeshift:SetChecked(O.InShapeshift);
SmartBuffOptionsFrame_cbFixBuffIssue:SetChecked(O.SBButtonFix);

SmartBuffOptionsFrame_cbAntiDaze:SetChecked(O.AntiDaze);
SmartBuffOptionsFrame_cbLinkGrpBuffCheck:SetChecked(O.LinkGrpBuffCheck);
SmartBuffOptionsFrame_cbLinkSelfBuffCheck:SetChecked(O.LinkSelfBuffCheck);

Expand Down Expand Up @@ -3977,16 +3977,6 @@ function SMARTBUFF_SetCheckButtonBuffs(mode)
SMARTBUFF_SetBuffs();
end

SmartBuffOptionsFrame_cbAntiDaze:Hide();

if (sPlayerClass == "HUNTER" or sPlayerClass == "ROGUE" or sPlayerClass == "WARRIOR") then
SmartBuffOptionsFrameBLDuration:Hide();
if (sPlayerClass == "HUNTER") then
SmartBuffOptionsFrame_cbLinkGrpBuffCheck:Hide();
SmartBuffOptionsFrame_cbAntiDaze:Show();
end
end

if (sPlayerClass == "DRUID" or sPlayerClass == "SHAMAN") then
SmartBuffOptionsFrame_cbInShapeshift:Show();
else
Expand Down Expand Up @@ -4030,6 +4020,7 @@ function SMARTBUFF_DropDownTemplate_OnClick(self)
UIDropDownMenu_SetSelectedValue(SmartBuffOptionsFrame_ddTemplates, i);
tmp = SMARTBUFF_TEMPLATES[i];
--SMARTBUFF_AddMsgD("Selected/Current Buff-Template: " .. tmp .. "/" .. currentTemplate);
SMARTBUFF_SetBuffs()
if (currentTemplate ~= tmp) then
SmartBuff_BuffSetup:Hide();
iLastBuffSetup = -1;
Expand Down Expand Up @@ -4617,7 +4608,9 @@ local function OnScroll(self, cData, sBtnName)
btn:SetNormalFontObject("GameFontNormalSmall");
btn:SetHighlightFontObject("GameFontHighlightSmall");
btn:SetText(cData[n]);
btn:SetChecked(t[cData[n]].EnableS);
if (t[cData[n]] ~= nil) then
btn:SetChecked(t[cData[n]].EnableS);
end
btn:Show();
else
btn:Hide();
Expand Down
2 changes: 1 addition & 1 deletion SmartBuff.toc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Interface: 110005
## Title: SmartBuff |cff0099ffRetail|r
## Version: 30.110005.1
## Version: 32.110005
## Author: |cff20d2ffCodermik & Aeldra|r (EU-Proudmoore)
## Contributing Author: |cff20d2ffSpeedwaystar
## Notes: Cast the most important buffs on you or party/raid members/pets. Use /sbm for options menu.
Expand Down
49 changes: 17 additions & 32 deletions SmartBuff.xml
Original file line number Diff line number Diff line change
Expand Up @@ -933,37 +933,6 @@
</OnLeave>
</Scripts>
</CheckButton>
<CheckButton name="SmartBuffOptionsFrame_cbAntiDaze" inherits="UICheckButtonTemplate">
<Size>
<AbsDimension x="24" y="24" />
</Size>
<Anchors>
<Anchor point="TOPLEFT" relativeTo="SmartBuffOptionsFrame_cbAutoSwitchTmp" relativePoint="TOPLEFT">
<Offset>
<AbsDimension x="0" y="-20" />
</Offset>
</Anchor>
</Anchors>
<HitRectInsets>
<AbsInset left="0" right="0" top="0" bottom="0" />
</HitRectInsets>
<Scripts>
<OnLoad>
getglobal(self:GetName().."Text"):SetText(SMARTBUFF_OFT_ANTIDAZE);
getglobal(self:GetName().."Text"):SetFontObject(GameFontNormalSmall);
</OnLoad>
<OnClick>
SMARTBUFF_OAntiDaze();
</OnClick>
<OnEnter>
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
GameTooltip:SetText(SMARTBUFF_OFTT_ANTIDAZE, SMARTBUFF_TTC_R, SMARTBUFF_TTC_G, SMARTBUFF_TTC_B, SMARTBUFF_TTC_A);
</OnEnter>
<OnLeave>
GameTooltip:Hide();
</OnLeave>
</Scripts>
</CheckButton>
<CheckButton name="SmartBuffOptionsFrame_cbLinkSelfBuffCheck" inherits="UICheckButtonTemplate" hidden="true">
<Size>
<AbsDimension x="24" y="24" />
Expand Down Expand Up @@ -1509,7 +1478,7 @@
</OnClick>
</Scripts>
</Button>
<Button name="SmartBuffOptionsFrameResetOrder" inherits="UIPanelButtonTemplate" text="SMARTBUFF_OFT_RESETLIST">
<Button name="SmartBuffOptionsFrameResetBuffs" inherits="UIPanelButtonTemplate" text="SMARTBUFF_OFT_RESETBUFFS">
<Size>
<AbsDimension x="88" y="33" />
</Size>
Expand All @@ -1518,6 +1487,22 @@
<Offset x="212" y="27" />
</Anchor>
</Anchors>
<Scripts>
<OnClick>
SMARTBUFF_OptionsFrame_Toggle();
StaticPopup_Show("SMARTBUFF_BUFFS_PURGE");
</OnClick>
</Scripts>
</Button>
<Button name="SmartBuffOptionsFrameResetOrder" inherits="UIPanelButtonTemplate" text="SMARTBUFF_OFT_RESETLIST">
<Size>
<AbsDimension x="88" y="33" />
</Size>
<Anchors>
<Anchor point="BOTTOMLEFT" relativeTo="$parent" relativePoint="BOTTOMLEFT">
<Offset x="306" y="27" />
</Anchor>
</Anchors>
<Scripts>
<OnClick>
SMARTBUFF_BuffOrderReset();
Expand Down
2 changes: 2 additions & 0 deletions localization.cn.lua
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ SMARTBUFF_OFT_HIDESABUTTON = "隐藏动作按钮";
SMARTBUFF_OFT_INCOMBAT = "战斗中触发";
SMARTBUFF_OFT_SMARTDEBUFF = "SmartDebuff";
SMARTBUFF_OFT_PURGE_DATA = "您确定要重置所有 SmartBuff 数据吗?\n此操作将强制重新加载 UI!";
SMARTBUFF_OFT_RESETBUFFS = "Reset Buffs";
SMARTBUFF_OFT_PURGE_BUFFS = "New Version, reset ALL SmartBuff buff data?\nThis will reset all buff profiles!";
SMARTBUFF_OFT_REQ_RELOAD = "新版本需要重新加载 GUI\n准备就绪后单击继续。";
SMARTBUFF_OFT_YES = "是的";
SMARTBUFF_OFT_NO = "不";
Expand Down
2 changes: 2 additions & 0 deletions localization.de.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ SMARTBUFF_OFT_LINKGRPBUFFCHECK = "Grp Link";
SMARTBUFF_OFT_LINKSELFBUFFCHECK = "Selbst Link";
SMARTBUFF_OFT_RESETALL = "Reset Alles";
SMARTBUFF_OFT_RESETLIST = "Reset Liste";
SMARTBUFF_OFT_RESETBUFFS = "Reset Buffs";
SMARTBUFF_OFT_PURGE_BUFFS = "New Version, reset ALL SmartBuff buff data?\nThis will reset all buff profiles!";
SMARTBUFF_OFT_YES = "Ja";
SMARTBUFF_OFT_NO = "Nein";
SMARTBUFF_OFT_OKAY = "Neu laden"
Expand Down
9 changes: 6 additions & 3 deletions localization.en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ SMARTBUFF_WHATSNEW = "\n\n|cffffffff Whats new:|r\n\n"
.." |cffffffffDragonflight version by Codermik, additional retail\n"
.." programming by Speedwaystar/MrWizard.\n"
.."\n\n"
.." Changes in r30.011024:\n\n"
.." * Delve performance bug fix.\n"
.." * Adding hearty food missing items\n"
.." Changes in r32.151124:\n\n"
.." * Purge buffs, not options on new release\n"
.." * No forced UI reloads, less disruptions\n"
.." * Bunch of minor bug fixes\n"
.."\n\n"
.." |c0000FF96Many thanks to Chris S., Samantha R. and\n"
.." Twilight's Sundries for their kind donations.\n"
Expand Down Expand Up @@ -109,6 +110,8 @@ SMARTBUFF_OFT_LINKGRPBUFFCHECK = "Grp link";
SMARTBUFF_OFT_LINKSELFBUFFCHECK = "Self link";
SMARTBUFF_OFT_RESETALL = "Reset All";
SMARTBUFF_OFT_RESETLIST = "Reset List";
SMARTBUFF_OFT_RESETBUFFS = "Reset Buffs";
SMARTBUFF_OFT_PURGE_BUFFS = "New Version, reset ALL SmartBuff buff data?\nThis will reset all buff profiles!";
SMARTBUFF_OFT_YES = "Yes";
SMARTBUFF_OFT_NO = "No";
SMARTBUFF_OFT_OKAY = "Continue"
Expand Down
2 changes: 2 additions & 0 deletions localization.es.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ SMARTBUFF_OFT_LINKGRPBUFFCHECK = "Grp link";
SMARTBUFF_OFT_LINKSELFBUFFCHECK = "Self link";
SMARTBUFF_OFT_RESETALL = "Reset All";
SMARTBUFF_OFT_RESETLIST = "Reset List";
SMARTBUFF_OFT_RESETBUFFS = "Reset Buffs";
SMARTBUFF_OFT_PURGE_BUFFS = "New Version, reset ALL SmartBuff buff data?\nThis will reset all buff profiles!";
SMARTBUFF_OFT_YES = "Yes";
SMARTBUFF_OFT_NO = "No";
SMARTBUFF_OFT_OKAY = "Continuar"
Expand Down
Loading