Module Visibility Toggling (w/ mzscript) Thread last updated on 2004-06-14 23:56:45

Posted by member 37809 on 2003-10-23 11:07:49

Traditional ways of using scripted bangs through mzscript to toggle modules' visibility with and without memory between litestep sessions/recycles.

This is for if you wish to have toggle buttons or the like to toggle visibility of modules instantly (without a recycle). It involves the hiding and showing of modules, as opposed to the loading/unloading (or creating/destroying stuff) of modules.*


METHOD 1: separate bangs.
To remember state, have variable FOO_visible "1" in a *mzVarFile (or in .rc, depending on mzscript version).
*script bang !_FOO_toggle
*script exec !ifeval ("%{FOO_visible}" = "0") '|_FOO_show' else '|_FOO_hide'
*script ~bang

*script bang !_FOO_hide
*script exec !hideSomethingEtc
*script exec !hideSomethingElse
*script exec !varset FOO_visible 0
*script exec !varsave FOO_visible
*script ~bang

*script bang !_FOO_show
*script exec !showSomethingEtc
*script exec !showSomethingElse
*script exec !varset FOO_visible 1
*script exec !varsave FOO_visible
*script ~bang

; assumes you have whatever you want to toggle initially hidden by .rc settings
*script start !ifeval ("%{FOO_visible}" = "1") '|_FOO_show'

(hint: replace all instances of 'FOO' to whatever for copying/pasting)


METHOD 2: single bang, because you don't like method 1; "it's needlessly big!", etc.
Again have FOO_visible defined in a varfile.
*script bang !_FOO_toggle
*script goto ("%{FOO_visible}" = "1") hide
*script exec !showSomethingEtc
*script exec !showSomethingElse
*script exec !varset FOO_visible 1
*script goto rest
*script label hide
*script exec !hideSomethingEtc
*script exec !hideSomethingElse
*script exec !varset FOO_visible 0
*script label rest
*script exec !varsave FOO_visible
*script ~bang

; and so you duplicate commands for showing here.
*script start !ifeval ("%{FOO_visible}" = "1") '|execute [!showSomethingEtc][!showSomethingElse]'


METHOD 3: toggle bang only, without memory.
useful if one of the modules you want to control lacks a !toggle bang.

The way this one is designed, you need not have FOO_visible defined initially.
*script bang !_FOO_toggle
*script gotoif ("%{FOO_visible}" <> "1") show
*script exec !hideSomethingEtc
*script exec !hideSomethingElse
*script exec !varset FOO_visible 0
*script exit
*script label show
*script exec !showSomethingEtc
*script exec !showSomethingElse
*script exec !varset FOO_visible 1
*script ~bang

But it also assumes you have the module(s) whose visibility you wish to control initially hidden by settings. If you wanted them initially shown, you could have FOO_visible "1" in a varfile or have *script start !varset FOO_visible "1". Also do not autosave vars.

Modify as you see fit to get the behaviour you want. As with everything, mzscript is dumb, so you must coordinate scripting and settings.

For variation, you can also use textedit to set .rc settings for the visibility of modules instead of using *script start's. If you don't want to use textedit, you can simply put the relevant .rc settings in a varfile. You can manipulate these as variables through mzscript, and (use the step.rc directive) include <varfile> so that modules can still use them.

*IMO these methods are still potentially complicated to implement.

Posted by member 71746 on 2003-10-25 21:25:08 link

I'm of the opinion that the first method is the best. If you think the second method "is way too big" you're not considering scalability. Method 1 lets you call the bangs to hide and show the modules separately from the toggle, so you can have have hotspots that explicitly show the module and hotspots that explicitly hide it, etc, without having to have multiple calls to the !LsBoxHide BoxName.

Posted by member 7 on 2003-10-26 05:15:43 link

Posted by member 57005 on 2004-06-07 00:50:48 link

Maybe a bit late to comment this post, but I felt I had to. ;) Anyway, great help for me at least. After I read this post I was able to create some nice memsaving toggle scripts with "!unloadmodule" and "!reloadmodule" for Rainlendar, Icondesk and grdTransparent.

Example:
*script start !Trans_Start

*script bang !Trans_Start
*Script gotoif ("$TransOn$" = "true") TransYes
*Script gotoif ("$TransOn$" = "false") TransNo
*script label TransYes
*Script exec !grdTransparentFade 1 240 100 2
*script exec !pause 1500
*script exec !UnloadModule $LitestepDir$modules\grdtransparent-1.1_beta_1.dll
*script label TransNo
*script ~bang

*script bang !Trans_hide
*script exec !varset TransOn false
*script exec !varsave TransOn
*script ~bang

*script bang !Trans_show
*script exec !varset TransOn true
*script exec !varsave TransOn
*script ~bang


:D

Posted by member 125450 on 2004-06-14 23:56:45 link

Here is some toggle script for resizing and moving other elements as well as handling lsbox

*Script bang !switchtray
*script exec !ifeval ("%{vtrayOn}" = "true") '!Netunloadmodule "vtray-1.06.dll"' else '!Netreloadmodule "vtray-1.06.dll"'
*script exec !ifeval ("%{vtrayOn}" = "true") '!LSBoxDestroy tray' else '!LSBoxCreate $ConfigDir$tray.box'
*script exec !ifeval ("%{vtrayOn}" = "true") '!varset vtrayOn "false"' else '!varset vtrayOn "true"'
*script exec !ifeval ("%{trayx}" = "0") '!varset trayx "125"' else '!varset trayx "0"'
*script exec !Reload
*script gotoif ("%{rabidvwmOn}" = "true") trayvwmtrue
*script gotoif ("%{rabidvwmOn}" = "false") trayvwmfalse
*script label trayvwmtrue
*script gotoif ("%{trayx}" = "135") trayvwmtrue135
*script gotoif ("%{trayx}" = "0") trayvwmtrue0
*script label trayvwmtrue135
*script exec !LsBoxMoveBox vwm -135 $ontopy$ 5 2
*script exec !taskberrisizer
*script exit

*Script bang !taskberrisizer
*script exec !Netunloadmodule "taskbar3-0.306_alpha-4.dll"
*script exec !pause 5
*script exec !Netreloadmodule "taskbar3-0.306_alpha-4.dll"
*script exec !LSBoxDestroy taskbar
*script exec !pause 5
*script exec !LSBoxCreate $ConfigDir$taskbar.box
*script ~bang