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

Issue 2 save normal blessings / allow Buff Presets #10

Merged
merged 11 commits into from
Jul 25, 2022
Merged
95 changes: 95 additions & 0 deletions PallyPower.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ function PallyPower:OnInitialize()
self.db.RegisterCallback(self, "OnProfileCopied", "OnProfileChanged")
self.db.RegisterCallback(self, "OnProfileReset", "OnProfileChanged")

if not PallyPower_SavedPresets or PallyPower_SavedPresets == nil then
PallyPower_SavedPresets = {}
PallyPower_SavedPresets["PallyPower_Assignments"] = {[0] = {}}
PallyPower_SavedPresets["PallyPower_NormalAssignments"] = {[0] = {}}
end

self.opt = self.db.profile
self.options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)

Expand Down Expand Up @@ -274,6 +280,15 @@ function PallyPower:OpenConfigWindow()
end
end

function tablecopy(tbl)
SaschaJankowiak marked this conversation as resolved.
Show resolved Hide resolved
if type(tbl) ~= "table" then return tbl end
local t = {}
for i,v in pairs(tbl) do
t[i] = tablecopy(v)
end
return t
end

function PallyPowerBlessings_Clear()
if InCombatLockdown() then return end

Expand Down Expand Up @@ -307,6 +322,77 @@ function PallyPowerBlessings_Refresh()
PallyPower:UpdateRoster()
end

function PallyPowerBlessings_Preset(shift)
if shift then --save current Assignments to preset
PallyPower_SavedPresets["PallyPower_Assignments"][0] = tablecopy(PallyPower_Assignments)
PallyPower_SavedPresets["PallyPower_NormalAssignments"][0] = tablecopy(PallyPower_NormalAssignments)
else -- load preset and publish to other pallys if possible
PallyPower:ClearAssignments(PallyPower.player)
PallyPower:SendMessage("CLEAR")
PallyPower_Assignments = tablecopy(PallyPower_SavedPresets["PallyPower_Assignments"][0])
PallyPower_NormalAssignments = tablecopy(PallyPower_SavedPresets["PallyPower_NormalAssignments"][0])

if PallyPower:CheckLeader(PallyPower.player) or PP_Leader == false then
C_Timer.After(
0.25,
function() -- send Class-Assignments
SaschaJankowiak marked this conversation as resolved.
Show resolved Hide resolved
for name in pairs(AllPallys) do
local s = ""
local BuffInfo = PallyPower_Assignments[name]
for i = 1, PALLYPOWER_MAXCLASSES do
if not BuffInfo[i] or BuffInfo[i] == 0 then
s = s .. "n"
else
s = s .. BuffInfo[i]
end
end
PallyPower:SendMessage("PASSIGN " .. name .. "@" .. s)
end

C_Timer.After(
0.25,
function() -- send Single-Assignments
for pname in pairs(PallyPower_NormalAssignments) do
if (PallyPower_NormalAssignments[pName]) then
for class in pairs(PallyPower_NormalAssignments[pName]) do
if PallyPower_NormalAssignments[pName][class] then
for tname in pairs(PallyPower_NormalAssignments[pName][class]) do
if PallyPower_NormalAssignments[pName][class][tname] and AllPallys[pname] and PallyPower:GetUnitIdByName(tname) then
if PallyPower_NormalAssignments[pname][class][tname] == nil or not AllPallys[pname][value] then
value = 0
else
value = PallyPower_NormalAssignments[pname][class][tname]
end
PallyPower:SendMessage("NASSIGN " .. pname .. " " .. class .. " " .. tname .. " " .. value)
end
end
end
end
end
end
C_Timer.After(
0.25,
function()
PallyPower:UpdateLayout()
PallyPower:UpdateRoster()
end
)
end
)
end
)
else
C_Timer.After(
0.25,
function()
PallyPower:UpdateLayout()
PallyPower:UpdateRoster()
end
)
end
end
end

function PallyPowerBlessings_Toggle()
if PallyPower.configFrame and PallyPower.configFrame:IsShown() then
PallyPower.configFrame:Hide()
Expand Down Expand Up @@ -3777,6 +3863,15 @@ function PallyPower:AutoAssign()
end
end

function PallyPower:Preset()
if InCombatLockdown() then return end

local shift = (IsShiftKeyDown() and PallyPowerBlessingsFrame:IsMouseOver())
SaschaJankowiak marked this conversation as resolved.
Show resolved Hide resolved
PallyPowerBlessings_Preset(shift)


SaschaJankowiak marked this conversation as resolved.
Show resolved Hide resolved
end

