Added GetUpdateRate

Added GetUpdateRate

Import "native/diddy.${TARGET}.${LANG}"
Import mojo

Extern

	#If LANG="cpp" Then
		Function RealMillisecs:Int() = "diddy::systemMillisecs"
		Function FlushKeys:Void() = "diddy::flushKeys"
		Function HideMouse:Void() = "diddy::hideMouse"
		Function ShowMouse:Void() = "diddy::showMouse"
		Function GetUpdateRate:Int() = "diddy::getUpdateRate"
	#Else
		Function RealMillisecs:Int() = "diddy.systemMillisecs"
		Function FlushKeys:Void() = "diddy.flushKeys"
		Function HideMouse:Void() = "diddy.hideMouse"
		Function ShowMouse:Void() = "diddy.showMouse"
		Function GetUpdateRate:Int() = "diddy.getUpdateRate"
	#End

Public

Function ExitApp:Void()
	Error ""
End

Function RectsOverlap:Int(x0:Float, y0:Float, w0:Float, h0:Float, x2:Float, y2:Float, w2:Float, h2:Float)
	If x0 > (x2 + w2) Or (x0 + w0) < x2 Then Return False
	If y0 > (y2 + h2) Or (y0 + h0) < y2 Then Return False
	Return True
End

Function DrawRectOutline:Void(x:Int, y:Int, w:Int, h:Int)
	w -= 1
	h -= 1
	DrawLine(x,y,x+w,y)
	DrawLine(x+w,y,x+w,y+h)
	DrawLine(x+w,y+h,x,y+h)
	DrawLine(x,y+h,x,y)
End

Function LoadBitmap:Image(path$, flags%=0)
	Local pointer:Image = LoadImage(path, 1, flags)

	If pointer = null
		Error "Error loading bitmap "+path
	End

   	Return pointer
End

Function LoadAnimBitmap:Image(path$, w%, h%, count%, tmpImage:Image)
	'tmpImage = loadBitmap(path) <-- This creates another image, decided to just copy the code here
	tmpImage = LoadImage(path)

	If tmpImage = null Then
		Error "Error loading bitmap "+path
	End

	local pointer:Image = tmpImage.GrabImage( 0, 0, w, h, count, Image.MidHandle)

   	Return pointer
End

Function LoadSoundSample:Sound(path$)
	local pointer:Sound = LoadSound(path)
	if pointer = null
		Error "Error loading sound "+path
	End
	Return pointer
End

Function FormatNumeric:String(value:Float)
	Local i:Int,s:String,ns:String,k:Int
	Local os:String
	s=String(value)
	os=s
	Local pos:Int=s.Length()
	If s.Find(".")>0 pos=s.Find(".") Else os=""
	For i=pos To 1 Step -1
		If k>2 ns+="." k=0
		k+=1
		ns=ns+Mid(s,i,1)
	Next
	s=""
	For i= ns.Length() To 1 Step -1
		s+=Mid(ns,i,1)
	Next
	If os<>"" s=s+","+os[pos+1..]
	Return s
End

Function Left$( str$,n:Int )
	If n>str.Length() n=str.Length()
	Return str[..n]
End

Function Right$( str$,n:Int )
	If n>str.Length() n=str.Length()
	Return str[str.Length()-n..]
End

Function LSet$( str$,n:Int,char:String=" " )
	Local rep:String
	For Local i:Int=1 To n
		rep=rep+char
	Next
	str=str+rep
	Return str[..n]
End

Function RSet$( str$,n:Int,char:String=" " )
	Local rep:String
	For Local i:Int=1 To n
		rep=rep+char
	Next
	str=rep+str
	Return str[str.Length()-n..]
End

Function Mid$( str$,pos:Int,size:Int=-1 )
	If pos>str.Length() Return ""
	pos-=1
	If( size<0 ) Return str[pos..]
	If pos<0 size=size+pos pos=0
	If pos+size>str.Length() size=str.Length()-pos
	Return str[pos..pos+size]
End

Function StripDir$( path$ )
	Local i:=path.FindLast( "/" )
	If i<>-1 Return path[i+1..]
	Return path
End

Function StripExt$( path$ )
	Local i:=path.FindLast( "." )
	If i<>-1 And path.Find( "/",i+1 )=-1 Return path[..i]
	Return path
End

Function StripAll$( path$ )
	Return StripDir( StripExt( path ) )
End

Function Round%(flot#)
	Return Floor(flot+0.5)
End

Function PointInSpot:Int(x1:Float, y1:Float, x2:Float, y2:Float, radius:Float)
	Local dx:Float = x2 - x1
	Local dy:Float = y2 - y1
	Return Sqrt(dx * dx + dy * dy) <= radius
End

Import "native/diddy.${TARGET}.${LANG}"
Import mojo

Extern

	#If LANG="cpp" Then
		Function RealMillisecs:Int() = "diddy::systemMillisecs"
		Function FlushKeys:Void() = "diddy::flushKeys"
		Function HideMouse:Void() = "diddy::hideMouse"
		Function ShowMouse:Void() = "diddy::showMouse"
	#Else
		Function RealMillisecs:Int() = "diddy.systemMillisecs"
		Function FlushKeys:Void() = "diddy.flushKeys"
		Function HideMouse:Void() = "diddy.hideMouse"
		Function ShowMouse:Void() = "diddy.showMouse"
	#End

Public

Function ExitApp:Void()
	Error ""
End

Function RectsOverlap:Int(x0:Float, y0:Float, w0:Float, h0:Float, x2:Float, y2:Float, w2:Float, h2:Float)
	If x0 > (x2 + w2) Or (x0 + w0) < x2 Then Return False
	If y0 > (y2 + h2) Or (y0 + h0) < y2 Then Return False
	Return True
End

Function DrawRectOutline:Void(x:Int, y:Int, w:Int, h:Int)
	w -= 1
	h -= 1
	DrawLine(x,y,x+w,y)
	DrawLine(x+w,y,x+w,y+h)
	DrawLine(x+w,y+h,x,y+h)
	DrawLine(x,y+h,x,y)
End

Function LoadBitmap:Image(path$, flags%=0)
	Local pointer:Image = LoadImage(path, 1, flags)

	If pointer = null
		Error "Error loading bitmap "+path
	End

   	Return pointer
End

Function LoadAnimBitmap:Image(path$, w%, h%, count%, tmpImage:Image)
	'tmpImage = loadBitmap(path) <-- This creates another image, decided to just copy the code here
	tmpImage = LoadImage(path)

	If tmpImage = null Then
		Error "Error loading bitmap "+path
	End

	local pointer:Image = tmpImage.GrabImage( 0, 0, w, h, count, Image.MidHandle)

   	Return pointer
End

Function LoadSoundSample:Sound(path$)
	local pointer:Sound = LoadSound(path)
	if pointer = null
		Error "Error loading sound "+path
	End
	Return pointer
End

Function FormatNumeric:String(value:Float)
	Local i:Int,s:String,ns:String,k:Int
	Local os:String
	s=String(value)
	os=s
	Local pos:Int=s.Length()
	If s.Find(".")>0 pos=s.Find(".") Else os=""
	For i=pos To 1 Step -1
		If k>2 ns+="." k=0
		k+=1
		ns=ns+Mid(s,i,1)
	Next
	s=""
	For i= ns.Length() To 1 Step -1
		s+=Mid(ns,i,1)
	Next
	If os<>"" s=s+","+os[pos+1..]
	Return s
End

Function Left$( str$,n:Int )
	If n>str.Length() n=str.Length()
	Return str[..n]
End

Function Right$( str$,n:Int )
	If n>str.Length() n=str.Length()
	Return str[str.Length()-n..]
End

Function LSet$( str$,n:Int,char:String=" " )
	Local rep:String
	For Local i:Int=1 To n
		rep=rep+char
	Next
	str=str+rep
	Return str[..n]
End

Function RSet$( str$,n:Int,char:String=" " )
	Local rep:String
	For Local i:Int=1 To n
		rep=rep+char
	Next
	str=rep+str
	Return str[str.Length()-n..]
End

Function Mid$( str$,pos:Int,size:Int=-1 )
	If pos>str.Length() Return ""
	pos-=1
	If( size<0 ) Return str[pos..]
	If pos<0 size=size+pos pos=0
	If pos+size>str.Length() size=str.Length()-pos
	Return str[pos..pos+size]
End

Function StripDir$( path$ )
	Local i:=path.FindLast( "/" )
	If i<>-1 Return path[i+1..]
	Return path
End

Function StripExt$( path$ )
	Local i:=path.FindLast( "." )
	If i<>-1 And path.Find( "/",i+1 )=-1 Return path[..i]
	Return path
End

Function StripAll$( path$ )
	Return StripDir( StripExt( path ) )
End

Function Round%(flot#)
	Return Floor(flot+0.5)
End

Function PointInSpot:Int(x1:Float, y1:Float, x2:Float, y2:Float, radius:Float)
	Local dx:Float = x2 - x1
	Local dy:Float = y2 - y1
	Return Sqrt(dx * dx + dy * dy) <= radius
End


Added imageSelectedMO to SimpleGui Button

Import diddy

Const VERTICAL:Int = 0
Const HORIZONTAL:Int = 1

Class SimpleMenu Extends List<SimpleButton>
	Field x:Float, y:Float
	Field buttonGap:Int = 0
	Field mouseOverName:String = ""
	Field clickedName:String = ""
	Field clearClickedName:Int = 1
	Field nextX:Int = 0
	Field nextY:Int = 0
	Field w:Int, h:Int
	Field addGap:Int = 0
	Field soundMouseOver:GameSound
	Field soundClick:GameSound
	Field useVirtualRes:Bool = False
	Field orientation:Int = VERTICAL

	Method New()
		Error "Please use a different constructor"
	End

	Method New(soundMouseOverFile$, soundClickFile$, x:Int, y:Int, gap:Int, useVirtualRes:Bool, orientation:Int = VERTICAL)
		Init(soundMouseOverFile, soundClickFile, x, y, gap, useVirtualRes, orientation)
	End

	Method Init:Void(soundMouseOverFile:String="", soundClickFile:String="", x:Float, y:Float, gap:Int, useVirtualRes:Bool, orientation:Int)
		Self.Clear()
		Self.useVirtualRes = useVirtualRes
		Self.orientation = orientation
		Self.x = x
		Self.y = y
		nextX = x
		nextY = y
		Self.buttonGap = gap
		w = 0
		h = 0
		mouseOverName = ""
		clickedName = ""
		addGap = 0
		If soundMouseOverFile<>"" Then
			soundMouseOver = New GameSound
			soundMouseOver.Load(soundMouseOverFile)
		End
		If soundClickFile<>"" Then
			soundClick = New GameSound
			soundClick.Load(soundClickFile)
		End
	End

	Method CalcWidth:Int()
		Local left:Int=10000
		Local right:Int=-10000
		Local b:SimpleButton
		For b = EachIn Self
			If b.x < left Then left = b.x
			If b.x+b.image.w > right Then right = b.x + b.image.w
		Next
		w = right - left
		Return w
	End

	Method CalcHeight:Int()
		Local top:Int=10000
		Local bot:Int=-10000
		Local b:SimpleButton
		For b = EachIn Self
			If b.y < top Then top = b.y
			If b.y+b.image.h > bot Then bot = b.y + b.image.h
		Next
		h = bot - top
		Return h
	End

	Method SetX:Void(thex#)
		CalcLeft()
		Local oldx# = x
		x = thex
		Local diff# = x - oldx
		Local b:SimpleButton
		For b = EachIn Self
			b.MoveBy(diff,0)
		Next
	End

	Method SetY:Void(they#)
		CalcTop()
		Local oldy# = y
		y = they
		Local diff# = y-oldy
		Local b:SimpleButton
		For b = EachIn Self
			b.MoveBy(0,diff)
		Next
	End

	Method CalcLeft:Void()
		x = 10000
		Local b:SimpleButton
		For b = EachIn Self
			If b.x <x Then x = b.x
		Next
	End

	Method CalcTop:Void()
		y = 10000
		Local b:SimpleButton
		For b = EachIn Self
			If b.y < y Then y = b.y
		Next
	End

	Method CentreHoriz:Void()
		CalcWidth()
		if useVirtualRes
			SetX((SCREEN_WIDTH-w)/2)
		Else
			SetX((DEVICE_WIDTH-w)/2)
		End
	End

	Method CentreVert:Void()
		CalcHeight()
		if useVirtualRes
			SetY((SCREEN_HEIGHT-h)/2)
		Else
			SetY((DEVICE_HEIGHT-h)/2)
		End
	End

	Method Centre:Void()
		CentreHoriz()
		CentreVert()
	End

	Method SetMenuAlpha:Void(alpha:Float)
		Local b:SimpleButton
		For b = EachIn Self
			b.alpha = alpha
		Next
	End

	Method AddButton:SimpleButton(buttonImageFile:String, mouseOverFile:String, name:String="")
		Local b:SimpleButton = ProcessAddButton(buttonImageFile, mouseOverFile, name)
		If orientation = VERTICAL
			IncreaseHeight(b)
		Else
			IncreaseWidth(b)
		End
		Return b
	End

	Method IncreaseHeight:Void(b:SimpleButton)
		nextY = nextY + b.image.h + buttonGap

		h = h + b.image.h
		If addGap Then
			h = h + buttonGap
		Else
			addGap = 1
		End
	End

	Method IncreaseWidth:Void(b:SimpleButton)
		nextX = nextX + b.image.w + buttonGap

		w = w + b.image.w
		If addGap Then
			w = w + buttonGap
		Else
			addGap = 1
		End
	End

	Method ProcessAddButton:SimpleButton(buttonImageFile:String, mouseOverFile:String, name:String)
		Local b:SimpleButton = New SimpleButton
		b.Load(buttonImageFile, mouseOverFile)
		b.useVirtualRes = Self.useVirtualRes
		b.orientation = Self.orientation
		If name <> "" Then b.name = name.ToUpper()
		If orientation = VERTICAL
			b.CentreX(nextY)
		Else
			b.MoveTo(nextX, nextY)
		End

		b.soundMouseOver = soundMouseOver
		b.soundClick = soundClick
		AddLast(b)
		Return b
	End

	Method FindButton:SimpleButton(name:String)
		name = name.ToUpper()
		Local b:SimpleButton
		For b = EachIn Self
			If b.name = name Then Return b
		Next
		Return Null
	End

	Method Clicked:Int(name:String)
		name = name.ToUpper()
		If name = clickedName
			If clearClickedName Then clickedName = ""
			Return 1
		Else
			Return 0
		End
	End

	Method Update:Int()
		If game.screenFade.active
			Return 0
		EndIf
		clickedName = ""
		Local b:SimpleButton
		For b = EachIn Self
			b.Update()
			If b.mouseOver Then mouseOverName = b.name
			If b.clicked Then clickedName = b.name
		Next
		Return 1
	End

	Method Precache:Void()
		For Local b:SimpleButton = EachIn Self
			b.Precache()
		Next
	End

	Method Draw:Void()
		For Local b:SimpleButton = EachIn Self
			b.Draw()
		Next
	End
End

Class SimpleButton Extends Sprite
	Field active:Int = 1
	Field clicked:Int = 0
	Field selected:Int = 0
	Field mouseOver:Int = 0
	Field disabled:Bool = False
	Field soundMouseOver:GameSound
	Field soundClick:GameSound
	Field imageMouseOver:GameImage
	Field imageSelected:GameImage
	Field imageSelectedMO:GameImage
	Field useVirtualRes:Bool = False
	Field orientation:Int = VERTICAL

	Method Precache:Void()
		If image<>null
			Super.Precache()
		End
	End

	Method Draw:Void()
		If active = 0 Then Return
		SetAlpha Self.alpha
		if mouseOver
			if selected And imageSelectedMO <> null Then
				DrawImage Self.imageSelectedMO.image, x, y
			Else
				DrawImage Self.imageMouseOver.image, x, y
			End
		ElseIf selected And imageSelected <> null Then
			DrawImage Self.imageSelected.image, x, y
		Else
			DrawImage Self.image.image, x, y
		EndIf
		SetAlpha 1
	End

	Method Click:Void()
		If clicked = 0
			clicked = 1
			If soundClick <> null
				soundClick.Play()
			End
		End
	End

	Method CentreX:Void(yCoord:Int)
		if useVirtualRes
			MoveTo((SCREEN_WIDTH-image.w)/2, yCoord)
		Else
			MoveTo((DEVICE_WIDTH-image.w)/2, yCoord)
		End

	End

	Method CentreY:Void(xCoord:Int)
		If useVirtualRes
			MoveTo((SCREEN_HEIGHT-image.h)/2, xCoord)
		Else
			MoveTo((DEVICE_HEIGHT-image.h)/2, xCoord)
		End
	End

	Method MoveBy:Void(dx:Float,dy:Float)
		x+=dx
		y+=dy
	End Method

	Method MoveTo:Void(dx:Float,dy:Float)
		x=dx
		y=dy
	End Method

	Method Load:Void(buttonImage:String, mouseOverImage:String = "", soundMouseOverFile:String="", soundClickFile:String="")
		Self.image = New GameImage
		image.Load(game.images.path + buttonImage, False)

		if  mouseOverImage <> ""
			imageMouseOver = New GameImage
			imageMouseOver.Load(game.images.path + mouseOverImage, False)
		End

		name = StripAll(buttonImage.ToUpper())

		If soundMouseOverFile<>"" Then
			soundMouseOver = New GameSound
			soundMouseOver.Load(soundMouseOverFile)
		End
		If soundClickFile<>"" Then
			soundClick = New GameSound
			soundClick.Load(soundClickFile)
		End
	End

	Method SetSelectedImage:Void(buttonImage:String, buttonImageMO:String = "")
		imageSelected = New GameImage
		imageSelected.Load(game.images.path + buttonImage, False)

		if  buttonImageMO <> ""
			imageSelectedMO = New GameImage
			imageSelectedMO.Load(game.images.path + buttonImageMO, False)
		End

	End

	Method Update:Void()
		If active = 0 or disabled Then Return
		Local mx:Int = game.mouseX
		Local my:Int = game.mouseY
		if not useVirtualRes
			mx = MouseX()
			my = MouseY()
		End
		If mx >= x And mx < x+image.w And my >= y And my < y+image.h Then
			If mouseOver = 0
				if soundMouseOver <> null
					soundMouseOver.Play()
				End
			End
			mouseOver = 1
			If MouseHit() Then
				Click()
			Else
				clicked = 0
			End
		Else
			mouseOver = 0
			clicked = 0
		End
	End
End

Class SimpleSlider Extends Sprite
	Field active:Int
	Field dotImage:GameImage
	Field dotX:Int, dotY:Int
	Field value:Int
	Field border:Int=0
	Field borderY:Int=5
	Field useVirtualRes:Bool = False

	Method New(barFile:String, dotFile:String, x:Int, y:int, border:int = 0, name:String="", borderY:int=5, useVirtualRes:Bool = True)
		Self.image = New GameImage
		Self.useVirtualRes = useVirtualRes

		image.Load(game.images.path + barFile, False)
		name = StripAll(barFile.ToUpper())

		dotImage = New GameImage
		dotImage.Load(game.images.path + dotFile, False)
		dotImage.name = StripAll(dotFile.ToUpper())

		Self.x = x
		Self.y = y
		Self.border = border
		Self.borderY = borderY

		Self.SetValue(50)
		Self.dotY = y-3
		Self.active = 1
	End

	Method SetValue:Void(toSet:int)
		value = toSet
		If toSet < 0 Then value = 0
		If toSet > 100 Then value = 100
		Local percent:Float = value/100.0
		dotX = x + border + (percent * (image.w - (border * 2))) - dotImage.w2
	End Method

	Method Update:Int()
		Local change:Int=0
		If active
			Local buffer:int = 10
			Local mx:Int = game.mouseX
			Local my:Int = game.mouseY
			if not useVirtualRes
				mx = MouseX()
				my = MouseY()
			End
			If mx >= x-buffer And mx < x + image.w + buffer And my >= y-borderY And my < y+image.h+borderY
				If MouseDown(MOUSE_LEFT)
					If mx <= x+border
						SetValue(0)
						change = 1
					ElseIf mx >= x+image.w-border
						SetValue(100)
						change = 1
					Else
						Local d:Float = mx - x - border
						Local p:Float = d/(image.w-(border*2))
						SetValue(Round(p*100))
						change = 1
					End
				End
			End
		End
		Return change
	End

	Method Draw:Void()
		If active
			DrawImage(image.image,x,y)
			DrawImage(dotImage.image,dotX,dotY)
		End
	End
End

Import diddy

Const VERTICAL:Int = 0
Const HORIZONTAL:Int = 1

Class SimpleMenu Extends List<SimpleButton>
	Field x:Float, y:Float
	Field buttonGap:Int = 0
	Field mouseOverName:String = ""
	Field clickedName:String = ""
	Field clearClickedName:Int = 1
	Field nextX:Int = 0
	Field nextY:Int = 0
	Field w:Int, h:Int
	Field addGap:Int = 0
	Field soundMouseOver:GameSound
	Field soundClick:GameSound
	Field useVirtualRes:Bool = False
	Field orientation:Int = VERTICAL

	Method New()
		Error "Please use a different constructor"
	End

	Method New(soundMouseOverFile$, soundClickFile$, x:Int, y:Int, gap:Int, useVirtualRes:Bool, orientation:Int = VERTICAL)
		Init(soundMouseOverFile, soundClickFile, x, y, gap, useVirtualRes, orientation)
	End

	Method Init:Void(soundMouseOverFile:String="", soundClickFile:String="", x:Float, y:Float, gap:Int, useVirtualRes:Bool, orientation:Int)
		Self.Clear()
		Self.useVirtualRes = useVirtualRes
		Self.orientation = orientation
		Self.x = x
		Self.y = y
		nextX = x
		nextY = y
		Self.buttonGap = gap
		w = 0
		h = 0
		mouseOverName = ""
		clickedName = ""
		addGap = 0
		If soundMouseOverFile<>"" Then
			soundMouseOver = New GameSound
			soundMouseOver.Load(soundMouseOverFile)
		End
		If soundClickFile<>"" Then
			soundClick = New GameSound
			soundClick.Load(soundClickFile)
		End
	End

	Method CalcWidth:Int()
		Local left:Int=10000
		Local right:Int=-10000
		Local b:SimpleButton
		For b = EachIn Self
			If b.x < left Then left = b.x
			If b.x+b.image.w > right Then right = b.x + b.image.w
		Next
		w = right - left
		Return w
	End

	Method CalcHeight:Int()
		Local top:Int=10000
		Local bot:Int=-10000
		Local b:SimpleButton
		For b = EachIn Self
			If b.y < top Then top = b.y
			If b.y+b.image.h > bot Then bot = b.y + b.image.h
		Next
		h = bot - top
		Return h
	End

	Method SetX:Void(thex#)
		CalcLeft()
		Local oldx# = x
		x = thex
		Local diff# = x - oldx
		Local b:SimpleButton
		For b = EachIn Self
			b.MoveBy(diff,0)
		Next
	End

	Method SetY:Void(they#)
		CalcTop()
		Local oldy# = y
		y = they
		Local diff# = y-oldy
		Local b:SimpleButton
		For b = EachIn Self
			b.MoveBy(0,diff)
		Next
	End

	Method CalcLeft:Void()
		x = 10000
		Local b:SimpleButton
		For b = EachIn Self
			If b.x <x Then x = b.x
		Next
	End

	Method CalcTop:Void()
		y = 10000
		Local b:SimpleButton
		For b = EachIn Self
			If b.y < y Then y = b.y
		Next
	End

	Method CentreHoriz:Void()
		CalcWidth()
		if useVirtualRes
			SetX((SCREEN_WIDTH-w)/2)
		Else
			SetX((DEVICE_WIDTH-w)/2)
		End
	End

	Method CentreVert:Void()
		CalcHeight()
		if useVirtualRes
			SetY((SCREEN_HEIGHT-h)/2)
		Else
			SetY((DEVICE_HEIGHT-h)/2)
		End
	End

	Method Centre:Void()
		CentreHoriz()
		CentreVert()
	End

	Method SetMenuAlpha:Void(alpha:Float)
		Local b:SimpleButton
		For b = EachIn Self
			b.alpha = alpha
		Next
	End

	Method AddButton:SimpleButton(buttonImageFile:String, mouseOverFile:String, name:String="")
		Local b:SimpleButton = ProcessAddButton(buttonImageFile, mouseOverFile, name)
		If orientation = VERTICAL
			IncreaseHeight(b)
		Else
			IncreaseWidth(b)
		End
		Return b
	End

	Method IncreaseHeight:Void(b:SimpleButton)
		nextY = nextY + b.image.h + buttonGap

		h = h + b.image.h
		If addGap Then
			h = h + buttonGap
		Else
			addGap = 1
		End
	End

	Method IncreaseWidth:Void(b:SimpleButton)
		nextX = nextX + b.image.w + buttonGap

		w = w + b.image.w
		If addGap Then
			w = w + buttonGap
		Else
			addGap = 1
		End
	End

	Method ProcessAddButton:SimpleButton(buttonImageFile:String, mouseOverFile:String, name:String)
		Local b:SimpleButton = New SimpleButton
		b.Load(buttonImageFile, mouseOverFile)
		b.useVirtualRes = Self.useVirtualRes
		b.orientation = Self.orientation
		If name <> "" Then b.name = name.ToUpper()
		If orientation = VERTICAL
			b.CentreX(nextY)
		Else
			b.MoveTo(nextX, nextY)
		End

		b.soundMouseOver = soundMouseOver
		b.soundClick = soundClick
		AddLast(b)
		Return b
	End

	Method FindButton:SimpleButton(name:String)
		name = name.ToUpper()
		Local b:SimpleButton
		For b = EachIn Self
			If b.name = name Then Return b
		Next
		Return Null
	End

	Method Clicked:Int(name:String)
		name = name.ToUpper()
		If name = clickedName
			If clearClickedName Then clickedName = ""
			Return 1
		Else
			Return 0
		End
	End

	Method Update:Int()
		If game.screenFade.active
			Return 0
		EndIf
		clickedName = ""
		Local b:SimpleButton
		For b = EachIn Self
			b.Update()
			If b.mouseOver Then mouseOverName = b.name
			If b.clicked Then clickedName = b.name
		Next
		Return 1
	End

	Method Precache:Void()
		For Local b:SimpleButton = EachIn Self
			b.Precache()
		Next
	End

	Method Draw:Void()
		For Local b:SimpleButton = EachIn Self
			b.Draw()
		Next
	End
End

Class SimpleButton Extends Sprite
	Field active:Int = 1
	Field clicked:Int = 0
	Field selected:Int = 0
	Field mouseOver:Int = 0
	Field disabled:Bool = False
	Field soundMouseOver:GameSound
	Field soundClick:GameSound
	Field imageMouseOver:GameImage
	Field imageSelected:GameImage
	Field useVirtualRes:Bool = False
	Field orientation:Int = VERTICAL

	Method Precache:Void()
		If image<>null
			Super.Precache()
		End
	End

	Method Draw:Void()
		If active = 0 Then Return
		SetAlpha Self.alpha
		if mouseOver
			DrawImage Self.imageMouseOver.image, x, y
		ElseIf selected And imageSelected <> null Then
			DrawImage Self.imageSelected.image, x, y
		Else
			DrawImage Self.image.image, x, y
		EndIf
		SetAlpha 1
	End

	Method Click:Void()
		If clicked = 0
			clicked = 1
			If soundClick <> null
				soundClick.Play()
			End
		End
	End

	Method CentreX:Void(yCoord:Int)
		if useVirtualRes
			MoveTo((SCREEN_WIDTH-image.w)/2, yCoord)
		Else
			MoveTo((DEVICE_WIDTH-image.w)/2, yCoord)
		End

	End

	Method CentreY:Void(xCoord:Int)
		If useVirtualRes
			MoveTo((SCREEN_HEIGHT-image.h)/2, xCoord)
		Else
			MoveTo((DEVICE_HEIGHT-image.h)/2, xCoord)
		End
	End

	Method MoveBy:Void(dx:Float,dy:Float)
		x+=dx
		y+=dy
	End Method

	Method MoveTo:Void(dx:Float,dy:Float)
		x=dx
		y=dy
	End Method

	Method Load:Void(buttonImage:String, mouseOverImage:String = "", soundMouseOverFile:String="", soundClickFile:String="")
		Self.image = New GameImage
		image.Load(game.images.path + buttonImage, False)

		if  mouseOverImage <> ""
			imageMouseOver = New GameImage
			imageMouseOver.Load(game.images.path + mouseOverImage, False)
		End

		name = StripAll(buttonImage.ToUpper())

		If soundMouseOverFile<>"" Then
			soundMouseOver = New GameSound
			soundMouseOver.Load(soundMouseOverFile)
		End
		If soundClickFile<>"" Then
			soundClick = New GameSound
			soundClick.Load(soundClickFile)
		End
	End

	Method SetSelectedImage:Void(buttonImage:String)
		imageSelected = New GameImage
		imageSelected.Load(game.images.path + buttonImage, False)
	End

	Method Update:Void()
		If active = 0 or disabled Then Return
		Local mx:Int = game.mouseX
		Local my:Int = game.mouseY
		if not useVirtualRes
			mx = MouseX()
			my = MouseY()
		End
		If mx >= x And mx < x+image.w And my >= y And my < y+image.h Then
			If mouseOver = 0
				if soundMouseOver <> null
					soundMouseOver.Play()
				End
			End
			mouseOver = 1
			If MouseHit() Then
				Click()
			Else
				clicked = 0
			End
		Else
			mouseOver = 0
			clicked = 0
		End
	End
End

Class SimpleSlider Extends Sprite
	Field active:Int
	Field dotImage:GameImage
	Field dotX:Int, dotY:Int
	Field value:Int
	Field border:Int=0
	Field borderY:Int=5
	Field useVirtualRes:Bool = False

	Method New(barFile:String, dotFile:String, x:Int, y:int, border:int = 0, name:String="", borderY:int=5, useVirtualRes:Bool = True)
		Self.image = New GameImage
		Self.useVirtualRes = useVirtualRes

		image.Load(game.images.path + barFile, False)
		name = StripAll(barFile.ToUpper())

		dotImage = New GameImage
		dotImage.Load(game.images.path + dotFile, False)
		dotImage.name = StripAll(dotFile.ToUpper())

		Self.x = x
		Self.y = y
		Self.border = border
		Self.borderY = borderY

		Self.SetValue(50)
		Self.dotY = y-3
		Self.active = 1
	End

	Method SetValue:Void(toSet:int)
		value = toSet
		If toSet < 0 Then value = 0
		If toSet > 100 Then value = 100
		Local percent:Float = value/100.0
		dotX = x + border + (percent * (image.w - (border * 2))) - dotImage.w2
	End Method

	Method Update:Int()
		Local change:Int=0
		If active
			Local buffer:int = 10
			Local mx:Int = game.mouseX
			Local my:Int = game.mouseY
			if not useVirtualRes
				mx = MouseX()
				my = MouseY()
			End
			If mx >= x-buffer And mx < x + image.w + buffer And my >= y-borderY And my < y+image.h+borderY
				If MouseDown(MOUSE_LEFT)
					If mx <= x+border
						SetValue(0)
						change = 1
					ElseIf mx >= x+image.w-border
						SetValue(100)
						change = 1
					Else
						Local d:Float = mx - x - border
						Local p:Float = d/(image.w-(border*2))
						SetValue(Round(p*100))
						change = 1
					End
				End
			End
		End
		Return change
	End

	Method Draw:Void()
		If active
			DrawImage(image.image,x,y)
			DrawImage(dotImage.image,dotX,dotY)
		End
	End
End


Removed extra Return statement

Removed extra Return statement

--HG--
extra : convert_revision : svn%3Ae934d3cd-0d57-f34a-94d0-9e8d31ae1c29/trunk%4056

Strict

Import diddy.collections
Import monkey.list

Function Main:Int()
	TestArrayList()
	'TestArrayListSorting()
	'SpeedComparison()
	'ArrayListSortingSpeed(10000)
	Return 0
End

Function TestArrayList:Void()
	Print("Adding 3 elements to l1...")
	Local l1:ArrayList<StringObject> = New ArrayList<StringObject>
	l1.Add("test3")
	l1.Add("test2")
	l1.Add("test1")
	Print("l1.Size="+l1.Size)

	Print("Adding 3 elements to l2...")
	Local l2:ArrayList<StringObject> = New ArrayList<StringObject>
	l2.Add("test6")
	l2.Add("test5")
	l2.Add("test4")
	Print("l2.Size="+l2.Size)

	Print("Adding contents of l2 to l1..")
	l1.AddAll(l2)
	Print("l1.Size="+l1.Size)

	Print("Calling l1.ToArray (creates a new array)...")
	Local arr:Object[] = l1.ToArray()
	Print("Array length="+arr.Length)
	Print("Looping on array with EachIn...")
	For Local o:Object = EachIn arr
		Print("value="+StringObject(o).value)
	Next

	Print("Calling l2.FillArray (reuses an existing array, and we know that the results will fit)...")
	Local len:Int = l2.FillArray(arr)
	Print("Returned value (size)="+len)
	Print("Looping on array with index...")
	For Local i:Int = 0 Until len
		Print("value["+i+"]="+StringObject(arr[i]).value)
	Next

	Print("Looping on l1 using EachIn...")
	For Local so:StringObject = EachIn l1
		Print("value="+so.value)
	Next

	Print("Looping on l1 manually with AbstractEnumerator...")
	Local oe:AbstractEnumerator<StringObject> = l1.ObjectEnumerator()
	While oe.HasNext()
		Local val:StringObject = oe.NextObject()
		Print("value="+val.value)
	End

	Print("Jumping to end of AbstractEnumerator and looping in reverse...")
	oe = l1.ObjectEnumerator()
	oe.Last()
	While oe.HasPrevious()
		Local val:StringObject = oe.PreviousObject()
		Print("value="+val.value)
	End
	Print("And now looping forward again...")
	While oe.HasNext()
		Local val:StringObject = oe.NextObject()
		Print("value="+val.value)
	End

	Print("Testing removing items with AbstractEnumerator (forward)...")
	Print("We'll remove the item 'test1'")
	oe = l1.ObjectEnumerator()
	While oe.HasNext()
		Local val:StringObject = oe.NextObject()
		Print("value="+val.value)
		If val.value = "test1" Then
			Print("Removing...")
			oe.Remove()
		End
	End

	Print("Now we'll loop back to make sure it worked...")
	oe.Last()
	While oe.HasPrevious()
		Local val:StringObject = oe.PreviousObject()
		Print("value="+val.value)
	End

	Print("Testing concurrency checks by removing within an EachIn loop (uncomment to test)...")
	#Rem
	For Local so:StringObject = EachIn l1
		Print("value="+so.value)
		Print("Manually removing it...")
		l1.RemoveAt(0)
		Print("Next call to HasNext should fail.")
	End
	#End
End

Function TestArrayListSorting:Void()
	Local al:ArrayList<IntObject> = New ArrayList<IntObject>()
	Print("Adding 8 ints")
	al.Add(New IntObject(5))
	al.Add(New IntObject(7))
	al.Add(New IntObject(5))
	al.Add(New IntObject(2))
	al.Add(New IntObject(10))
	al.Add(New IntObject(1))
	al.Add(New IntObject(11))
	al.Add(New IntObject(8))

	Print("Printing them pre-sort")
	For Local o:IntObject = EachIn(al)
		Print("o="+o.value)
	Next

	Print("Sorting ascending")
	al.Sort()
	Print("Printing them post-sort")
	For Local o:IntObject = EachIn(al)
		Print("o="+o.value)
	Next

	Print("Sorting Descending")
	al.Sort(True)
	Print("Printing them post-sort")
	For Local o:IntObject = EachIn(al)
		Print("o="+o.value)
	Next
End

Function SpeedComparison:Void()
	Local al:ArrayList<StringObject> = New ArrayList<StringObject>(1000000)
	Local lst:List<StringObject> = New List<StringObject>()

	Local startTime:Int

	Print("Testing adding 1000000 items to an ArrayList")
	startTime = RealMillisecs()
	For Local i:Int = 0 Until 1000000
		al.Add("test")'+i)
	Next
	Print("Took: "+(RealMillisecs()-startTime))

	Print("Testing adding 1000000 items to a List")
	startTime = RealMillisecs()
	For Local i:Int = 0 Until 1000000
		lst.AddLast("test")'+i)
	Next
	Print("Took: "+(RealMillisecs()-startTime))

	Print("Testing looping through an ArrayList with EachIn")
	startTime = RealMillisecs()
	For Local so:StringObject = EachIn al
		' do nothing
	Next
	Print("Took: "+(RealMillisecs()-startTime))

	Print("Testing looping through a List with EachIn")
	startTime = RealMillisecs()
	For Local so:StringObject = EachIn lst
		' do nothing
	Next
	Print("Took: "+(RealMillisecs()-startTime))

	Print("Testing looping through an ArrayList manually")
	startTime = RealMillisecs()
	For Local i:Int = 0 Until al.Size
		Local so:StringObject = al.Get(i)
		' do nothing
	Next
	Print("Took: "+(RealMillisecs()-startTime))

	Print("Testing ToArray")
	startTime = RealMillisecs()
	Local arr:Object[] = al.ToArray()
	Print("Took: "+(RealMillisecs()-startTime))

	Print("Testing looping through an ArrayList ToArray ("+arr.Length+" elements)")
	startTime = RealMillisecs()
	For Local i:Int = 0 Until arr.Length
		' do nothing
	Next
	Print("Took: "+(RealMillisecs()-startTime))
End

Function ArrayListSortingSpeed:Void(numToTest:Int=1000)
	Local startTime:Int

	Local al:ArrayList<IntObject> = New ArrayList<IntObject>(numToTest+10)
	Print("Seeding with: " + RealMillisecs())
	Print("Adding "+numToTest+" random ints")
	startTime = RealMillisecs()
	For Local i%=1 To numToTest
		al.Add(New IntObject(Int(Rnd()*1000)))
	Next
	Print("Took: "+(RealMillisecs()-startTime))
	Print("Size: "+al.Size)
	Print("First 10:")
	For Local i%=0 To 9
		Print(al.Get(i).value)
	Next

	Print("Sorting ascending")
	startTime = RealMillisecs()
	al.Sort()
	Print("Took: "+(RealMillisecs()-startTime))
	Print("First 10:")
	For Local i%=0 To 9
		Print(al.Get(i).value)
	Next

	Print("Clearing")
	startTime = RealMillisecs()
	al.Clear()
	Print("Took: "+(RealMillisecs()-startTime))

	Print("Adding "+numToTest+" random ints again")
	startTime = RealMillisecs()
	For Local i%=1 To numToTest
		al.Add(New IntObject(Int(Rnd()*1000)))
	Next
	Print("Took: "+(RealMillisecs()-startTime))
	Print("Size: "+al.Size)
	Print("First 10:")
	For Local i%=0 To 9
		Print(al.Get(i).value)
	Next

	Print("Sorting descending")
	startTime = RealMillisecs()
	al.Sort(True)
	Print("Took: "+(RealMillisecs()-startTime))
	Print("First 10:")
	For Local i%=0 To 9
		Print(al.Get(i).value)
	Next

	Print("Trying floats")
	Local fal:ArrayList<FloatObject> = New ArrayList<FloatObject>(numToTest+10)
	Print("Adding "+numToTest+" random floats")
	startTime = RealMillisecs()
	For Local i%=1 To numToTest
		fal.Add(New FloatObject(Rnd()*1000))
	Next
	Print("Took: "+(RealMillisecs()-startTime))
	Print("Size: "+fal.Size)
	Print("First 10:")
	For Local i%=0 To 9
		Print(fal.Get(i).value)
	Next

	Print("Sorting ascending")
	startTime = RealMillisecs()
	fal.Sort()
	Print("Took: "+(RealMillisecs()-startTime))
	Print("First 10:")
	For Local i%=0 To 9
		Print(fal.Get(i).value)
	Next

	Print("Clearing")
	startTime = RealMillisecs()
	fal.Clear()
	Print("Took: "+(RealMillisecs()-startTime))

	Print("Adding "+numToTest+" random floats again")
	startTime = RealMillisecs()
	For Local i%=1 To numToTest
		fal.Add(New FloatObject(Rnd()*1000))
	Next
	Print("Took: "+(RealMillisecs()-startTime))
	Print("Size: "+al.Size)
	Print("First 10:")
	For Local i%=0 To 9
		Print(fal.Get(i).value)
	Next

	Print("Sorting descending")
	startTime = RealMillisecs()
	fal.Sort(True)
	Print("Took: "+(RealMillisecs()-startTime))
	Print("First 10:")
	For Local i%=0 To 9
		Print(fal.Get(i).value)
	Next
End

Strict

Import diddy.collections
Import monkey.list

Function Main:Int()
	TestArrayList()
	'TestArrayListSorting()
	'SpeedComparison()
	'ArrayListSortingSpeed(10000)
	Return 0
	Return 0
End

Function TestArrayList:Void()
	Print("Adding 3 elements to l1...")
	Local l1:ArrayList<StringObject> = New ArrayList<StringObject>
	l1.Add("test3")
	l1.Add("test2")
	l1.Add("test1")
	Print("l1.Size="+l1.Size)

	Print("Adding 3 elements to l2...")
	Local l2:ArrayList<StringObject> = New ArrayList<StringObject>
	l2.Add("test6")
	l2.Add("test5")
	l2.Add("test4")
	Print("l2.Size="+l2.Size)

	Print("Adding contents of l2 to l1..")
	l1.AddAll(l2)
	Print("l1.Size="+l1.Size)

	Print("Calling l1.ToArray (creates a new array)...")
	Local arr:Object[] = l1.ToArray()
	Print("Array length="+arr.Length)
	Print("Looping on array with EachIn...")
	For Local o:Object = EachIn arr
		Print("value="+StringObject(o).value)
	Next

	Print("Calling l2.FillArray (reuses an existing array, and we know that the results will fit)...")
	Local len:Int = l2.FillArray(arr)
	Print("Returned value (size)="+len)
	Print("Looping on array with index...")
	For Local i:Int = 0 Until len
		Print("value["+i+"]="+StringObject(arr[i]).value)
	Next

	Print("Looping on l1 using EachIn...")
	For Local so:StringObject = EachIn l1
		Print("value="+so.value)
	Next

	Print("Looping on l1 manually with AbstractEnumerator...")
	Local oe:AbstractEnumerator<StringObject> = l1.ObjectEnumerator()
	While oe.HasNext()
		Local val:StringObject = oe.NextObject()
		Print("value="+val.value)
	End

	Print("Jumping to end of AbstractEnumerator and looping in reverse...")
	oe = l1.ObjectEnumerator()
	oe.Last()
	While oe.HasPrevious()
		Local val:StringObject = oe.PreviousObject()
		Print("value="+val.value)
	End
	Print("And now looping forward again...")
	While oe.HasNext()
		Local val:StringObject = oe.NextObject()
		Print("value="+val.value)
	End

	Print("Testing removing items with AbstractEnumerator (forward)...")
	Print("We'll remove the item 'test1'")
	oe = l1.ObjectEnumerator()
	While oe.HasNext()
		Local val:StringObject = oe.NextObject()
		Print("value="+val.value)
		If val.value = "test1" Then
			Print("Removing...")
			oe.Remove()
		End
	End

	Print("Now we'll loop back to make sure it worked...")
	oe.Last()
	While oe.HasPrevious()
		Local val:StringObject = oe.PreviousObject()
		Print("value="+val.value)
	End

	Print("Testing concurrency checks by removing within an EachIn loop (uncomment to test)...")
	#Rem
	For Local so:StringObject = EachIn l1
		Print("value="+so.value)
		Print("Manually removing it...")
		l1.RemoveAt(0)
		Print("Next call to HasNext should fail.")
	End
	#End
End

Function TestArrayListSorting:Void()
	Local al:ArrayList<IntObject> = New ArrayList<IntObject>()
	Print("Adding 8 ints")
	al.Add(New IntObject(5))
	al.Add(New IntObject(7))
	al.Add(New IntObject(5))
	al.Add(New IntObject(2))
	al.Add(New IntObject(10))
	al.Add(New IntObject(1))
	al.Add(New IntObject(11))
	al.Add(New IntObject(8))

	Print("Printing them pre-sort")
	For Local o:IntObject = EachIn(al)
		Print("o="+o.value)
	Next

	Print("Sorting ascending")
	al.Sort()
	Print("Printing them post-sort")
	For Local o:IntObject = EachIn(al)
		Print("o="+o.value)
	Next

	Print("Sorting Descending")
	al.Sort(True)
	Print("Printing them post-sort")
	For Local o:IntObject = EachIn(al)
		Print("o="+o.value)
	Next
End

Function SpeedComparison:Void()
	Local al:ArrayList<StringObject> = New ArrayList<StringObject>(1000000)
	Local lst:List<StringObject> = New List<StringObject>()

	Local startTime:Int

	Print("Testing adding 1000000 items to an ArrayList")
	startTime = RealMillisecs()
	For Local i:Int = 0 Until 1000000
		al.Add("test")'+i)
	Next
	Print("Took: "+(RealMillisecs()-startTime))

	Print("Testing adding 1000000 items to a List")
	startTime = RealMillisecs()
	For Local i:Int = 0 Until 1000000
		lst.AddLast("test")'+i)
	Next
	Print("Took: "+(RealMillisecs()-startTime))

	Print("Testing looping through an ArrayList with EachIn")
	startTime = RealMillisecs()
	For Local so:StringObject = EachIn al
		' do nothing
	Next
	Print("Took: "+(RealMillisecs()-startTime))

	Print("Testing looping through a List with EachIn")
	startTime = RealMillisecs()
	For Local so:StringObject = EachIn lst
		' do nothing
	Next
	Print("Took: "+(RealMillisecs()-startTime))

	Print("Testing looping through an ArrayList manually")
	startTime = RealMillisecs()
	For Local i:Int = 0 Until al.Size
		Local so:StringObject = al.Get(i)
		' do nothing
	Next
	Print("Took: "+(RealMillisecs()-startTime))

	Print("Testing ToArray")
	startTime = RealMillisecs()
	Local arr:Object[] = al.ToArray()
	Print("Took: "+(RealMillisecs()-startTime))

	Print("Testing looping through an ArrayList ToArray ("+arr.Length+" elements)")
	startTime = RealMillisecs()
	For Local i:Int = 0 Until arr.Length
		' do nothing
	Next
	Print("Took: "+(RealMillisecs()-startTime))
End

Function ArrayListSortingSpeed:Void(numToTest:Int=1000)
	Local startTime:Int

	Local al:ArrayList<IntObject> = New ArrayList<IntObject>(numToTest+10)
	Print("Seeding with: " + RealMillisecs())
	Print("Adding "+numToTest+" random ints")
	startTime = RealMillisecs()
	For Local i%=1 To numToTest
		al.Add(New IntObject(Int(Rnd()*1000)))
	Next
	Print("Took: "+(RealMillisecs()-startTime))
	Print("Size: "+al.Size)
	Print("First 10:")
	For Local i%=0 To 9
		Print(al.Get(i).value)
	Next

	Print("Sorting ascending")
	startTime = RealMillisecs()
	al.Sort()
	Print("Took: "+(RealMillisecs()-startTime))
	Print("First 10:")
	For Local i%=0 To 9
		Print(al.Get(i).value)
	Next

	Print("Clearing")
	startTime = RealMillisecs()
	al.Clear()
	Print("Took: "+(RealMillisecs()-startTime))

	Print("Adding "+numToTest+" random ints again")
	startTime = RealMillisecs()
	For Local i%=1 To numToTest
		al.Add(New IntObject(Int(Rnd()*1000)))
	Next
	Print("Took: "+(RealMillisecs()-startTime))
	Print("Size: "+al.Size)
	Print("First 10:")
	For Local i%=0 To 9
		Print(al.Get(i).value)
	Next

	Print("Sorting descending")
	startTime = RealMillisecs()
	al.Sort(True)
	Print("Took: "+(RealMillisecs()-startTime))
	Print("First 10:")
	For Local i%=0 To 9
		Print(al.Get(i).value)
	Next

	Print("Trying floats")
	Local fal:ArrayList<FloatObject> = New ArrayList<FloatObject>(numToTest+10)
	Print("Adding "+numToTest+" random floats")
	startTime = RealMillisecs()
	For Local i%=1 To numToTest
		fal.Add(New FloatObject(Rnd()*1000))
	Next
	Print("Took: "+(RealMillisecs()-startTime))
	Print("Size: "+fal.Size)
	Print("First 10:")
	For Local i%=0 To 9
		Print(fal.Get(i).value)
	Next

	Print("Sorting ascending")
	startTime = RealMillisecs()
	fal.Sort()
	Print("Took: "+(RealMillisecs()-startTime))
	Print("First 10:")
	For Local i%=0 To 9
		Print(fal.Get(i).value)
	Next

	Print("Clearing")
	startTime = RealMillisecs()
	fal.Clear()
	Print("Took: "+(RealMillisecs()-startTime))

	Print("Adding "+numToTest+" random floats again")
	startTime = RealMillisecs()
	For Local i%=1 To numToTest
		fal.Add(New FloatObject(Rnd()*1000))
	Next
	Print("Took: "+(RealMillisecs()-startTime))
	Print("Size: "+al.Size)
	Print("First 10:")
	For Local i%=0 To 9
		Print(fal.Get(i).value)
	Next

	Print("Sorting descending")
	startTime = RealMillisecs()
	fal.Sort(True)
	Print("Took: "+(RealMillisecs()-startTime))
	Print("First 10:")
	For Local i%=0 To 9
		Print(fal.Get(i).value)
	Next
End