It is currently April 19th, 2024, 3:47 am

Confusion with ActionTimer and IfCondition

Get help with creating, editing & fixing problems with skins
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Confusion with ActionTimer and IfCondition

Post by balala »

Yincognito wrote: August 15th, 2020, 8:08 pm An even bigger catastrophe is when the Log is nice and clean but the code just doesn't work the way it's suppose to. It means you have to find the needle in the haystack yourself... :sly:
:17denial Right. That's a nightmare!!!
BrrDoesRainmeter
Posts: 7
Joined: July 30th, 2020, 10:16 pm

Re: Confusion with ActionTimer and IfCondition

Post by BrrDoesRainmeter »

Not sure if I should make a new post about this but I had another question regarding the code im working on. I think I got the hang of the ActionTimer plugin (At least enough for this skin :D) and the variables I'm trying to change are working great; but now I'm running into another problem. The behavior I'm attempting to create is when moused over, the box expands and reveals icons that fade in. If the icons are moused over, the opacity value increases to indicate that it's "highlighted." When the mouse leaves the box, the icons dissapear. This all works but only if I've moused over the icon and image at least once. Otherwise the variables change but thats not reflected in the meters.

This is what I'm workin with :D (thanks in advance)

P.S. Any help with reducing CPU usage would be marvelous but not required

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
U=[!UpdateMeasureGroup Sliders][!UpdateMeterGroup Sliders][!Redraw]
H=2
W=10
Offset=-190
SlideAmount=10
NormalColor= 255,255,255,#Alpha#
NormalColor1= 255,255,255,#Alpha1#
HoverColor=255,255,255,150
HoverColor1=255,255,255,175
PalletColor=45,32,228,255
Alpha=1
Alpha1=1
FadeAmt=20
FadeAmt1=25

[MeasureSlider]
Measure=Plugin
Plugin=ActionTimer
Group=Sliders
ActionList1=Repeat Open,#W#,20
ActionList2=Repeat Close,#W#,20
ActionList3=Repeat FadeIn,#H#,5
ActionList4=Repeat FadeOut,#H#,5
ActionList5=Repeat Fadein1,#H#,5
ActionList6=Repeat FadeOut1,#H#,5
Open=[!SetVariable Offset "(Clamp(#Offset#+#SlideAmount#,-190,0))"]#U#
Close=[!SetVariable Offset "(Clamp(#Offset#-#SlideAmount#,-190,0))"]#U#
FadeIn=[!SetVariable Alpha "(Clamp(#Alpha#+#FadeAmt#,1,100))"]#U#
FadeOut=[!SetVariable Alpha "(Clamp(#Alpha#-#FadeAmt#,1,100))"]#U#
FadeIn1=[!SetVariable Alpha1 "(Clamp(#Alpha1#+#FadeAmt1#,1,125))"]#U#
FadeOut1=[!SetVariable Alpha1 "(Clamp(#Alpha1#-#FadeAmt1#,1,125))"]#U#
IfCondition=#Offset# = -190
IfTrueAction=[!SetOption MeterPanel MouseOverAction """[!CommandMeasure MeasureSlider "Stop 2"][!CommandMeasure MeasureSlider "Execute 1"]"""]
IfCondition2=#Offset# = 0
IfTrueAction2=[!SetOption MeterPanel MouseLeaveAction """[!CommandMeasure MeasureSlider "Stop 1"][!CommandMeasure MeasureSlider "Execute 2"]"""]
IfCondition3=#Offset# = 0 
IfTrueAction3=[!CommandMeasure MeasureSlider "Stop 4"][!CommandMeasure MeasureSlider "Execute 3"]
IfCondition4=#Offset# = -190
IfTrueAction4=[!CommandMeasure MeasureSlider "Stop 3"][!CommandMeasure MeasureSlider "Execute 4"]
IfCondition5=#Offset# = 0
IfTrueAction5=[!CommandMeasure MeasureSlider "Stop 6"][!CommandMeasure MeasureSlider "Execute 5"]
IfCondition6=#Offset# = -190
IfTrueAction6=[!CommandMeasure MeasureSlider "Stop 5"][!CommandMeasure MeasureSlider "Execute 6"]
DynamicVariables=1