function PallyPower:CalcSkillRanks(name)
local wisdom, might, kings, salv, light, sanct
if AllPallys[name][1] then
Expand Down
2 changes: 2 additions & 0 deletions PallyPowerValues.lua
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ PALLYPOWER_REFRESH = L["Refresh"]
PALLYPOWER_REFRESH_DESC = L["PP_REFRESH_TOOLTIP"]
PALLYPOWER_AUTOASSIGN = L["Auto-Assign"]
PALLYPOWER_AUTOASSIGN_DESC = L["AUTO_ASSIGN_TOOLIP"]
PALLYPOWER_PRESET = L["Preset"]
PALLYPOWER_PRESET_DESC = L["PRESET_TOOLIP"]
SaschaJankowiak marked this conversation as resolved.
Show resolved Hide resolved
PALLYPOWER_REPORT = L["Blessings Report"]
PALLYPOWER_REPORT_DESC = L["BLESSING_REPORT_TOOLTIP"]
PALLYPOWER_FREEASSIGN = L["Free Assignment"]
Expand Down
30 changes: 29 additions & 1 deletion PallyPower_TBC.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1853,12 +1853,40 @@
</OnLeave>
</Scripts>
</Button>
<Button name = "$parentPreset" inherits = "GameMenuButtonTemplate" text = "PALLYPOWER_PRESET" hidden = "false">
<Size>
<AbsDimension x = "100" y = "20"/>
</Size>
<Anchors>
<Anchor point = "BOTTOMRIGHT" relativeTo = "$parentAutoAssign" relativePoint = "BOTTOMLEFT">
<Offset>
<AbsDimension x = "-7" y = "0"/>
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnClick>
PallyPower:Preset();
</OnClick>
<OnEnter>
if PallyPower.opt.ShowTooltips then
GameTooltip:SetOwner(self, "ANCHOR_BOTTOM");
GameTooltip:SetText(PALLYPOWER_PRESET_DESC);
GameTooltip:Show(self, motion);
CursorUpdate(self, motion);
end
</OnEnter>
<OnLeave>
GameTooltip:Hide(self, motion);
</OnLeave>
</Scripts>
</Button>
<Button name = "$parentReport" inherits = "GameMenuButtonTemplate" text = "PALLYPOWER_REPORT" hidden = "false">
<Size>
<AbsDimension x = "120" y = "20"/>
</Size>
<Anchors>
<Anchor point = "BOTTOMRIGHT" relativeTo = "$parentAutoAssign" relativePoint = "BOTTOMLEFT">
<Anchor point = "BOTTOMRIGHT" relativeTo = "$parentPreset" relativePoint = "BOTTOMLEFT">
<Offset>
<AbsDimension x = "-7" y = "0"/>
</Offset>
Expand Down
30 changes: 29 additions & 1 deletion PallyPower_Vanilla.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1840,12 +1840,40 @@
</OnLeave>
</Scripts>
</Button>
<Button name = "$parentPreset" inherits = "GameMenuButtonTemplate" text = "PALLYPOWER_PRESET" hidden = "false">
<Size>
<AbsDimension x = "100" y = "20"/>
</Size>
<Anchors>
<Anchor point = "BOTTOMRIGHT" relativeTo = "$parentAutoAssign" relativePoint = "BOTTOMLEFT">
<Offset>
<AbsDimension x = "-7" y = "0"/>
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnClick>
PallyPower:Preset();
</OnClick>
<OnEnter>
if PallyPower.opt.ShowTooltips then
GameTooltip:SetOwner(self, "ANCHOR_BOTTOM");
GameTooltip:SetText(PALLYPOWER_PRESET_DESC);
GameTooltip:Show(self, motion);
CursorUpdate(self, motion);
end
</OnEnter>
<OnLeave>
GameTooltip:Hide(self, motion);
</OnLeave>
</Scripts>
</Button>
<Button name = "$parentReport" inherits = "GameMenuButtonTemplate" text = "PALLYPOWER_REPORT" hidden = "false">
<Size>
<AbsDimension x = "120" y = "20"/>
</Size>
<Anchors>
<Anchor point = "BOTTOMRIGHT" relativeTo = "$parentAutoAssign" relativePoint = "BOTTOMLEFT">
<Anchor point = "BOTTOMRIGHT" relativeTo = "$parentPreset" relativePoint = "BOTTOMLEFT">
<Offset>
<AbsDimension x = "-7" y = "0"/>
</Offset>
Expand Down
30 changes: 29 additions & 1 deletion PallyPower_Wrath.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1883,12 +1883,40 @@
</OnLeave>
</Scripts>
</Button>
<Button name = "$parentPreset" inherits = "GameMenuButtonTemplate" text = "PALLYPOWER_PRESET" hidden = "false">
<Size>
<AbsDimension x = "100" y = "20"/>
</Size>
<Anchors>
<Anchor point = "BOTTOMRIGHT" relativeTo = "$parentAutoAssign" relativePoint = "BOTTOMLEFT">
<Offset>
<AbsDimension x = "-7" y = "0"/>
</Offset>
</Anchor>
</Anchors>
<Scripts>
<OnClick>
PallyPower:Preset();
SaschaJankowiak marked this conversation as resolved.
Show resolved Hide resolved
</OnClick>
<OnEnter>
if PallyPower.opt.ShowTooltips then
GameTooltip:SetOwner(self, "ANCHOR_BOTTOM");
GameTooltip:SetText(PALLYPOWER_PRESET_DESC);
GameTooltip:Show(self, motion);
CursorUpdate(self, motion);
end
</OnEnter>
<OnLeave>
GameTooltip:Hide(self, motion);
</OnLeave>
</Scripts>
</Button>
<Button name = "$parentReport" inherits = "GameMenuButtonTemplate" text = "PALLYPOWER_REPORT" hidden = "false">
<Size>
<AbsDimension x = "120" y = "20"/>
</Size>
<Anchors>
<Anchor point = "BOTTOMRIGHT" relativeTo = "$parentAutoAssign" relativePoint = "BOTTOMLEFT">
<Anchor point = "BOTTOMRIGHT" relativeTo = "$parentPreset" relativePoint = "BOTTOMLEFT">
<Offset>
<AbsDimension x = "-7" y = "0"/>
</Offset>
Expand Down