Page 2 of 6
Re: ConfigActive 2.0
Posted: June 22nd, 2018, 10:36 pm
by raiguard
jsmorley wrote:LeftMouseUpAction=[&MeasureScript:Test('LoadSkin\ToggledSkin')]
LoadSkin\ToggledSkin LoadSkin\\ToggledSkin LoadSkin\ToggledSkin
Inline Lua is intended to "return" some value to the section variable, but that doesn't mean you have to use the value it returns... It actually doesn't have to return anything at all.
That's an acceptable workaround. Hopefully the !CommandMeasure thing is a bug that is fixable. I have been dealing with that for over a year, and just assumed it was a consequence of LUA needing double backslashes. I never knew it was a bug!
Anyway, thanks.
Re: ConfigActive 2.0
Posted: June 22nd, 2018, 10:37 pm
by jsmorley
raiguard wrote:
That's an acceptable workaround. Hopefully the !CommandMeasure thing is a bug that is fixable. I have been dealing with that for over a year, and just assumed it was a consequence of LUA needing double backslashes. I never knew it was a bug!
Anyway, thanks.
Unless I'm missing something, this means that Inline Lua can just "deprecate" using !CommandMeasure to fire Lua functions...
We will look at !CommandMeasure, but I fear that behavior might be baked into the DNA of Lua, and might be hard to fix without backwards compatibility issues, or having to hack core Lua code that puts at risk future Lua version updates. We will see.
Re: ConfigActive 2.0
Posted: June 22nd, 2018, 10:40 pm
by raiguard
jsmorley wrote:Unless I'm missing something, this means that Inline Lua can just "deprecate" using !CommandMeasure to fire Lua functions...
Well, there are disadvantages. First off, you would need to use DynamicVariables on anything that needs to invoke LUA commands (which probably isn't too much of a deal, but it could have a slight performance impact). Secondly, it doesn't appear that Inline LUA can use table function arguments.
LeftMouseUpAction=[&MeasureScript:ToggleSkin{configName = '[#toggledSkinConfig]', configState = [&MeasureConfigActive:IsActive([#toggledSkinConfig])]}] throws an error. While when used in a !CommandMeasure it works fine.
Re: ConfigActive 2.0
Posted: June 22nd, 2018, 10:43 pm
by jsmorley
raiguard wrote:Well, there are disadvantages. First off, you would need to use DynamicVariables on anything that needs to invoke LUA commands (which probably isn't too much of a deal, but it could have a slight performance impact). Secondly, it doesn't appear that Inline LUA can use table function arguments.
LeftMouseUpAction=[&MeasureScript:ToggleSkin{configName = '[#toggledSkinConfig]', configState = [&MeasureConfigActive:IsActive([#toggledSkinConfig])]}] throws an error. While when used in a !CommandMeasure it works fine.
I'm not entirely sure you do need DynamicVariables if you are not in fact returning anything.
Yeah, you can't pass a direct call to a table with an index to it, you would have to pass some reference to the table name (if needed) and the index separately in the arguments, then use that to access the table.
The major difference is that you can just execute raw Lua code using !CommandMeasure, where Inline Lua can only execute a named function(), with any parameters you want. However, I could argue that that isn't fatal, you just need to define your functions carefully.
Edit: Yeah, you don't need DynamicVaraiables.
Re: ConfigActive 2.0
Posted: June 22nd, 2018, 10:52 pm
by raiguard
jsmorley wrote:I'm not entirely sure you do need DynamicVariables if you are not in fact returning anything.
Ah, you're right.
jsmorley wrote:Yeah, you can't pass a direct call to a table with an index to it, you would have to pass some reference to the table name and the index separately in the arguments, then use that to access the table.
The point of this was to make arguments optional. I couldn't find an argument order that would allow me to make them optional without needing to manually input 'nil' for one or more of the other arguments if you don't want to use them. For example, if you want to toggle a specific variant, you would need to use
ToggleSkin('[#toggledSkinConfig]', [&MeasureConfigActive:IsActive([#toggledSkinConfig])], nil, 'Variant1.ini', '[&MeasureConfigActive:ConfigVariantName([#toggledSkinConfig])]') if the function is
function ToggleSkin(configName, configState, toState, skinIni, activeIni).
Anyway, that's unfortunate. It sounds really complicated if I still want to use a table when using Inline LUA, so I'll just scrap that and use nil.
Edit: Typing 'nil' as a function argument in Inline LUA appears to translate into a zero when the function gets the value. That's odd.
Re: ConfigActive 2.0
Posted: June 22nd, 2018, 11:30 pm
by raiguard
Finished updating my sample skin and figured I would share it here. It works like a charm! I even managed to add a new feature while I was at it! Thanks for all your help.
LoadSkin.gif
Code: Select all
[Rainmeter]
MiddleMouseUpAction=[!Refresh]
AccurateText=1
[Variables]
toggledSkinConfig=LoadSkin\ToggledSkin
toggledSkinConfigActive=[&MeasureConfigActive:IsActive([#toggledSkinConfig])]
toggledSkinConfigActiveIni=[&MeasureConfigActive:ConfigVariantName([#toggledSkinConfig])]
variant1Ini=Variant1.ini
variant2Ini=Variant2.ini
[MeasureConfigActive]
Measure=Plugin
Plugin=ConfigActive
DynamicVariables=1
[MeasureScript]
Measure=Script
ScriptFile=#@#Scripts\LoadSkin.lua
ToggleOn=[\x5a]
ToggleOff=[\x56]
RadioOn=[\x5c]
RadioOff=[\x5b]
ToggleGroup=SkinToggles
[StyleLabelString]
FontFace=Roboto
FontColor=240,240,240
FontSize=10
AntiAlias=1
X=3R
Y=-1r
[StyleToggleButton]
FontFace=ElegantIcons
FontColor=138,210,250
FontSize=12
AntiAlias=1
X=5
Y=4R
Group=SkinToggles
DynamicVariables=1
[MeterBackground]
Meter=Shape
Shape=Rectangle 0,0,128,102 | Fill Color 15,15,15 | StrokeWidth 0
[MeterToggleConfigButton]
Meter=String
MeterStyle=StyleToggleButton
Y=5
Text=[&MeasureScript:GetIcon([#toggledSkinConfigActive])]
LeftMouseUpAction=[&MeasureScript:ToggleSkin('[#toggledSkinConfig]', [#toggledSkinConfigActive])]
[MeterToggleConfigLabel]
Meter=String
MeterStyle=StyleLabelString
Text=Toggle Config
[MeterLoadVariant1Button]
Meter=String
MeterStyle=StyleToggleButton
Text=[&MeasureScript:GetIcon([#toggledSkinConfigActive], '[#variant1Ini]', '[#toggledSkinConfigActiveIni]')]
LeftMouseUpAction=[&MeasureScript:ToggleSkin('[#toggledSkinConfig]', [#toggledSkinConfigActive], '[#variant1Ini]', '[#toggledSkinConfigActiveIni]', 1)]
[MeterLoadVariant1Label]
Meter=String
MeterStyle=StyleLabelString
Text=Load Variant 1
[MeterLoadVariant2Button]
Meter=String
MeterStyle=StyleToggleButton
Text=[&MeasureScript:GetIcon([#toggledSkinConfigActive], '[#variant2Ini]', '[#toggledSkinConfigActiveIni]')]
LeftMouseUpAction=[&MeasureScript:ToggleSkin('[#toggledSkinConfig]', [#toggledSkinConfigActive], '[#variant2Ini]', '[#toggledSkinConfigActiveIni]', 1)]
[MeterLoadVariant2Label]
Meter=String
MeterStyle=StyleLabelString
Text=Load Variant 2
[MeterToggleVariant1Button]
Meter=String
MeterStyle=StyleToggleButton
Text=[&MeasureScript:GetIcon([#toggledSkinConfigActive], '[#variant1Ini]', '[#toggledSkinConfigActiveIni]', true)]
LeftMouseUpAction=[&MeasureScript:ToggleSkin('[#toggledSkinConfig]', [#toggledSkinConfigActive], '[#variant1Ini]', '[#toggledSkinConfigActiveIni]')]
[MeterToggleVariant1Label]
Meter=String
MeterStyle=StyleLabelString
Text=Toggle Variant 1
[MeterToggleVariant2Button]
Meter=String
MeterStyle=StyleToggleButton
Text=[&MeasureScript:GetIcon([#toggledSkinConfigActive], '[#variant2Ini]', '[#toggledSkinConfigActiveIni]', true)]
LeftMouseUpAction=[&MeasureScript:ToggleSkin('[#toggledSkinConfig]', [#toggledSkinConfigActive], '[#variant2Ini]', '[#toggledSkinConfigActiveIni]')]
[MeterToggleVariant2Label]
Meter=String
MeterStyle=StyleLabelString
Text=Toggle Variant 2
Code: Select all
debug = false
function Initialize()
toggleOn = SELF:GetOption('ToggleOn', '[#toggleOn]')
toggleOff = SELF:GetOption('ToggleOff', '[#toggleOff]')
radioOn = SELF:GetOption('RadioOn', toggleOn)
radioOff = SELF:GetOption('RadioOff', toggleOff)
toggleGroup = SELF:GetOption('ToggleGroup', 'SkinToggles')
end
function Update() end
-- Toggles the specified skin.
function ToggleSkin(configName, configState, skinIni, activeIni, toState)
configName = configName:gsub('\\', '\\\\'):gsub('\\\\', '\\')
toState = toState or skinIni and (skinIni == activeIni and -1 or 1) or configState * -1
if toState == 1 then
if skinIni == nil then
SKIN:Bang('!ActivateConfig', configName)
else
SKIN:Bang('!ActivateConfig', configName, skinIni)
end
else
SKIN:Bang('!DeactivateConfig', configName)
end
SKIN:Bang('!UpdateMeterGroup', toggleGroup)
SKIN:Bang('!Redraw')
return ''
end
function Test(input)
local newInput = string.gsub(input, '\\', '\\\\')
local oldInput = string.gsub(newInput, '\\\\', '\\')
print(input, newInput, oldInput)
return input .. ' ' .. newInput .. ' ' .. oldInput
end
-- Returns the corresponding button state depending on the state of the skin
function GetIcon(configState, skinIni, activeIni, radioOverride)
if activeIni == nil then
if configState == 1 then return toggleOn
else return toggleOff end
else
if activeIni == skinIni then return radioOverride and toggleOn or radioOn
else return radioOverride and toggleOff or radioOff end
end
end
-- function to make logging messages less cluttered
function LogHelper(message, type)
if type == nil then type = 'Debug' end
if debug == true then
SKIN:Bang("!Log", message, type)
elseif type ~= 'Debug' then
SKIN:Bang("!Log", message, type)
end
end
Edit: Oops, accidentally left the test function in there.
Re: ConfigActive 2.0
Posted: June 23rd, 2018, 11:27 pm
by jsmorley
Raiguard,
I have posted a 2.1 version of the plugin, that allows escaped "\", as in Illustro\\System to be sent to it and it will ignore the extra slash.
Re: ConfigActive 2.0
Posted: June 24th, 2018, 3:15 pm
by raiguard
Ah sorry, I somehow didn't see this yesterday. I wouldn't have put it past you to fix that because using Inline LUA works well enough, but since you put forth the effort, I appreciate it!
Re: ConfigActive 2.1
Posted: November 29th, 2018, 1:20 am
by raiguard
Hey jsmorley, I was looking at this to reference the documentation you wrote, and noticed that the documentation is broken. It didn't used to be, so it might have something to do with the forum update. Just thought I'd let you know.
Re: ConfigActive 2.1
Posted: November 29th, 2018, 3:06 am
by jsmorley
raiguard wrote: ↑November 29th, 2018, 1:20 am
Hey jsmorley, I was looking at this to reference the documentation you wrote, and noticed that the documentation is broken. It didn't used to be, so it might have something to do with the forum update. Just thought I'd let you know.
Thanks.