It is currently May 2nd, 2024, 4:56 am

Month Progress Bar

Get help with creating, editing & fixing problems with skins
pclman
Posts: 4
Joined: September 27th, 2012, 1:06 am

Month Progress Bar

Post by pclman »

I am trying to make a progress bar that will show the progression of time in a month; that is, it will show how far through the month we are. I have:

Code: Select all

[mMonth]
Measure=Time
Format=%#m
Substitute="1":"31","2":"28","3":"31","4":"30","5":"31","6":"30","7":"31","8":"31","9":"30","10":"31","11":"30","12":"31"


[MeterProgressBar]
Meter=BAR
MeasureName=mMonth
X=1
Y=R
H=30
BarImage=Bar.png
BarOrientation=Horizontal


[MeterBackground]
Meter=IMAGE
ImageName=BG1.png
x=0
y=r
AntiAlias=1

Unfortunately, it doesn't work. The bar is always full, even though it is not yet the end of the month. I believe I may be misunderstanding the progress bar syntax; I am quite new to this. If anyone knows how I would go about fixing it, I would be very grateful.
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Month Progress Bar

Post by Kaelri »

There are two small problems. The first is with your Substitute pattern. Each part of the Substitute is applied cumulatively, which means that the "output" of one part is used as the "input" for the next. So if the month is January (1), then it will do

1 --> "1":"31" --> 31

and then

31 --> "3":"31" --> 311

You can avoid this by including the leading zeroes:

Code: Select all

[mMonth]
Measure=Time
Format=%m
Substitute="01":"31","02":"28","03":"31","04":"30","05":"31","06":"30","07":"31","08":"31","09":"30","10":"31","11":"30","12":"31"
The second problem is that this measure now only provides the total number of days in the current month; your bar has no way of knowing what the current date is. You need to add a second measure that provides the day of the month, and uses the total number as the "max value." Rainmeter then uses both numbers to calculate the progress.

Code: Select all

[MeasureMonthTotal]
Measure=Time
Format=%m
Substitute="01":"31","02":"28","03":"31","04":"30","05":"31","06":"30","07":"31","08":"31","09":"30","10":"31","11":"30","12":"31"

[MeasureMonthCurrent]
Measure=Time
Format=%d
MaxValue=[MeasureMonthTotal]
DynamicVariables=1

[MeterProgressBar]
Meter=BAR
MeasureName=MeasureMonthCurrent
X=1
Y=R
H=30
BarImage=Bar.png
BarOrientation=Horizontal
pclman
Posts: 4
Joined: September 27th, 2012, 1:06 am

Re: Month Progress Bar

Post by pclman »

Thank you so much!
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Month Progress Bar

Post by smurfier »

If you want to account for leap year...

Code: Select all

[MeasureLeap]
Measure=Time
Format=28 + (((((%Y %% 4) = 0) && ((%Y %% 100) <> 0)) || ((%Y %% 400) = 0)) )

[MeasureMonthTotal]
Measure=Time
Format=%m
Substitute="01":"31","03":"31","04":"30","05":"31","06":"30","07":"31","08":"31","09":"30","10":"31","11":"30","12":"31","02":"[MeasureLeap]"
DynamicVariables=1

[MeasureMonthCurrent]
Measure=Time
Format=%d
MaxValue=([MeasureMonthTotal])
DynamicVariables=1

[MeterProgressBar]
Meter=BAR
MeasureName=MeasureMonthCurrent
X=1
Y=R
H=30
W=100
BarImage=Bar.png
BarOrientation=Horizontal
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .