It is currently April 27th, 2024, 1:54 am

Meter Bar change based on IfCondition

Get help with creating, editing & fixing problems with skins
Mo0mZseventysix
Posts: 3
Joined: February 12th, 2023, 4:01 pm

Meter Bar change based on IfCondition

Post by Mo0mZseventysix »

Hello all, thanks in advance for your time and assistance! I will try my best to explain myself...

I'm making a battery skin with the meter bar inside a .png frame that makes it look like a hitpoints meter. It worked perfect when it was just straight up one meter bar simply relaying battery power. The trouble presented itself when I tried to get it to change to a different bar (a brighter red) using a second .png. As you can see below I tried to use an IfCondition/IfTrueAction command so when running on battery power its the first .png and when it's plugged in the meter shows the second .png.

I am not showing an error in the log when I refresh so I am at a loss.

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

[Metadata]
Name=Hitpoints Battery
Author=
Information=
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0


[MeasureBattery]
Measure=Plugin
Plugin=Plugins\PowerPlugin.dll
PowerState=PERCENT

[MeasurePower]
Measure=Plugin
Plugin=PowerPlugin
PowerState=ACLine
MeasureName=MeasurePower
IfCondition=(MeasurePower=0)
IfTrueAction=[!ShowMeter "MeterPowerBar"][!HideMeter "MeterPowerBar2"][!Redraw]
IfCondition2=(MeasurePower=1)
IfTrueAction=[!ShowMeter "MeterPowerBar2"][!HideMeter "MeterPowerBar"][!Redraw]


[MeterBatteryFrame]
Meter=IMAGE
ImageName=#@#powerbar
X=0
Y=0

[MeterPowerBar]
Meter=BAR
BarImage=#@#red power bar
MeasureName=MeasurePower
X=0
Y=0
BarOrientation=Horizontal
H=100
W=100

[MeterPowerBar2]
Meter=BAR
BarImage=#@#chargingredpowerbar
MeasureName=MeasurePower
X=0
Y=0
BarOrientation=Horizontal
H=100
W=100
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5407
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Meter Bar change based on IfCondition

Post by eclectic-tech »

I am not using a laptop with a battery, but I noticed a few things you can change:

Remove MeasureName=MeasurePower from the [MeasurePower] section, not a valid option.

Change both measure names in your bar meters ( [MeterPowerBar] and [MeterPowerBar2] ) to MeasureName=MeasureBattery so they show the battery percent, not the 1 or 0 values of the power plugin measure.

If you are still having issues, please post a package rmskin so we have the code an images to test.
User avatar
balala
Rainmeter Sage
Posts: 16174
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Meter Bar change based on IfCondition

Post by balala »

Mo0mZseventysix wrote: February 20th, 2023, 5:46 pm I'm making a battery skin with the meter bar inside a .png frame that makes it look like a hitpoints meter. It worked perfect when it was just straight up one meter bar simply relaying battery power. The trouble presented itself when I tried to get it to change to a different bar (a brighter red) using a second .png. As you can see below I tried to use an IfCondition/IfTrueAction command so when running on battery power its the first .png and when it's plugged in the meter shows the second .png.

I am not showing an error in the log when I refresh so I am at a loss.
There is a small mistake in the [MeasurePower] measure: there are two IfTrueAction options and this is not alowed. Number the second occurrance of this option: IfTrueAction=[!ShowMeter "MeterPowerBar2"][!HideMeter "MeterPowerBar"][!Redraw] has to be IfTrueAction2=[!ShowMeter "MeterPowerBar2"][!HideMeter "MeterPowerBar"][!Redraw]
Mo0mZseventysix
Posts: 3
Joined: February 12th, 2023, 4:01 pm

Re: Meter Bar change based on IfCondition

Post by Mo0mZseventysix »

Thank you both for the assistance. I made the suggested changes and it works fine when the laptop is unplugged but as soon as I plug in the AC the frame shoots up into the top left hand corner, empty of the power bar and frozen in place, while the second power bar (the one indicating that it is plugged in) is frozen in the middle of my desktop.

I have attached a rmskin as requested to show you what I mean
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16174
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Meter Bar change based on IfCondition

Post by balala »

Mo0mZseventysix wrote: February 20th, 2023, 10:57 pm Thank you both for the assistance. I made the suggested changes and it works fine when the laptop is unplugged but as soon as I plug in the AC the frame shoots up into the top left hand corner, empty of the power bar and frozen in place, while the second power bar (the one indicating that it is plugged in) is frozen in the middle of my desktop.
There is a problem with the @Resources\chargingredpowerbar.png image: its size is 1920 x 1080 pixels, which is equal to the resolution of my screen and most probably yours as well. There is a huge transparent surface around the image which is placed into the center of it. The @Resources\redpowerbar.png image, used by the [MeterPowerBar] meter, isn't so large, its size being 766 x 88 pixels. It also has small transparent region around the dark red rectangle, but that's not too large. This is why the two bars act differently. Take into account the following as well:
By default the skins are set to be kept on screen (if you right click a skin and you go to Settings, in the submenu there is checked the Keep on screen setting). Skins having this setting are kept on screen, you can't drag them to go partially outside of the screen. Due to the position of the two meters in your skin ([MeterBatteryFrame] and [MeterPowerBar2] are almost on the same position) and the above mentioned large transparent area of the @Resources\chargingredpowerbar.png image (used by the [MeterPowerBar2] meter), you see this meter not in place.
You can fix this issue by:
  • Removing the transparent area from both images used by the two meters ([MeterPowerBar] and [MeterPowerBar2]).
  • Resize one (or both) images, to get them with same size.
  • Realign the meters of your skin.
If you don't exactly know how to achieve this, for first please do the image processing (removing of transparent areas and resizing the images). If they are ready, post back the resulted images and I'm gonna help you with realigning the meters in a proper way (assuming you don't exactly know how to do this).
Mo0mZseventysix
Posts: 3
Joined: February 12th, 2023, 4:01 pm

Re: Meter Bar change based on IfCondition

Post by Mo0mZseventysix »

Problem resolved. I followed your suggestions to the letter and it works exactly as desired. Thank you so very much for your help.
User avatar
balala
Rainmeter Sage
Posts: 16174
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Meter Bar change based on IfCondition

Post by balala »

Mo0mZseventysix wrote: February 23rd, 2023, 3:14 am Problem resolved. I followed your suggestions to the letter and it works exactly as desired.
Great! Glad you got it working.