PDA

View Full Version : Connecting 2 vis-ses


Valio
12th March 2003, 17:14
Here's my problem:
In my skin are two vis-components (one for the left [L] and another one for the right channel [R]). Now I want them to change their mode simultanely, so if the mode of (L) is changed, the mode of (R) should be changed accordingly and vice-versa. Unfortunately there's no OnModeChange-event or so for vis-components. I tried it by scripting by mouseclickevents (OnLeftButtonDown, OnLeftButtonUp, OnRightButtonDown, OnRightButtonUp) on the visses (is that the correct plural?:p) but this still didn't worked as fine as it should (I don't know why...). The only workaround I've got is to put two transparent layers over those vises and to script the mouseclickevents for them...but that's still a bit sucky 'cause you can't control the vismode with the popupmenu...uff :igor: ...has anybody got a better solution for this?

thepyr0x
12th March 2003, 17:22
you could do something like System.onPaint and just check vis.getMode over and over again

Valio
12th March 2003, 17:33
uhm...well, if I've found the onPaint-event anywhere I'll tell you...

Naamloos
12th March 2003, 17:36
your workaround should do fine :)

thepyr0x
12th March 2003, 17:37
how strange
it used to be in std.mi (old builds)
what happened to it?
you could also use something like on vis.onFrame (which is in std.mi)

Valio
12th March 2003, 17:57
I also already tried that... :-(
vis.onFrame has no effect in my version (#488), does it have in yours?

thepyr0x
12th March 2003, 18:17
iunno I've never tried lol
it's prolly best to use your workaround, and maybe as a check do vis.getMode on every onPlay just to make sure they haven't gone around your workaround (going into the options or w/e)

Hollow
12th March 2003, 18:31
Go with a version of your work around. Place a clear layer over the vis's, then when that layer is clicked, or right click just emulate what the clicks should do. This way the difference is transparent to the user, and it still does what you want.

Valio
12th March 2003, 19:16
How can I emulate a popup menu?
Won't the entries in the menu be just in the language I write them? (Not thaaaaat bad, just to know)

Hollow
12th March 2003, 20:41
yeah, I guess they will be, thats something I've never even considered.

As to how to actually do it,
Class Layer VisCover;

Global PopupMenu VisMenu;
Global Vis Vis1, Vis2;
Global VisCover VisCover1, VisCover2;

Function PopVisMenu();
Function SetActive();
Function BuildVisMenu();

//Be sure to check that these are the right values
//ie those returned by vis.getmode();
#define VIS_OFF 0
#define VIS_SPECTRUM 1
#define VIS_SCOPE 2

System.onScriptLoaded()
{
Group sg = GetScriptGroup();

//the clear layer over vis #1,
VisCover1 = sg.findObject("viscover1");
Vis1 = sg.findObject("vis1");

//the clear layer over vis#2
VisCover2 = sg.findObject("viscover2");
Vis2 = sg.findObject("vis2");

BuildVisMenu();
}

System.onScriptUnloading()
{
delete VisMenu;
}

VisCover.onRightButtonUp(int x, int y)
{
PopVisMenu();
}

VisCover.onLeftButtonDown(int x, int y)
{
vis1.nextMode();
vis2.nextMode();
SetActive();
}

PopVisMenu()
{
int cmd = VisMenu.popAtMouse();
vis1.setMode(cmd);
vis2.setMode(cmd);
SetActive();
}

SetActive()
{
for(int i = 0; i<=2; i++)
VisMenu.checkCommand(i,0);
VisMenu.checkCommand(vis1.getMode(),1);
}

BuildVisMenu()
{
VisMenu = new PopupMenu;
VisMenu.addCommand("No Visualization", VIS_OFF, 0, 0);
VisMenu.addCommand("Spectrum Analyzer", VIS_SPECTRUM, 0, 0);
VisMenu.addCommand("Oscilliscope", VIS_SCOPE, 0, 0);
SetActive();
}

That should get you started. It assumes that both vis's are in the same group, but cannot be covered by the same clear cover. I haven't tried to compile it, and i suspect that there is at least one typo, but it gets you off in the right direction.

Valio
14th March 2003, 20:40
Thanks a lot, everything works fine, except that the main popup also appears after you made your choose by rightclicking...but, well, it's not that bad...

frisbeemonkey
14th March 2003, 20:56
After PopVisMenu(); in your onRightButtonUp(), add the line:
complete;
That should prevent the main popup from showing up.
Hope this helps,
~FrisbeeMonkey

iPlayTheSpoons
14th March 2003, 21:11
you should aslo use onRightButtonDown istead of up

Hollow
15th March 2003, 00:44
no. onRightButtonUp is correct as per how winamp itself does it. Open it up and right click on the vis. it doesn't appear until the right button is released.

Oh and doesn't complete only work right in guiobjects right now? you might need to change the class layer viscover to class guiobject viscover for it to work correctly.