It is currently April 24th, 2024, 2:23 pm

hide image on disconnect

Get help with creating, editing & fixing problems with skins
simzy
Posts: 6
Joined: December 17th, 2018, 12:08 am

hide image on disconnect

Post by simzy »

So i am trying to make a skin so that will show upon connection of xbox controller and hides on disconnect but will also change the icon depending on whether battery is above or below 50% but i am at a loss, i am using XInput dll posted here

Code: Select all

[Rainmeter]
Author=Simzy
Update=10
AccurateText=1
BackgroundMode=3
;Background=#@#Background.png

;~~~~[Variables]~~~~;

[Variables]
FontName=Ubuntu
FontColor=160,32,240
FontSize=10

;~~~[Measure]~~~;

[measureController0Connect]
Measure=Plugin
Plugin=XInput.dll
Device=0
Channel=Connected

[measureController0Battery]
Measure=Plugin
Plugin=XInput.dll
Device=0
Channel=Battery_Pad

;~~~[Meter]~~~;

[meterController0Connect]
Meter=String
StringAlign=Center
IfCondition=measureController0Connect = 1
IfTrueAction=!Execute [!ShowMeter [meterController0Connect] [!UpdateMeter *] [!Redraw]
IfFalseAction=!Execute [!HideMeter [meterController0Connect] [!UpdateMeter *] [!Redraw]

[meterController0Battery]
Meter=String
StringAlign=Center
IfCondition=measureController0Battery = 0.33
IfTrueAction=!Execute [!ShowMeter "msadbattery"] [!UpdateMeter *] [!Redraw]
IfCondition2=(measureController0Battery >= 0.50) && (measureController0Battery <= 1)
IfTrueAction2=!Execute [!ShowMeter "mhappybattery"] [!UpdateMeter *] [!Redraw]


[mhappybattery]
Meter=Image
ImageName=#@#battery_happy.png
H=117
W=160

[msadbattery]
Meter=Image
ImageName=#@#battery_sad.png
H=117
W=160
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: hide image on disconnect

Post by mak_kawa »

IfCondition syntax can not be placed in meters. Instead, it should be placed in measures to work.
User avatar
balala
Rainmeter Sage
Posts: 16164
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: hide image on disconnect

Post by balala »

mak_kawa wrote: April 6th, 2019, 3:52 am IfCondition syntax can not be placed in meters. Instead, it should be placed in measures to work.
Yes, mak_kawa is right here. You have to move the IfConditons into measures. For example:

Code: Select all

[Rainmeter]
Author=Simzy
Update=10
AccurateText=1
BackgroundMode=3
;Background=#@#Background.png

;~~~~[Variables]~~~~;

[Variables]
FontName=Ubuntu
FontColor=160,32,240
FontSize=10

;~~~[Measure]~~~;

[measureController0Connect]
Measure=Plugin
Plugin=XInput.dll
Device=0
Channel=Connected
IfCondition=measureController0Connect = 1
IfTrueAction=[!ShowMeter "meterController0Connect"][!Redraw]
IfFalseAction=[!HideMeter "meterController0Connect"][!Redraw]

[measureController0Battery]
Measure=Plugin
Plugin=XInput.dll
Device=0
Channel=Battery_Pad
IfCondition=measureController0Battery = 0.33
IfTrueAction=[!ShowMeter "msadbattery"][!Redraw]
IfCondition2=(measureController0Battery >= 0.50) && (measureController0Battery <= 1)
IfTrueAction2=[!ShowMeter "mhappybattery"][!Redraw]

;~~~[Meter]~~~;

[meterController0Connect]
Meter=String
StringAlign=Center

[meterController0Battery]
Meter=String
StringAlign=Center

[mhappybattery]
Meter=Image
ImageName=#@#battery_happy.png
H=117
W=160

[msadbattery]
Meter=Image
ImageName=#@#battery_sad.png
H=117
W=160
Note the followings:
  • I moved the IfConditions from the [meterController0Connect] and [meterController0Battery] meters to the [measureController0Connect] and [measureController0Battery] measures.
  • The IfConditions placed into the [measureController0Battery] measure don't cover the whole range of the domain. IfCondition is true if the measure gets the 0.33 value, while IfCondition2 for values above 0.5. What should go on for other values (below 0.5, excepting 0.33)?
  • !Execute is a deprecated bang. Don't use it.
  • Although once the Author option belonged to the [Rainmeter] section, a while ago it was moved to [Metadata]. You also should have to move it.
  • Update=10? Why? Don't use a such small value. In fact the smallest possible value is 16 (Note here), but not even this isn't needed. I think the default Update=1000 is the best choice in this case (unless your skin has some not posted parts, which requires a such small Update). I'd probably replace this.
simzy
Posts: 6
Joined: December 17th, 2018, 12:08 am

Re: hide image on disconnect

Post by simzy »

the only values that would change apart from the connect and disconnect would be 0.33, 0.50, 0.75 and 1.0 for the battery level but i only want two images for above 50 and below 50, my biggest issue is making the skin hide when i disconnect my controller. I am basing the commands around this https://forum.rainmeter.net/viewtopic.php?f=128&t=20108&hilit=xinput
User avatar
balala
Rainmeter Sage
Posts: 16164
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: hide image on disconnect

Post by balala »

simzy wrote: April 6th, 2019, 1:15 pm the only values that would change apart from the connect and disconnect would be 0.33, 0.50, 0.75 and 1.0 for the battery level but i only want two images for above 50 and below 50, my biggest issue is making the skin hide when i disconnect my controller. I am basing the commands around this https://forum.rainmeter.net/viewtopic.php?f=128&t=20108&hilit=xinput
I don't know that plugin and can't even try it out, because I'm not using XBox, but if only those values are involved, the IfCondition can be modified this way:

Code: Select all

[measureController0Battery]
...
IfCondition=(measureController0Battery>=0.50)
IfTrueAction=[!ShowMeter "mhappybattery"][!Redraw]
IfFalseAction=[!ShowMeter "msadbattery"][!Redraw]
There probably some !HideMeter bangs also would be required (I suppose):

Code: Select all

[measureController0Battery]
...
IfCondition=(measureController0Battery>=0.50)
IfTrueAction=[!ShowMeter "mhappybattery"][!HideMeter "msadbattery"][!Redraw]
IfFalseAction=[!ShowMeter "msadbattery"][!HideMeter "mhappybattery"][!Redraw]