MattNY177 wrote: ↑
March 27th, 2019, 4:16 pm
I'm trying to come up with the most efficient way to form Meter/Measure combinations, so that string meters can easily reference corresponding measures on a large scale WITHOUT having to type each individual meter's MeasureName option. Where this can get tricky is when you have hundreds of meters, each meter having multiple corresponding measures that can be toggled using !SetOption or !WriteKeyValue to update the MeasureName.
My question is, what is the best practice for setting up these types of relationships? Should I approach every skin as if the Meter name is always the starting point, and every measure name is derived from that by adding a prefix/postfix to the #CURRENTSECTION# variable?
I went down the road you have, and the best way to handle this is stop creating hundreds of measures/meters, and just reuse
a single one (or a couple of them). Now, of course, I don't know the specifics in your case, but generally, if you have repetitive things measured/handled, then you should identify the things that are similar to all of them, create one or more base measure/meters containing the similarities, and then at runtime just adapt that/those measure/meters by tweaking the relevant index/bangs/variables that are subject to change.
Of course, sometimes such tricks are just not possible, as you'd want to get all things in one big measurement/parse because maybe you need all the values to calculate something else, but those are the exceptions. In all the other cases, you'd generally want to measure or display just a part of the whole at a given moment, and this is where the bangs changing the relevant indexes or variables come handy.
To illustrate this, take a look at this little excerpt from a skin I wrote:
Code: Select all
IfTrueAction=[!SetVariable DiskIDPrefix "_"][!SetVariable DiskID [MS_Rainmeter_Counter]][!SetVariable DiskIDPostfix ""]
IfFalseAction=[!SetVariable DiskIDPrefix ""][!SetVariable DiskID [MS_Rainmeter_Counter]][!SetVariable DiskIDPostfix ":"]
Counter=Disk Read Bytes/sec
IfTrueAction=[!SetOption MT_Rainmeter_DiskReadUse Text "Disks Read"][!SetOption MT_Rainmeter_DiskReadUse ToolTipTitle "Disk #DiskID#: [MS_Rainmeter_#DiskID#Used]"][!SetOption MT_Rainmeter_DiskReadUse ToolTipText "Read [MS_Rainmeter_DiskReadRate]Bs"][!SetOption MT_Rainmeter_DiskReadUseValue MeasureName MS_UsageMonitor_DiskReadRateValue]
IfFalseAction=[!SetOption MT_Rainmeter_DiskReadUse Text "#DiskID# Read"][!SetOption MT_Rainmeter_DiskReadUse ToolTipTitle "Disk #DiskID#: [MS_Rainmeter_#DiskID#Used]"][!SetOption MT_Rainmeter_DiskReadUse ToolTipText "Read [MS_Rainmeter_DiskReadRate]Bs"][!SetOption MT_Rainmeter_DiskReadUseValue MeasureName MS_Rainmeter_DiskUsedValue]
MeterStyle=SCell | STitleColText
MouseScrollUpAction=[!SetOption MS_Rainmeter_Counter Formula ((MS_Rainmeter_Counter<=(0))?(24):(MS_Rainmeter_Counter-1))][!UpdateMeasureGroup "DiskGroup"][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetOption MS_Rainmeter_Counter Formula ((MS_Rainmeter_Counter>=(24))?(0):(MS_Rainmeter_Counter+1))][!UpdateMeasureGroup "DiskGroup"][!UpdateMeter *][!Redraw]
MeterStyle=SCell | SPrimaryColText
This is adapted and cut off from the main skin, so it won't work, but what it does is reuse
a single [MS_UsageMonitor_DiskReadRate]
measure to measure the read rate of any of the 25 possible drives (i.e._Total
, plus C:
, etc.), by using bangs to change variables like #DiskIDPrefix#
on mouse scroll, variables that are also used to set the relevant Name
option of the [MS_UsageMonitor_DiskReadRate]
measure in order to measure the previous or the next drive read rates. Bottom line, instead of creating 25 measures and meters to handle each drive individually, I only work with 2 or 3 that will dynamically change their "index-like" option on demand, to measure the desired drive.
This way of approaching things made my skins span on just a couple of pages instead of tens and tens of pages, simplified the process and the readability, probably improved performance a little bit (since I'm only measuring one thing instead of 25 things) and overall made it easier for me to work on my skins. Sure, there will be some long bang rows in the process, but it's just a row, not lots of pages.
One other thing you could do to make things easier is to use the regex search/replace function in Notepad++, on the whole document or just the selected text (if you're not doing it already, that is). That helps a lot in changing lots of text according to the desired pattern, and it only takes a couple of seconds, if you build your regexes properly.