HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [resolved] How hard is a slider on the scripting side?  (Read 914 times)

Thazager

  • General Accounts
  • *
  • Posts: 1149
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
[resolved] How hard is a slider on the scripting side?
« on: Jan 27, 13, 02:59:31 AM »

I have tried several ways of adding in a few sliders. I have looked through some of the facegen code and _guislider methods, and not finding something that works. I managed to build this but it is not functioning at all.

method HE_onSliderMouseDrag(args references Class GUIMouseEvent)
  thumb as NodeRef of Class GUISlider = args.source
  when thumb.name
    is "Redthumb"
      println("Red = " + thumb.pos)
    .
    is "Greenthumb"
      println("Green = " + thumb.pos)
    .
    is "Bluethumb"
      println("Blue = " + thumb.pos)
    .
  .
.
« Last Edit: Feb 02, 13, 07:02:03 PM by Thazager »
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1149
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: How hard is a slider on the scripting side?
« Reply #1 on: Jan 27, 13, 09:52:21 PM »

I have not been able to get a slider working quite right, but I have made something close that uses the sliders for input values. Here is the current script. Using the mouse clicking it requires a click after the slider is moved.

This code is being used to change the colors of the GUIs on screen. One example is added in.

Code: [Select]
method onMouseClick(args references Class GUIMouseEvent)
  slide as NodeRef of Class GUISlider = args.source
  colorVal as Float = (slide.pos + 10) / 20   // calc 0.0 - 1.0 values

  // get current colors
  realColor as NodeRef of Class GUIPanel = FindGUIControlByName(None, "game.HaV_ColorTest.realColor" )
  Red as Float = realColor.defaultStatePresentation.color.r
  Green as Float = realColor.defaultStatePresentation.color.g
  Blue as Float = realColor.defaultStatePresentation.color.b

  // get which color is changing
  when slide.parent.name
    is "RedSlider"
      Red = colorVal
    .
    is "GreenSlider"
      Green = colorVal
    .
    is "BlueSlider"
      Blue = colorVal
    .
  .
  // put in new color
  println("R = " + Red)
  println("G = " + Green)
  println("B = " + Blue)
  realColor.defaultStatePresentation.color = MiscUtils:MakeRGBA( Red, Green, Blue, 1.0 )

  // which sections get new colors
  chatWindow as NodeRef of Class GUIPanel = FindGUIControlByName(None, "game.HaV_ChatWindow.frontPanel" )
  chatWindow.defaultStatePresentation.color = MiscUtils:MakeRGBA( Red, Green, Blue, 1.0 )
.

Logged

HE-Cooper

  • *****
  • Posts: 2221
    • View Profile
Re: How hard is a slider on the scripting side?
« Reply #2 on: Jan 28, 13, 08:37:47 AM »

HJ Ref is filled with sliders, the social world system menu also uses sliders.
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1149
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: How hard is a slider on the scripting side?
« Reply #3 on: Jan 28, 13, 07:55:19 PM »

Ok, thanks. I shall check them out.

add:
These lines seem to work nicely for reading the slider movement.

method _onSliderValueChange(args references Class GUIValueChangeEvent)
  slide as NodeRef of Class GUISlider = args.source
  newPosition as Float = args.value
« Last Edit: Feb 02, 13, 07:04:07 PM by Thazager »
Logged