It is currently March 29th, 2024, 11:01 am

Code Affecting Other Chunks of Code

Get help with creating, editing & fixing problems with skins
CM62
Posts: 15
Joined: June 2nd, 2018, 10:46 pm

Code Affecting Other Chunks of Code

Post by CM62 »

Was working on the previously mentioned project when a silly thought came to me. "Self, what if you could make the visualizer fullscreen for stuff like family parties?" So now, I will be adding this to the project as well, but on the condition that it works (obviously going to be testing it first before adding it). Anywho, to the question: could this be done with a simple "If condition" statement, and then make a "button" that toggles the state of the condition, adding the fullscreen effect as what happens when condition is met? It seems ham-handed, and I lack the programming finesse at the moment to streamline that kind of stuff, but if it works, it works, and it can be tinkered with later. If not (or a better method), is there a different tried-and-true way to go about this? Simple yes or no works. I just want to make sure the logic is sound.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Code Affecting Other Chunks of Code

Post by balala »

CM62 wrote:Anywho, to the question: could this be done with a simple "If condition" statement, and then make a "button" that toggles the state of the condition, adding the fullscreen effect as what happens when condition is met?
I think it could. Have to create a variable within the [Variables] section. Let's name this variable FullScreen:

Code: Select all

[Variables]
FullScreen=0
Now add a simple Calc measure, which will make the needed settings, depending on the value of the FullScreen variable:

Code: Select all

[MeasureFullScreen]
Measure=Calc
Formula=#FullScreen#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=ADD-HERE-THE-BANGS-WHICH-MAKE-THE-SKIN-NOT-FULLSCREEN
IfFalseAction=ADD-HERE-THE-BANGS-WHICH-MAKE-THE-SKIN-FULLSCREEN
DynamicVariables=1
And finally the "button" should have to set the value of the FullScreen variable. It should have to use a following kind of option:

Code: Select all

[MeterButton]
...
LeftMouseUpAction=[!SetVariable FullScreen "(1-#FullScreen#)"][!UpdateMeasure "MeasureFullScreen"][!UpdateMeter "#CURRENTSECTION#"]
DynamicVariables=1
When clicked, this meter sets the value of the FullScreen variable from 0 to 1, or vice-versa, from 1 to 0, depending on its initial value. The IfTrueAction and IfFalseAction options of the [MeasureFullScreen] measure make the needed settings.
CM62
Posts: 15
Joined: June 2nd, 2018, 10:46 pm

Re: Code Affecting Other Chunks of Code

Post by CM62 »

Thanks for the quick reply and the bonus code guides, balala. I'll be sure to get cracking on it as soon as I can!
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Code Affecting Other Chunks of Code

Post by balala »

CM62 wrote:I'll be sure to get cracking on it as soon as I can!
Do so and let me know if it did help.
CM62
Posts: 15
Joined: June 2nd, 2018, 10:46 pm

Re: Code Affecting Other Chunks of Code

Post by CM62 »

Well, the good news is that the images at least show up. The bad news is that I am still miserable at coding, and the bangs are just rubbing salt in. All three images just stack on top of each other, and the mouse changes when I hover over the button, but nothing changes when clicked. I am not quite sure which bang to use or if it is even the right syntax. What I have below is your outlines fleshed out a bit more, minus the bangs working.

Ifcondition coding:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

[Metadata]
Name=FullScreen Alternator
Author=CM62
Information=Test to make a skin fullscreen and revert 
Version=1.0
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0

[Variables]
FullScreen=0

[MeasureFullScreen]
Measure=Calc
Formula=#FullScreen#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!SetOption MeterBig Visible]
IfFalseAction=[!SetOption MeterSmall Visible]
DynamicVariables=1

[MeterBig]
Meter=Image
ImageName=#@#Images\Large.png
X=0
Y=0
H=700
W=700

[MeterSmall]
Meter=Image
ImageName=#@#Images\Small.png
X=0
Y=0
H=200
W=200

[MeterButton]
Meter=Image
ImageName=#@#Images\Button.png
X=0
Y=0
H=100
W=100
LeftMouseUpAction=[!SetVariable FullScreen "(1-#FullScreen#)"][!UpdateMeasure "MeasureFullScreen"][!UpdateMeter "#CURRENTSECTION#"]
DynamicVariables=1
While researching bangs, I tried my hand at the !SetOption in a different code because it looked like a simpler, more stream-lined option, but it came back with the same results as the code above, minus the button image and the mouse changing when it hovers.

!SetOption coding:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

[Metadata]
Name=FullScreen 2
Author=CM62
Information=Second FullScreen Test using SetOption Bang
Version=1
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0

[Variables]

[MeterLarge]
Meter=Image
ImageName=#@#Images\Large.png
X=0
Y=0
W=700
H=700

