# Kontakt GUI Interface Questions



## MeatHook (Jan 19, 2011)

Hello,

I am fairly new to KSP scripting, but am getting the hang of it.

Except for some GUI stuff, that is. It seems that documentation for that is a little hard to come by! (Unless I just haven't found it yet!)

Anyway, there are two things I have not been able to figure out how to do:

1) Tabbed backgrounds -- I know how the background image can be offset to show a different image, but have not been able to find out how to implement tabs to be able to switch images (and sets of UI controls) that way...

2) Graphics images -- I have seen libraries that have small images / icons on the background that can change / be changed (and even animated!) but so far have not found any documentation at all regarding how to do this...

Can anyone help out or guide me to some documentation / tutorials on how to do both of these things? I have looked through the KSP scripting guides, all the way up to the 4.2 beta, with no luck so far (unless I totally missed it!)

TIA!
Terry.


----------



## EvilDragon (Jan 19, 2011)

About switching the graphics when clicking between tabs:

Suppose your image is 900 pixels high, that's 300 pixels per tab. You would add this in the "on init" callback of each script tab you want it on:

First script:

on init
_set_skin_offset(0)

Second script:

on init
_set_skin_offset(330)

etc.



In Kontakt 4 this is EVEN EASIER, you can do it in one shot for all tabs, without the need to change the number! Just add this line to the start of each script:


set_skin_offset($CURRENT_SCRIPT_SLOT*_<height of the image per tab>_)


----------



## RiffWraith (Jan 19, 2011)

Hello 

Not sure if this helps, but one thing to bear in mind: while sliders, menus, and switches can have graphic files associated with them, knobs can not.

Cheers.


----------



## MeatHook (Jan 19, 2011)

EvilDragon: So, it sounds like each tab has to go in a different script slot then? Would I then use the script in slot 1 for all the main processing (the on_note, etc..), and then only have UI related processing in the other 4 slots (and use PGS commands to send the control info back to the 1st slot)? So, then, would each tab be controlled by a button/switch? I still am not sure at all how to code up the switching between tabs...

RiffWraith: From what I have read, tables can as well...but what about labels? And, if labels can have graphic files, how would I animate them? I know I would have to have a png file with all the animations in it, but how would I cycle through them?

Thanks again guys! Seems like for every question I get answered, I end up with 2 or 3 more! The actual processing (on_note, on_controller, all of that) so far has been fairly straightforward, as it is well documented. But all the documentation about GUI stuff seems to be quite lacking!

Terry.


----------



## polypx (Jan 19, 2011)

Like kb says, you can keep it all in one script and just use buttons or switches or menus to change the skin offset and hide/unhide controls.

You can't have graphics on labels. If you want to make an animation you need to use a slider or a lot of skins.

If you work your way through the K Player Developers Guide, you'll get a good handle on how this all works. There are simple versions of everything in there.

And as Mario said once upon a time, get Knobman. 

cheers
Dan


----------



## MeatHook (Jan 19, 2011)

polypx @ Wed Jan 19 said:


> Like kb says, you can keep it all in one script and just use buttons or switches or menus to change the skin offset and hide/unhide controls.
> 
> You can't have graphics on labels. If you want to make an animation you need to use a slider or a lot of skins.
> 
> ...



Yes, definitely going to download Knobman! Starting to figure a bunch of this out. I was just re-reading through the KSP Reference Manual (the newest one that comes with the 4.2 beta), and noticed this in it:

$CONTROL_PAR_PICTURE_STATE
the picture state of the control for tables, value edits and labels

To me, this sounds like I can set a $CONTROL_PAR_PICTURE for a table, value edit, or label! And, by the sounds of it, this $CONTROL_PAR_PICTURE_STATE may allow me to select which animation frame I want to display in the graphic...exactly what I was looking for!!! :D 

I will have to experiment with this and see what I can come up with!!!

Thanks again everyone for your help!
Terry.


----------



## EvilDragon (Jan 19, 2011)

polypx @ 19.1.2011 said:


> You can't have graphics on labels.



Yes, you can  That's how I made the evil unclickable knob!


$CONTROL_PAR_PICTURE_STATE works best with labels who have graphics loaded on them. It's a K4 feature from the first incarnation of K4.


And yes, you don't necessarily HAVE to have scripts for each tab, although sometimes that makes things easier, to separate different UI sections more clearly. But definitely it can be done all in one tab.


----------



## kotori (Jan 20, 2011)

EvilDragon @ Wed Jan 19 said:


> $CONTROL_PAR_PICTURE_STATE works best with labels who have graphics loaded on them. It's a K4 feature from the first incarnation of K4.



Think of it like this: with a noninteractive control such as a ui_label you have full control over the picture state (or animation frame if you wish). For other controls like a button it's Kontakt that is in charge over whether to display eg. a pressed/unpressed/mouse-hover state, so in that case you don't have any direct control over the state. You can indirectly influence it by setting the button variable to be pressed or not pressed though, but you cannot animate it freely.

As already pointed out the "Kontakt 4 Player Developer Guide" has more info. I'm not sure why NI puts the info only there though, since this is of general interest.

If you want to create an animation you use a ui_label and change it's picture state in a loop (you need a wait instruction too in order for it not to change too quickly).

Cheers,
Nils


----------



## bouziane faycel (Nov 2, 2017)

EvilDragon said:


> Yes, you can  That's how I made the evil unclickable knob!
> 
> 
> $CONTROL_PAR_PICTURE_STATE works best with labels who have graphics loaded on them. It's a K4 feature from the first incarnation of K4.
> ...





EvilDragon said:


> About switching the graphics when clicking between tabs:
> 
> Suppose your image is 900 pixels high, that's 300 pixels per tab. You would add this in the "on init" callback of each script tab you want it on:
> 
> ...



hey evel pls is ther a way or commend to make a livel meter or knob or ........ behind of picture.


----------



## bouziane faycel (Nov 2, 2017)

hey evel i want to make a livel meter behind of th picture. but i can't. pls is ther a way or commend to do this. i try but allways the level is Before of the picture. i want to make allways the picture in before not in behind


----------



## bouziane faycel (Nov 2, 2017)

the picture is inserted picture not a wallpaper


----------



## EvilDragon (Nov 3, 2017)

In Kontakt 5.7, you can use $CONTROL_PAR_Z_LAYER to put things on top or below each other.


----------



## bouziane faycel (Nov 3, 2017)

thank you Evil. but I've seen a library named aviram arabic strings programmed on kontakt 5.5.2, and has this property. if you can plz tell me the complet commend $CONTROL_PAR_Z_LAYER thenks bro


----------



## bouziane faycel (Nov 4, 2017)

hey Evil i finaly solved my prob with an other fonction. thank you for your help


----------



## Aviram Dayan Production (Nov 22, 2017)

bouziane faycel said:


> thank you Evil. but I've seen a library named aviram arabic strings programmed on kontakt 5.5.2, and has this property. if you can plz tell me the complet commend $CONTROL_PAR_Z_LAYER thenks bro



Hello *bouziane faycel* (this post very old no? )
anyway, it's true about my old library
the trick is to use with transparent bg above in exact location,
when the level matter happen.

and about ui_level_meter i don't recommend to use that and also for gui stuff
There are a lot of bugs and also It's very limited, and not really pretty 

the much better alternative is - to do animation for ui_slider or ui_label

i hope That's new for you, or helped you
Best Aviram


----------