[MeterPanel]
Meter=Image
Group=Sliders
Y=(0 + #Offset#)
W=176
H=250
SolidColor=#PalletColor#
DynamicVariables=1

[MeterKovaaksContainer]
Meter=Image
Group=Sliders
ImagePath=C:\Users\Imort\Documents\Rainmeter\Skins\Dynamic-Objects\@Resources\Images\Icons
ImageName=BackgroundIcon.png
ImageTint=#NormalColor#
W=150
H=45
X=13
Y=(195 + #Offset#)
MouseOverAction=[!SetOption #CURRENTSECTION# ImageTint #HoverColor#][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# ImageTint #NormalColor#][!UpdateMeter #CURRENTSECTION#][!Redraw]
LeftMouseUpAction="steam://rungameid/824270"
DynamicVariables=1

[MeterKovaaks]
Meter=Image
Group=Sliders
ImagePath=C:\Users\Imort\Documents\Rainmeter\Skins\Dynamic-Objects\@Resources\Images\Icons
ImageName=KovaaksW.png
ImageTint=#NormalColor1#
H=67
X=54
Y=(186 + #Offset#)
MouseOverAction=[!SetOption #CURRENTSECTION# ImageTint #HoverColor#][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseLeaveAction=[!SetOption #CURRENTSECTION# ImageTint #NormalColor1#][!UpdateMeter #CURRENTSECTION#][!Redraw]
AntiAlias=1
DynamicVariables=1
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Confusion with ActionTimer and IfCondition

Post by Yincognito »

BrrDoesRainmeter wrote: August 24th, 2020, 9:34 am Not sure if I should make a new post about this but I had another question regarding the code im working on. I think I got the hang of the ActionTimer plugin (At least enough for this skin :D) and the variables I'm trying to change are working great; but now I'm running into another problem. The behavior I'm attempting to create is when moused over, the box expands and reveals icons that fade in. If the icons are moused over, the opacity value increases to indicate that it's "highlighted." When the mouse leaves the box, the icons dissapear. This all works but only if I've moused over the icon and image at least once. Otherwise the variables change but thats not reflected in the meters.

This is what I'm workin with :D (thanks in advance)

P.S. Any help with reducing CPU usage would be marvelous but not required
This will do the job:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
U=[!UpdateMeasureGroup Sliders][!UpdateMeterGroup Sliders][!Redraw]
H=2
W=10
Offset=-190
SlideAmount=10
NormalColor=255,255,255,[#Alpha]
NormalColor1=255,255,255,[#Alpha1]
HoverColor=255,255,255,150
HoverColor1=255,255,255,175
PalletColor=45,32,228,255
Alpha=1
Alpha1=1
FadeAmt=5
FadeAmt1=6.25

[MeasureSlider]
Measure=Plugin
Plugin=ActionTimer
Group=Sliders
ActionList1=Repeat Open,#W#,20 | Wait 5 | EnableHover
ActionList2=DisableHover | Wait 5 | Repeat Close,#W#,20
Open=[!SetVariable Offset "(Clamp(#Offset#+#SlideAmount#,-190,0))"][!SetVariable Alpha "(Clamp(#Alpha#+#FadeAmt#,1,100))"][!SetVariable Alpha1 "(Clamp(#Alpha1#+#FadeAmt1#,1,125))"]#U#
EnableHover=[!SetOption MeterKovaaksContainer MeterStyle StyleMouseActions][!SetOption MeterKovaaks MeterStyle StyleMouseActions1]
Close=[!SetVariable Offset "(Clamp(#Offset#-#SlideAmount#,-190,0))"][!SetVariable Alpha "(Clamp(#Alpha#-#FadeAmt#,1,100))"][!SetVariable Alpha1 "(Clamp(#Alpha1#-#FadeAmt1#,1,125))"]#U#
DisableHover=[!SetOption MeterKovaaksContainer MeterStyle ""][!SetOption MeterKovaaks MeterStyle ""]
DynamicVariables=1

[StyleMouseActions]
MouseOverAction=[!SetOption #CURRENTSECTION# ImageTint #HoverColor#]#U#
MouseLeaveAction=[!SetOption #CURRENTSECTION# ImageTint #*NormalColor*#]#U#

[StyleMouseActions1]
MouseOverAction=[!SetOption #CURRENTSECTION# ImageTint #HoverColor1#]#U#
MouseLeaveAction=[!SetOption #CURRENTSECTION# ImageTint #*NormalColor1*#]#U#

[MeterPanel]
Meter=Image
Group=Sliders
Y=(0 + #Offset#)
W=176
H=250
SolidColor=#PalletColor#
MouseOverAction=[!CommandMeasure MeasureSlider "Stop 2"][!CommandMeasure MeasureSlider "Execute 1"]
MouseLeaveAction=[!CommandMeasure MeasureSlider "Stop 1"][!CommandMeasure MeasureSlider "Execute 2"]
DynamicVariables=1

[MeterKovaaksContainer]
Meter=Image
Group=Sliders
ImagePath=C:\Users\Imort\Documents\Rainmeter\Skins\Dynamic-Objects\@Resources\Images\Icons
ImageName=BackgroundIcon.png
ImageTint=#NormalColor#
W=150
H=45
X=13
Y=(195 + #Offset#)
LeftMouseUpAction="steam://rungameid/824270"
DynamicVariables=1

[MeterKovaaks]
Meter=Image
Group=Sliders
ImagePath=C:\Users\Imort\Documents\Rainmeter\Skins\Dynamic-Objects\@Resources\Images\Icons
ImageName=KovaaksW.png
ImageTint=#NormalColor1#
H=67
X=54
Y=(186 + #Offset#)
AntiAlias=1
DynamicVariables=1
So, you didn't quite get the hang of the ActionTimer plugin ... yet. :D You added lots of needless actions and conditions that didn't do much, instead of writing the things you wanted to happen at the same time in the same actions, like above (e.g. you wanted the slide and the fade to happen at the same time, but only the slide was present in the actions that were triggered by hovering on [MeterPanel] in your original code). You also tried to fix this by adding conditions to the ActionTimer measure, but those happened only when #Offset# was -190 or 0, and not in between, gradually, as you expected. Setting the [MeterPanel]'s mouse actions using !SetOption in the conditions was pointless, when you could just add them directly to the meter instead. And so on. But then, it's fine for a start, don't worry.

To resume what I did:
- added the setting of the fade variables in the Open and Close actions, in order to happen when the slide did
- because of the above, the fade amounts had to be modified, in order to cover the entire fade intervals in 20 steps (aka the number of Open and Close repeats)
- I had to modify the way the Alpha, Alpha1, NormalColor and NormalColor1 were referenced, so that things happen properly. More specifically, I had to use the nested notation for the alpha variables in the [Variables] section (since they were nested into the normal color variables anyway), see nesting variables for details; then, I had to set the normal color variables in their literal form when changing the Tint of the Kovaacs meters, to "postpone" resolving them from the time of setting to the time of actual usage in the mouse actions, see escaping variables for details
- in order to prevent the mouse actions in the Kovaaks meters from being triggered when the slide was not yet complete (as you probably attempted as well, judging by the looks of your original code), I had to create another two actions in the ActionTimer measure, i.e. EnableHover and DisableHover which, instead of changing the value of the mouse actions by using !SetOption (which would have created some complications in escaping the variables, especially those that were already escaped, like the normal color variables mentioned above, even when using magic quotes) did their job by using a "trick" and changing the meters' MeterStyle options (where I moved those mouse actions to), in effect "disabling" and "enabling" them

And that was it. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
BrrDoesRainmeter
Posts: 7
Joined: July 30th, 2020, 10:16 pm

Re: Confusion with ActionTimer and IfCondition

Post by BrrDoesRainmeter »

Wow thanks so much, this is literally exactly the behavior I was looking for. I appreciate all the explaination of what I should have done as well, will definitely help me improve. I'll check out the links posted and go line by line to learn what proper use of the plugin looks like! I was planning on going back through my code once I got it to work to fix the redundancy, but seeing a proper example of that REALLY helps!

Appreciate ya, friend! Will do my best to keep learning :thumbup:
User avatar
Yincognito
Rainmeter Sage
Posts: 7125
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Confusion with ActionTimer and IfCondition

Post by Yincognito »

BrrDoesRainmeter wrote: August 25th, 2020, 3:28 am Wow thanks so much, this is literally exactly the behavior I was looking for. I appreciate all the explaination of what I should have done as well, will definitely help me improve. I'll check out the links posted and go line by line to learn what proper use of the plugin looks like! I was planning on going back through my code once I got it to work to fix the redundancy, but seeing a proper example of that REALLY helps!

Appreciate ya, friend! Will do my best to keep learning :thumbup:
Glad you liked it - looking forward to you learning more and become better day by day. Cheers! ;-)

P.S. Part of the reason why this is exactly what you wanted is because you explained properly what you wanted (or expected to happen) as well as the problems in the first place. That's the first thing someone that helps needs, and it's refreshing to see a clear description of those things. So your code was a little messy, but at least your description of expected behavior and problems was spot on.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth