From 5a8cc026cb6fc591795b8b8e0abec245771889bb Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 12 Oct 2007 23:01:07 +0000 Subject: Updates --- menu.bmx | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 menu.bmx (limited to 'menu.bmx') diff --git a/menu.bmx b/menu.bmx new file mode 100644 index 0000000..b441a0f --- /dev/null +++ b/menu.bmx @@ -0,0 +1,76 @@ +' +' Provides simple menus +' +' $Id$ +' +Import noddybox.bitmapfont + +Type TMenu + Field list:TList + Field img:TImage + Field font:TBitmapFont + Field ypos:Int + Field xpos:Int + Field yoff:Int + Field w:Int + Field h:Int + Field count:Int + Field mbdown:Int + + Function Create:TMenu(f:TBitmapFont, img:TImage, y:Int) + Local menu:TMenu=New TMenu + + menu.list=New TList + menu.img=img + menu.font=f + menu.ypos=y + menu.w=ImageWidth(img) + menu.h=ImageHeight(img) + menu.xpos=GraphicsWidth()/2-menu.w/2 + menu.yoff=menu.h/2-f.TextHeight("X")/2 + menu.mbdown=False + Return menu + End Function + + Method Add(s:String) + list.AddLast(s) + End Method + + ' Returns the selected item, or "" for none + ' + Method Render:String() + Local y:Int=ypos + Local in:String="" + Local mx:Int=MouseX() + Local my:Int=MouseY() + Local any:Int=False + + For Local s:String=EachIn list + If (mx>xpos And mxy And my