KSP: Custom switch is cropped by row height

Studio KRUT
Studio KRUT Member Posts: 7 Member
edited October 22 in Scripting Workshop

Trying to get into KSP. I have managed to set my custom knobs (aka sliders) but the switches seems to get cropped along a grid. They are png-strips with 6 sprites. The mouse over animation is working, I see the frames aree changing.

But I can't figure out how to allow them to occupy the full height, i.e. not be cropped. Each frame is 68x130px. I tried to set CONTROL_PAR_HEIGHT as I saw in an example on yummybeats, but to no effect.


What am I missing?


script as written in sublime:


on init

   make_perfview

   set_ui_height_px(414)   

   set_ui_width_px(1000)   

   set_control_par_str($INST_WALLPAPER_ID,$CONTROL_PAR_PICTURE,"friends-gui-2")   

   set_control_par_str($INST_ICON_ID,$CONTROL_PAR_PICTURE,"logo-blue")   


   declare ui_slider $cc1_knob (0,127)

   declare ui_slider $cc2_knob (0,127)


   {----- 


   set_text($cc1_knob,"A-E-ST")

   set_text(cc2_knob,"ratt2")


   -----}


   declare cc1_ch := 74

   declare cc2_ch := 71


   declare $cc1_knobId

   $cc1_knobId := get_ui_id($cc1_knob)


   set_control_par_str($cc1_knobId, $CONTROL_PAR_PICTURE, "gui-knob")                  

   set_control_par($cc1_knobId,$CONTROL_PAR_MOUSE_BEHAVIOUR,-1000)                  


   declare $cc2_knobId

   $cc2_knobId := get_ui_id($cc2_knob)


   set_control_par_str($cc2_knobId, $CONTROL_PAR_PICTURE, "gui-knob")                  

   set_control_par($cc2_knobId,$CONTROL_PAR_MOUSE_BEHAVIOUR,-1000)   


   declare ui_switch sw_tuned

   set_text(sw_tuned,"Tuned")

   set_control_par_str(get_ui_id(sw_tuned), $CONTROL_PAR_PICTURE, "gui-switch-v")

   set_control_par(get_ui_id(sw_tuned),$CONTROL_PAR_WIDTH,68)

   set_control_par(get_ui_id(sw_tuned),$CONTROL_PAR_HEIGHT,130)


   declare ui_switch sw_efkt1

   set_text(sw_efkt1,"efkt1")

   set_control_par_str(sw_efkt1, $CONTROL_PAR_PICTURE, "gui-switch-v")


   declare ui_switch sw_efkt2

   set_text(sw_efkt2,"efkt2")

   set_control_par_str(sw_efkt2, $CONTROL_PAR_PICTURE, "gui-switch-v")


   move_control(cc1_knob, 4, 2)

   move_control(cc2_knob, 5,2)

   move_control(sw_tuned, 1,2)

   move_control(sw_efkt1, 2,2)

   move_control(sw_efkt2, 3,2)


   make_persistent(cc1_knob)

   make_persistent(cc2_knob)

   make_persistent(sw_tuned)

   make_persistent(sw_efkt1)

   make_persistent(sw_efkt2)


   set_control_help(cc1_knob,"Crossfade between articulations" )

   set_control_help(cc2_knob,"We don't know yet" )

   set_control_help(sw_tuned,"Switch tune correction on/off" )

   set_control_help(sw_efkt1,"effect number one" )

   set_control_help(sw_efkt2,"effect number two")




end on


on ui_control (cc1_knob)

   set_controller(cc1_ch, cc1_knob)

end on


on ui_control (cc2_knob)

   set_controller(cc2_ch,cc2_knob)

end on


on controller

   if CC_NUM=cc1_ch

      set_controller(cc1_ch, cc1_knob)

   end if


   if CC_NUM=cc2_ch

      set_controller(cc2_ch, cc2_knob)

   end if


end on


on ui_control (sw_tuned)


end on


on ui_control (sw_efkt1)


end on


on ui_control (sw_efkt2)


end on


on note

   disallow_group($ALL_GROUPS)

   if sw_tuned=0

      allow_group(0)

      allow_group(1)

      allow_group(2)

   else

      allow_group(3)

      allow_group(4)

      allow_group(5)

   end if




end on

Comments

  • Gablux
    Gablux Member Posts: 88 Helper

    A few things to double check:

    • in the text file with the same name as the PNG, is the number of animations correct?
    • same text file, "Horizontal Animation: no"
    • check that the height you are setting with $CONTROL_PAR_HEIGHT (130) is correct. Your PNG would have to be 780px tall. (130x6)
    • You are not setting the width and height of the efkt1 switch.

    Extra: you probably want to set the text for these buttons as "" (empty)

  • corbo-billy
    corbo-billy Member Posts: 101 Helper

    Or in the text file, a blank tenth line present can improve things sometimes.

  • Studio KRUT
    Studio KRUT Member Posts: 7 Member

    Thanks!

    I had number of animations at 6 and I had the blank tenth line. Also png was 780 px tall.

    I didn't see that I missed setting height and width on efkt1, but I guess the "sw_tuned" would be correct...

    What I ended up doing was making all switches horizontal instead. So solved by a compromise for this time.

This discussion has been closed.
Back To Top