It is currently March 29th, 2024, 1:47 am

Images overlapping instead of showing on correct condition

Get help with creating, editing & fixing problems with skins
FlatulentFish
Posts: 3
Joined: February 19th, 2021, 4:55 am

Images overlapping instead of showing on correct condition

Post by FlatulentFish »

Hey all,

So I'm fairly new to how rainmeter works on the back end and have been doing a lot of reading to try and figure this out myself but I just can't seem to get it doing what I want it to.

I found a very old skin that is a simple battery meter for my xbox controller using the xinput plugin, and I noticed that when the battery drops its levels to the thresholds the image doesn't update, instead I realised that they are actually overlapping each other.

No matter what I've tried seems to get it to work, any help would be super appreciated!

Code: Select all

;~~~[Measure]~~~;

[measureController0Connect]
Measure=Plugin
Plugin=XInput.dll
Channel=Connected
IfCondition=measureController0Connect = 1
IfTrueAction=[!RainmeterShowFade][!Redraw]
IfFalseAction=[!RainmeterHideFade][!Redraw]

[measureController0Battery]
Measure=Plugin
Plugin=XInput.dll
Channel=Battery_Pad
IfCondition=measureController0Battery = 0.33
IfTrueAction=[!ShowMeter mbatlow][!HideMeter mbatmid][!HideMeter mbatfull][!Redraw]
IfCondition2=measureController0Battery = 0.50
IfTrueAction2=[!ShowMeter mbatmid][!HideMeter mbatlow][!HideMeter mbatfull][!Redraw]
IfCondition3=measureController0Battery =0.75
IfTrueAction3=[!ShowMeter mbatfull][!HideMeter mbatlow][!HideMeter mbatmid][!Redraw]
Update=30

;~~~[Meter]~~~;

[mbatfull]
Meter=Image
ImageName=#@#batfull.png
W=45
H=25

[mbatmid]
Meter=Image
ImageName=#@#batmid.png
W=45
H=25

[mbatlow]
Meter=Image
ImageName=#@#batlow.png
W=45
H=25

[mbatempty]
Meter=Image
ImageName=#@#batempty.png
W=45
H=25
FlatulentFish
Posts: 3
Joined: February 19th, 2021, 4:55 am

Re: Images overlapping instead of showing on correct condition

Post by FlatulentFish »

Whelp I decided to try making it work as a string/bar meter instead and that seemed to work perfectly.

Unsure why I didn't try that from the start but here we are I guess, I prefer how it looks since it matches the rest of my suite perfectly but knowing why the image part didn't work will help me understand rainmeter a bit more I think.

If anyone is interested the code is:

Code: Select all

[Metadata]
Name=Controller Battery Bar
Author=FlatulentFish
Credits=StArL0rd84, simzy and Rasylver

[Variables]
FontName=VCR OSD Mono
FontName2=VCR OSD Mono
FontColor=255, 255, 255, 160
FontHeight=12
AntiAlias=1

[measureXInput_Connect]
Measure=Plugin
Plugin=XInput
Channel=Connected
IfCondition=measureXInput_Connect = 1
IfTrueAction=[!RainmeterShowFade][!Redraw]
IfFalseAction=[!RainmeterHideFade][!Redraw]

[measureXInput_Battery]
Measure=Plugin
Plugin=XInput
Channel=Battery_Pad

[meterBattery2]
Meter=bar
MeasureName=measureXInput_Battery
BarColor=255,255,255,255
SolidColor=255, 255, 255, 50
X=10
Y=25
W=180
H=5
BarOrientation=HORIZONTAL

[MeterPercent]
Meter=STRING
MeasureName=measureXInput_Battery
StringAlign=RIGHT
X=195
Y=40
FontColor=#FontColor#
FontSize=#FontHeight#
FontFace=#FontName2#
AntiAlias=1
Text="%1%"
Percentual=1
AutoScale=1

[MeterLabel]
Meter=STRING
Text="XBOX ELITE V2 POWER"
X=7
Y=0
FontColor=#FontColor#
FontSize=#FontHeight#
FontFace=#FontName#
AntiAlias=1
Image

Is what the whole suite looks like if anyone was also interested in that.

All credits go to StArL0rd84 and simzy on these forums for posting their skins/code and to Rasylver for Lines 2.0 since thats what I based the look off.
User avatar
CodeCode
Posts: 1363
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Images overlapping instead of showing on correct condition

Post by CodeCode »

Using ifconditions work smoother with a range applied to their parameters, something similar to this:

Code: Select all

IfCondition=(measureController0Battery >= 0.01 && measureController0Battery >= 0.33)
IfTrueAction=[!ShowMeter mbatlow][!HideMeter mbatmid][!HideMeter mbatfull][!Redraw]
IfCondition2=(measureController0Battery >= 0.34 && measureController0Battery <= 0.74)
IfTrueAction2=[!ShowMeter mbatmid][!HideMeter mbatlow][!HideMeter mbatfull][!Redraw]
IfCondition3=(measureController0Battery >=0.75 && measureController0Battery <= 0.99)
IfTrueAction3=[!ShowMeter mbatfull][!HideMeter mbatlow][!HideMeter mbatmid][!Redraw]
have not tested it but that is the gist.

