media: remember listened music in random mode
- Show and Play only tracks, that you haven't heard yet!
This commit is contained in:
+223
-103
@@ -12,6 +12,9 @@
|
|||||||
LibCompat = LibStub:GetLibrary("LibCompat-1.0")
|
LibCompat = LibStub:GetLibrary("LibCompat-1.0")
|
||||||
-- Create global table
|
-- Create global table
|
||||||
_G.LeaPlusDB = _G.LeaPlusDB or {}
|
_G.LeaPlusDB = _G.LeaPlusDB or {}
|
||||||
|
LeaPlusDB = _G.LeaPlusDB -- локальный псевдоним
|
||||||
|
LeaPlusDB["ListenedTracks"] = LeaPlusDB["ListenedTracks"] or {}
|
||||||
|
|
||||||
|
|
||||||
-- Create locals
|
-- Create locals
|
||||||
local LeaPlusLC, LeaPlusCB, LeaDropList, LeaConfigList, LeaLockList = {}, {}, {}, {}, {}
|
local LeaPlusLC, LeaPlusCB, LeaDropList, LeaConfigList, LeaLockList = {}, {}, {}, {}, {}
|
||||||
@@ -4367,22 +4370,24 @@ function LeaPlusLC:Player()
|
|||||||
-- ===== helpers ==================================================
|
-- ===== helpers ==================================================
|
||||||
local chatTypeIndexToName = {}
|
local chatTypeIndexToName = {}
|
||||||
for t in pairs(ChatTypeInfo) do
|
for t in pairs(ChatTypeInfo) do
|
||||||
chatTypeIndexToName[ GetChatTypeIndex(t) ] = t
|
chatTypeIndexToName[GetChatTypeIndex(t)] = t
|
||||||
end
|
end
|
||||||
|
|
||||||
local function CleanAndColour(msg, lineID)
|
local function CleanAndColour(msg, lineID)
|
||||||
msg = gsub(msg, "|T.-|t", "") -- strip textures
|
msg = gsub(msg, "|T.-|t", "") -- strip textures
|
||||||
msg = gsub(msg, "|A.-|a", "") -- strip atlases
|
msg = gsub(msg, "|A.-|a", "") -- strip atlases
|
||||||
local inf = ChatTypeInfo[ chatTypeIndexToName[lineID] ]
|
local inf = ChatTypeInfo[chatTypeIndexToName[lineID]]
|
||||||
local r, g, b = (inf and inf.r) or 1, (inf and inf.g) or 1, (inf and inf.b) or 1
|
local r, g, b = (inf and inf.r) or 1, (inf and inf.g) or 1, (inf and inf.b) or 1
|
||||||
local hex = format("|cff%02x%02x%02x", r*255, g*255, b*255)
|
local hex = format("|cff%02x%02x%02x", r * 255, g * 255, b * 255)
|
||||||
return hex .. msg:gsub("|r", "|r"..hex) .. "|r"
|
return hex .. msg:gsub("|r", "|r" .. hex) .. "|r"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function WindowActive(idx)
|
local function WindowActive(idx)
|
||||||
local shown = select(7, FCF_GetChatWindowInfo(idx))
|
local shown = select(7, FCF_GetChatWindowInfo(idx))
|
||||||
if shown then return true end
|
if shown then
|
||||||
local f = _G["ChatFrame"..idx]
|
return true
|
||||||
|
end
|
||||||
|
local f = _G["ChatFrame" .. idx]
|
||||||
return (f and f.isDocked)
|
return (f and f.isDocked)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -4391,21 +4396,24 @@ function LeaPlusLC:Player()
|
|||||||
saver:RegisterEvent("PLAYER_LOGOUT")
|
saver:RegisterEvent("PLAYER_LOGOUT")
|
||||||
saver:SetScript("OnEvent", function()
|
saver:SetScript("OnEvent", function()
|
||||||
local name, realm = LibCompat.UnitFullName("player")
|
local name, realm = LibCompat.UnitFullName("player")
|
||||||
realm = realm or GetRealmName() ; if not name then return end
|
realm = realm or GetRealmName();
|
||||||
|
if not name then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
LeaPlusDB["ChatHistoryName"] = name .. "-" .. realm
|
LeaPlusDB["ChatHistoryName"] = name .. "-" .. realm
|
||||||
LeaPlusDB["ChatHistoryTime"] = time()
|
LeaPlusDB["ChatHistoryTime"] = time()
|
||||||
|
|
||||||
for i = 1, 50 do
|
for i = 1, 50 do
|
||||||
if i ~= 2 and _G["ChatFrame"..i] and WindowActive(i) then
|
if i ~= 2 and _G["ChatFrame" .. i] and WindowActive(i) then
|
||||||
local cf, num = _G["ChatFrame"..i], _G["ChatFrame"..i]:GetNumMessages()
|
local cf, num = _G["ChatFrame" .. i], _G["ChatFrame" .. i]:GetNumMessages()
|
||||||
local first = (num > 128) and (num - 128 + 1) or 1
|
local first = (num > 128) and (num - 128 + 1) or 1
|
||||||
LeaPlusDB["ChatHistory"..i] = {}
|
LeaPlusDB["ChatHistory" .. i] = {}
|
||||||
|
|
||||||
for n = first, num do
|
for n = first, num do
|
||||||
local txt, _, lineID = cf:GetMessageInfo(n)
|
local txt, _, lineID = cf:GetMessageInfo(n)
|
||||||
if txt and not txt:find(L["Restored"], 1, true) then
|
if txt and not txt:find(L["Restored"], 1, true) then
|
||||||
tinsert(LeaPlusDB["ChatHistory"..i], CleanAndColour(txt, lineID))
|
tinsert(LeaPlusDB["ChatHistory" .. i], CleanAndColour(txt, lineID))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -4414,16 +4422,20 @@ function LeaPlusLC:Player()
|
|||||||
|
|
||||||
-- ===== RESTORE once UI is up ====================================
|
-- ===== RESTORE once UI is up ====================================
|
||||||
local function Restore()
|
local function Restore()
|
||||||
if not (LeaPlusDB["ChatHistoryTime"] and LeaPlusDB["ChatHistoryName"]) then return end
|
if not (LeaPlusDB["ChatHistoryTime"] and LeaPlusDB["ChatHistoryName"]) then
|
||||||
if time() - LeaPlusDB["ChatHistoryTime"] > 10 then return end
|
return
|
||||||
|
end
|
||||||
|
if time() - LeaPlusDB["ChatHistoryTime"] > 10 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
for i = 1, 50 do
|
for i = 1, 50 do
|
||||||
if i ~= 2 and _G["ChatFrame"..i] and WindowActive(i) then
|
if i ~= 2 and _G["ChatFrame" .. i] and WindowActive(i) then
|
||||||
local cf = _G["ChatFrame"..i]
|
local cf = _G["ChatFrame" .. i]
|
||||||
cf:Clear()
|
cf:Clear()
|
||||||
local restored = 0
|
local restored = 0
|
||||||
|
|
||||||
for _, line in ipairs(LeaPlusDB["ChatHistory"..i] or {}) do
|
for _, line in ipairs(LeaPlusDB["ChatHistory" .. i] or {}) do
|
||||||
cf:AddMessage(line)
|
cf:AddMessage(line)
|
||||||
restored = restored + 1
|
restored = restored + 1
|
||||||
end
|
end
|
||||||
@@ -4442,9 +4454,9 @@ function LeaPlusLC:Player()
|
|||||||
LeaPlusDB["ChatHistoryName"] = nil
|
LeaPlusDB["ChatHistoryName"] = nil
|
||||||
LeaPlusDB["ChatHistoryTime"] = nil
|
LeaPlusDB["ChatHistoryTime"] = nil
|
||||||
for i = 1, 50 do
|
for i = 1, 50 do
|
||||||
LeaPlusDB["ChatHistory"..i] = nil
|
LeaPlusDB["ChatHistory" .. i] = nil
|
||||||
LeaPlusDB["ChatTemp"..i] = nil
|
LeaPlusDB["ChatTemp" .. i] = nil
|
||||||
LeaPlusDB["ChatHistory"..i.."Count"] = nil
|
LeaPlusDB["ChatHistory" .. i .. "Count"] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5759,20 +5771,24 @@ function LeaPlusLC:Player()
|
|||||||
local SquareMapPanel = LeaPlusLC:CreatePanel("Square Minimap", "SquareMapPanel")
|
local SquareMapPanel = LeaPlusLC:CreatePanel("Square Minimap", "SquareMapPanel")
|
||||||
|
|
||||||
-- Add a dropdown menu for mail icon position
|
-- Add a dropdown menu for mail icon position
|
||||||
LeaPlusLC:CreateDropDown("MiniMapMailIconPos", "Mail Icon Position", SquareMapPanel, 146, "TOPLEFT", 16, -112, {L["Top Left"], L["Top Right"], L["Bottom Left"], L["Bottom Right"]}, "Set the position of the minimap mail icon.")
|
LeaPlusLC:CreateDropDown("MiniMapMailIconPos", "Mail Icon Position", SquareMapPanel, 146, "TOPLEFT", 16, -112, { L["Top Left"], L["Top Right"], L["Bottom Left"], L["Bottom Right"] }, "Set the position of the minimap mail icon.")
|
||||||
|
|
||||||
-- Function to update mail icon position based on the dropdown selection
|
-- Function to update mail icon position based on the dropdown selection
|
||||||
local function UpdateMailIconPosition()
|
local function UpdateMailIconPosition()
|
||||||
local mailIcon = MiniMapMailFrame
|
local mailIcon = MiniMapMailFrame
|
||||||
if mailIcon then
|
if mailIcon then
|
||||||
mailIcon:ClearAllPoints()
|
mailIcon:ClearAllPoints()
|
||||||
if LeaPlusLC["MiniMapMailIconPos"] == 1 then -- Top Left
|
if LeaPlusLC["MiniMapMailIconPos"] == 1 then
|
||||||
|
-- Top Left
|
||||||
mailIcon:SetPoint("TOPLEFT", Minimap, "TOPLEFT", -19, 14)
|
mailIcon:SetPoint("TOPLEFT", Minimap, "TOPLEFT", -19, 14)
|
||||||
elseif LeaPlusLC["MiniMapMailIconPos"] == 2 then -- Top Right
|
elseif LeaPlusLC["MiniMapMailIconPos"] == 2 then
|
||||||
|
-- Top Right
|
||||||
mailIcon:SetPoint("TOPRIGHT", Minimap, "TOPRIGHT", 19, 14)
|
mailIcon:SetPoint("TOPRIGHT", Minimap, "TOPRIGHT", 19, 14)
|
||||||
elseif LeaPlusLC["MiniMapMailIconPos"] == 3 then -- Bottom Left
|
elseif LeaPlusLC["MiniMapMailIconPos"] == 3 then
|
||||||
|
-- Bottom Left
|
||||||
mailIcon:SetPoint("BOTTOMLEFT", Minimap, "BOTTOMLEFT", -19, -14)
|
mailIcon:SetPoint("BOTTOMLEFT", Minimap, "BOTTOMLEFT", -19, -14)
|
||||||
elseif LeaPlusLC["MiniMapMailIconPos"] == 4 then -- Bottom Right
|
elseif LeaPlusLC["MiniMapMailIconPos"] == 4 then
|
||||||
|
-- Bottom Right
|
||||||
mailIcon:SetPoint("BOTTOMRIGHT", Minimap, "BOTTOMRIGHT", 19, -14)
|
mailIcon:SetPoint("BOTTOMRIGHT", Minimap, "BOTTOMRIGHT", 19, -14)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -5788,7 +5804,7 @@ function LeaPlusLC:Player()
|
|||||||
|
|
||||||
-- Add a dropdown menu for LFG button position with no "Default" position, only custom ones
|
-- Add a dropdown menu for LFG button position with no "Default" position, only custom ones
|
||||||
LeaPlusLC:CreateDropDown("MiniMapLFGIconPos", "LFG Icon Position", SquareMapPanel, 146, "TOPLEFT", 16, -172,
|
LeaPlusLC:CreateDropDown("MiniMapLFGIconPos", "LFG Icon Position", SquareMapPanel, 146, "TOPLEFT", 16, -172,
|
||||||
{L["Top Left"], L["Top Right"], L["Bottom Left"], L["Bottom Right"]}, "Set the position of the minimap LFG icon.")
|
{ L["Top Left"], L["Top Right"], L["Bottom Left"], L["Bottom Right"] }, "Set the position of the minimap LFG icon.")
|
||||||
|
|
||||||
-- Function to update LFG button position based on the dropdown selection
|
-- Function to update LFG button position based on the dropdown selection
|
||||||
local function UpdateLFGIconPosition()
|
local function UpdateLFGIconPosition()
|
||||||
@@ -5797,13 +5813,17 @@ function LeaPlusLC:Player()
|
|||||||
lfgIcon:ClearAllPoints()
|
lfgIcon:ClearAllPoints()
|
||||||
|
|
||||||
-- Apply custom positions inside the minimap with a slight outset from the edges
|
-- Apply custom positions inside the minimap with a slight outset from the edges
|
||||||
if LeaPlusLC["MiniMapLFGIconPos"] == 1 then -- Top Left
|
if LeaPlusLC["MiniMapLFGIconPos"] == 1 then
|
||||||
|
-- Top Left
|
||||||
lfgIcon:SetPoint("TOPLEFT", Minimap, "TOPLEFT", 5, -5) -- Slightly inset
|
lfgIcon:SetPoint("TOPLEFT", Minimap, "TOPLEFT", 5, -5) -- Slightly inset
|
||||||
elseif LeaPlusLC["MiniMapLFGIconPos"] == 2 then -- Top Right
|
elseif LeaPlusLC["MiniMapLFGIconPos"] == 2 then
|
||||||
|
-- Top Right
|
||||||
lfgIcon:SetPoint("TOPRIGHT", Minimap, "TOPRIGHT", -5, -5) -- Slightly inset
|
lfgIcon:SetPoint("TOPRIGHT", Minimap, "TOPRIGHT", -5, -5) -- Slightly inset
|
||||||
elseif LeaPlusLC["MiniMapLFGIconPos"] == 3 then -- Bottom Left
|
elseif LeaPlusLC["MiniMapLFGIconPos"] == 3 then
|
||||||
|
-- Bottom Left
|
||||||
lfgIcon:SetPoint("BOTTOMLEFT", Minimap, "BOTTOMLEFT", 5, 5) -- Slightly inset
|
lfgIcon:SetPoint("BOTTOMLEFT", Minimap, "BOTTOMLEFT", 5, 5) -- Slightly inset
|
||||||
elseif LeaPlusLC["MiniMapLFGIconPos"] == 4 then -- Bottom Right
|
elseif LeaPlusLC["MiniMapLFGIconPos"] == 4 then
|
||||||
|
-- Bottom Right
|
||||||
lfgIcon:SetPoint("BOTTOMRIGHT", Minimap, "BOTTOMRIGHT", -5, 25) -- Slightly inset
|
lfgIcon:SetPoint("BOTTOMRIGHT", Minimap, "BOTTOMRIGHT", -5, 25) -- Slightly inset
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -5819,7 +5839,7 @@ function LeaPlusLC:Player()
|
|||||||
|
|
||||||
|
|
||||||
-- Add a dropdown menu for Battlefield icon position
|
-- Add a dropdown menu for Battlefield icon position
|
||||||
LeaPlusLC:CreateDropDown("MiniMapBattlefieldIconPos", "Battlefield Icon Position", SquareMapPanel, 146, "TOPLEFT", 16, -232, {L["Top Left"], L["Top Right"], L["Bottom Left"], L["Bottom Right"]}, "Set the position of the minimap battlefield icon.")
|
LeaPlusLC:CreateDropDown("MiniMapBattlefieldIconPos", "Battlefield Icon Position", SquareMapPanel, 146, "TOPLEFT", 16, -232, { L["Top Left"], L["Top Right"], L["Bottom Left"], L["Bottom Right"] }, "Set the position of the minimap battlefield icon.")
|
||||||
|
|
||||||
-- Function to update Battlefield icon position based on the dropdown selection
|
-- Function to update Battlefield icon position based on the dropdown selection
|
||||||
local function UpdateBattlefieldIconPosition()
|
local function UpdateBattlefieldIconPosition()
|
||||||
@@ -5828,13 +5848,17 @@ function LeaPlusLC:Player()
|
|||||||
battlefieldIcon:ClearAllPoints()
|
battlefieldIcon:ClearAllPoints()
|
||||||
|
|
||||||
-- Apply custom positions inside the minimap with a slight outset from the edges
|
-- Apply custom positions inside the minimap with a slight outset from the edges
|
||||||
if LeaPlusLC["MiniMapBattlefieldIconPos"] == 1 then -- Top Left
|
if LeaPlusLC["MiniMapBattlefieldIconPos"] == 1 then
|
||||||
|
-- Top Left
|
||||||
battlefieldIcon:SetPoint("TOPLEFT", Minimap, "TOPLEFT", 5, -5) -- Slightly inset
|
battlefieldIcon:SetPoint("TOPLEFT", Minimap, "TOPLEFT", 5, -5) -- Slightly inset
|
||||||
elseif LeaPlusLC["MiniMapBattlefieldIconPos"] == 2 then -- Top Right
|
elseif LeaPlusLC["MiniMapBattlefieldIconPos"] == 2 then
|
||||||
|
-- Top Right
|
||||||
battlefieldIcon:SetPoint("TOPRIGHT", Minimap, "TOPRIGHT", -5, -5) -- Slightly inset
|
battlefieldIcon:SetPoint("TOPRIGHT", Minimap, "TOPRIGHT", -5, -5) -- Slightly inset
|
||||||
elseif LeaPlusLC["MiniMapBattlefieldIconPos"] == 3 then -- Bottom Left
|
elseif LeaPlusLC["MiniMapBattlefieldIconPos"] == 3 then
|
||||||
|
-- Bottom Left
|
||||||
battlefieldIcon:SetPoint("BOTTOMLEFT", Minimap, "BOTTOMLEFT", 5, 5) -- Slightly inset
|
battlefieldIcon:SetPoint("BOTTOMLEFT", Minimap, "BOTTOMLEFT", 5, 5) -- Slightly inset
|
||||||
elseif LeaPlusLC["MiniMapBattlefieldIconPos"] == 4 then -- Bottom Right
|
elseif LeaPlusLC["MiniMapBattlefieldIconPos"] == 4 then
|
||||||
|
-- Bottom Right
|
||||||
battlefieldIcon:SetPoint("BOTTOMRIGHT", Minimap, "BOTTOMRIGHT", -5, 25) -- Slightly inset
|
battlefieldIcon:SetPoint("BOTTOMRIGHT", Minimap, "BOTTOMRIGHT", -5, 25) -- Slightly inset
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -6074,8 +6098,6 @@ function LeaPlusLC:Player()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local function HideMinimapButtons()
|
local function HideMinimapButtons()
|
||||||
local searchStr = LeaPlusDB["MiniExcludeList"]
|
local searchStr = LeaPlusDB["MiniExcludeList"]
|
||||||
-- Thanks to https://github.com/s0h2x/pretty_minimap for good list of buttons to ignore!
|
-- Thanks to https://github.com/s0h2x/pretty_minimap for good list of buttons to ignore!
|
||||||
@@ -6654,7 +6676,8 @@ function LeaPlusLC:Player()
|
|||||||
GameTimeFrame:Hide()
|
GameTimeFrame:Hide()
|
||||||
|
|
||||||
Minimap:HookScript("OnMouseUp", function(self, button)
|
Minimap:HookScript("OnMouseUp", function(self, button)
|
||||||
if IsShiftKeyDown() then -- Check if the Shift key is pressed
|
if IsShiftKeyDown() then
|
||||||
|
-- Check if the Shift key is pressed
|
||||||
if button == "MiddleButton" then
|
if button == "MiddleButton" then
|
||||||
GameTimeFrame_OnClick(self) -- Trigger the GameTimeFrame function
|
GameTimeFrame_OnClick(self) -- Trigger the GameTimeFrame function
|
||||||
end
|
end
|
||||||
@@ -6673,9 +6696,9 @@ function LeaPlusLC:Player()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if LeaPlusLC["HideMiniPOIArrows"] == "On" then
|
if LeaPlusLC["HideMiniPOIArrows"] == "On" then
|
||||||
local frame=CreateFrame("Frame");
|
local frame = CreateFrame("Frame");
|
||||||
frame:RegisterEvent("PLAYER_ENTERING_WORLD");
|
frame:RegisterEvent("PLAYER_ENTERING_WORLD");
|
||||||
frame:SetScript("OnEvent",function(self,event,...)
|
frame:SetScript("OnEvent", function(self, event, ...)
|
||||||
-- Put code here
|
-- Put code here
|
||||||
Minimap:SetStaticPOIArrowTexture("Interface\\addons\\Leatrix_Plus\\assets\\ROTATING-MINIMAPARROW")
|
Minimap:SetStaticPOIArrowTexture("Interface\\addons\\Leatrix_Plus\\assets\\ROTATING-MINIMAPARROW")
|
||||||
end);
|
end);
|
||||||
@@ -6975,7 +6998,6 @@ function LeaPlusLC:Player()
|
|||||||
trackerContainer:SetPoint('CENTER', trackerHolder)
|
trackerContainer:SetPoint('CENTER', trackerHolder)
|
||||||
trackerContainer:SetClampedToScreen(false)
|
trackerContainer:SetClampedToScreen(false)
|
||||||
|
|
||||||
|
|
||||||
local function SetWatchFrameHeight()
|
local function SetWatchFrameHeight()
|
||||||
local top = WatchFrame:GetTop() or 0
|
local top = WatchFrame:GetTop() or 0
|
||||||
local screenHeight = GetScreenHeight()
|
local screenHeight = GetScreenHeight()
|
||||||
@@ -13182,16 +13204,17 @@ function LeaPlusLC:Player()
|
|||||||
frame:SetMinResize(600, 50)
|
frame:SetMinResize(600, 50)
|
||||||
frame:SetMaxResize(600, 680)
|
frame:SetMaxResize(600, 680)
|
||||||
frame:SetBackdrop({
|
frame:SetBackdrop({
|
||||||
bgFile = "Interface\\BUTTONS\\WHITE8X8",
|
bgFile = "Interface\\BUTTONS\\WHITE8X8",
|
||||||
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
||||||
tile = true, tileSize = 16,
|
tile = true, tileSize = 16,
|
||||||
edgeSize = 16, insets = { left=4, right=4, top=4, bottom=4 },
|
edgeSize = 16, insets = { left = 4, right = 4, top = 4, bottom = 4 },
|
||||||
})
|
})
|
||||||
frame:SetBackdropColor(0, 0, 0, 0.6)
|
frame:SetBackdropColor(0, 0, 0, 0.6)
|
||||||
|
|
||||||
-- ADDITION 1: Add to UISpecialFrames for ESC key functionality
|
-- ADDITION 1: Add to UISpecialFrames for ESC key functionality
|
||||||
-- This allows the ESC key to close the window if it doesn't have a more specific target.
|
-- This allows the ESC key to close the window if it doesn't have a more specific target.
|
||||||
if _G.UISpecialFrames then -- Ensure the table exists (it always should in WoW client)
|
if _G.UISpecialFrames then
|
||||||
|
-- Ensure the table exists (it always should in WoW client)
|
||||||
tinsert(_G.UISpecialFrames, "LeaPlusRecentChatFrame")
|
tinsert(_G.UISpecialFrames, "LeaPlusRecentChatFrame")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -13282,22 +13305,32 @@ function LeaPlusLC:Player()
|
|||||||
-- 3) ScrollFrame (ElvUI) --
|
-- 3) ScrollFrame (ElvUI) --
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
local scroll = CreateFrame("ScrollFrame", "LeaPlusRecentChatScroll", frame, "UIPanelScrollFrameTemplate")
|
local scroll = CreateFrame("ScrollFrame", "LeaPlusRecentChatScroll", frame, "UIPanelScrollFrameTemplate")
|
||||||
scroll:SetPoint("TOPLEFT", frame, "TOPLEFT", 26, -36)
|
scroll:SetPoint("TOPLEFT", frame, "TOPLEFT", 26, -36)
|
||||||
scroll:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -34, 8)
|
scroll:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -34, 8)
|
||||||
|
|
||||||
local sb = scroll.ScrollBar or LeaPlusRecentChatScrollScrollBar
|
local sb = scroll.ScrollBar or LeaPlusRecentChatScrollScrollBar
|
||||||
sb:ClearAllPoints()
|
sb:ClearAllPoints()
|
||||||
sb:SetPoint("TOPLEFT", scroll, "TOPRIGHT", 3, -16)
|
sb:SetPoint("TOPLEFT", scroll, "TOPRIGHT", 3, -16)
|
||||||
sb:SetPoint("BOTTOMLEFT", scroll, "BOTTOMRIGHT", 3, 16)
|
sb:SetPoint("BOTTOMLEFT", scroll, "BOTTOMRIGHT", 3, 16)
|
||||||
|
|
||||||
-- right-click to close on all areas (frame and scroll are static)
|
-- right-click to close on all areas (frame and scroll are static)
|
||||||
frame:HookScript("OnMouseDown", function(_, btn) if btn == "RightButton" then Close() end end)
|
frame:HookScript("OnMouseDown", function(_, btn)
|
||||||
scroll:HookScript("OnMouseDown", function(_,btn) if btn == "RightButton" then Close() end end)
|
if btn == "RightButton" then
|
||||||
|
Close()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
scroll:HookScript("OnMouseDown", function(_, btn)
|
||||||
|
if btn == "RightButton" then
|
||||||
|
Close()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
-- dynamically resize edit-box height
|
-- dynamically resize edit-box height
|
||||||
ResizeEdit = function(count)
|
ResizeEdit = function(count)
|
||||||
local currentEdit = LeaPlusLC.RecentChatEdit
|
local currentEdit = LeaPlusLC.RecentChatEdit
|
||||||
if not currentEdit then return end
|
if not currentEdit then
|
||||||
|
return
|
||||||
|
end
|
||||||
local _, size = currentEdit:GetFont()
|
local _, size = currentEdit:GetFont()
|
||||||
local needed = count * (size + 2)
|
local needed = count * (size + 2)
|
||||||
currentEdit:SetHeight(math.max(needed, scroll:GetHeight()))
|
currentEdit:SetHeight(math.max(needed, scroll:GetHeight()))
|
||||||
@@ -13307,7 +13340,9 @@ function LeaPlusLC:Player()
|
|||||||
scroll:SetScript("OnMouseWheel", function(self, delta)
|
scroll:SetScript("OnMouseWheel", function(self, delta)
|
||||||
local currentEdit = LeaPlusLC.RecentChatEdit
|
local currentEdit = LeaPlusLC.RecentChatEdit
|
||||||
local maxScrollRange = self:GetVerticalScrollRange()
|
local maxScrollRange = self:GetVerticalScrollRange()
|
||||||
if not maxScrollRange or maxScrollRange <= 0 then return end
|
if not maxScrollRange or maxScrollRange <= 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
local currentScroll = self:GetVerticalScroll()
|
local currentScroll = self:GetVerticalScroll()
|
||||||
local viewHeight = self:GetHeight()
|
local viewHeight = self:GetHeight()
|
||||||
local stepAmount
|
local stepAmount
|
||||||
@@ -13317,7 +13352,9 @@ function LeaPlusLC:Player()
|
|||||||
local fontHeight = 14
|
local fontHeight = 14
|
||||||
if currentEdit and currentEdit:IsShown() then
|
if currentEdit and currentEdit:IsShown() then
|
||||||
local _, fh = currentEdit:GetFont()
|
local _, fh = currentEdit:GetFont()
|
||||||
if fh and fh > 0 then fontHeight = fh end
|
if fh and fh > 0 then
|
||||||
|
fontHeight = fh
|
||||||
|
end
|
||||||
end
|
end
|
||||||
local linesToScroll = 3
|
local linesToScroll = 3
|
||||||
stepAmount = fontHeight * linesToScroll
|
stepAmount = fontHeight * linesToScroll
|
||||||
@@ -13338,7 +13375,7 @@ function LeaPlusLC:Player()
|
|||||||
----------------------------------------
|
----------------------------------------
|
||||||
local chatTypeIndexToName = {}
|
local chatTypeIndexToName = {}
|
||||||
for chatType in pairs(ChatTypeInfo) do
|
for chatType in pairs(ChatTypeInfo) do
|
||||||
chatTypeIndexToName[ GetChatTypeIndex(chatType) ] = chatType
|
chatTypeIndexToName[GetChatTypeIndex(chatType)] = chatType
|
||||||
end
|
end
|
||||||
|
|
||||||
ScrollToBottomReliable = function(scrollInstance, editInstance, maxAttempts)
|
ScrollToBottomReliable = function(scrollInstance, editInstance, maxAttempts)
|
||||||
@@ -13347,7 +13384,9 @@ function LeaPlusLC:Player()
|
|||||||
local attempts = 0
|
local attempts = 0
|
||||||
local function tryScroll()
|
local function tryScroll()
|
||||||
attempts = attempts + 1
|
attempts = attempts + 1
|
||||||
if not editInstance or not editInstance:IsShown() then return end
|
if not editInstance or not editInstance:IsShown() then
|
||||||
|
return
|
||||||
|
end
|
||||||
local curHeight = editInstance:GetHeight()
|
local curHeight = editInstance:GetHeight()
|
||||||
if curHeight ~= lastHeight and attempts < maxAttempts then
|
if curHeight ~= lastHeight and attempts < maxAttempts then
|
||||||
lastHeight = curHeight
|
lastHeight = curHeight
|
||||||
@@ -13394,13 +13433,23 @@ function LeaPlusLC:Player()
|
|||||||
LibCompat.After(0.02, function()
|
LibCompat.After(0.02, function()
|
||||||
local currentEdit = LeaPlusLC.RecentChatEdit
|
local currentEdit = LeaPlusLC.RecentChatEdit
|
||||||
local currentScroll = LeaPlusLC.RecentChatScroll
|
local currentScroll = LeaPlusLC.RecentChatScroll
|
||||||
if not currentEdit or not currentEdit:IsShown() or currentEdit ~= self_hooked_edit then return end
|
if not currentEdit or not currentEdit:IsShown() or currentEdit ~= self_hooked_edit then
|
||||||
|
return
|
||||||
|
end
|
||||||
local fontHeight = select(2, currentEdit:GetFont()) or 14
|
local fontHeight = select(2, currentEdit:GetFont()) or 14
|
||||||
local cursorPos = currentEdit:GetCursorPosition()
|
local cursorPos = currentEdit:GetCursorPosition()
|
||||||
local text = currentEdit:GetText()
|
local text = currentEdit:GetText()
|
||||||
local n = 0; for i = 1, cursorPos do if text:sub(i,i) == "\n" then n = n + 1 end end
|
local n = 0;
|
||||||
|
for i = 1, cursorPos do
|
||||||
|
if text:sub(i, i) == "\n" then
|
||||||
|
n = n + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
local line = n + 1
|
local line = n + 1
|
||||||
local totalLines = 1; for _ in text:gmatch("\n") do totalLines = totalLines + 1 end
|
local totalLines = 1;
|
||||||
|
for _ in text:gmatch("\n") do
|
||||||
|
totalLines = totalLines + 1
|
||||||
|
end
|
||||||
local scrollMax = currentScroll:GetVerticalScrollRange()
|
local scrollMax = currentScroll:GetVerticalScrollRange()
|
||||||
if line == totalLines then
|
if line == totalLines then
|
||||||
currentScroll:SetVerticalScroll(scrollMax)
|
currentScroll:SetVerticalScroll(scrollMax)
|
||||||
@@ -13409,15 +13458,21 @@ function LeaPlusLC:Player()
|
|||||||
local scrollHeight = currentScroll:GetHeight()
|
local scrollHeight = currentScroll:GetHeight()
|
||||||
local minLine = math.floor(scrollMin / fontHeight + 1.5)
|
local minLine = math.floor(scrollMin / fontHeight + 1.5)
|
||||||
local maxLine = math.floor((scrollMin + scrollHeight) / fontHeight + 0.5)
|
local maxLine = math.floor((scrollMin + scrollHeight) / fontHeight + 0.5)
|
||||||
if line < minLine then currentScroll:SetVerticalScroll((line - 1) * fontHeight)
|
if line < minLine then
|
||||||
elseif line > maxLine then currentScroll:SetVerticalScroll(math.max(0, (line - math.floor(scrollHeight / fontHeight)) * fontHeight))
|
currentScroll:SetVerticalScroll((line - 1) * fontHeight)
|
||||||
|
elseif line > maxLine then
|
||||||
|
currentScroll:SetVerticalScroll(math.max(0, (line - math.floor(scrollHeight / fontHeight)) * fontHeight))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
edit:HookScript("OnMouseDown", function(_, btn) if btn == "RightButton" then Close() end end)
|
edit:HookScript("OnMouseDown", function(_, btn)
|
||||||
|
if btn == "RightButton" then
|
||||||
|
Close()
|
||||||
|
end
|
||||||
|
end)
|
||||||
edit:SetScript("OnEscapePressed", Close) -- This is important for when editbox has focus
|
edit:SetScript("OnEscapePressed", Close) -- This is important for when editbox has focus
|
||||||
|
|
||||||
edit:ClearFocus()
|
edit:ClearFocus()
|
||||||
@@ -13437,16 +13492,16 @@ function LeaPlusLC:Player()
|
|||||||
if msg then
|
if msg then
|
||||||
msg = gsub(msg, "|T.-|t", "")
|
msg = gsub(msg, "|T.-|t", "")
|
||||||
msg = gsub(msg, "|A.-|a", "")
|
msg = gsub(msg, "|A.-|a", "")
|
||||||
local info = ChatTypeInfo[ chatTypeIndexToName[lineID] ]
|
local info = ChatTypeInfo[chatTypeIndexToName[lineID]]
|
||||||
local r,g,b = (info and info.r) or 1, (info and info.g) or 1, (info and info.b) or 1
|
local r, g, b = (info and info.r) or 1, (info and info.g) or 1, (info and info.b) or 1
|
||||||
local hex = format("|cff%02x%02x%02x", r*255, g*255, b*255)
|
local hex = format("|cff%02x%02x%02x", r * 255, g * 255, b * 255)
|
||||||
msg = hex .. msg:gsub("|r","|r"..hex) .. "|r"
|
msg = hex .. msg:gsub("|r", "|r" .. hex) .. "|r"
|
||||||
table.insert(lines, msg)
|
table.insert(lines, msg)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
title.count:SetText("Messages: "..count)
|
title.count:SetText("Messages: " .. count)
|
||||||
edit:SetText(table.concat(lines, "\n"))
|
edit:SetText(table.concat(lines, "\n"))
|
||||||
ResizeEdit(count)
|
ResizeEdit(count)
|
||||||
ScrollToBottomReliable(scroll, edit, 20)
|
ScrollToBottomReliable(scroll, edit, 20)
|
||||||
@@ -13454,18 +13509,18 @@ function LeaPlusLC:Player()
|
|||||||
end
|
end
|
||||||
|
|
||||||
for id = 1, NUM_CHAT_WINDOWS do
|
for id = 1, NUM_CHAT_WINDOWS do
|
||||||
local tab = _G["ChatFrame"..id.."Tab"]
|
local tab = _G["ChatFrame" .. id .. "Tab"]
|
||||||
if tab then
|
if tab then
|
||||||
tab:HookScript("OnMouseUp", (function(idx)
|
tab:HookScript("OnMouseUp", (function(idx)
|
||||||
return function(self, btn)
|
return function(self, btn)
|
||||||
if btn == "LeftButton" and IsControlKeyDown() then
|
if btn == "LeftButton" and IsControlKeyDown() then
|
||||||
-- If the same frame is already shown, toggle it off.
|
-- If the same frame is already shown, toggle it off.
|
||||||
-- Otherwise, show new content or first content.
|
-- Otherwise, show new content or first content.
|
||||||
if frame:IsShown() and LeaPlusLC.RecentChatEdit and LeaPlusLC.CurrentRecentChatSource == _G["ChatFrame"..idx] then
|
if frame:IsShown() and LeaPlusLC.RecentChatEdit and LeaPlusLC.CurrentRecentChatSource == _G["ChatFrame" .. idx] then
|
||||||
Close()
|
Close()
|
||||||
else
|
else
|
||||||
LeaPlusLC.CurrentRecentChatSource = _G["ChatFrame"..idx] -- Track source
|
LeaPlusLC.CurrentRecentChatSource = _G["ChatFrame" .. idx] -- Track source
|
||||||
ShowChatbox(_G["ChatFrame"..idx])
|
ShowChatbox(_G["ChatFrame" .. idx])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -13473,8 +13528,8 @@ function LeaPlusLC:Player()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
LeaPlusLC.RecentChatFrame = frame
|
LeaPlusLC.RecentChatFrame = frame
|
||||||
LeaPlusLC.RecentChatTitle = title
|
LeaPlusLC.RecentChatTitle = title
|
||||||
LeaPlusLC.RecentChatScroll = scroll
|
LeaPlusLC.RecentChatScroll = scroll
|
||||||
-- LeaPlusLC.RecentChatEdit is now set dynamically in ShowChatbox
|
-- LeaPlusLC.RecentChatEdit is now set dynamically in ShowChatbox
|
||||||
-- LeaPlusLC.CurrentRecentChatSource is a new helper variable to track the source for toggling
|
-- LeaPlusLC.CurrentRecentChatSource is a new helper variable to track the source for toggling
|
||||||
@@ -15171,6 +15226,15 @@ function LeaPlusLC:RunOnce()
|
|||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
function LeaPlusLC:MediaFunc()
|
function LeaPlusLC:MediaFunc()
|
||||||
|
|
||||||
|
local trackStartTime = 0
|
||||||
|
|
||||||
|
local function GetTrackIDFromPath(path)
|
||||||
|
local filename = path:match("([^/]+)$")
|
||||||
|
local basename = filename and filename:match("([^.]+)")
|
||||||
|
return basename or filename
|
||||||
|
end
|
||||||
|
|
||||||
-- Helper function for shortening paths in debug prints
|
-- Helper function for shortening paths in debug prints
|
||||||
local function getShortDisplayPathForDebug(fullPathString)
|
local function getShortDisplayPathForDebug(fullPathString)
|
||||||
-- Ensure it's a string before trying string operations
|
-- Ensure it's a string before trying string operations
|
||||||
@@ -15190,7 +15254,8 @@ function LeaPlusLC:RunOnce()
|
|||||||
|
|
||||||
-- Check for color code prefix like "|CffffffaaZone Name |rActualPath"
|
-- Check for color code prefix like "|CffffffaaZone Name |rActualPath"
|
||||||
local p, t = fullPathString:match("^(.-|r)(.*)$")
|
local p, t = fullPathString:match("^(.-|r)(.*)$")
|
||||||
if p and t and t ~= "" then -- Ensure both parts were captured and 't' (the path part) is not empty
|
if p and t and t ~= "" then
|
||||||
|
-- Ensure both parts were captured and 't' (the path part) is not empty
|
||||||
prefix = p
|
prefix = p
|
||||||
contentToShorten = t
|
contentToShorten = t
|
||||||
end
|
end
|
||||||
@@ -15231,7 +15296,8 @@ function LeaPlusLC:RunOnce()
|
|||||||
if type(rawItem) == "table" and rawItem.zone then
|
if type(rawItem) == "table" and rawItem.zone then
|
||||||
displayText = rawItem.zone
|
displayText = rawItem.zone
|
||||||
elseif type(rawItem) == "string" then
|
elseif type(rawItem) == "string" then
|
||||||
if strfind(rawItem, "#") then -- It's a track string
|
if strfind(rawItem, "#") then
|
||||||
|
-- It's a track string
|
||||||
local prefix = ""
|
local prefix = ""
|
||||||
local trackPathWithDuration = rawItem
|
local trackPathWithDuration = rawItem
|
||||||
local p, t = rawItem:match("^(.-|r)(.*)$")
|
local p, t = rawItem:match("^(.-|r)(.*)$")
|
||||||
@@ -15285,7 +15351,9 @@ function LeaPlusLC:RunOnce()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local bWidth = button:GetFontString():GetStringWidth() or 0
|
local bWidth = button:GetFontString():GetStringWidth() or 0
|
||||||
if bWidth > 290 then bWidth = 290 end
|
if bWidth > 290 then
|
||||||
|
bWidth = 290
|
||||||
|
end
|
||||||
button:SetHitRectInsets(0, 454 - bWidth, 0, 0)
|
button:SetHitRectInsets(0, 454 - bWidth, 0, 0)
|
||||||
button:SetPushedTextOffset(0, 0)
|
button:SetPushedTextOffset(0, 0)
|
||||||
button:GetFontString():SetWidth(290)
|
button:GetFontString():SetWidth(290)
|
||||||
@@ -15423,6 +15491,23 @@ function LeaPlusLC:RunOnce()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function MarkCurrentTrackListened()
|
||||||
|
if LastFolder == L["Random"] and LastPlayed and trackStartTime and trackStartTime > 0 then
|
||||||
|
print("last folder ok")
|
||||||
|
local elapsed = GetTime() - trackStartTime
|
||||||
|
if elapsed >= 30 then
|
||||||
|
print("time ok (" .. math.floor(elapsed) .. "s)")
|
||||||
|
local id = GetTrackIDFromPath(LastPlayed)
|
||||||
|
if id and id ~= "" then
|
||||||
|
print("id ok")
|
||||||
|
LeaPlusDB["ListenedTracks"][id] = true
|
||||||
|
LeaPlusLC:Print("Added track to listened: " .. id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Create scroll bar
|
-- Create scroll bar
|
||||||
scrollFrame = CreateFrame("ScrollFrame", "LeaPlusScrollFrame", LeaPlusLC["Page9"], "FauxScrollFrameTemplate")
|
scrollFrame = CreateFrame("ScrollFrame", "LeaPlusScrollFrame", LeaPlusLC["Page9"], "FauxScrollFrameTemplate")
|
||||||
scrollFrame:SetPoint("TOPLEFT", 0, -32)
|
scrollFrame:SetPoint("TOPLEFT", 0, -32)
|
||||||
@@ -15439,6 +15524,8 @@ function LeaPlusLC:RunOnce()
|
|||||||
LeaPlusLC:LockItem(stopBtn, true)
|
LeaPlusLC:LockItem(stopBtn, true)
|
||||||
-- REPLACEMENT: Stop-button handler (stopBtn:SetScript("OnClick", ...))
|
-- REPLACEMENT: Stop-button handler (stopBtn:SetScript("OnClick", ...))
|
||||||
stopBtn:SetScript("OnClick", function()
|
stopBtn:SetScript("OnClick", function()
|
||||||
|
MarkCurrentTrackListened()
|
||||||
|
trackStartTime = 0
|
||||||
StopMusic()
|
StopMusic()
|
||||||
if PrevMusicCVar == "0" then
|
if PrevMusicCVar == "0" then
|
||||||
SetCVar("Sound_EnableMusic", "0")
|
SetCVar("Sound_EnableMusic", "0")
|
||||||
@@ -15465,14 +15552,15 @@ function LeaPlusLC:RunOnce()
|
|||||||
|
|
||||||
-- Function to play a track and show the static highlight bar
|
-- Function to play a track and show the static highlight bar
|
||||||
local function PlayTrack()
|
local function PlayTrack()
|
||||||
-- stop anything already playing
|
-- Зафиксировать предыдущий трек, если слушали >=30 сек
|
||||||
|
MarkCurrentTrackListened()
|
||||||
|
-- Остановить текущее воспроизведение (если было)
|
||||||
StopMusic()
|
StopMusic()
|
||||||
|
|
||||||
local file, trackTime
|
local file, trackTime
|
||||||
local currentPlaylistItem = playlist[tracknumber] -- Get the item that is about to play
|
local currentPlaylistItem = playlist[tracknumber]
|
||||||
|
|
||||||
if currentPlaylistItem and strfind(currentPlaylistItem, "#") then
|
if currentPlaylistItem and strfind(currentPlaylistItem, "#") then
|
||||||
-- mp3 entry with explicit length
|
|
||||||
file, trackTime = currentPlaylistItem:match("([^,]+)%#([^,]+)")
|
file, trackTime = currentPlaylistItem:match("([^,]+)%#([^,]+)")
|
||||||
local cleanFile = file:gsub("(|C%a%a%a%a%a%a%a%a)[^|]*(|r)", "")
|
local cleanFile = file:gsub("(|C%a%a%a%a%a%a%a%a)[^|]*(|r)", "")
|
||||||
if strfind(file, "cinematics/") then
|
if strfind(file, "cinematics/") then
|
||||||
@@ -15482,39 +15570,42 @@ function LeaPlusLC:RunOnce()
|
|||||||
else
|
else
|
||||||
cleanFile = "sound/music/" .. cleanFile
|
cleanFile = "sound/music/" .. cleanFile
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Новый трек: сохраняем время старта
|
||||||
|
trackStartTime = GetTime()
|
||||||
PlayMusic(cleanFile)
|
PlayMusic(cleanFile)
|
||||||
isPlayingTrack = 1
|
isPlayingTrack = 1
|
||||||
else
|
else
|
||||||
-- If track is invalid or not found
|
-- Нет валидного трека
|
||||||
isPlayingTrack = 0
|
isPlayingTrack = 0
|
||||||
LastPlayed = "" -- Clear LastPlayed if nothing is actually playing
|
trackStartTime = nil
|
||||||
|
LastPlayed = ""
|
||||||
if LeaPlusLC.TrackTimer then
|
if LeaPlusLC.TrackTimer then
|
||||||
LeaPlusLC.TrackTimer:Cancel()
|
LeaPlusLC.TrackTimer:Cancel()
|
||||||
end
|
end
|
||||||
UpdateList() -- Refresh list to show no track is playing/highlighted
|
UpdateList()
|
||||||
return -- Exit if no valid track to play
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Обновить таймер окончания предыдущего трека
|
||||||
if LeaPlusLC.TrackTimer then
|
if LeaPlusLC.TrackTimer then
|
||||||
LeaPlusLC.TrackTimer:Cancel()
|
LeaPlusLC.TrackTimer:Cancel()
|
||||||
end
|
end
|
||||||
if trackTime then
|
if trackTime then
|
||||||
LeaPlusLC.TrackTimer = LibCompat.NewTimer(trackTime + 1, function()
|
LeaPlusLC.TrackTimer = LibCompat.NewTimer(trackTime + 1, function()
|
||||||
|
-- По окончании: фиксируем текущий трек и переходим к следующему
|
||||||
|
MarkCurrentTrackListened()
|
||||||
StopMusic()
|
StopMusic()
|
||||||
if tracknumber > #playlist then -- If it was incremented beyond the end
|
if tracknumber > #playlist then
|
||||||
tracknumber = 1
|
tracknumber = 1
|
||||||
end
|
end
|
||||||
PlayTrack() -- This will play playlist[tracknumber]
|
PlayTrack()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
LastPlayed = currentPlaylistItem -- Set LastPlayed to the track that just started playing
|
-- Обновить статус
|
||||||
|
LastPlayed = currentPlaylistItem
|
||||||
-- Advance tracknumber for the *next* time PlayTrack is called (e.g., by timer or next click)
|
|
||||||
tracknumber = tracknumber + 1
|
tracknumber = tracknumber + 1
|
||||||
|
|
||||||
-- Remove the visual update loop from here
|
|
||||||
-- Instead, call your new UpdateList function
|
|
||||||
UpdateList()
|
UpdateList()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -15538,7 +15629,8 @@ function LeaPlusLC:RunOnce()
|
|||||||
local clearButton = CreateFrame("Button", nil, sBox)
|
local clearButton = CreateFrame("Button", nil, sBox)
|
||||||
clearButton:SetSize(14, 14) -- As per your snippet
|
clearButton:SetSize(14, 14) -- As per your snippet
|
||||||
clearButton:SetNormalTexture("Interface\\FriendsFrame\\ClearBroadcastIcon")
|
clearButton:SetNormalTexture("Interface\\FriendsFrame\\ClearBroadcastIcon")
|
||||||
if clearButton:GetNormalTexture() then -- Good practice to check if texture was set
|
if clearButton:GetNormalTexture() then
|
||||||
|
-- Good practice to check if texture was set
|
||||||
clearButton:GetNormalTexture():SetTexCoord(0, 1, 0, 1) -- Ensure full texture is shown
|
clearButton:GetNormalTexture():SetTexCoord(0, 1, 0, 1) -- Ensure full texture is shown
|
||||||
clearButton:GetNormalTexture():SetVertexColor(1.0, 0.82, 0.0, 0.6) -- As per your snippet (60% alpha white)
|
clearButton:GetNormalTexture():SetVertexColor(1.0, 0.82, 0.0, 0.6) -- As per your snippet (60% alpha white)
|
||||||
end
|
end
|
||||||
@@ -15719,6 +15811,7 @@ function LeaPlusLC:RunOnce()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
-- Function to show random track listing
|
-- Function to show random track listing
|
||||||
local function ShowRandomList()
|
local function ShowRandomList()
|
||||||
-- If random track is currently playing, stop playback since random track list will be changed
|
-- If random track is currently playing, stop playback since random track list will be changed
|
||||||
@@ -15744,15 +15837,26 @@ function LeaPlusLC:RunOnce()
|
|||||||
local rTrack = ZoneList[rCategory][rZone].tracks[random(1, #ZoneList[rCategory][rZone].tracks)]
|
local rTrack = ZoneList[rCategory][rZone].tracks[random(1, #ZoneList[rCategory][rZone].tracks)]
|
||||||
-- Only allow tracks that are real mp3 (exclude SoundKit/non-file)
|
-- Only allow tracks that are real mp3 (exclude SoundKit/non-file)
|
||||||
if rTrack and rTrack ~= "" and strfind(rTrack, "#") and strfind(rTrack:lower(), ".mp3") then
|
if rTrack and rTrack ~= "" and strfind(rTrack, "#") and strfind(rTrack:lower(), ".mp3") then
|
||||||
local zoneLabel = "|Cffffffaa" .. ZoneList[rCategory][rZone].zone .. " |r" .. rTrack
|
local trackID = GetTrackIDFromPath(rTrack)
|
||||||
if not tContains(ListData, zoneLabel) and not tContains(randomBannedList, L[ZoneList[rCategory][rZone].zone]) and not tContains(randomBannedList, rTrack) then
|
-- гарантируем, что подтаблица существует (на всякий случай)
|
||||||
tinsert(ListData, zoneLabel)
|
if not LeaPlusDB["ListenedTracks"] then
|
||||||
|
LeaPlusDB["ListenedTracks"] = {}
|
||||||
|
end
|
||||||
|
-- база инициализирована заранее, используем квадратные скобки
|
||||||
|
if not LeaPlusDB["ListenedTracks"][trackID] then
|
||||||
|
local zoneLabel = "|Cffffffaa" .. ZoneList[rCategory][rZone].zone .. " |r" .. rTrack
|
||||||
|
if not tContains(ListData, zoneLabel)
|
||||||
|
and not tContains(randomBannedList, L[ZoneList[rCategory][rZone].zone])
|
||||||
|
and not tContains(randomBannedList, rTrack)
|
||||||
|
then
|
||||||
|
tinsert(ListData, zoneLabel)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- If nothing found, show hint
|
-- If nothing found, show hint
|
||||||
if #ListData <= 4 then
|
if #ListData <= 4 then
|
||||||
tinsert(ListData, "|cff999999(No playable music tracks in random pool)|r")
|
tinsert(ListData, "|cff999999(You have listened it all!)|r")
|
||||||
end
|
end
|
||||||
-- Refresh the track listing
|
-- Refresh the track listing
|
||||||
UpdateList()
|
UpdateList()
|
||||||
@@ -15853,9 +15957,15 @@ function LeaPlusLC:RunOnce()
|
|||||||
return
|
return
|
||||||
elseif originalTrackItemFromListData and type(originalTrackItemFromListData) == "string" and strfind(originalTrackItemFromListData, "#") then
|
elseif originalTrackItemFromListData and type(originalTrackItemFromListData) == "string" and strfind(originalTrackItemFromListData, "#") then
|
||||||
-- Playable track
|
-- Playable track
|
||||||
if GetCVar("Sound_EnableAllSound") == "0" then SetCVar("Sound_EnableAllSound", "1") end
|
if GetCVar("Sound_EnableAllSound") == "0" then
|
||||||
if not PrevMusicCVar then PrevMusicCVar = GetCVar("Sound_EnableMusic") end
|
SetCVar("Sound_EnableAllSound", "1")
|
||||||
if GetCVar("Sound_EnableMusic") == "0" then SetCVar("Sound_EnableMusic", "1") end
|
end
|
||||||
|
if not PrevMusicCVar then
|
||||||
|
PrevMusicCVar = GetCVar("Sound_EnableMusic")
|
||||||
|
end
|
||||||
|
if GetCVar("Sound_EnableMusic") == "0" then
|
||||||
|
SetCVar("Sound_EnableMusic", "1")
|
||||||
|
end
|
||||||
|
|
||||||
wipe(playlist)
|
wipe(playlist)
|
||||||
local listDataIndexForClickedItem = 0
|
local listDataIndexForClickedItem = 0
|
||||||
@@ -15894,8 +16004,12 @@ function LeaPlusLC:RunOnce()
|
|||||||
end
|
end
|
||||||
|
|
||||||
LeaPlusLC:LockItem(stopBtn, false)
|
LeaPlusLC:LockItem(stopBtn, false)
|
||||||
if ListData[1] == "|cffffd800" .. L["Random"] then TempFolder = L["Random"] end
|
if ListData[1] == "|cffffd800" .. L["Random"] then
|
||||||
if ListData[1] == "|cffffd800" .. L["Search"] then TempFolder = L["Search"] end
|
TempFolder = L["Random"]
|
||||||
|
end
|
||||||
|
if ListData[1] == "|cffffd800" .. L["Search"] then
|
||||||
|
TempFolder = L["Search"]
|
||||||
|
end
|
||||||
|
|
||||||
tracknumber = 1
|
tracknumber = 1
|
||||||
LastPlayed = playlist[1]
|
LastPlayed = playlist[1]
|
||||||
@@ -15961,7 +16075,9 @@ function LeaPlusLC:RunOnce()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if foundZone then break end
|
if foundZone then
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
@@ -16006,6 +16122,7 @@ function LeaPlusLC:RunOnce()
|
|||||||
LeaPlusLC["Page9"]:SetScript("OnEvent", function(self, event)
|
LeaPlusLC["Page9"]:SetScript("OnEvent", function(self, event)
|
||||||
-- REPLACEMENT: PLAYER_LOGOUT part of Page9:SetScript("OnEvent", ...)
|
-- REPLACEMENT: PLAYER_LOGOUT part of Page9:SetScript("OnEvent", ...)
|
||||||
if event == "PLAYER_LOGOUT" then
|
if event == "PLAYER_LOGOUT" then
|
||||||
|
MarkCurrentTrackListened()
|
||||||
StopMusic()
|
StopMusic()
|
||||||
if PrevMusicCVar == "0" then
|
if PrevMusicCVar == "0" then
|
||||||
SetCVar("Sound_EnableMusic", "0")
|
SetCVar("Sound_EnableMusic", "0")
|
||||||
@@ -17657,13 +17774,16 @@ function LeaPlusLC:CreateEditBox(frame, parent, width, height, anchor, x, y, tab
|
|||||||
midRegion:SetPoint("RIGHT", rightRegion, "LEFT", 0, 0)
|
midRegion:SetPoint("RIGHT", rightRegion, "LEFT", 0, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
eb:SetScript("OnTabPressed", function(self)
|
eb:SetScript("OnTabPressed", function(self)
|
||||||
self:ClearFocus()
|
self:ClearFocus()
|
||||||
if IsShiftKeyDown() then
|
if IsShiftKeyDown() then
|
||||||
if shifttab and LeaPlusCB[shifttab] then LeaPlusCB[shifttab]:SetFocus() end
|
if shifttab and LeaPlusCB[shifttab] then
|
||||||
|
LeaPlusCB[shifttab]:SetFocus()
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if tab and LeaPlusCB[tab] then LeaPlusCB[tab]:SetFocus() end
|
if tab and LeaPlusCB[tab] then
|
||||||
|
LeaPlusCB[tab]:SetFocus()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
return eb
|
return eb
|
||||||
|
|||||||
Reference in New Issue
Block a user