It is currently March 28th, 2024, 12:00 pm

keeping the last setting after refresh or loading skin

Get help with creating, editing & fixing problems with skins
Post Reply
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

keeping the last setting after refresh or loading skin

Post by xenium »

Hi,
I have 3 buttons (s1, s2, s3). Each time they are activated, they display an image (bg1, bg2, bg3).
When the image corresponding to the button is displayed, the respective button is hidden, and remains displayed, the other 2 buttons
I would like the last setting to be kept when refreshing or when loading the skin
For example, if the last setting is to display the bg3 image,this will be displayed after refreshing or loading the skin
At this time, regardless of the last setting, it returns to the first image,bg1

Thank you

This is the code:

Code: Select all

[BG1]
Meter=Image
ImageName=#@#bg1.png
X=0
Y=0
W=210

[BG2]
Meter=Image
ImageName=#@#bg2.png
X=0
Y=0
W=210
Hidden=1

[BG3]
Meter=Image
ImageName=#@#bg3.png
X=0
Y=0
W=210
Hidden=1

[S1]
Meter=IMAGE
ImageName=#@#S1.png
X=180
Y=35
AntiAlias=1
hidden=1
LeftMouseUpAction=[!ShowMeter "BG1"][!HideMeter "BG2"][!HideMeter "BG3"][!HideMeter "S1"][!ShowMeter "S2"][!ShowMeter "S3"]

[S2]
Meter=IMAGE
ImageName=#@#S2.png
X=180
Y=55
AntiAlias=1
LeftMouseUpAction=[!ShowMeter "BG2"][!HideMeter "BG1"][!HideMeter "BG3"][!HideMeter "S2"][!ShowMeter "S1"][!ShowMeter "S3"]

[S3]
Meter=IMAGE
ImageName=#@#S3.png
X=180
Y=75
AntiAlias=1
LeftMouseUpAction=[!ShowMeter "BG3"][!HideMeter "BG1"][!HideMeter "BG2"][!HideMeter "S3"][!ShowMeter "S1"][!ShowMeter "S2"] 
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: keeping the last setting after refresh or loading skin

Post by balala »

xenium wrote:I would like the last setting to be kept when refreshing or when loading the skin
For example, if the last setting is to display the bg3 image,this will be displayed after refreshing or loading the skin
At this time, regardless of the last setting, it returns to the first image,bg1
This is requiring to introduce a variable, which sets what would be visible at a given moment.
Introduce a such variable into the [Variables] section:

Code: Select all

[Variables]
Setting=0
Add a measure (I named it [MeasureSettings]), which through some IfCondition option sets the visible meters:

Code: Select all

[MeasureSettings]
Measure=Calc
Formula=#Setting#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!ShowMeter "BG1"][!HideMeter "BG2"][!HideMeter "BG3"][!HideMeter "S1"][!ShowMeter "S2"][!ShowMeter "S3"]
IfCondition2=(#CURRENTSECTION#=1)
IfTrueAction2=[!ShowMeter "BG2"][!HideMeter "BG1"][!HideMeter "BG3"][!HideMeter "S2"][!ShowMeter "S1"][!ShowMeter "S3"]
IfCondition3=(#CURRENTSECTION#=2)
IfTrueAction3=[!ShowMeter "BG3"][!HideMeter "BG1"][!HideMeter "BG2"][!HideMeter "S3"][!ShowMeter "S1"][!ShowMeter "S2"] 
DynamicVariables=1
Note that which meters are visible depends on the value of the measure.
Now replace the LeftMouseUpAction options of the [S1], [S2] and [S3] meters, as it follows:

Code: Select all

[S1]
Meter=IMAGE
...
LeftMouseUpAction=[!SetVariable Setting "0"][!WriteKeyValue Variables Setting "0"][!UpdateMeasure "MeasureSettings"]

[S2]
Meter=IMAGE
...
LeftMouseUpAction=[!SetVariable Setting "1"][!WriteKeyValue Variables Setting "1"][!UpdateMeasure "MeasureSettings"]

[S3]
Meter=IMAGE
...
LeftMouseUpAction=[!SetVariable Setting "2"][!WriteKeyValue Variables Setting "2"][!UpdateMeasure "MeasureSettings"]
As you can see, each of these meters sets a value for the Setting variable, but this is done in two ways: dynamically (through the !SetVariable bang - this is immediately used by the [MeasureSettings] measure) and the same value is written to the [Variables] section. This newly written value of the variable makes the skin to keep the last setting. After a refresh, the last value of the variable (written by the !WriteKeyValue bang) is reused.
Just note here that if you do all this, you can add a Hidden=1 option to each meter of the skin, those which have to be visible at certain setting will be shown by the [MeasureSettings] measure.
User avatar
xenium
Posts: 841
Joined: January 4th, 2018, 9:52 pm

Re: keeping the last setting after refresh or loading skin

Post by xenium »

balala wrote:This is requiring to introduce a variable, which sets what would be visible at a given moment.
Introduce a such variable into the [Variables] section:

Code: Select all

[Variables]
Setting=0
Add a measure (I named it [MeasureSettings]), which through some IfCondition option sets the visible meters:

Code: Select all

[MeasureSettings]
Measure=Calc
Formula=#Setting#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!ShowMeter "BG1"][!HideMeter "BG2"][!HideMeter "BG3"][!HideMeter "S1"][!ShowMeter "S2"][!ShowMeter "S3"]
IfCondition2=(#CURRENTSECTION#=1)
IfTrueAction2=[!ShowMeter "BG2"][!HideMeter "BG1"][!HideMeter "BG3"][!HideMeter "S2"][!ShowMeter "S1"][!ShowMeter "S3"]
IfCondition3=(#CURRENTSECTION#=2)
IfTrueAction3=[!ShowMeter "BG3"][!HideMeter "BG1"][!HideMeter "BG2"][!HideMeter "S3"][!ShowMeter "S1"][!ShowMeter "S2"] 
DynamicVariables=1
Note that which meters are visible depends on the value of the measure.
Now replace the LeftMouseUpAction options of the [S1], [S2] and [S3] meters, as it follows:

Code: Select all

[S1]
Meter=IMAGE
...
LeftMouseUpAction=[!SetVariable Setting "0"][!WriteKeyValue Variables Setting "0"][!UpdateMeasure "MeasureSettings"]

[S2]
Meter=IMAGE
...
LeftMouseUpAction=[!SetVariable Setting "1"][!WriteKeyValue Variables Setting "1"][!UpdateMeasure "MeasureSettings"]

[S3]
Meter=IMAGE
...
LeftMouseUpAction=[!SetVariable Setting "2"][!WriteKeyValue Variables Setting "2"][!UpdateMeasure "MeasureSettings"]
As you can see, each of these meters sets a value for the Setting variable, but this is done in two ways: dynamically (through the !SetVariable bang - this is immediately used by the [MeasureSettings] measure) and the same value is written to the [Variables] section. This newly written value of the variable makes the skin to keep the last setting. After a refresh, the last value of the variable (written by the !WriteKeyValue bang) is reused.
Just note here that if you do all this, you can add a Hidden=1 option to each meter of the skin, those which have to be visible at certain setting will be shown by the [MeasureSettings] measure.
:17good

Thank you very much ! :bow:
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: keeping the last setting after refresh or loading skin

Post by balala »

Glad to help, if I did.
Post Reply