However, the percentile bar meter is even better since it visualizes the entire range rather than fixed percentiles.
ƈǟռ'ȶ ʄɨӼ ɨȶ ɨʄ ɨȶ ǟɨռ'ȶ ɮʀօӄɛ - ʊռʟɛֆֆ ɨȶ ɨֆ ɨռ ƈօɖɛ.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Images overlapping instead of showing on correct condition

Post by balala »

CodeCode wrote: February 19th, 2021, 8:44 am Using ifconditions work smoother with a range applied to their parameters, something similar to this:

Code: Select all

IfCondition=(measureController0Battery >= 0.01 && measureController0Battery >= 0.33)
IfTrueAction=[!ShowMeter mbatlow][!HideMeter mbatmid][!HideMeter mbatfull][!Redraw]
IfCondition2=(measureController0Battery >= 0.34 && measureController0Battery <= 0.74)
IfTrueAction2=[!ShowMeter mbatmid][!HideMeter mbatlow][!HideMeter mbatfull][!Redraw]
IfCondition3=(measureController0Battery >=0.75 && measureController0Battery <= 0.99)
IfTrueAction3=[!ShowMeter mbatfull][!HideMeter mbatlow][!HideMeter mbatmid][!Redraw]
There is small mistake in the above IfCondition option, related to the second inequality (IfCondition=(measureController0Battery >= 0.01 && measureController0Battery >= 0.33)). It probably should be IfCondition=(measureController0Battery >= 0.01 && measureController0Battery <= 0.33).
But I think the conditions in the posted form are too complicated. I'd propose the following conditions:

Code: Select all

IfCondition=(measureController0Battery<0.34)
...
IfCondition2=((measureController0Battery>=0.34)&&(measureController0Battery<0.74))
...
IfCondition3=(measureController0Battery>=0.74)
...
No need to check if the measure value is above or equal to 0.01, respectivelly below or equal to 0.99, because these conditions I suppose are always true (however I admit I didn't check, because I don't have installed the XInput plugin).
I also added some extra parenthesys to the IfCondition2, but this is just one of my habits, which I always apply.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Images overlapping instead of showing on correct condition

Post by jsmorley »

To be clear, any use of the logical operators && (AND) or || (OR) require that the tests on the left and right of the operator be enclosed in (parentheses).

IfCondition=(MeasureOne >= 5) && (MeasureOne < 10)

https://docs.rainmeter.net/manual/formulas/#Logical
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Images overlapping instead of showing on correct condition

Post by balala »

jsmorley wrote: February 19th, 2021, 12:59 pm To be clear, any use of the logical operators && (AND) or || (OR) require that the tests on the left and right of the operator be enclosed in (parentheses).

IfCondition=(MeasureOne >= 5) && (MeasureOne < 10)
Yep, I knew about this, but missed it for a moment when posted my reply.
However there is something interesting I just realized now: if the parentheses are missing, it seem that always the second condition is evalueated. For instance:

Code: Select all

[MyMeasure]
Measure=Calc
Formula=( MyMeasure + 1 )
IfCondition=(MyMeasure>10)
IfTrueAction=[!SetOption MyMeter FontColor "255,0,0"][!UpdateMeter "MyMeter"][!Redraw]
IfCondition2=((MyMeasure>10)&&(MyMeasure<=10))
IfTrueAction2=[!SetOption MyMeter FontColor "0,255,0"][!UpdateMeter "MyMeter"][!Redraw]

[MyMeter]
Meter=STRING
MeasureName=MyMeasure
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
FontEffectColor=0,0,0
StringEffect=Shadow
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=%1
As you can see the conditions used into the IfCondition2 option of [MyMeasure] are correctly enclosed into parentheses and accordingly the option is working well. The condition is always false so the color of [MyMeter] is never set to green, the string remaining white up to 10, when, according to the IfTrueAction, it turns red. But if I remove the parentheses around the conditions stauated into IfCondition2 (IfCondition2=(MyMeasure>10&&MyMeasure<=10)), the condition becomes true at the very first moment after refreshing / loading the skin and the string is set to green. When the measure goes above 10 the color is set to red, according to the bangs of IfTrueAction (IfCondition becoming true) and it stays so. My guess is that if the conditions are not enclosed into parentheses, the second condition is evaluated. Is this correct?
FlatulentFish
Posts: 3
Joined: February 19th, 2021, 4:55 am

Re: Images overlapping instead of showing on correct condition

Post by FlatulentFish »

Thanks everyone for the replies!

I read through it all and managed to get the picture one working! But yeah as you said the percentage string is more accurate and I think it suits my overall theme better