media: highlight playing track
This commit is contained in:
+49
-47
@@ -15187,55 +15187,58 @@ function LeaPlusLC:RunOnce()
|
|||||||
local ZoneList = Leatrix_Plus["ZoneList"]
|
local ZoneList = Leatrix_Plus["ZoneList"]
|
||||||
|
|
||||||
-- Show relevant list items
|
-- Show relevant list items
|
||||||
|
-- Replace your UpdateList entirely with this:
|
||||||
local function UpdateList()
|
local function UpdateList()
|
||||||
FauxScrollFrame_Update(scrollFrame, #ListData, numButtons, 16)
|
FauxScrollFrame_Update(scrollFrame, #ListData, numButtons, 16)
|
||||||
for index = 1, numButtons do
|
for index = 1, numButtons do
|
||||||
local offset = index + FauxScrollFrame_GetOffset(scrollFrame)
|
local offset = index + FauxScrollFrame_GetOffset(scrollFrame)
|
||||||
local button = scrollFrame.buttons[index]
|
local button = scrollFrame.buttons[index]
|
||||||
button.index = offset
|
button.index = offset
|
||||||
|
|
||||||
if offset <= #ListData then
|
if offset <= #ListData then
|
||||||
-- Show zone listing or track listing
|
local text = ListData[offset].zone or ListData[offset]
|
||||||
button:SetText(ListData[offset].zone or ListData[offset])
|
|
||||||
-- Set width of highlight texture
|
-- Set the text and immediately reset its color to white:
|
||||||
|
button:SetText(text)
|
||||||
|
button:GetFontString():SetTextColor(1.0, 1.0, 1.0)
|
||||||
|
|
||||||
|
-- highlight‐texture sizing
|
||||||
if button:GetTextWidth() > 290 then
|
if button:GetTextWidth() > 290 then
|
||||||
button.t:SetSize(290, 16)
|
button.t:SetSize(290, 16)
|
||||||
else
|
else
|
||||||
button.t:SetSize(button:GetTextWidth(), 16)
|
button.t:SetSize(button:GetTextWidth(), 16)
|
||||||
end
|
end
|
||||||
-- Show the button
|
|
||||||
button:Show()
|
button:Show()
|
||||||
-- Hide highlight bar texture by default
|
|
||||||
button.s:Hide()
|
button.s:Hide()
|
||||||
-- Hide highlight bar if the button is a heading
|
|
||||||
if strfind(button:GetText(), "|c") then
|
if strfind(text, "|c") then
|
||||||
button.t:Hide()
|
button.t:Hide()
|
||||||
end
|
end
|
||||||
-- Show last played track highlight bar texture
|
|
||||||
if LastPlayed == button:GetText() then
|
-- only show the highlight bar—and recolor—if this really is the current track in the current folder:
|
||||||
local HeadingOfCurrentFolder = ListData[1]
|
if LastPlayed == text and ListData[1] == HeadingOfClickedTrack then
|
||||||
if HeadingOfCurrentFolder == HeadingOfClickedTrack then
|
button.s:Show()
|
||||||
button.s:Show()
|
button:GetFontString():SetTextColor(1.0, 0.82, 0.0)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
-- Show last played folder highlight bar texture
|
|
||||||
if LastFolder == button:GetText() then
|
-- still keep your “last‐folder” bar logic unchanged:
|
||||||
|
if LastFolder == text then
|
||||||
button.s:Show()
|
button.s:Show()
|
||||||
end
|
end
|
||||||
-- Set width of highlight bar
|
|
||||||
|
-- resize the bar again (you already had this)
|
||||||
if button:GetTextWidth() > 290 then
|
if button:GetTextWidth() > 290 then
|
||||||
button.s:SetSize(290, 16)
|
button.s:SetSize(290, 16)
|
||||||
else
|
else
|
||||||
button.s:SetSize(button:GetTextWidth(), 16)
|
button.s:SetSize(button:GetTextWidth(), 16)
|
||||||
end
|
end
|
||||||
-- Limit click to label width
|
|
||||||
|
-- your hit‐rect, wrap, etc. all unchanged:
|
||||||
local bWidth = button:GetFontString():GetStringWidth() or 0
|
local bWidth = button:GetFontString():GetStringWidth() or 0
|
||||||
if bWidth > 290 then
|
if bWidth > 290 then bWidth = 290 end
|
||||||
bWidth = 290
|
|
||||||
end
|
|
||||||
button:SetHitRectInsets(0, 454 - bWidth, 0, 0)
|
button:SetHitRectInsets(0, 454 - bWidth, 0, 0)
|
||||||
-- Disable label click movement
|
|
||||||
button:SetPushedTextOffset(0, 0)
|
button:SetPushedTextOffset(0, 0)
|
||||||
-- Disable word wrap and set width
|
|
||||||
button:GetFontString():SetWidth(290)
|
button:GetFontString():SetWidth(290)
|
||||||
button:GetFontString():SetWordWrap(false)
|
button:GetFontString():SetWordWrap(false)
|
||||||
else
|
else
|
||||||
@@ -15243,10 +15246,9 @@ function LeaPlusLC:RunOnce()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Give function file level scope (it's used in SetPlusScale to set the highlight bar scale)
|
|
||||||
LeaPlusLC.UpdateList = UpdateList
|
LeaPlusLC.UpdateList = UpdateList
|
||||||
|
|
||||||
|
|
||||||
-- Right-button click to go back
|
-- Right-button click to go back
|
||||||
local function BackClick()
|
local function BackClick()
|
||||||
-- Return to the current zone list (back button)
|
-- Return to the current zone list (back button)
|
||||||
@@ -15412,17 +15414,17 @@ function LeaPlusLC:RunOnce()
|
|||||||
local isPlayingTrack = 0
|
local isPlayingTrack = 0
|
||||||
|
|
||||||
-- Function to play a track and show the static highlight bar
|
-- Function to play a track and show the static highlight bar
|
||||||
-- REPLACEMENT: PlayTrack() (overwrite the whole current definition)
|
|
||||||
local function PlayTrack()
|
local function PlayTrack()
|
||||||
|
|
||||||
-- stop anything already playing
|
-- stop anything already playing
|
||||||
StopMusic()
|
StopMusic()
|
||||||
|
|
||||||
local file, trackTime
|
local file, trackTime
|
||||||
if playlist[tracknumber] and strfind(playlist[tracknumber], "#") then
|
local currentPlaylistItem = playlist[tracknumber] -- Get the item that is about to play
|
||||||
|
|
||||||
|
if currentPlaylistItem and strfind(currentPlaylistItem, "#") then
|
||||||
-- mp3 entry with explicit length
|
-- mp3 entry with explicit length
|
||||||
file, trackTime = playlist[tracknumber]:match("([^,]+)%#([^,]+)")
|
file, trackTime = currentPlaylistItem:match("([^,]+)%#([^,]+)")
|
||||||
local cleanFile = file:gsub("(|C%a%a%a%a%a%a%a%a)[^|]*(|r)", "") -- strip colour codes
|
local cleanFile = file:gsub("(|C%a%a%a%a%a%a%a%a)[^|]*(|r)", "")
|
||||||
if strfind(file, "cinematics/") then
|
if strfind(file, "cinematics/") then
|
||||||
cleanFile = "interface/" .. cleanFile
|
cleanFile = "interface/" .. cleanFile
|
||||||
elseif strfind(file, "cinematicvoices/") or strfind(file, "ambience/") or strfind(file, "spells/") then
|
elseif strfind(file, "cinematicvoices/") or strfind(file, "ambience/") or strfind(file, "spells/") then
|
||||||
@@ -15432,42 +15434,42 @@ function LeaPlusLC:RunOnce()
|
|||||||
end
|
end
|
||||||
PlayMusic(cleanFile)
|
PlayMusic(cleanFile)
|
||||||
isPlayingTrack = 1
|
isPlayingTrack = 1
|
||||||
|
else
|
||||||
|
-- If track is invalid or not found
|
||||||
|
isPlayingTrack = 0
|
||||||
|
LastPlayed = "" -- Clear LastPlayed if nothing is actually playing
|
||||||
|
if LeaPlusLC.TrackTimer then
|
||||||
|
LeaPlusLC.TrackTimer:Cancel()
|
||||||
|
end
|
||||||
|
UpdateList() -- Refresh list to show no track is playing/highlighted
|
||||||
|
return -- Exit if no valid track to play
|
||||||
end
|
end
|
||||||
|
|
||||||
-- cancel any previous timer and create a new one for this track
|
|
||||||
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()
|
||||||
StopMusic()
|
StopMusic()
|
||||||
if tracknumber == #playlist then
|
if tracknumber > #playlist then -- If it was incremented beyond the end
|
||||||
tracknumber = 1
|
tracknumber = 1
|
||||||
end
|
end
|
||||||
PlayTrack()
|
PlayTrack() -- This will play playlist[tracknumber]
|
||||||
isPlayingTrack = 1
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
LastPlayed = playlist[tracknumber]
|
LastPlayed = currentPlaylistItem -- Set LastPlayed to the track that just started playing
|
||||||
|
|
||||||
|
-- Advance tracknumber for the *next* time PlayTrack is called (e.g., by timer or next click)
|
||||||
tracknumber = tracknumber + 1
|
tracknumber = tracknumber + 1
|
||||||
|
|
||||||
-- static highlight
|
-- Remove the visual update loop from here
|
||||||
for index = 1, numButtons do
|
-- Instead, call your new UpdateList function
|
||||||
local button = scrollFrame.buttons[index]
|
UpdateList()
|
||||||
local item = button:GetText()
|
|
||||||
if item and strfind(item, "#") then
|
|
||||||
local itm = item:match("([^,]+)%#")
|
|
||||||
if itm == file and LastFolder == TempFolder then
|
|
||||||
button.s:Show()
|
|
||||||
else
|
|
||||||
button.s:Hide()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Create editbox for search
|
-- Create editbox for search
|
||||||
local sBox = LeaPlusLC:CreateEditBox("MusicSearchBox", LeaPlusLC["Page9"], 100, 24, "TOPLEFT", 135, -260, "MusicSearchBox", "MusicSearchBox", 50)
|
local sBox = LeaPlusLC:CreateEditBox("MusicSearchBox", LeaPlusLC["Page9"], 100, 24, "TOPLEFT", 135, -260, "MusicSearchBox", "MusicSearchBox", 50)
|
||||||
sBox:SetMaxLetters(50)
|
sBox:SetMaxLetters(50)
|
||||||
|
|||||||
Reference in New Issue
Block a user