screenshot: new module to auto-perform screenshots

* cache pvp rank to avoid false positives due to drunk effects
* option to trigger time based
* option to trigger on levelup
* option to trigger on battleground
* option to trigger on item loot
* option to trigger at honorable kills
* option to trigger on pvp rank changes
* option to trigger on reputation tier
This commit is contained in:
Road-block
2019-03-31 14:59:21 +02:00
committed by shagu
parent e1590cc5d4
commit 5952f16d1a
5 changed files with 222 additions and 0 deletions
+10
View File
@@ -831,6 +831,16 @@ function pfUI:LoadConfig()
pfUI:UpdateConfig("abuttons", nil, "spacing", "2")
pfUI:UpdateConfig("abuttons", nil, "hideincombat", "1")
pfUI:UpdateConfig("screenshot", nil, "interval", "0")
pfUI:UpdateConfig("screenshot", nil, "levelup", "1")
pfUI:UpdateConfig("screenshot", nil, "pvprank", "1")
pfUI:UpdateConfig("screenshot", nil, "faction", "1")
pfUI:UpdateConfig("screenshot", nil, "battleground", "1")
pfUI:UpdateConfig("screenshot", nil, "hk", "1")
pfUI:UpdateConfig("screenshot", nil, "loot", "4")
pfUI:UpdateConfig("screenshot", nil, "hideui", "0")
pfUI:UpdateConfig("screenshot", nil, "caption", "0")
pfUI:UpdateConfig("gm", nil, "disable", "1")
pfUI:UpdateConfig("gm", nil, "server", "elysium")
+14
View File
@@ -44,6 +44,7 @@ pfUI_translation["enUS"] = {
["Banker"] = nil,
["Bankslots Per Row"] = nil,
["Bar Background"] = nil,
["Battleground"] = nil,
["Blacklist"] = nil,
["Border Color"] = nil,
["Bottom"] = nil,
@@ -68,6 +69,7 @@ pfUI_translation["enUS"] = {
["Button Spacing"] = nil,
["Buy"] = nil,
["Cache"] = nil,
["Caption"] = nil,
["Castbar"] = nil,
["Castbar Height"] = nil,
["Casting Color"] = nil,
@@ -236,6 +238,7 @@ pfUI_translation["enUS"] = {
["Enable Weapon Buff Display"] = nil,
["Enable Zone Text On Minimap Mouseover"] = nil,
["Encode"] = nil,
["Ended"] = nil,
["Equipped Item Color"] = nil,
["Exp"] = nil,
["Experience"] = nil,
@@ -282,6 +285,7 @@ pfUI_translation["enUS"] = {
["Hide Critters"] = nil,
["Hide Group Frames While In Raid"] = nil,
["Hide Totems"] = nil,
["Hide UI"] = nil,
["Hide When Entering Combat"] = nil,
["Highlight Equipped Items"] = nil,
["Highlight Not Usable Spells"] = nil,
@@ -290,6 +294,7 @@ pfUI_translation["enUS"] = {
["Highlight Settings That Require Reload"] = nil,
["Highlight Target Nameplate"] = nil,
["Highlight Unusable Items"] = nil,
["Honorable Kill"] = nil,
["Hoverbind"] = nil,
["Huge (PixelPerfect)"] = nil,
["Icon"] = nil,
@@ -327,12 +332,14 @@ pfUI_translation["enUS"] = {
["Legacy"] = nil,
["Legacy Click Handlers (Breaks Vertical Position and Overlap)"] = nil,
["Level"] = nil,
["Level Up"] = nil,
["Lists of added and deleted buttons are cleared"] = nil,
["Load profile"] = nil,
["Localtime"] = nil,
["Lock Actionbars"] = nil,
["Login"] = nil,
["Loot"] = nil,
["Looted"] = nil,
["Loot & Spam"] = nil,
["Macro Text Color"] = nil,
["Macro Text Size"] = nil,
@@ -379,6 +386,7 @@ pfUI_translation["enUS"] = {
["Only Count Bagspace On Regular Bags"] = nil,
["Only Show Chat Dock On Mouseover"] = nil,
["Only Show Indicators for Dispellable Debuffs"] = nil,
["Options"] = nil,
["Other Panel: Minimap"] = nil,
["Out Of Mana Color"] = nil,
["Out Of Range Color"] = nil,
@@ -402,6 +410,7 @@ pfUI_translation["enUS"] = {
["Power Bar Height"] = nil,
["Power Bar Width"] = nil,
["Profile"] = nil,
["PvP Rank"] = nil,
["Raid"] = nil,
["Raid Icon Size"] = nil,
["Random"] = nil,
@@ -412,6 +421,7 @@ pfUI_translation["enUS"] = {
["Remaining"] = nil,
["Remove button from the frame"] = nil,
["Removed button"] = nil,
["Reputation Level"] = nil,
["Reputation"] = nil,
["Request Rolls"] = nil,
["Reroll"] = nil,
@@ -439,6 +449,7 @@ pfUI_translation["enUS"] = {
["Scale"] = nil,
["Scaling"] = nil,
["Screen Resolution"] = nil,
["Screenshot"] = nil,
["Scrolling Combat Text Font"] = nil,
["Search"] = nil,
["Seconds Before Chat Fade"] = nil,
@@ -512,6 +523,7 @@ pfUI_translation["enUS"] = {
["This Session"] = nil,
["Time"] = nil,
["Time Remaining"] = nil,
["Timer (minutes, 0 to disable)"] = nil,
["Timestamp Brackets"] = nil,
["Timestamp Color"] = nil,
["Timestamp Format"] = nil,
@@ -526,6 +538,7 @@ pfUI_translation["enUS"] = {
["Top Right"] = nil,
["Tracking Icon Size"] = nil,
["Trigger Actions On Key Down"] = nil,
["Trigger"] = nil,
["UI-Scale"] = nil,
["Unbuffed"] = nil,
["Unit Frame Border Size"] = nil,
@@ -553,6 +566,7 @@ pfUI_translation["enUS"] = {
["Welcome to |cff33ffccpf|cffffffffUI|r!\n\nI'm the first run wizard that will guide you through some basic configuration. If you're lazy, feel free to hit the \"Defaults\" button. If you wish to run this dialog again, go to the settings and hit the \"Reset Firstrun\" button.\n\nVisit |cff33ffcchttp://shagu.org|r to check for the latest version."] = nil,
["Whitelist"] = nil,
["Wobble Zoom"] = nil,
["Won"] = nil,
["XP"] = nil,
["XP Percentage"] = nil,
["Your interface is now set up.\n\nFor advanced configuration, just open the |cff33ffccpf|rUI settings via the escape menu or type \"|cffffffaa/pfui|r\" into the chat.\n\n Have a nice trip!\n\n|cffaaaaaa- Shagu"] = nil,
+25
View File
@@ -1068,6 +1068,17 @@ pfUI:RegisterModule("gui", function ()
local entry = string.format("%d:%s", i, string.format("%s%s%s", _G.ITEM_QUALITY_COLORS[i].hex, _G[string.format("ITEM_QUALITY%d_DESC",i)], FONT_COLOR_CODE_CLOSE))
table.insert(pfUI.gui.dropdowns.loot_rarity, entry)
end
pfUI.gui.dropdowns.screenshot_battle = {
"0:".._G.NONE,
"1:"..T["Won"],
"2:"..T["Ended"],
}
pfUI.gui.dropdowns.screenshot_loot = {"0:".._G.NONE}
for i=3, 5 do
local entry = string.format("%d:%s", i, string.format("%s%s%s", _G.ITEM_QUALITY_COLORS[i].hex, _G[string.format("ITEM_QUALITY%d_DESC",i)], FONT_COLOR_CODE_CLOSE))
table.insert(pfUI.gui.dropdowns.screenshot_loot, entry)
end
end
do -- Generate Config UI
@@ -1373,6 +1384,20 @@ pfUI:RegisterModule("gui", function ()
CreateConfig(nil, T["Enable Durations On Foreign Frames"], C.appearance.cd, "foreign", "checkbox")
end)
CreateGUIEntry(T["Settings"], T["Screenshot"], function()
CreateConfig(nil, T["Trigger"], nil, nil, "header")
CreateConfig(nil, T["Timer (minutes, 0 to disable)"], C.screenshot, "interval")
CreateConfig(nil, T["Level Up"], C.screenshot, "levelup", "checkbox")
CreateConfig(nil, T["PvP Rank"], C.screenshot, "pvprank", "checkbox")
CreateConfig(nil, T["Reputation Level"], C.screenshot, "faction", "checkbox")
CreateConfig(nil, T["Battleground"], C.screenshot, "battleground", "dropdown", pfUI.gui.dropdowns.screenshot_battle)
CreateConfig(nil, T["Honorable Kill"], C.screenshot, "hk", "checkbox")
CreateConfig(nil, T["Looted"], C.screenshot, "loot", "dropdown", pfUI.gui.dropdowns.screenshot_loot)
CreateConfig(nil, T["Options"], nil, nil, "header")
CreateConfig(nil, T["Hide UI"], C.screenshot, "hideui", "checkbox")
CreateConfig(nil, T["Caption"], C.screenshot, "caption", "checkbox")
end)
CreateGUIEntry(T["Settings"], T["GM-Mode"], function()
CreateConfig(nil, T["Disable GM-Mode"], C.gm, "disable", "checkbox")
CreateConfig(nil, T["Selected Core"], C.gm, "server", "dropdown", pfUI.gui.dropdowns.gmserver_text)
+172
View File
@@ -0,0 +1,172 @@
pfUI:RegisterModule("screenshot", function ()
if C.screenshot.interval == "0"
and C.screenshot.levelup == "0"
and C.screenshot.pvprank == "0"
and C.screenshot.faction == "0"
and C.screenshot.battleground == "0"
and C.screenshot.hk == "0"
and C.screenshot.loot == "0" then
return
end
local LOOT_ITEM_SELF_MULTIPLEregex = string.gsub(_G.LOOT_ITEM_SELF_MULTIPLE,"%%sx%%d", "(.+)x(%%d+)")
local LOOT_ITEM_SELFregex = string.gsub(_G.LOOT_ITEM_SELF,"%%s", "(.+)")
local FACTION_STANDING_CHANGEDregex = string.gsub(_G.FACTION_STANDING_CHANGED,"%%s", "(.+)")
local color2quality = {}
for i=-1,6 do
color2quality[_G.ITEM_QUALITY_COLORS[i].hex] = i
end
pfUI.screenshot = CreateFrame("Frame")
pfUI.screenshot.caption = CreateFrame("Frame")
pfUI.screenshot.caption:SetPoint("TOP",nil,"TOP",0,-10)
pfUI.screenshot.caption:SetWidth(400)
pfUI.screenshot.caption:SetHeight(200)
pfUI.screenshot.caption.text = pfUI.screenshot.caption:CreateFontString("Label", "OVERLAY")
pfUI.screenshot.caption.text:SetFont("Interface\\AddOns\\pfUI\\fonts\\BigNoodleTitling.ttf", 32, "THICKOUTLINE")
pfUI.screenshot.caption.text:SetShadowColor(0,0,0)
pfUI.screenshot.caption.text:SetShadowOffset(2,1)
pfUI.screenshot.caption.text:SetAllPoints(pfUI.screenshot.caption)
pfUI.screenshot.caption.text:SetJustifyH("CENTER")
pfUI.screenshot.caption.text:SetJustifyV("TOP")
function pfUI.screenshot.OnEvent()
return this[event]~=nil and this[event](this,event,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11)
end
pfUI.screenshot:SetScript("OnEvent", pfUI.screenshot.OnEvent)
if tonumber(C.screenshot.interval) > 0 then
pfUI.screenshot._elapsed = 0
pfUI.screenshot._interval = tonumber(C.screenshot.interval)*60
pfUI.screenshot:SetScript("OnUpdate", function()
this._elapsed = this._elapsed + arg1
if this._elapsed > this._interval then
local dt = date("%a, %b %d, %Y %X")
local loc = string.format("%s - %s",GetRealZoneText(),GetSubZoneText())
this:CustomScreenshot("interval", dt, loc)
end
end)
pfUI.screenshot:Show()
end
pfUI.screenshot:RegisterEvent("PLAYER_ENTERING_WORLD")
if C.screenshot.levelup == "1" then
if UnitLevel("player") < MAX_PLAYER_LEVEL then
pfUI.screenshot:RegisterEvent("PLAYER_LEVEL_UP")
end
end
if C.screenshot.pvprank == "1" then
pfUI.screenshot:RegisterEvent("PLAYER_PVP_RANK_CHANGED")
end
if C.screenshot.faction == "1" then
pfUI.screenshot:RegisterEvent("CHAT_MSG_SYSTEM")
end
if C.screenshot.battleground ~= "0" then
pfUI.screenshot:RegisterEvent("UPDATE_BATTLEFIELD_SCORE")
pfUI.screenshot:RegisterEvent("UPDATE_BATTLEFIELD_STATUS")
end
if C.screenshot.hk == "1" then
pfUI.screenshot:RegisterEvent("PLAYER_PVP_KILLS_CHANGED")
end
if C.screenshot.loot ~= "0" then
pfUI.screenshot:RegisterEvent("CHAT_MSG_LOOT")
end
function pfUI.screenshot:CustomScreenshot(source, ...)
local now = GetTime()
if self._last and (now - self._last < 2) then return end
self._elapsed = 0
if C.screenshot.hideui == "1" then
UIParent:Hide()
end
if C.screenshot.caption == "1" then
if arg.n > 0 then
self.caption.text:SetText(table.concat(arg,"\n"))
self.caption:Show()
end
end
self:RegisterEvent("SCREENSHOT_SUCCEEDED")
self:RegisterEvent("SCREENSHOT_FAILED")
TakeScreenshot()
self._last = now
end
function pfUI.screenshot:PLAYER_ENTERING_WORLD()
local _
_, self._lastRank = GetPVPRankInfo(UnitPVPRank("player"))
end
function pfUI.screenshot:SCREENSHOT_SUCCEEDED()
self:UnregisterEvent("SCREENSHOT_SUCCEEDED")
self:UnregisterEvent("SCREENSHOT_FAILED")
UIParent:Show()
self.caption:Hide()
end
pfUI.screenshot.SCREENSHOT_FAILED = pfUI.screenshot.SCREENSHOT_SUCCEEDED
function pfUI.screenshot:PLAYER_LEVEL_UP()
local dt = date("%a, %b %d, %Y %X")
local loc = string.format("%s - %s",GetRealZoneText(),GetSubZoneText())
local name = string.format("%s : Level %d!",UnitName("player"),arg1)
self:CustomScreenshot("levelup", dt, loc, name)
end
function pfUI.screenshot:PLAYER_PVP_RANK_CHANGED()
local rankName, rankNumber = GetPVPRankInfo(UnitPVPRank("player"))
if self._lastRank and self._lastRank ~= rankNumber then
self._lastRank = rankNumber
local dt = date("%a, %b %d, %Y %X")
local loc = string.format("%s - %s",GetRealZoneText(),GetSubZoneText())
local name = string.format("%s : Rank %s!",UnitName("player"),rankName or _G.NONE)
self:CustomScreenshot("pvprank", dt, loc, name)
end
end
function pfUI.screenshot:CHAT_MSG_SYSTEM()
local _,_, standing, rep = string.find(arg1, FACTION_STANDING_CHANGEDregex)
if standing and rep then
local dt = date("%a, %b %d, %Y %X")
local loc = string.format("%s - %s",GetRealZoneText(),GetSubZoneText())
self:CustomScreenshot("faction", dt, loc, string.format("%s:%s!",rep,standing))
end
end
function pfUI.screenshot:UPDATE_BATTLEFIELD_STATUS()
local factioncode = UnitFactionGroup("player") == "Alliance" and 1 or 0
if GetBattlefieldInstanceExpiration() > 0 then
local won = GetBattlefieldWinner() and GetBattlefieldWinner() == factioncode
if C.screenshot.battleground == "2"
or (C.screenshot.battleground == "1" and won) then
local dt = date("%a, %b %d, %Y %X")
local loc = string.format("%s - %s",GetRealZoneText(),GetSubZoneText())
self:CustomScreenshot("battleground", dt, loc)
end
end
end
pfUI.screenshot.UPDATE_BATTLEFIELD_SCORE = pfUI.screenshot.UPDATE_BATTLEFIELD_STATUS
function pfUI.screenshot:PLAYER_PVP_KILLS_CHANGED()
local _, instancetype = IsInInstance()
if instancetype and instancetype == "pvp" then return end -- not if we're in a BG
local dt = date("%a, %b %d, %Y %X")
local loc = string.format("%s - %s",GetRealZoneText(),GetSubZoneText())
self:CustomScreenshot("hk", dt, loc, "Honorable Kill!")
end
function pfUI.screenshot:CHAT_MSG_LOOT()
local _,_, item, amount = string.find(arg1, LOOT_ITEM_SELF_MULTIPLEregex)
if amount then -- ignore stacks
return
else
_,_, item = string.find(arg1, LOOT_ITEM_SELFregex)
if item then
local _, _, itemColor, itemString, itemName = string.find(item, "^(|c%x+)|H(.+)|h(%[.+%])")
local quality = color2quality[itemColor]
if quality and quality >= tonumber(C.screenshot.loot) then
local dt = date("%a, %b %d, %Y %X")
local loc = string.format("%s - %s",GetRealZoneText(),GetSubZoneText())
local name = string.format("You got %s!",item)
self:CustomScreenshot("loot", dt, loc, name)
end
end
end
end
end)
+1
View File
@@ -147,3 +147,4 @@ modules\socialmod.lua
modules\firstrun.lua
modules\addonbuttons.lua
modules\afkcam.lua
modules\screenshot.lua