#define scr_menu_init //scr_menu made by Martin Larsson 2008 (martin.kj.larsson@telia.com) //version 1 //DEFINING MENU VARIABLES //public variables menu_base_x=room_width/2; //x-origin menu_base_y=50; //y-origin menu_base_width=96; //Default width menu_base_height=32; //Default height menu_base_xscale=1.5; //Top x-scale limit (1=no scaling) menu_base_yscale=1.5; //Top y-scale limit (1=no scaling) menu_base_xspeed=20; //The x-speed of scaling (1=no speed) menu_base_yspeed=20; //The y-speed of scaling (1=no speed) menu_base_halign=0; //The horizontal alignment of the buttons (-1=left, 0=center, 1=right) menu_base_separate=8; //The distance between the buttons menu_base_number=5; //Number of buttons menu_base_font=font_menu; //The font used when drawing the text menu_base_dots=true; //Whether to show dots when the string is to long or not menu_base_color_text=c_black; //Text color menu_base_color_outline=c_black; //Outline color menu_base_color_normal=c_yellow; //Normal color menu_base_color_hover=make_color(255,255,192); //Color when the mouse is hovering over the button menu_base_color_pressed=c_olive; //Color when the mouse is pressed on the button menu_base_fade=96; //The amount of shade on the button menu_base_shade=0.5; //The anpha amount on the shade from the button (0=no shade) menu_base_shade_xoffset=4; //The x-offset of the shade menu_base_shade_yoffset=4; //The y-offset of the shade //private variables for (i=0;i=menu_x[i] and mouse_x=menu_y[i] and mouse_y1) menu_xscale[i]-=menu_base_xscale/menu_base_xspeed; if (menu_yscale[i]>1) menu_yscale[i]-=menu_base_yscale/menu_base_yspeed; } //Adjust the scale so it wont get under 1 if (menu_xscale[i]<1+menu_base_xscale/menu_base_xspeed/4) menu_xscale[i]=1; if (menu_yscale[i]<1+menu_base_yscale/menu_base_yspeed/4) menu_yscale[i]=1; //Adjust the scale so it wont get over the top scale limit if (menu_xscale[i]>menu_base_xscale-menu_base_xscale/menu_base_xspeed/4) menu_xscale[i]=menu_base_xscale; if (menu_yscale[i]>menu_base_yscale-menu_base_yscale/menu_base_yspeed/4) menu_yscale[i]=menu_base_yscale; //Setting the x- and y-coordinates if (menu_base_halign=-1) menu_x[i]=floor(menu_base_x-menu_base_width*menu_xscale[i]); else if (menu_base_halign=0) menu_x[i]=floor(menu_base_x-menu_base_width*menu_xscale[i]/2); else if (menu_base_halign=1) menu_x[i]=menu_base_x; menu_y[i]=menu_base_y+count_y; //Setting the width and height menu_width[i]=floor(menu_xscale[i]*menu_base_width); menu_height[i]=floor(menu_yscale[i]*menu_base_height); //Increases count_y to move on to the next button count_y+=menu_height[i]+menu_base_separate; } return re; #define scr_menu_draw draw_set_halign(fa_center); draw_set_valign(fa_middle); //Making the shade if (menu_base_shade>0) { draw_set_color(c_black); draw_set_alpha(menu_base_shade); for (i=0;imenu_width[i]-8 or string_height(word+"...")>menu_height[i]-8) { //Takes away the last letter until the text fit inside the button word=string_copy(menu_text[i],1,count); count-=1; } word=word+"..."; } else //No dots at the end { while (string_width(word)>menu_width[i]-8 or string_height(word)>menu_height[i]-8) { word=string_copy(menu_text[i],1,count); count-=1; } } draw_text(menu_x[i]+menu_width[i]/2,menu_y[i]+menu_height[i]/2,word); } } #define scr_menu_hover //returns the index of the button that the mouse hovers over (-1=noone) for (i=0;i=menu_x[i] and mouse_x=menu_y[i] and mouse_y