Radio and Check button script
A script to make a button like and within your game.
Radio and Check button script |
//////////////// Radio and Check button script ////////////////////
// // Copyright Simon Donkers 27-1-2005 // www.simondonkers.com - gmmentor@simondonkers.com // // place in the draw event // treat uninitialised varibles as 0 // for check button: // selected = whether clicked on. needs to be initialised by you!!! // for radiobutton: // global.argument4 = id of the selected object // argument0 = x // argument1 = y // argument2 = 0 = check button 1 = radiobutton // argument3 = discription // argument4 = class. clicking on an object of the same class will // unclick all other. class = string. only required for radiobutton // ///////////////////////////////////////////////////// //button discription draw_text(argument0 + 18,argument1 + 8-string_height(argument3)/2,argument3); if argument2 = 0 then { //check button brush_color := c_white; pen_color := c_gray; pen_size := 2; //draw button draw_rectangle(argument0,argument1,argument0 + 16,argument1 + 16); if selected then { pen_color := c_black; //draw cross in it draw_line(argument0 + 3,argument1 + 3,argument0 + 10,argument1 + 10); draw_line(argument0 + 3,argument1 + 10,argument0 + 10,argument1 + 3); } //if pressed if mouse_button = mb_left and pressed = false and mouse_x>argument0 andmouse_x<argument0 + 16 and mouse_y>argument1 and mouse_y<argument1 + 16 then { if selected then { selected := false; } else { selected := true; } mouse_clear(mb_left); } pressed := mouse_button = mb_left; } if argument2 = 1 then { //radiobutton brush_color := c_white; pen_color := c_gray; pen_size := 2; //draw button draw_circle(argument0 + 8,argument1 + 8,8); execute_string('selected := global.' + argument4); if selected = id then { //draw circle in brush_color := c_black; pen_color := c_white; draw_circle(argument0 + 8,argument1 + 8,5); } //if pressed if mouse_button = mb_left and pressed = false and mouse_x>argument0 andmouse_x<argument0 + 16 and mouse_y>argument1 and mouse_y<argument1 + 16 then { if selected!= id then { execute_string('global.' + argument4 + ' := id;'); } mouse_clear(mb_left); } pressed := mouse_button = mb_left; } |