diff --git a/README.md b/README.md index c88cbf4..6751616 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ -> **A simple expereince tracking addon for World of Warcraft 1.17.1 Turlte WoW giving you the freedom of simplicity** +> **A simple expereince tracking addon for World of Warcraft 1.17.1 Turtle WoW giving you the freedom of simplicity**
Not for Classic or Retail!.
@@ -40,6 +40,8 @@ Each element is designed to be simple, compact, and fit the wow theme asthetics. * `/sl lock` - locks tracker in place * `/sl ttswap` - swaps the tooltip (left > right) * `/sl scale ` - scales the frame to set amount +* `/sl min` - toggles minimal mode (removes buttons and background elements) +* `/sl announce` - toggles kill XP announcements in the center of screen ## Features @@ -57,6 +59,7 @@ Each element is designed to be simple, compact, and fit the wow theme asthetics. * Moveable * Hideable * Scaleable +* Minimal mode option @@ -133,3 +136,8 @@ Each element is designed to be simple, compact, and fit the wow theme asthetics. +Minimal Mode: + +![452790609-628cad4f-9f4b-4a88-b2eb-e915faa49ba3](https://github.com/user-attachments/assets/faea01b7-d98b-4a74-9ed3-07acf1a48db0) + + diff --git a/Tracker.lua b/Tracker.lua index 434955d..be60a21 100644 --- a/Tracker.lua +++ b/Tracker.lua @@ -14,6 +14,29 @@ local questsToLvl = 0; local killsPerHour = 0 local questsPerHour = 0 +-- Add rolling average tracking +local killXPHistory = {} +local questXPHistory = {} +local MAX_HISTORY = 10 -- Track last 10 kills/quests + +local function updateRollingAverage(history, newValue) + table.insert(history, newValue) + local count = table.getn(history) + + if count > MAX_HISTORY then + table.remove(history, 1) + count = MAX_HISTORY + end + + local sum = 0 + for i = 1, count do + sum = sum + history[i] + end + + local average = sum / count + return average +end + local bn = { [1] = "Kills", [2] = "Quests", @@ -50,6 +73,13 @@ local function InitializeTracker() end end) + -- Clean up existing frame if it exists + if _G[fn] then + _G[fn]:Hide() + _G[fn] = nil + end + + Tracker.track = CreateFrame("Frame", fn, UIParent) Tracker.track:SetWidth(60) Tracker.track:SetHeight(130) Tracker.track:SetMovable(true) @@ -76,9 +106,7 @@ local function InitializeTracker() end end) - Tracker.track:SetScript("OnHide", function() - end) Tracker.track:SetScript("OnMouseDown", function() @@ -88,7 +116,6 @@ local function InitializeTracker() Tracker.track:SetScript("OnMouseUp", function() this:StopMovingOrSizing() - local point, relativeTo, relativePoint, xOfs, yOfs = this:GetPoint() local parentName = "UIParent" @@ -101,55 +128,104 @@ local function InitializeTracker() } end) + -- Only set backdrop if not in minimal mode + if not SLDatastore.data[SLProfile].Store.minimal then + Tracker.track:SetBackdrop({ + bgFile = SL:GetTexture("Background"), + edgeFile = SL:GetTexture("Frame"), + tile = true, + tileSize = 128, + edgeSize = 32, + insets = { + left = 5, + right = 5, + top = 22, + bottom = 5 + }, + }) + + local name = Tracker.track:CreateFontString(nil, "OVERLAY", "GameFontNormal") + name:SetPoint("TOPLEFT", 0, -5) + name:SetWidth(37) + name:SetHeight(12) + name:SetJustifyH("CENTER") + name:SetText("SL") + Tracker.track.name = name + + local close = CreateFrame("Button", fn .. "CloseButton", Tracker.track, "UIPanelCloseButton") + close:SetPoint("TOPRIGHT", Tracker.track, 4, 4) + close:SetScript("OnClick", function() + SLDatastore.data[SLProfile].Store.toggle = false + Tracker.track:Hide() + end) + Tracker.track.close = close + + local resize = CreateFrame("Button", fn .. "ResizeButton", Tracker.track, "UIPanelButtonTemplate") + resize:SetWidth(16) + resize:SetHeight(16) + resize:GetNormalTexture():SetTexture("Interface\\AddOns\\SimpleUI\\Media\\Textures\\ResizeGrip") + resize:GetHighlightTexture():SetTexture("Interface\\AddOns\\SimpleUI\\Media\\Textures\\ResizeGrip") + resize:GetPushedTexture():SetTexture("Interface\\AddOns\\SimpleUI\\Media\\Textures\\ResizeGrip") + resize:SetPoint("BOTTOMRIGHT", Tracker.track, "BOTTOMRIGHT", 0, -1) + + local savedScale = SLDatastore.data[SLProfile].Store.trackerScale + if savedScale then + Tracker.e:ScaleTracker(savedScale) + end - Tracker.track:SetBackdrop({ - bgFile = SL:GetTexture("Background"), - edgeFile = SL:GetTexture("Frame"), - tile = true, - tileSize = 128, - edgeSize = 32, - insets = { - left = 5, - right = 5, - top = 22, - bottom = 5 - }, - }) - - local name = Tracker.track:CreateFontString(nil, "OVERLAY", "GameFontNormal") - name:SetPoint("TOPLEFT", 0, -5) - name:SetWidth(37) - name:SetHeight(12) - name:SetJustifyH("CENTER") - name:SetText("SL") - - Tracker.track.name = name - - local close = CreateFrame("Button", fn .. "CloseButton", Tracker.track, "UIPanelCloseButton") - close:SetPoint("TOPRIGHT", Tracker.track, 4, 4) - close:SetScript("OnClick", function() - SLDatastore.data[SLProfile].Store.toggle = false - Tracker.track:Hide() - end) - - Tracker.track.close = close + resize:SetScript("OnMouseDown", function() + Tracker.e.isResizing = true + Tracker.e.startScale = Tracker.track:GetScale() + Tracker.e.startCursorX, Tracker.e.startCursorY = GetCursorPosition() + end) + + resize:SetScript("OnMouseUp", function() + Tracker.e.isResizing = false + end) + + resize:SetScript("OnUpdate", function() + if Tracker.e.isResizing then + local cursorX, cursorY = GetCursorPosition() + local diffX = cursorX - Tracker.e.startCursorX + + -- Calculate new scale based on mouse movement + local newScale = math.max(0.5, math.min(3, Tracker.e.startScale + (diffX / 200))) + Tracker.e:ScaleTracker(newScale) + ShowSLMessage(string.format("Tracker scaled to %.1f.", newScale), 3) + end + end) + end local prevButton - - for i = 1, 4 do local button = CreateFrame("Button", fn .. "TrackerButton" .. bn[i], Tracker.track, "UIPanelButtonTemplate") button:SetWidth(45) button:SetHeight(20) - if i == 1 then - button:SetPoint("TOP", Tracker.track, "TOP", 2, -25) + -- Adjust button positions based on minimal mode + if SLDatastore.data[SLProfile].Store.minimal then + -- In minimal mode, only show first and last buttons + if i == 1 then + button:SetPoint("TOP", Tracker.track, "TOP", 0, 0) + button:Show() + prevButton = button -- Keep track of first button for time button + elseif i == 4 then + button:SetPoint("TOP", prevButton, "BOTTOM", 0, -5) + button:Show() + else + button:Hide() + end else - button:SetPoint("TOP", prevButton, "BOTTOM", 0, -5) + -- Normal mode, show all buttons + if i == 1 then + button:SetPoint("TOP", Tracker.track, "TOP", 2, -25) + else + button:SetPoint("TOP", prevButton, "BOTTOM", 0, -5) + end + button:Show() + prevButton = button end - prevButton = button - local norm = button:GetNormalTexture() local highlight = button:GetHighlightTexture() local push = button:GetPushedTexture() @@ -161,7 +237,6 @@ local function InitializeTracker() button.text:SetJustifyH("RIGHT") button.text:SetText("N/A") - if i == 1 then norm:SetTexture(SL:GetTexture("Button")) norm:SetVertexColor(0.4, 0, 0, 1) @@ -184,20 +259,17 @@ local function InitializeTracker() if unitName and gainedStr then local gainedNum = tonumber(gainedStr) if gainedNum then - local restedXP = GetXPExhaustion() or 0 - local gainedRest = 0 - - if restedXP > 0 then - gainedRest = math.min(gainedNum, restedXP) - end killsThisSession = killsThisSession + 1 - xpPerKill = gainedNum + gainedRest + xpPerKill = updateRollingAverage(killXPHistory, gainedNum) Tracker.e:UpdateKillStats(gainedNum) Tracker.e:UpdateKills() - Tracker.e:UpdateTimer(xpPerKill) - ShowSLMessage( - string.format("%d XP gained, you need to kill %d more %s", gainedNum, killsToLvl, - unitName), 5) + Tracker.e:UpdateTimer(gainedNum) + + if SLDatastore.data[SLProfile].Store.announce then + ShowSLMessage( + string.format("%d XP gained, you need to kill %d more %s", gainedNum, killsToLvl, + unitName), 5) + end button.text:SetText(killsToLvl) end @@ -205,12 +277,13 @@ local function InitializeTracker() end end end) - --UIErrorsFrame:AddMessage("Hello, World!", 1, 0, 0, 1, 3) button:SetScript("OnEnter", function() Tracker.e:UpdateTooltip(button) GameTooltip:SetText("|cff1a9fc0Kill Stats|r") GameTooltip:AddLine(" ") + GameTooltip:AddDoubleLine(SL.util.Colorize("Average XP per Kill:", 1, 1, 0.5), + SL.util.Colorize(math.floor(xpPerKill), 0.8, 0, 0), 1, 1, 1) GameTooltip:AddDoubleLine(SL.util.Colorize("Kills This Session:", 1, 1, 0.5), SL.util.Colorize(killsThisSession, 0.8, 0, 0), 1, 1, 1) GameTooltip:AddDoubleLine(SL.util.Colorize("Kills/Hour:", 1, 1, 0.5), @@ -245,7 +318,7 @@ local function InitializeTracker() local gainedNum = tonumber(gainedStr) if gainedNum then questsThisSession = questsThisSession + 1 - xpPerQuest = gainedNum + xpPerQuest = updateRollingAverage(questXPHistory, gainedNum) Tracker.e:UpdateQuestStats() Tracker.e:UpdateQuests() Tracker.e:UpdateTimer(gainedNum) @@ -386,7 +459,7 @@ local function InitializeTracker() Tracker.e:ResetTracker() ShowSLMessage("Tracker has been reset") elseif arg1 == "RightButton" then - SL:Print("/sl |cff1a9fc0lock|r, |cff1a9fc0ttswap|r, |cff1a9fc0scale |r") + SL:Print("/sl |cff1a9fc0toggle|r, |cff1a9fc0lock|r, |cff1a9fc0ttswap|r, |cff1a9fc0scale |r, |cff1a9fc0min|r, |cff1a9fc0announce|r") end end) end @@ -396,41 +469,6 @@ local function InitializeTracker() button.texture:SetVertexColor(0.5, 0.4, 0, 1) ]] end - local resize = CreateFrame("Button", fn .. "ResizeButton", Tracker.track, "UIPanelButtonTemplate") - resize:SetWidth(16) - resize:SetHeight(16) - resize:GetNormalTexture():SetTexture("Interface\\AddOns\\SimpleUI\\Media\\Textures\\ResizeGrip") - resize:GetHighlightTexture():SetTexture("Interface\\AddOns\\SimpleUI\\Media\\Textures\\ResizeGrip") - resize:GetPushedTexture():SetTexture("Interface\\AddOns\\SimpleUI\\Media\\Textures\\ResizeGrip") - resize:SetPoint("BOTTOMRIGHT", Tracker.track, "BOTTOMRIGHT", 0, -1) - - local savedScale = SLDatastore.data[SLProfile].Store.trackerScale - if savedScale then - Tracker.e:ScaleTracker(savedScale) - end - - resize:SetScript("OnMouseDown", function() - Tracker.e.isResizing = true - Tracker.e.startScale = Tracker.track:GetScale() - Tracker.e.startCursorX, Tracker.e.startCursorY = GetCursorPosition() - end) - - resize:SetScript("OnMouseUp", function() - Tracker.e.isResizing = false - end) - - resize:SetScript("OnUpdate", function() - if Tracker.e.isResizing then - local cursorX, cursorY = GetCursorPosition() - local diffX = cursorX - Tracker.e.startCursorX - - -- Calculate new scale based on mouse movement - local newScale = math.max(0.5, math.min(3, Tracker.e.startScale + (diffX / 200))) - Tracker.e:ScaleTracker(newScale) - ShowSLMessage(string.format("Tracker scaled to %.1f.", newScale), 3) - end - end) - SLASH_SIMPLELVL1 = "/simplelvl" SLASH_SIMPLELVL2 = "/sl" SlashCmdList["SIMPLELVL"] = Tracker.e.Commands @@ -515,11 +553,6 @@ function Tracker.e:UpdateExperience(button) local needed = math.floor(maxXP - currXP) local perc = math.floor((currXP / maxXP) * 100) local barsLeft = 20 - math.floor(perc / 5) - local restedXP = GetXPExhaustion() - local restedPerc - if restedXP ~= nil then - restedPerc = math.floor((restedXP / maxXP) * 100) - end Tracker.e:UpdateTooltip(button) GameTooltip:SetText("|cff1a9fc0Experience|r") GameTooltip:AddLine(" ") @@ -528,10 +561,6 @@ function Tracker.e:UpdateExperience(button) GameTooltip:AddDoubleLine(SL.util.Colorize("Needed", 1, 1, 0.5), needed, 1, 1, 1) GameTooltip:AddDoubleLine(SL.util.Colorize("Pecent", 1, 1, 0.5), SL.util.Colorize("[" .. perc .. "%]", 0, 0.9, 1), 1, 1, 1) - if restedXP ~= nil then - GameTooltip:AddDoubleLine(SL.util.Colorize("Rested", 1, 1, 0.5), - SL.util.Colorize(restedXP .. " [" .. restedPerc .. "%]", 0, 0.9, 1), 1, 1, 1) - end GameTooltip:AddLine(" ") GameTooltip:AddDoubleLine(SL.util.Colorize("Bars", 1, 1, 0.5), barsLeft, 1, 1, 1) end @@ -581,10 +610,13 @@ function Tracker.e:ResetTracker() questsToLvl = 0 killsPerHour = 0 questsPerHour = 0 + + -- Clear history + killXPHistory = {} + questXPHistory = {} self:InitializeTimer() - for i = 1, 4 do local button = _G[fn .. "TrackerButton" .. bn[i]] if button then @@ -632,17 +664,58 @@ function Tracker.e.Commands(msg) elseif command == "reset" then Tracker.e:ResetTracker() ShowSLMessage("Tracker has been reset") + elseif command == "min" then + SLDatastore.data[SLProfile].Store.minimal = not SLDatastore.data[SLProfile].Store.minimal + -- Recreate the frame to apply minimal mode changes + InitializeTracker() + -- Update button visibility + for i = 1, 4 do + local button = _G[fn .. "TrackerButton" .. bn[i]] + if button then + if SLDatastore.data[SLProfile].Store.minimal then + if i == 1 or i == 4 then + button:Show() + else + button:Hide() + end + else + button:Show() + end + end + end + ShowSLMessage("Minimal mode " .. (SLDatastore.data[SLProfile].Store.minimal and "enabled" or "disabled")) + elseif command == "announce" then + SLDatastore.data[SLProfile].Store.announce = not SLDatastore.data[SLProfile].Store.announce + ShowSLMessage("Kill XP announcements " .. (SLDatastore.data[SLProfile].Store.announce and "enabled" or "disabled")) else - SL:Print("/sl |cff1a9fc0toggle|r, |cff1a9fc0lock|r, |cff1a9fc0ttswap|r, |cff1a9fc0scale |r,") + SL:Print("/sl |cff1a9fc0toggle|r, |cff1a9fc0lock|r, |cff1a9fc0ttswap|r, |cff1a9fc0scale |r, |cff1a9fc0min|r, |cff1a9fc0announce|r") end end function SLLoadTracker() + -- Check if character is level 60 + if UnitLevel("player") >= 60 then + SL:Print("SimpleLvl disabled - Character is level 60") + return + end + InitializeTracker() + -- Apply minimal mode if it was enabled + if SLDatastore.data[SLProfile].Store.minimal then + Tracker.e:UpdateMinimalMode() + end end Tracker.e:RegisterEvent("PLAYER_ENTERING_WORLD") Tracker.e:SetScript("OnEvent", function() + -- Check if character is level 60 + if UnitLevel("player") >= 60 then + if Tracker.track then + Tracker.track:Hide() + end + return + end + this:InitializeTimer() end) --SL.InitTrack = InitializeTracker