[MeterSmall]
Meter=Image
ImageName=#@#Images\Small.png
X=0
Y=0
W=200
H=200

[MeterButton]
Meter=Image
Image=[MeterSmall]
DynamicVariables=1
LeftMouseUpAction=!SetOption MeterButton Image [MeterLarge]
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Code Affecting Other Chunks of Code

Post by balala »

There are more issues in your code:
  1. The "Ifcondition coding":
    The !SetOption bangs used in these options are wrong, because as you can see in the description of this bang, it needs at least three parameters: Meter/Measure, Option and Value (and eventually one further, the Config, but I think this doesn't apply in your case). But your bangs have only two parameters:
    CM62 wrote:

    Code: Select all

    [MeasureFullScreen]
    Measure=Calc
    Formula=#FullScreen#
    IfCondition=(#CURRENTSECTION#=0)
    IfTrueAction=[!SetOption MeterBig Visible]
    IfFalseAction=[!SetOption MeterSmall Visible]
    ...
    What I think you wanted to do is to hide / show one or the other meter. If I am right, here is how to deal this:

    Code: Select all

    [MeasureFullScreen]
    Measure=Calc
    Formula=#FullScreen#
    IfCondition=(#CURRENTSECTION#=0)
    IfTrueAction=[!ShowMeter "MeterBig"][!HideMeter "MeterSmall"][!Redraw]
    IfFalseAction=[!ShowMeter "MeterSmall"][!HideMeter "MeterBig"][!Redraw]
    ...
    Instead of setting some Visible options (as you did), to show or hide a meter, you have to use the !ShowMeter and !HideMeter bangs.
    Also note that the three Image meters are placed to the same position: X=0 and Y=0. While this isn't a problem related to [MeterBig] and [MeterSmall] (because anyway just one of them is visible at a time - if I'm not wrong), you probably might want to move the [MeterButton] meter. I'd replace its X and Y options with something like: X=0r and Y=3R. These options are positioning the button relatively to the previous meter.
  2. "!SetOption coding":
    An Image meter doesn't have an Image option, written this way. This option should have to be ImageName. So:
    • The Image option of the [MeterButton] meter should have to be ImageName and its value should have to be not a meter name, but a path of an image file. Replace the Image=[MeterSmall] option with ImageName=#@#Images\Small.png.
    • The LeftMouseUpAction option of the [MeterButton] meter, probably should have to be something like: LeftMouseUpAction=[color=#FF0000][[/color]!SetOption MeterButton Image[color=#FF0000]Name[/color] [color=#FF0000]"#@#Images\Large.png"][/color] (I highlighted here the added / changes parts). Note that beside replacing the Image option name with ImageName and setting the value of this option not to a meter name, but to a concrete image, I also added brackets around the bang. While these aren't absolutely needed, using them seems to be a good practice. With this option, when you click the "button", its image will be changed to Large.png.
CM62
Posts: 15
Joined: June 2nd, 2018, 10:46 pm

Re: Code Affecting Other Chunks of Code

Post by CM62 »

You were correct on the first code. It is now working and can alternate between the two images by clicking on the button, retaining their respective sizes. With the !SetOption code, I changed what you suggested and it turned out to be a one-shot, where small.png worked as a button to change to large.png, but the image size stayed the same as small.png and would not revert.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Code Affecting Other Chunks of Code

Post by balala »

CM62 wrote:I changed what you suggested and it turned out to be a one-shot, where small.png worked as a button to change to large.png, but the image size stayed the same as small.png and would not revert.
Obviously, because there are no bangs to revert it back.
You can do this same way as the first code (using the same Calc measure). Add the appropriate bangs to the IfTrueAction and IfFalseAction options of the [MeasureFullScreen] measure:

Code: Select all

[MeasureFullScreen]
Measure=Calc
Formula=#FullScreen#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!ShowMeter "MeterBig"][!HideMeter "MeterSmall"][!SetOption MeterButton ImageName "#@#Images\Large.png"][!UpdateMeter "MeterButton"][!Redraw]
IfFalseAction=[!ShowMeter "MeterSmall"][!HideMeter "MeterBig"][!SetOption MeterButton ImageName "#@#Images\Small.png"] [!UpdateMeter "MeterButton"][!Redraw]
In this moment you can completely remove the ImageName option of the [MeterButton] meter, because the image is set up by the above newly added bangs.
CM62
Posts: 15
Joined: June 2nd, 2018, 10:46 pm

Re: Code Affecting Other Chunks of Code

Post by CM62 »

So I swapped out the small image with a visualizer (undefinist's VisBubble) that I have already successfully transplanted into another code, yet it does not work in this one. I checked for size, layer order, and all the necessary background files, but it only shows the black background image I gave it. Is it something that is still missing, some more bad coding, or something else? Is it that they are measures that they cannot be toggled on and off, since there is no "!Show/Hide Measure" or are they still considered meters? I figure [sRefresher] is an unnecessary meter to show, but I tested each of the others and they are needed.

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

[Metadata]
Name=FullScreen Alternator
Author=CM62
Information=Test to make a skin fullscreen and revert 
Version=1.0
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0

[Variables]
FullScreen=0

[MeasureFullScreen]
Measure=Calc
Formula=#FullScreen#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!ShowMeter "meterTitle"][!ShowMeter "sFactoryBandMeasures"][!ShowMeter "sFactoryBars"][!ShowMeter "sRefresher"][!ShowMeter "sColor"][!HideMeter "MeterBig"][!Redraw][!UpdateMeasure *]
IfFalseAction=[!ShowMeter "MeterBig"][!HideMeter "meterTitle"][!HideMeter "sFactoryBandMeasures"][!HideMeter "sFactoryBars"][!HideMeter "sRefresher"][!HideMeter "sColor"][!Redraw][!UpdateMeasure *]
DynamicVariables=1

[MeterBig]
Meter=Image
ImageName=#@#Images\Large.png
X=0
Y=0
H=700
W=700

[meterTitle]
Meter=Image
ImageName=#@#Images\Visualizer_Background.png
; Using MeterStyle=styleTitle will basically "copy" the
; contents of the [styleTitle] section here during runtime.
X=0
Y=0
W=250
H=175

[sFactoryBandMeasures]
Measure=Script
ScriptFile=#SCRIPT#Factory.lua
IncFile=#INC#BandMeasures.inc
Number=#NumOfItems#
SectionName=mBand%%
Option0=Measure
Value0=Plugin
Option1=Plugin
Value1=AudioLevel
Option2=Parent
Value2=mAudioOut
Option3=Type
Value3=Band
Option4=BandIdx
Value4={%%+1}
UpdateDivider=-1
@Include=#INC#BandMeasures.inc

[sFactoryBars]
Measure=Script
ScriptFile=#SCRIPT#Factory.lua
IncFile=#INC#Lines.inc
Number=#NumOfItems#
SectionName=%%
Option0=Meter
Value0=Roundline
Option1=MeterStyle
Value1=styleLine
Option2=StartAngle
Value2={#FORMULA_THETA#}
Option3=X
Value3={#Radius#*Cos(#FORMULA_THETA#%(PI*2))+#Radius#+#ExtrudeMax#}
Option4=Y
Value4={#RadiusY#*Sin(#FORMULA_THETA#%(PI*2))+#RadiusY#+#ExtrudeMax#}
Option5=LineLength
Value5=((#FORMULA_AVG#=0)?{#ExtrudeMin#=0?-1:#ExtrudeMin#}:((#FORMULA_AVG#-[mBand%%])*{#Smoothing#}+[mBand%%])*{#ExtrudeMax#-#ExtrudeMin#}+#ExtrudeMin#)
Option6=DynamicVariables
Value6=1
UpdateDivider=-1
@Include=#INC#Lines.inc

; Helper script to always refresh skin twice instead of once
; This is so that it loads the updated .inc files
[sRefresher]
Measure=Script
ScriptFile=#SCRIPT#Refresher.lua
UpdateDivider=-1
Refreshed=0

[sColor]
Measure=Script
ScriptFile=#SCRIPT#Color.lua
UpdateDivider=-1
NumOfItems=#NumOfItems#
Color=#ItemColor#
;C4FB7200:0|C4FB72cc:30|85ECF099:60|85ECF099:80|85ECF000

[MeterButton]
Meter=Image
ImageName=#@#Images\Button.png
X=0
Y=0
H=20
W=20
LeftMouseUpAction=[!SetVariable FullScreen "(1-#FullScreen#)"][!UpdateMeasure "MeasureFullScreen"][!UpdateMeter "#CURRENTSECTION#"]
DynamicVariables=1
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Code Affecting Other Chunks of Code

Post by balala »

CM62 wrote:So I swapped out the small image with a visualizer (undefinist's VisBubble) that I have already successfully transplanted into another code, yet it does not work in this one. I checked for size, layer order, and all the necessary background files, but it only shows the black background image I gave it. Is it something that is still missing, some more bad coding, or something else? Is it that they are measures that they cannot be toggled on and off, since there is no "!Show/Hide Measure" or are they still considered meters? I figure [sRefresher] is an unnecessary meter to show, but I tested each of the others and they are needed.
In such cases the first thing you should have to do would be to check the log. What it says?
On the other hand is very hard to help you, because your code uses a lot of files we don't have. Eg:
  • .lua files: Factory.lua, Refresher.lua, Color.lua
  • .inc file: BandMeasures.inc, Lines.inc
  • Images: Large.png, Visualizer_Background.png, Button.png.
Without these files, we can't help. So, please pack the whole config and upload it, to provide us the needed and included files.