Skip to content

Commit

Permalink
Added options to screenshot on level up
Browse files Browse the repository at this point in the history
You can screenshot per 10 levels or every level. You can enabled or disable this per the config which is disabled by default.

Fixed missing arg in PLAYER_LEVEL_UP.

Updated Dashi!
  • Loading branch information
Kkthnx committed Jan 26, 2025
1 parent 81787b4 commit 55fd85b
Show file tree
Hide file tree
Showing 15 changed files with 419 additions and 275 deletions.
15 changes: 15 additions & 0 deletions LevelUpFX/Config/Settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ namespace:RegisterSettings("LevelUpFXDB", {
tooltip = "50% chance to perform the 'CHEER' emote when you level up.",
default = false,
},
{
key = "screenShotOnLevelUp",
type = "toggle",
title = "Screenshot on Level Up",
tooltip = "Automatically take a screenshot one second after leveling up.",
default = false,
},
{
key = "screenShotEveryLevel",
type = "toggle",
title = "Screenshot Every Level",
tooltip = "Take a screenshot for every level up, not just at specific levels.",
default = false,
requires = "screenShotOnLevelUp",
},
{
key = "chatEmoteOnLevelUp",
type = "toggle",
Expand Down
29 changes: 26 additions & 3 deletions LevelUpFX/LevelUpFX.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ local function ShowLevelUpMessage(level, statGains, isMoving)
background:SetPoint("BOTTOM")
background:SetSize(326, 103)
background:SetTexCoord(0.00195313, 0.63867188, 0.03710938, 0.23828125)
background:SetVertexColor(1, 1, 1, 0.7)
background:SetVertexColor(1, 1, 1, 0.6)

-- Top gold bar
local topBar = frame:CreateTexture(nil, "ARTWORK")
Expand Down Expand Up @@ -129,6 +129,30 @@ local function ShowLevelUpMessage(level, statGains, isMoving)
frame:Show()
end

-- Add screenshot functionality here
if namespace:GetOption("screenShotOnLevelUp") then
if not namespace.ScreenShotFrame then
-- Create the screenshot frame if it doesn't exist
namespace.ScreenShotFrame = CreateFrame("Frame")
namespace.ScreenShotFrame:Hide()
namespace.ScreenShotFrame:SetScript("OnUpdate", function(self, elapsed)
self.delay = self.delay - elapsed
if self.delay < 0 then
Screenshot()
self:Hide()
end
end)
end

-- Check if we should take a screenshot for this level
local screenshotLevels = { [10] = true, [20] = true, [30] = true, [40] = true, [50] = true, [60] = true }

if screenshotLevels[level] or namespace:GetOption("screenShotEveryLevel") then
namespace.ScreenShotFrame.delay = 1
namespace.ScreenShotFrame:Show()
end
end

-- Perform the "CHEER" emote if enabled and not moving
if not isMoving and namespace:GetOption("cheerOnLevelUp") then
if math.random() < 0.5 then
Expand All @@ -142,8 +166,7 @@ local function ShowLevelUpMessage(level, statGains, isMoving)
end
end

-- Event handler
namespace:RegisterEvent("PLAYER_LEVEL_UP", function(_, level, _, _, _, strengthDelta, agilityDelta, staminaDelta, intellectDelta, spiritDelta)
namespace:RegisterEvent("PLAYER_LEVEL_UP", function(_, level, _, _, _, _, strengthDelta, agilityDelta, staminaDelta, intellectDelta, spiritDelta)
local statGains = {
Strength = strengthDelta or 0,
Agility = agilityDelta or 0,
Expand Down
2 changes: 1 addition & 1 deletion LevelUpFX/LevelUpFX_Classic.toc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Title: |cff5bc0beLevelUpFX|r
## Notes: Celebrate your level-ups with style! Displays a animated message and stats gained whenever you level up in World of Warcraft Classic Era.|n|n|cff669DFFDeveloper|cffffffff:|r |nJosh "|CFF7b8489Kkthnx|r" Russell|n|n|cff009cdePayPal|r|cffffffff:|r |n|cffffffffwww.paypal.me/KkthnxTV|r|n|n|cfff96854Patreon|r|cffffffff:|r |n|cffffffffwww.patreon.com/Kkthnx|r
## Author: Josh "Kkthnx" Russell, DaleHuntGB
## Version: 1.0.2
## Version: 1.0.3
## IconTexture: 236567
## SavedVariables: LevelUpFXDB
## X-Support: Classic
Expand Down
8 changes: 4 additions & 4 deletions LevelUpFX/Libs/Dashi/modules/build.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
local _, addon = ...

--[[ namespace:IsRetail()
--[[ namespace:IsRetail() ![](https://img.shields.io/badge/function-blue)
Checks if the current client is running the "retail" version.
--]]
function addon:IsRetail()
return WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
end

--[[ namespace:IsClassicEra()
--[[ namespace:IsClassicEra() ![](https://img.shields.io/badge/function-blue)
Checks if the current client is running the "classic era" version (e.g. vanilla).
--]]
function addon:IsClassicEra()
return WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
end

--[[ namespace:IsClassic()
--[[ namespace:IsClassic() ![](https://img.shields.io/badge/function-blue)
Checks if the current client is running the "classic" version.
--]]
function addon:IsClassic()
Expand All @@ -24,7 +24,7 @@ function addon:IsClassic()
end

local _, buildVersion, _, interfaceVersion = GetBuildInfo()
--[[ namespace:HasBuild(_buildNumber_[, _interfaceVersion_])
--[[ namespace:HasBuild(_buildNumber_[, _interfaceVersion_]) ![](https://img.shields.io/badge/function-blue)
Checks if the current client is running a build equal to or newer than the specified.
Optionally also check against the interface version.
--]]
Expand Down
23 changes: 11 additions & 12 deletions LevelUpFX/Libs/Dashi/modules/defer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,27 @@ end
local function defer(info)
table.insert(queue, info)

if not addon:IsEventRegistered('PLAYER_REGEN_ENABLED', iterate) then
addon:RegisterEvent('PLAYER_REGEN_ENABLED', iterate)
if not addon:IsEventRegistered("PLAYER_REGEN_ENABLED", iterate) then
addon:RegisterEvent("PLAYER_REGEN_ENABLED", iterate)
end
end


--[[ namespace:Defer(_callback_[, _..._])
--[[ namespace:Defer(_callback_[, _..._]) ![](https://img.shields.io/badge/function-blue)
Defers a function `callback` (with optional arguments) until after combat ends.
Callback can be the global name of a function.
Triggers immediately if player is not in combat.
--]]
function addon:Defer(callback, ...)
if type(callback) == 'string' then
if type(callback) == "string" then
callback = _G[callback]
end

addon:ArgCheck(callback, 1, 'function')
addon:ArgCheck(callback, 1, "function")

if InCombatLockdown() then
defer({
callback = callback,
args = {...},
args = { ... },
})
else
local successful, ret = pcall(callback, ...)
Expand All @@ -54,20 +53,20 @@ function addon:Defer(callback, ...)
end
end

--[[ namespace:DeferMethod(_object_, _method_[, _..._])
--[[ namespace:DeferMethod(_object_, _method_[, _..._]) ![](https://img.shields.io/badge/function-blue)
Defers a `method` on `object` (with optional arguments) until after combat ends.
Triggers immediately if player is not in combat.
--]]
function addon:DeferMethod(object, method, ...)
addon:ArgCheck(object, 1, 'table')
addon:ArgCheck(method, 2, 'string')
addon:ArgCheck(object[method], 2, 'function')
addon:ArgCheck(object, 1, "table")
addon:ArgCheck(method, 2, "string")
addon:ArgCheck(object[method], 2, "function")

if InCombatLockdown() then
defer({
object = object,
method = method,
args = {...},
args = { ... },
})
else
local successful, ret = pcall(object[method], object, ...)
Expand Down
Loading

0 comments on commit 55fd85b

Please sign in to comment.