Skip to content

Commit

Permalink
Release version 1.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Siarkowy committed Oct 26, 2016
2 parents f36a871 + 9a51db3 commit 7b8d497
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 13 deletions.
1 change: 1 addition & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ and deleting of officer note backups. It requires enabled sDKP Backups addon.

* `/sdkp backup create` — Saves a new officer note backup.
* `/sdkp backup restore <timestamp>` — Loads specified backup to officer notes.
* `/sdkp backup revert <player> <timestamp>` — Reverts player's DKP from specified backup.
* `/sdkp backup list [<guild>]` — Lists all saved backups. Guild name parameter is optional.
* `/sdkp backup diff <timestamp>` — Shows differences from specified to current roster DKP data.
* `/sdkp backup delete <timestamp>` — Deletes backup specified by creation timestamp.
Expand Down
2 changes: 1 addition & 1 deletion sDKP/sDKP.toc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## X-Website: https://github.com/SiarkowyMods/sDKP
## X-License: GNU GPL v3
## SavedVariables: sDKP_DB
## Version: 1.8
## Version: 1.8.1

# Libs
Libs\ChatThrottleLib\ChatThrottleLib.lua
Expand Down
30 changes: 23 additions & 7 deletions sDKP_Backups/Backups.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ function sDKP:BackupNotes()
end

function sDKP:RestoreNotes(timestamp)
local backup = self:GetBackup(timestamp)
if not (backup and IsInGuild() and CanViewOfficerNote() and CanEditOfficerNote()) then return end
local backup = assert(self:GetBackup(timestamp), "Specified backup does not exist")
assert(IsInGuild() and CanViewOfficerNote() and CanEditOfficerNote(), "Cannot write to officer notes")

local num = 0
for i = 1, GetNumGuildMembers() do
Expand All @@ -74,6 +74,17 @@ function sDKP:RestoreNotes(timestamp)
return num
end

function sDKP:RevertFromBackup(timestamp, name)
assert(name ~= "" and name, "Player name required")

local backup = assert(self:GetBackup(timestamp), "Specified backup does not exist")
assert(IsInGuild() and CanViewOfficerNote() and CanEditOfficerNote(), "Cannot write to officer notes")

local char = assert(self(name), "Player not in your guild")
GuildRosterSetOfficerNote(char:GetMain().id, assert(backup[name], "No backup data for specified player"))
return true
end

function sDKP:DeleteBackup(timestamp)
local backup = self:GetBackup(timestamp)

Expand Down Expand Up @@ -107,26 +118,31 @@ do
return GRAY
end

function sDKP:VisualDiff(timestamp)
function sDKP:VisualDiff(timestamp, chan)
chan = chan or "SELF"
local backup = self:GetBackup(timestamp)

if backup then
self:Printf("Current to %s note differences:", date(self:Get("log.dateformat"), timestamp))
self:Announce(chan, "Roster differences vs. %s:", date(self:Get("log.dateformat"), timestamp))

local count = 0
for name, note in pairs(backup) do
local _, net, tot, hrs = self:ParseOfficerNote(note)
local char = self:GetCharacter(name)

if char and (net ~= char.net or tot ~= char.tot or hrs ~= char.hrs) then
self:Echo(" %s: %s%+d net|r, %s%+d tot|r, %s%+d hrs|r", name,
self:Announce(chan, " %s %s%+d net|r, %s%+d tot|r, %s%+d hrs|r%s",
self.ClassColoredPlayerName(name),
col(net, char.net), char.net - net,
col(tot, char.tot), char.tot - tot,
col(hrs, char.hrs), char.hrs - hrs)
col(hrs, char.hrs), char.hrs - hrs,
chan ~= "SELF" and "" or (
" |Hsdkp:bkp:4:%d:%s|h|cff88ffff(revert)|r|h"):format(
timestamp, name))
count = count + 1
end
end
self:Echo("Total of %d |4difference:differences;.", count)
self:Announce(chan, "Total of %d difference(s).", count)
else
self:Print("Non-existent backup ID supplied.")
end
Expand Down
5 changes: 4 additions & 1 deletion sDKP_Backups/Hyperlinks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ StaticPopupDialogs["SDKP_BACKUP"] = {
local Popup = StaticPopupDialogs.SDKP_BACKUP

sDKP.HyperlinkHandlers.bkp = function(btn, data)
local action, id = string.split(":", data)
local action, id, rest = string.split(":", data, 3)

action = tonumber(action) or 0
id = tonumber(id) or 0
Expand Down Expand Up @@ -61,5 +61,8 @@ sDKP.HyperlinkHandlers.bkp = function(btn, data)

elseif action == 3 then -- diff
self:VisualDiff(id)

elseif action == 4 then -- revert
self:RevertFromBackup(id, rest)
end
end
18 changes: 15 additions & 3 deletions sDKP_Backups/Slash.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ sDKP.Slash.args.backup = {
name = "Diff",
desc = "Show differences between saved and current roster DKP values.",
type = "execute",
usage = "<timestamp>",
usage = "<timestamp>[ @<channel>]",
func = function(self, param)
self:VisualDiff(self.ParamToTimestamp(param))
local param, chan = self.ExtractChannel(param, "SELF")
self:VisualDiff(self.ParamToTimestamp(param), chan)
end
},
list = {
Expand All @@ -57,6 +58,17 @@ sDKP.Slash.args.backup = {
func = function(self, param)
self:Printf("%d |4note:notes; restored.", self:RestoreNotes(self.ParamToTimestamp(param)) or 0)
end
}
},
revert = {
name = "Revert",
desc = "Reverts player's DKP from backup.",
type = "execute",
usage = "<player> <timestamp>",
func = function(self, param)
local player, backup = param:match("(%w+) (%d+)")
assert(player and backup, "Specify both player and timestamp")
self:RevertFromBackup(self.ParamToTimestamp(backup), player)
end
},
}
}
2 changes: 1 addition & 1 deletion sDKP_Backups/sDKP_Backups.toc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## X-Website: https://github.com/SiarkowyMods/sDKP
## SavedVariables: sDKP_BACKUPS
## Dependencies: sDKP
## Version: 1.1
## Version: 1.2

Backups.lua
Slash.lua
Expand Down

0 comments on commit 7b8d497

Please sign in to comment.