It is currently September 29th, 2022, 5:48 pm

Set value of every variable in a skin/section?

Get help with creating, editing & fixing problems with skins
Hylia
Posts: 2
Joined: September 20th, 2022, 12:57 am

Set value of every variable in a skin/section?

Post by Hylia »

I feel like what I'm struggling with is either impossible or stupidly easy. Basically, I am making a skin with customizable color settings, with many individual elements/meters to set the colors of. I'm trying to store the color data in a separate .inc file, with a variable for each meter. I also want to implement a setting to let the user set every key to the same color at once, but I've run into a snag. Each individual variable defaults to point to the same "BaseColor" variable, but is changed to its own rgb value when it is customized. I'd like to make a button which, basically, resets every variable back to point to the BaseColor variable, but I can't figure out how. Is there a way to do this, or should I be rethinking how this process works?
User avatar
balala
Rainmeter Sage
Posts: 14566
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Set value of every variable in a skin/section?

Post by balala »

Hylia wrote: September 20th, 2022, 1:34 am I feel like what I'm struggling with is either impossible or stupidly easy. Basically, I am making a skin with customizable color settings, with many individual elements/meters to set the colors of. I'm trying to store the color data in a separate .inc file, with a variable for each meter. I also want to implement a setting to let the user set every key to the same color at once, but I've run into a snag. Each individual variable defaults to point to the same "BaseColor" variable, but is changed to its own rgb value when it is customized. I'd like to make a button which, basically, resets every variable back to point to the BaseColor variable, but I can't figure out how. Is there a way to do this, or should I be rethinking how this process works?
Hard to follow without a code, however what I think is you should have to a !SetVariable bang for every color. Something like this: LeftMouseUpAction=[!SetVariable Color1 "#BaseColor#"][!SetVariable Color2 "#BaseColor#"]...[!SetVariable ColorN "#BaseColor#"][!UpdateMeter *][!Redraw]. Obviously in order this to work, the meters have to have the color set to the proper variables, for instance [Meter1] has to have for example the SolidColor set to SolidColor=#Color1#, [Meter2] to SolidColor=#Color2# and so on.
Doesn't this work? Make sure you have a DynamicVariables=1 option set on every meter which you'd like to set the color on.
If I misunderstood something and you have a different code, please post a code / sample of the code.
Hylia
Posts: 2
Joined: September 20th, 2022, 12:57 am

Re: Set value of every variable in a skin/section?

Post by Hylia »

That sorta answers my question actually. I was wondering if there were a more dynamic way to achieve the code you wrote out, but at this point I'm guessing there isn't. The skin I'm trying to create is basically a customizable keypad map, where the user will be able to customize the number and layout of keys to a theoretically limitless degree. That would mean a basically limitless number of individual color variables to be kept track of and reset. I had hoped to find a way to tell rainmeter to just deal with every variable at once without having to spell out what that means, so I could write something like

Code: Select all

[!WriteAllVariables Variables #BaseColor# "#CURRENTPATH#\Profiles\#CurrentProfile#\Colors.inc"]
instead of having to write out

Code: Select all

[!WriteKeyVariable Color1, Color2, Color3...]
etc. If thats not something rainmeter can do though, I could just cap the number of each type of key at like 255 and keep the command measure to write them all in its own .inc file so as to not clutter up the main color picking .ini file. I was basically trying to avoid the massive tedium of doing it this way by writing one line of code as opposed to potentially over 1,000 but such is life haha.
User avatar
balala
Rainmeter Sage
Posts: 14566
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Set value of every variable in a skin/section?

Post by balala »

Hylia wrote: September 21st, 2022, 5:33 pm so I could write something like

Code: Select all

[!WriteAllVariables Variables #BaseColor# "#CURRENTPATH#\Profiles\#CurrentProfile#\Colors.inc"]
A !WriteAllVariables bangs doesn't exist. I assume you wanted to write repeated !WriteKeyValue, right?
Hylia wrote: September 21st, 2022, 5:33 pm That sorta answers my question actually. I was wondering if there were a more dynamic way to achieve the code you wrote out, but at this point I'm guessing there isn't.
Even if there might be some ways to "dynamically" set those variables, a limitless such action is hard to be implemented in Rainmeter. A way to do something like this is to create an ActionTimer plugin measure, which should count from 1 up to the highest index and for each count, it should execute the appropriate action, setting the variable. Even if this probably is not something what couldn't be done, it's not widely used in Rainmeter (I know I'll get some disapproval again, but I still sustain: Rainmeter is not a procedural programming language and as such, many of techniques used into a programming language, can't be used or at least can be extremely hardly).
However, you might try something like this:

Code: Select all

[Variables]
Num=0
NumOfVars=ADD-HERE-THE-NUMBER-OF-VARIABLES

[MeasureSetVariables]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat SetAction,50,#NumOfVars#
SetAction=[!SetVariable Color#Num# "#BaseColor#"][!SetVariable Num "(#Num#+1)"][!UpdateMeasure "MeasureSetVariables"]
DynamicVariables=1
To get this measure executed and the variables set, you need a for instance LeftMouseUpAction option on the meter which you want to use as the button like this: LeftMouseUpAction=[!CommandMeasure "MeasureSetVariable" "Execute 1"]. Also note that you have to add the number of variables (and appropriately number of executions of the SetAction option) into the [Variables] section as the NumOfVars variable (for instance if you set the NumOfVars to NumOfVars=10, you'll get set the Color1 - Color10 variables, not more, not less.
It's recommended to add further bangs to the SetAction option, to update the meter(s) which uses the variables. Not knowing the code, I can1T say exactly what bang should you use, but most probably some !UpdateMeter bangs, along with a !Redraw. You also can play with the Wait time of the ActionList1 option, the 50, which is the time passing between two consecutive executions of the SetAction option and is expressed into milliseconds.
If you can't realize what did I describe above (it's definitely not extremely wasy), please come back with your questions.