// Source - https://github.com/faissaloo/GMLmenus/blob/master/GMLmenus_example.gmx/scripts/draw_menu.gml ///draw_menu(str,background,foreground,x,y,hpadding,vpadding,height,mouse_button) //Distributed under the MIT licence: ///////////////////////////////////////// /*Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ ///////////////////////////////////////// //Height is the height of 1 box //Menu syntax: // |s = seperator (Bug: if |s is placed next to a |n an extra menu item would be added) // |n = new item var str, background, foreground,xx,yy, width, height; str = " "+argument0 //A hacky thing so that it draws the first item properly, I should probably properly fix this later background = argument1 foreground = argument2 xx = argument3 yy = argument4 width = 0//argument5 hpadding = argument5 vpadding = argument6 height = argument7 mb=argument8 //This is the main mouse button, I added this to give more choice to the dev //xx and yy should be corrected if they are placed outside of the room or if they will lead to the menu being cut off by the edge of the room item_list = ds_list_create() item_string = "" /////////////////////////////////// for (i=0;iwidth { width=string_width(item_string) } ds_list_add(item_list,item_string) //Add a new item to the list item_string="" //Reset the item_string } } } draw_set_color(background) //draw_rectangle(xx,yy,xx+width,yy+(height*ds_list_size(item_list)),false) //Background, temporary? draw_button(xx,yy,xx+width+(hpadding*2),yy+(height*(ds_list_size(item_list)-1))+vpadding,true) //Background, temporary? for (i=0;ixx) and (mouse_xyy) and mouse_check_button_released(mb) { //show_message(i+1) //Debugging return i+1; //Returns the number of the item in the list, we're adding 1 because 0 is reserved for if nothing is clicked } } if mouse_check_button_released(mb) and !(mouse_x>xx and mouse_y>yy and mouse_x