s_slider { GUI_CREATE { int backColor = packcolor (0,0,0,0) //CAN BE INITIALIZED int controlColor = packcolor (255,255,255,255) //CAN BE INITIALIZED int framehighlightColor = packcolor (200,200,230,0) //CAN BE INITIALIZED int labelTextColor = packcolor (200,0,0,0) //CAN BE INITIALIZED int borderColor = packcolor (0,0,0,0) //CAN BE INITIALIZED int filledColor = packcolor (0,100,0,0) //CAN BE INITIALIZED int itemWidth = 0 //MUST BE INITIALIZED int itemheight = 0 int slider_min_val = 0 //MUST BE INITIALIZED int slider_max_val = 127 //MUST BE INITIALIZED int handleheight = 10 int handlewidth = 6 int label_alignment int is_vertical = true int id = 0 string label = "" //CAN BE INITIALIZED font3d labelFont3d //MUST BE INITIALIZED position offsetLabel //CAN BE INITIALIZED //LOCAL WORK VARIABLEs int nSelected = 0 //the current selected item from the list of items int over_me = false //am I over the list's region? int first_delay = 30 //time delay value n/60; for the buttons int second_delay = 5 //time delay value n/60; for the buttons object o_slider_handle = s_slider_handle framerate = 30 } GUI_INIT { region = 0,0 to itemWidth,itemheight if is_vertical == true { o_slider_handle.location = location.x+(itemwidth/2), (location.y + itemheight) - (itemheight*nselected)/(slider_max_val-slider_min_val), location.z+1 } else { o_slider_handle.location = location.x+(itemwidth*nselected)/(slider_max_val-slider_min_val),location.y+(itemheight/2),location.z+1 } initialize (o_slider_handle) } GUI_ACTIVATE { activate(o_slider_handle) } GUI_DEACTIVATE { deactivate(o_slider_handle) } LBUTTON_UPDATE { if (mouse.left == BUTTON_PRESSED) || (mouse.left == BUTTON_HELD) { if is_vertical == true { o_slider_handle.location.y = mouse.y mail (o_slider_handle.location.y,this) } else { o_slider_handle.location.x = mouse.x mail (o_slider_handle.location.x,this) } } } REGION_ENTERED { over_me = true } REGION_EXITED { over_me = false } GUI_MAILBOX // MAILBOX IS USED TO HANDLE MESSAGES FROM SLIDER BAR { focus(this) // current value of slider = (the difference vals of slider to get a net of values * current pixel value ) / total num of pixels (width of slider gutter) if is_vertical == true { nSelected = slider_max_val - (slider_max_val-slider_min_val)*(-(location.y-getmessage()))/itemheight } else { nSelected = (slider_max_val-slider_min_val)*(-(location.x-getmessage()))/itemwidth } mail(nSelected) } GUI_CHAR { int key = getchar() // tab section if you have our GOS Script tab routine // if (key == 9) //9 is the value of a tab // { // mail(M_TABEVENT) // } } GUI_DRAW { if itemheight { // draw background setpencolor(backColor) ldrawrect 0,0 to itemwidth,itemheight setpencolor(filledColor) drawrect location.x, o_slider_handle.location.y to location.x + itemwidth, location.y + itemheight // draw border setpencolor(borderColor) ldrawframe 0,0 to itemwidth,itemheight } // draw hot border if gotfocus(this) { setpencolor(framehighlightcolor) ldrawframe 0,0 to itemwidth,itemheight } //Use for an optional label for the top of box if (length$(label) > 0) { print3d_attributes = labelFont3D, labelTextColor,1,1,1,0,0,label_alignment lprint3d_position = offsetLabel.x+1, offsetLabel.y lprint3d_margins = offsetLabel.x, offsetLabel.y to (offsetLabel.x + itemwidth),(offsetLabel.y + getprint3dheight(label)+3) print3d label } } } s_slider_handle { GUI_CREATE { int up = true //this object is used for either the up or down arrow; this is the flag so it knows int timeToMove //created to store a delay value for button presses pane p_handle // if you choose to use bitmap for the handle int use_bitmap = false framerate = 10 } GUI_INIT { if exists(p_handle) { if parent.is_vertical == true { parent.handleheight = getheight(p_handle) } else { parent.handlewidth = getwidth(p_handle) } use_bitmap = true origin (p_handle) = ((getwidth(p_handle))/2),((getheight(p_handle))/2) region = -((getwidth(p_handle))/2),-((getheight(p_handle))/2) to ((getwidth(p_handle))/2),((getheight(p_handle))/2) } else { region = -(parent.handlewidth/2), -(parent.handleheight/2) to (parent.handlewidth/2), (parent.handleheight/2) } } LBUTTON_UPDATE { if (mouse.left == BUTTON_HELD) // this drags the thumbslider as long as the button is held { if parent.is_vertical == true { if mouse.y < parent.location.y { location.y = parent.location.y mail (parent.location.y) } else { if mouse.y > parent.location.y+parent.itemheight { location.y = parent.location.y+parent.itemheight mail (parent.location.y+parent.itemheight) } else { location.y = mouse.y mail (location.y) } } } else { if mouse.x < parent.location.x { location.x = parent.location.x mail (parent.location.x) } else { if mouse.x > parent.location.x+parent.itemwidth { location.x = parent.location.x+parent.itemwidth mail (parent.location.x+parent.itemwidth) } else { location.x = mouse.x mail (location.x) } } } always_in_region = true } else // if anything else but held, release the thumbslider { always_in_region = false } } GUI_DRAW { if use_bitmap { render p_handle, location.x,location.y // if you decide to use a graphic for each arrow, here's where they need to be } else { // draw background setpencolor(parent.controlColor) ldrawrect -(parent.handlewidth/2), 0-(parent.handleheight/2) to (parent.handlewidth/2), (parent.handleheight/2) // draw border setpencolor(parent.borderColor) ldrawframe -(parent.handlewidth/2), 0-(parent.handleheight/2) to (parent.handlewidth/2), (parent.handleheight/2) } } }