Rhyuno wrote: ↑August 12th, 2024, 10:31 amI'm experiencing this problem with both options and never had it with the "original" setup.
Alright, after having slept on it I approached this a bit differently and managed to write the formulas in a way that allows for either of the "line always in the chosen vertical position" and "line in the chosen position only when not at the start or end of the lyrics" variants to be chosen, by simply changing the value of one of the two variables that I included in an improved version of the sample skin earlier (
LockLine =
0 for the 2nd variant,
1 for the 1st variant;
LockPerc = decimal percentage starting from the top of the lyrics container where the line should stay):
Code: Select all
[Variables]
BackgroundW=400
BackgroundH=600
StrokeWidth=2
CornerRadius=10
Margin=10
BackgroundColor=0,0,0,128
StrokeColor=255,128,0,255
InfoColor0=255,128,128,255
InfoColor1=128,128,255,255
InfoColor2=128,255,128,255
InfoColor3=255,128,255,255
ControlColor0=255,255,128,255
ControlColor1=128,255,255,255
ControlColor2=128,255,255,255
ControlColor3=255,255,128,255
LyricsColor=192,192,192,255
KaraokeColor=255,255,255,255
FontEffectColor=0,0,0,255
FontColor=255,255,255,255
FontFace=Monotype Corsiva
FontSize=16
StringEffect=Shadow
FontPerc=0.75
BarHPerc=0.80
BarSolid=128,128,128,255
BarColor=0,255,0,255
ControlNum=4
ControlGap=50
Prev=[\x23EE]
Stop=[\x23F9]
Play=[\x23F5]
Next=[\x23ED]
Pause=[\x23F8]
BoxColor=0,0,0,128
Plugin=NowPlaying
Player=Winamp
Offset=0
LockLine=0
LockPerc=0
LineH=0
Lines=0
Line=0
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
---Measures---
[Status]
Group=PlayerGroup
Measure=Plugin
Plugin=#Plugin#
PlayerName=#Player#
PlayerType=Status
RegExpSubstitute=1
Substitute="^0$":"Closed","^1$":"Open"
DynamicVariables=1
[State]
Group=PlayerGroup
Measure=Plugin
Plugin=#Plugin#
PlayerName=[Status]
PlayerType=State
RegExpSubstitute=1
Substitute="^0$":"Stopped","^1$":"Playing","^2$":"Paused"
IfCondition=(State=1)
IfTrueAction=[!SetOption Play Text "#Pause#"]
IfFalseAction=[!SetOption Play Text "#Play#"]
DynamicVariables=1
[Artist]
Group=PlayerGroup
Measure=Plugin
Plugin=#Plugin#
PlayerName=[Status]
PlayerType=Artist
RegExpSubstitute=1
Substitute="^$":"No Artist"
DynamicVariables=1
[Album]
Group=PlayerGroup
Measure=Plugin
Plugin=#Plugin#
PlayerName=[Status]
PlayerType=Album
RegExpSubstitute=1
Substitute="^$":"No Album"
DynamicVariables=1
[Title]
Group=PlayerGroup
Measure=Plugin
Plugin=#Plugin#
PlayerName=[Status]
PlayerType=Title
RegExpSubstitute=1
Substitute="^$":"No Title"
DynamicVariables=1
[Duration]
Group=PlayerGroup
Measure=Plugin
Plugin=#Plugin#
PlayerName=[Status]
PlayerType=Duration
RegExpSubstitute=1
Substitute="(?<!\d)(\d)(?!\d)":"0\1"
DynamicVariables=1
[Position]
Group=PlayerGroup
Measure=Plugin
Plugin=#Plugin#
PlayerName=[Status]
PlayerType=Position
RegExpSubstitute=1
Substitute="(?<!\d)(\d)(?!\d)":"0\1"
OnChangeAction=[!UpdateMeasureGroup LinesGroup]
DynamicVariables=1
[Progress]
Group=PlayerGroup
Measure=Plugin
Plugin=#Plugin#
PlayerName=[Status]
PlayerType=Progress
DynamicVariables=1
[Track]
Group=PlayerGroup
Measure=String
String=[Artist] - [Album] - [Title] - [Duration:]
OnChangeAction=[!SetVariable Line 0][!SetVariable Offset 0][!CommandMeasure SyncedLyrics "Update"]
DynamicVariables=1
[SyncedLyrics]
Measure=WebParser
URL=https://lrclib.net/api/get?artist_name=[&Artist]&album_name=[&Album]&track_name=[&Title]&duration=[&Duration:]
UserAgent=Rainmeter 4.5.18 (https://github.com/rainmeter)
RegExp=(?siU)[{,]"syncedLyrics":"(.*)"[,}]
StringIndex=1
UpdateRate=-1
RegExpSubstitute=1
Substitute='(?sU)\\"':'"',"(?sU)\\n":"#CRLF#"
IfMatch=(?siU)\[\x005B][Position].+\R
IfMatchAction=[!SetOption LyricsText "InlineSetting" "Color | #KaraokeColor#"][!SetOption LyricsText "InlinePattern" "(?siU)\[\x005B][Position].+\R"]
IfMatchMode=1
FinishAction=[!UpdateMeasureGroup LinesGroup]
DynamicVariables=1
[Lines]
Group=LinesGroup
Measure=String
String=[SyncedLyrics]
UpdateDivider=-1
RegExpSubstitute=1
Substitute="(?siU).+(?:\R|$)":"+1","(?siU)^(.*)$":"0\1","\\\d+":""
OnUpdateAction=[!SetVariable Lines ([Lines])][!SetVariable LineH ([LyricsText:H]/([#Lines]=0?1:[#Lines]))]
DynamicVariables=1
[Line]
Group=LinesGroup
Measure=String
String=[SyncedLyrics]
UpdateDivider=-1
RegExpSubstitute=1
Substitute="(?siU)(?|^(.*)\[\x005B][Position].+(?:\R|$).*?$|^((?:.+(?:\R|$)){#Line#}).*?$)":"\1","\\\d+":"","(?siU).+(?:\R|$)":"+1","(?siU)^(.*)$":"0\1","\\\d+":""
OnUpdateAction=[!SetVariable Line ([Position:]=0?0:[Line])][!SetVariable Offset ([#LineH]*[#Line])]
DynamicVariables=1
[Reset]
Group=LinesGroup
Measure=Calc
Formula=([Position:]=0?1:0)
UpdateDivider=-1
IfCondition=(Reset=1)
IfTrueAction=[!SetOption LyricsText "InlineSetting" "Color | #KaraokeColor#"][!SetOption LyricsText "InlinePattern" "^$"]
IfConditionMode=1
OnUpdateAction=[!UpdateMeter *][!Redraw]
DynamicVariables=1
---Styles---
[Texts]
FontEffectColor=#FontEffectColor#
FontColor=#FontColor#
FontFace=#FontFace#
FontSize=#FontSize#
AntiAlias=1
StringEffect=#StringEffect#
---Meter---
[Background]
Meter=Shape
Shape=Rectangle (#StrokeWidth#/2),(#StrokeWidth#/2),(#BackgroundW#-#StrokeWidth#),(#BackgroundH#-#StrokeWidth#),(#CornerRadius#),(#CornerRadius#) | Fill Color #BackgroundColor# | Stroke Color #StrokeColor# | StrokeWidth #StrokeWidth#
UpdateDivider=-1
[Information]
Meter=String
MeterStyle=Texts
StringAlign=Center
X=(#BackgroundW#/2)
Y=(#Margin#)
W=(#BackgroundW#-#Margin#*2)
InlineSetting=Color | #InfoColor0#
InlinePattern=^(?:\N*\R){0}(\N*)
InlineSetting2=Color | #InfoColor1#
InlinePattern2=^(?:\N*\R){1}(\N*)
InlineSetting3=Color | #InfoColor2#
InlinePattern3=^(?:\N*\R){2}(\N*)
InlineSetting4=Color | #InfoColor3#
InlinePattern4=^(?:\N*\R){3}(\N*)
MeasureName=Artist
MeasureName2=Album
MeasureName3=Title
MeasureName4=Duration
MeasureName5=Position
MeasureName6=Progress
MeasureName7=Status
MeasureName8=State
Text=%1#CRLF#%2#CRLF#%3#CRLF#%5 of %4 (%6%) - Player is %7 & %8
DynamicVariables=1
[ProgressBar]
Meter=Bar
MeasureName=Progress
X=(#Margin#)
Y=(#Margin#/2)R
W=(#BackgroundW#-#Margin#*2)
H=(#FontSize#*#BarHPerc#)
BarColor=#BarColor#
SolidColor=#BarSolid#
BarOrientation=Horizontal
LeftMouseDownAction=[!CommandMeasure Progress "SetPosition $MouseX:%$"][!UpdateMeasureGroup PlayerGroup][!UpdateMeter *][!Redraw]
DynamicVariables=1
[Prev]
Meter=String
MeterStyle=Texts
X=(#BackgroundW#/2-#ControlGap#/2*(#ControlNum#-1))
Y=(#Margin#/2)R
StringAlign=Center
FontColor=#ControlColor0#
Text=#Prev#
LeftMouseUpAction=[!CommandMeasure Status "Previous"][!UpdateMeasureGroup PlayerGroup][!UpdateMeter *][!Redraw]
[Stop]
Meter=String
MeterStyle=Texts
X=(#ControlGap#)r
Y=(0)r
StringAlign=Center
FontColor=#ControlColor1#
Text=#Stop#
LeftMouseUpAction=[!CommandMeasure Status "Stop"][!UpdateMeasureGroup PlayerGroup][!UpdateMeter *][!Redraw]
[Play]
Meter=String
MeterStyle=Texts
X=(#ControlGap#)r
Y=(0)r
StringAlign=Center
FontColor=#ControlColor2#
Text=#Play#
LeftMouseUpAction=[!CommandMeasure Status "PlayPause"][!UpdateMeasureGroup PlayerGroup][!UpdateMeter *][!Redraw]
[Next]
Meter=String
MeterStyle=Texts
X=(#ControlGap#)r
Y=(0)r
StringAlign=Center
FontColor=#ControlColor3#
Text=#Next#
LeftMouseUpAction=[!CommandMeasure Status "Next"][!UpdateMeasureGroup PlayerGroup][!UpdateMeter *][!Redraw]
[LyricsBox]
Meter=Image
X=(#Margin#)
Y=(#Margin#/2)R
W=(#BackgroundW#-#Margin#*2)
H=(#BackgroundH#-[LyricsBox:Y]-#Margin#)
SolidColor=#BoxColor#
UpdateDivider=-1
DynamicVariables=1
[LyricsContainer]
Meter=Image
X=([LyricsBox:X])
Y=([LyricsBox:Y])
W=([LyricsBox:W])
H=([LyricsBox:H])
SolidColor=0,0,0,255
UpdateDivider=-1
MouseScrollUpAction=[!SetVariable Offset (Clamp(#Offset#-#LineH#,[LyricsContainer:H]*#LockPerc#*(1-#LockLine#),Clamp([LyricsText:H]-[LyricsContainer:H]*(1-#LockLine#),0,[LyricsText:H])+[LyricsContainer:H]*#LockPerc#*(1-#LockLine#)))][!UpdateMeter LyricsContainer][!UpdateMeter LyricsText][!Redraw]
MouseScrollDownAction=[!SetVariable Offset (Clamp(#Offset#+#LineH#,[LyricsContainer:H]*#LockPerc#*(1-#LockLine#),Clamp([LyricsText:H]-[LyricsContainer:H]*(1-#LockLine#),0,[LyricsText:H])+[LyricsContainer:H]*#LockPerc#*(1-#LockLine#)))][!UpdateMeter LyricsContainer][!UpdateMeter LyricsText][!Redraw]
DynamicVariables=1
[LyricsText]
Container=LyricsContainer
Meter=String
MeterStyle=Texts
StringAlign=Center
FontColor=#LyricsColor#
FontSize=(#FontSize#*#FontPerc#)
X=([LyricsBox:W]/2)
Y=(-Clamp(#Offset#-[LyricsContainer:H]*#LockPerc#,-[LyricsContainer:H]*#LockPerc#*#LockLine#,Clamp([LyricsText:H]-[LyricsContainer:H],0,[LyricsText:H])+[LyricsContainer:H]*(1-#LockPerc#)*#LockLine#))
W=([LyricsBox:W])
MeasureName=SyncedLyrics
Text=%1
DynamicVariables=1
The improved sample includes:
- the ability to work with either NowPlaying or WebNowPlaying, by changing the value of the
Plugin variable in
[Variables] accordingly
- the ability to loosely or strictly "lock" the vertical position of the current line in the lyrics box via the
LockLine and
LockPerc variables, see above
- the ability to detect changing the track for either plugin, as mentioned earlier in the thread, via the
[Track] measure
- corrections to the way the current line is computed, see the slightly adjusted
Substitute in the
[Line] measure
- the ability to reset the highlighted / karaoke line to nothing when the track position is 0 (aka track is stopped), in the
[Reset] measure
- the adjusted formulas for any variant of locking the current line vertical position, in the scroll actions of
[LyricsContainer] and the
Y of
[LyricsText]
Feel free to add what you prefer in the code you posted above. You can use a
LockLine of 0 for the loose lock or 1 for the strict lock, and a
LockPerc of 0.43 as per your code. Alternatively, if you don't like adding the variables or the longer formulas and you only need one of the position locking variants, you can skip adding the variables and just replace
#LockLine# and
#LockPerc# with your chosen values in the formulas and, when possible, reduce the formulas if some terms
cancel each other or themselves out.
What's probably left to do if desired is to allow horizontal scrolling too, in case the lyrics lines are too long to fit the container (considering that wrapping them has unwanted effects on computing the line height, aka
#LineH#). I suppose that would work best on mouse hovering near the left and right sides of the container, since mouse scrolling on the container is already populated by the vertical scrolling. I'll let you do that if you want, since it's trivial to change the
X of
[LyricsText] from some
MouseOverAction / MouseLeaveAction in
[LyricsContainer] (the result should be
clamped though, so that it doesn't go forever).