adding LowLevel

adding LowLevel

added some LowLevel functions to the Maniac Framework.

#Rem monkeydoc Module maniac.maniacLowLevel
	LowLevel Modue-Version 0.1.4  ~n
	Copyright (C) 2015  Stephan Duckerschein~n

	This is the Maniac LowLevel Module.~n
	Functions in here should only be called by the Maniac Higher Level Functions.~n
	So the user shouldn't worry about the following Classes and Functions, unless he needs some special lowlevel Functions~n
	~n
	VERSION HISTORY: ~n

	0.1.4  @ 21.01.2015~n
		added: ll_ContainDate, ll_convertsDateToMonth, ll_convertDateToDay
	0.1.3  @ 18.01.2015~n
		added: ll_Tween
	0.1.2~n
		added: ll_Width
	0.1.1~n
		Integrated some Debug Stuff
	0.1.0~n
		added some

	Implemented Feature: LowLevel
		- Calculating Distance between two Points
		- Calculating Delta Timing Values
		- Some Date Convert & Checking Functions
#End

Import mojo
Import maniac

#rem	Put them into the main maniac Source File
Global gl_clicked:Bool
Global gl_mousereleased:Bool
#end

#Rem monkeydoc
	### READY TO USE ###~n
	This Functions checks the actual MouseState.~n
	It will be called automatically within the maniacUpdate() Method.
#End
Function Maniac_CheckMouseState()
	If MANIAC_DEBUG = True
		Maniac_Debug.addCall()
	Endif
	gl_mousereleased = False
	If gl_clicked = False and TouchHit()
		gl_clicked = True
	Endif

	If TouchDown()

	Else
		If gl_clicked = True
			gl_mousereleased = True
			gl_clicked = False
		Endif
	Endif
End Function

#Rem monkeydoc
	### READY TO USE ###~n
	This Function calculates the distance between two Points in Pixels.
	returning the Ergebnis as a Float
#End
Function ll_Distance:Float(fromX:Float,fromY:Float,toX:Float,toY:Float)
	If MANIAC_DEBUG = True
		Maniac_Debug.addCalc()
		Maniac_Debug.addCall()
	Endif
	Local dx:Float = fromX-toX
	Local dy:Float = fromY-toY
	Return Sqrt(dx*dx+dy*dy)
End Function

#Rem monkeydoc
	### READY TO USE ###~n
	This function Calculates the time ellapsed since last frame.
	It will be called automatically within the maniacUpdate() Method.
	For using the Delta-Timing System, make sure to call maniacUpdate() once a frame within your OnUpdate().
#End
Function ll_UpdateSpeeds()
	If MANIAC_DEBUG = True
		Maniac_Debug.addCalc()
		Maniac_Debug.addCall()
	Endif
	Local currentTime = Millisecs()
	local deltaTime = currentTime - maniac_lastTime
  	maniac_lastTime = currentTime

  	'And calculate a scale value to convert -per-second values to -per-frame values
  	maniac_timeScale = deltaTime / 1000.0
End Function

#Rem monkeydoc
	### READY TO USE ###~n
	This function Calculates the width of ... .
#End
Function ll_Width:Float(_Width:Float,_Number:Float,_Distance:Float)
	If MANIAC_DEBUG = True
		Maniac_Debug.addCalc()
		Maniac_Debug.addCall()
	Endif
	Local fW:Float
	fW = (_Width-_Number*_Distance-_Distance)/(_Number)
	Return fW
End Function

#Rem monkeydoc
	### Experimental ###~n
	This Function initialises a new Tween Object with Costum setting.
	Makes the Tweening a little bit more code-dynamic
	Useable: Bounce, Elastic, Quad, Sine , Back , Circ
	ToDo: -Linear , Cubic , Expo , Quart , Quint

#End
Function ll_Tween:Tween(_Style:String,_Ease:String = "In",_fromX:Float,_toX:Float,_AnimTime:Int )
	Select _Style
		Case "Bounce"
			Select _Ease
				Case "Out" '#easeOut
					Return (New Tween(Tween.Bounce.EaseOut,_fromX,_toX,_AnimTime))
				Case "In" '#easeIn
					Return (New Tween(Tween.Bounce.EaseIn,_fromX,_toX,_AnimTime))
				Case "InOut" '#easeInOut
					Return (New Tween(Tween.Bounce.EaseInOut,_fromX,_toX,_AnimTime))
				Case "OutIn" '#easeInOut
					Return (New Tween(Tween.Bounce.EaseInOut,_fromX,_toX,_AnimTime))
			End Select

		Case "Elastic"
			Select _Ease
				Case "Out" '#easeOut
					Return  (New Tween(Tween.Elastic.EaseOut,_fromX,_toX,_AnimTime))
				Case "In" '#easeIn
					Return (New Tween(Tween.Elastic.EaseIn,_fromX,_toX,_AnimTime))
				Case "InOut" '#easeInOut
					Return (New Tween(Tween.Elastic.EaseInOut,_fromX,_toX,_AnimTime))
				Case "OutIn" '#easeInOut
					Return (New Tween(Tween.Elastic.EaseInOut,_fromX,_toX,_AnimTime))
			End Select

		Case "Quad"
			Select _Ease
				Case "Out" '#easeOut
					Return  (New Tween(Tween.Quad.EaseOut,_fromX,_toX,_AnimTime))
				Case "In" '#easeIn
					Return (New Tween(Tween.Quad.EaseIn,_fromX,_toX,_AnimTime))
				Case "InOut" '#easeInOut
					Return (New Tween(Tween.Quad.EaseInOut,_fromX,_toX,_AnimTime))
				Case "OutIn" '#easeInOut
					Return (New Tween(Tween.Quad.EaseInOut,_fromX,_toX,_AnimTime))
			End Select

		Case "Sine"
			Select _Ease
				Case "Out" '#easeOut
					Return  (New Tween(Tween.Sine.EaseOut,_fromX,_toX,_AnimTime))
				Case "In" '#easeIn
					Return (New Tween(Tween.Sine.EaseIn,_fromX,_toX,_AnimTime))
				Case "InOut" '#easeInOut
					Return (New Tween(Tween.Sine.EaseInOut,_fromX,_toX,_AnimTime))
				Case "OutIn" '#easeInOut
					Return (New Tween(Tween.Sine.EaseInOut,_fromX,_toX,_AnimTime))
			End Select

		Case "Back"
			Select _Ease
				Case "Out" '#easeOut
					Return  (New Tween(Tween.Back.EaseOut,_fromX,_toX,_AnimTime))
				Case "In" '#easeIn
					Return (New Tween(Tween.Back.EaseIn,_fromX,_toX,_AnimTime))
				Case "InOut" '#easeInOut
					Return (New Tween(Tween.Back.EaseInOut,_fromX,_toX,_AnimTime))
				Case "OutIn" '#easeInOut
					Return (New Tween(Tween.Back.EaseInOut,_fromX,_toX,_AnimTime))
			End Select

		Case "Circ"
			Select _Ease
				Case "Out" '#easeOut
					Return  (New Tween(Tween.Circ.EaseOut,_fromX,_toX,_AnimTime))
				Case "In" '#easeIn
					Return (New Tween(Tween.Circ.EaseIn,_fromX,_toX,_AnimTime))
				Case "InOut" '#easeInOut
					Return (New Tween(Tween.Circ.EaseInOut,_fromX,_toX,_AnimTime))
				Case "OutIn" '#easeInOut
					Return (New Tween(Tween.Circ.EaseInOut,_fromX,_toX,_AnimTime))
			End Select

		Case "Cubic"
			Select _Ease
				Case "Out" '#easeOut
					Return  (New Tween(Tween.Cubic.EaseOut,_fromX,_toX,_AnimTime))
				Case "In" '#easeIn
					Return (New Tween(Tween.Cubic.EaseIn,_fromX,_toX,_AnimTime))
				Case "InOut" '#easeInOut
					Return (New Tween(Tween.Cubic.EaseInOut,_fromX,_toX,_AnimTime))
				Case "OutIn" '#easeInOut
					Return (New Tween(Tween.Cubic.EaseInOut,_fromX,_toX,_AnimTime))
			End Select
		Case "Expo"
			Select _Ease
				Case "Out" '#easeOut
					Return  (New Tween(Tween.Expo.EaseOut,_fromX,_toX,_AnimTime))
				Case "In" '#easeIn
					Return (New Tween(Tween.Expo.EaseIn,_fromX,_toX,_AnimTime))
				Case "InOut" '#easeInOut
					Return (New Tween(Tween.Expo.EaseInOut,_fromX,_toX,_AnimTime))
				Case "OutIn" '#easeInOut
					Return (New Tween(Tween.Expo.EaseInOut,_fromX,_toX,_AnimTime))
			End Select
		Case "Quart"
			Select _Ease
				Case "Out" '#easeOut
					Return  (New Tween(Tween.Quart.EaseOut,_fromX,_toX,_AnimTime))
				Case "In" '#easeIn
					Return (New Tween(Tween.Quart.EaseIn,_fromX,_toX,_AnimTime))
				Case "InOut" '#easeInOut
					Return (New Tween(Tween.Quart.EaseInOut,_fromX,_toX,_AnimTime))
				Case "OutIn" '#easeInOut
					Return (New Tween(Tween.Quart.EaseInOut,_fromX,_toX,_AnimTime))
			End Select

		Default
			Print "Starting default tweenModifier"
	End Select
End Function

#Rem monkeydoc
	Color of centre of lightning strike
#End
Function ll_ColorCentre()
	If MANIAC_DEBUG = True
		Maniac_Debug.addCall()
	Endif
	SetColor 255,255,255

End Function

#Rem monkeydoc
	Main color theme of lightning strike
#End
Function ll_ColorInnerEdge()
	If MANIAC_DEBUG = True
		Maniac_Debug.addCall()
	Endif
	SetColor 0,128,255

End Function

#Rem monkeydoc
	;;Faint outer colour of lightning strike...
#End
Function ll_ColorOuterEdge()

	If MANIAC_DEBUG = True
		Maniac_Debug.addCall()
	Endif
	SetColor 0,32,128

End Function

Global ll_months:String[] = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]
Global ll_day:Int[] = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,24,25,26,27,28,29,30,31]

#Rem monkeydoc
	Checks if a String Contains a Date a la "Jan_02" or "Aug_22" ...
#End
Function ll_ContainDate:Bool(iStr:String)

	For Local m:Int = 0 Until 12
		For Local d:Int = 0 Until 31
			Local strDay:String
			If ll_day[d] < 10
				strDay = "0" + ll_day[d]
			Else
				strDay = ll_day[d]
			Endif
			If iStr.Contains(ll_months[m]+"_"+strDay)
				Return True
			Endif
		Next
	Next

	Return False
End Function

#Rem monkeydoc
	Returns an Integer belonging to a Month.
	Jan = 0 , Feb = 1 ...
#End
Function ll_convertDateToMonth:Int(_Date:String)
	For Local m:Int = 0 To 12

		If _Date.Contains(ll_months[m])
			Return m
		Endif
	Next
End Function

#Rem monkeydoc
	Returns an Integer belonging to a Day.
	01 = 0 , 02 = 1 ...
#End
Function ll_convertDateToDay:Int(_Date:String)
	For Local d:Int = 0 To 31
		Local strDay:String
		If ll_day[d] < 10
			strDay = "0" + ll_day[d]
		Else
			strDay = ll_day[d]
		Endif
		If _Date.Contains(strDay)
			Return d
		Endif
	Next

End Function

#rem
	The following Skew and Mirror functions are from Danilo posted on Monkey
	http://www.monkey-x.com/Community/posts.php?topic=8066
#end
' - Shear/Skew  -------------------->> REQUIRES DECISION: What's the best name? Skew or Shear?
Function SkewX:Void(angle:Float)
    Transform(1,0,Tan(angle),1,0,0)
End

Function SkewY:Void(angle:Float)
    Transform(1,Tan(angle),0,1,0,0)
End

Function ShearX:Void(angle:Float)
    Transform(1,0,Tan(angle),1,0,0)
End

Function ShearY:Void(angle:Float)
    Transform(1,Tan(angle),0,1,0,0)
End

' - Mirror
Function MirrorX:Void()
    Transform(1,0,0,-1,0,0)
End

Function MirrorY:Void()
    Transform(-1,0,0,1,0,0)
End

' - 'At' functions apply a function
'        at/around a specific point

' - Shear/Skew  -------------------->> REQUIRES DECISION: What's the best name? Skew or Shear?
Function SkewXAt:Void(x:Float, y:Float, angle:Float)
    Translate(x, y)
    Transform(1,0,Tan(angle),1,0,0)
    Translate(-x, -y)
End

Function SkewYAt:Void(x:Float, y:Float, angle:Float)
    Translate(x, y)
    Transform(1,Tan(angle),0,1,0,0)
    Translate(-x, -y)
End

Function ShearXAt:Void(x:Float, y:Float, angle:Float)
    Translate(x, y)
    Transform(1,0,Tan(angle),1,0,0)
    Translate(-x, -y)
End

Function ShearYAt:Void(x:Float, y:Float, angle:Float)
    Translate(x, y)
    Transform(1,Tan(angle),0,1,0,0)
    Translate(-x, -y)
End

Function RotateAt:Void(x:Float, y:Float, angle:Float)
    Translate(x, y)
    Rotate(angle)
    Translate(-x, -y)
End

Function ScaleAt:Void(x:Float, y:Float, scaleX:Float, scaleY:Float)
    Translate(x, y)
    Scale(scaleX, scaleY)
    Translate(-x, -y)
End

Function MirrorXAt:Void(x:Float, y:Float)
    Translate(x, y)
    Transform(1,0,0,-1,0,0)
    Translate(-x, -y)
End

Function MirrorYAt:Void(x:Float, y:Float)
    Translate(x, y)
    Transform(-1,0,0,1,0,0)
    Translate(-x, -y)
End

' - reset Matrix to standard
Function ResetMatrix:Void()
    SetMatrix(1,0,0,1,0,0)
End

#Rem monkeydoc
	TO DO
	This wil be a Class for a Logo.
	It consists of seperate Layers, all will be animated by its own.
#End
Class ManiacLogo
	Field X:Float,Y:Float,Width:Float,Height:Float

End Class

error: pathspec 'maniac/maniacLowLevel.monkey' did not match any file(s) known to git


Added OnSignalEmit call

Added OnSignalEmit call

Strict

Import flxsignal

Class FlxSignalObserver

	Field enabled:Bool

Private
	Field _signal:FlxSignal

	Field _listener:FlxSignalListener

	Field _instant:Bool

	Field _priority:Int

Public
	Method New(listener:FlxSignalListener, instant:Bool = False, signal:FlxSignal = Null, priority:Int = 0)
		_signal = signal
		enabled = True
		_listener = listener
		_instant = instant
		_priority = priority
	End Method

	Method Destroy:Void()
		_signal = Null
		_listener = Null
	End Method

	Method Apply:Void(data:Object)
		If ( Not enabled) Return
		If (_instant) Remove()

		_listener.OnSignalEmit(_signal, data)
	End Method

	Method Remove:Void()
		_signal.Remove(Self)
	End Method

	Method Priority:Int() Property
		Return _priority
	End Method

End Class

Interface FlxSignalListener

	Method OnSignalEmit:Void(signal:FlxSignal, data:Object)

End Interface

Strict

Import flxsignal

Class FlxSignalObserver

	Field enabled:Bool

Private
	Field _signal:FlxSignal

	Field _listener:FlxSignalListener

	Field _instant:Bool

	Field _priority:Int

Public
	Method New(listener:FlxSignalListener, instant:Bool = False, signal:FlxSignal = Null, priority:Int = 0)
		_signal = signal
		enabled = True
		_listener = listener
		_instant = instant
		_priority = priority
	End Method

	Method Destroy:Void()
		_signal = Null
		_listener = Null
	End Method

	Method Apply:Void(data:Object)
		If ( Not enabled) Return
		If (_instant) Remove()
	End Method

	Method Remove:Void()
		_signal.Remove(Self)
	End Method

	Method Priority:Int() Property
		Return _priority
	End Method

End Class

Interface FlxSignalListener

	Method OnSignalEmit:Void(signal:FlxSignal, data:Object)

End Interface


Added Fontmodul

Added Fontmodul

#Rem monkeydoc Module maniac.maniacFont
	Fontmodule-Version 1.1  ~n
	Copyright (C) 2015  Stephan Duckerschein~n

	Here You can find my Font Module.
	You can use it for drawing with another Font then the Monkey Standard.
	It features automatically wraps the Text into a Rectangle and let it Write like a Fontmachine.

	CHANGES: maniacFont
	Version 1.1 added:
		- Method: getW:int(txt:String) returns the lengths of a String in Pixel
		- italic style to the Wrap method as parameter

	Implemented Feature: FONT
		- Wrapping a Text with a certain Font to Rectangle
		- Writing Italic Text
#End

Import mojo
Import maniacLowLevel

Const CHARACTER_ASCII := 0
Const CHARACTER_WIDTH := 1
Const CHARACTER_HEIGHT := 2
Const CHARACTER_PAGE := 3
Const CHARACTER_RECT_X := 4
Const CHARACTER_RECT_Y := 5
Const CHARACTER_RECT_WIDTH := 6
Const CHARACTER_RECT_HEIGHT := 7
Const CHARACTER_OFFSET_X := 8
Const CHARACTER_OFFSET_Y := 9

#Rem monkeydoc
	This is the Font Class.
	It automatically wraps the Text into a Rectangle.
	You can even let it Write like a Fontmachine.
#End
Class ManiacFont
    Field width:Int = 0
    Field height:Int = 0
    Field pages:Image[0]
    Field baseCharacter:Int = 0
    Field characters:FontCharacter[256]

	#Rem monkeydoc
		This is the Constructor for the Font Class-Object.

	#End
    Method New(_width:Int,_height:Int,_pages:String[],_characters:Int[][])
        ' --- setup the font object with the data passed in! ---
        width = _width
        height = _height

        'load in the page images
        pages = New Image[_pages.Length()]
        For Local index := 0 Until _pages.Length()
            pages[index] = LoadImage(_pages[index])
        Next

        'create the
        For Local character := Eachin _characters
            characters[character[CHARACTER_ASCII]] = New FontCharacter(character[CHARACTER_WIDTH],character[CHARACTER_HEIGHT],pages[character[CHARACTER_PAGE]],character[CHARACTER_RECT_X],character[CHARACTER_RECT_Y],character[CHARACTER_RECT_WIDTH],character[CHARACTER_RECT_HEIGHT],character[CHARACTER_OFFSET_X],character[CHARACTER_OFFSET_Y])
        Next
    End

    Method Draw(text:String,x:Float,y:Float)
        ' --- draw a single line of text ---
        Local length:Int = text.Length()
        Local character:FontCharacter

        For Local index := 0 Until length
            character = characters[text[index]]
            If character <> Null
                print text[index]
                DrawImage(character.image,x,y)
                x += character.width
            Endif
        Next
    End

    #Rem monkeydoc
		This Method returns the width in Pixel of the given text.
	#End
    Method getW:Int(text:String)
    	Local n:Int = text.Length()
    	Local l:Int
    	Local character:FontCharacter
    	For Local index := 0 Until n
            character = characters[text[index]]
            If character <> Null
                l += character.width
            Endif
        Next

        Return l
    End Method

    function getH:Float()
    	Return 27
    End Function

	#Rem monkeydoc
		This Method fits the Text to the given Container Dimensions.

		<pre>
		Example:
		font.Wrap("Hallo Welt",100,100,200,400,0)

		</pre>
	#End
    Method Wrap(text:String,containerX:Float,containerY:Float,containerWidth:Float,containerHeight:Float,count:Int=-1,bitalic:Bool = False)
    	If MANIAC_DEBUG = True
			'Maniac_Debug.addCalc()
			Maniac_Debug.addCall()
		Endif
        ' --- wrap text within an area ---
        'get the number of characters that will be rendered from the text
        If count < 0 Or count > text.Length() count = text.Length()

        Local drawX:Float = containerX
        Local drawY:Float = containerY
        Local lineStart:Bool = True
        Local textIndex:Int = 0
        Local textLength = text.Length()
        Local wordStart:Int
        Local wordLength:Int
        Local wordWidth:Int
        Local character:FontCharacter

        While textIndex < count
            'find the next complete word!
            wordStart = textIndex
            wordLength = 0
            For Local wordIndex := textIndex Until textLength
                If text[wordIndex] = 32
                    'break out as a word has been found
                    Exit
                Else
                    'increase the word length
                    wordLength += 1
                Endif
            Next

            'calculate the width of the word
            wordWidth = 0
            For Local wordIndex := wordStart Until wordStart + wordLength
                character = characters[text[wordIndex]]
                If character <> Null wordWidth += character.width
            Next

            'add split character
            If lineStart = False
                character = characters[32]
                If character
                    If drawX + character.width <= containerX + containerWidth
                        DrawImage(character.image,drawX,drawY)
                        drawX += character.width
                    Else
                        drawX = containerX
                        drawY += height
                        If drawY + height > containerHeight Return
                        lineStart = True
                    Endif
                Endif
            Endif

            'make sure only drawing upto count!
            textIndex += 1
            If textIndex > count Return

			If bitalic = True
				ShearXAt(drawX, drawY, -20)
			Endif
            'render the word
            'print text[wordStart..wordStart+wordLength]+" :: "+(drawX + wordWidth)+" / "+(containerX + containerWidth)
            If drawX + wordWidth <= containerX + containerWidth Or wordWidth <= containerWidth
                'move WHOLE word onto new line
                If drawX + wordWidth > containerX + containerWidth
                    drawX = containerX
                    drawY += height
                    If drawY + height > containerHeight Return
                    lineStart = True
                Endif

                'draw word as a whole!
                For Local drawIndex := wordStart Until wordStart + wordLength
                    'print String.FromChar(text[drawIndex])
                    character = characters[text[drawIndex]]
                    If character <> Null
                        DrawImage(character.image,drawX,drawY)
                        drawX += character.width
                    Endif

                    'make sure only drawing upto count!
                    textIndex += 1
                    If textIndex > count Return
                Next
                lineStart = False
            Else
                'need to split the word onto multiple lines!
                 For Local drawIndex := wordStart Until wordStart + wordLength
                    character = characters[text[drawIndex]]
                    If character
                        'look for going onto new line!
                        If drawX + character.width > containerX + containerWidth
                            drawX = containerX
                            drawY += height
                            If drawY + height > containerHeight Return
                            lineStart = True
                        Endif

                        'draw the character
                        DrawImage(character.image,drawX,drawY)
                        drawX += character.width
                        lineStart = False
                    Endif

                    'make sure only drawing upto count!
                    textIndex += 1
                    If textIndex > count Return
                Next
            Endif

            '
        Wend

        ResetMatrix()
    End
End

Class FontCharacter
    Field width:Int
    Field height:Int
    Field image:Image

    Method New(_width:Int,_height:Int,page:Image,rectX:Int,rectY:Int,rectWidth:Int,rectHeight:Int,offsetX:Int,offsetY:Int)
        width = _width
        height = _height
        image = page.GrabImage(rectX,rectY,rectWidth,rectHeight)
        image.SetHandle(-offsetX,-offsetY)
    End
End

error: pathspec 'maniac/maniacFont.monkey' did not match any file(s) known to git


First revision of transformation module.

--HG--
branch : development

Strict

Public
Import exception
Import functions
Import collections

Private
Import mojo

Public
Const TRANSFORM_NONE:Int = 0
Const TRANSFORM_POSITION:Int = 1
Const TRANSFORM_ALPHA:Int = 2
Const TRANSFORM_SCALE:Int = 3
Const TRANSFORM_ROTATION:Int = 4
Const TRANSFORM_COLOR:Int = 5
Const TRANSFORM_COUNT:Int = 6

Const EASE_NONE:Int = 0
Const EASE_IN_DOUBLE:Int = 1
Const EASE_IN:Int = 2
Const EASE_IN_HALF:Int = 3
Const EASE_OUT:Int = 4
Const EASE_OUT_HALF:Int = 5
Const EASE_OUT_DOUBLE:Int = 6
Const EASE_IN_OUT:Int = 7

Const COLORSPACE_RGB:Int = 0
Const COLORSPACE_HSL:Int = 1

Class TransformationGroup
Private
	Global hslArray:Float[] = New Float[3]
	Global rgbArray:Int[] = New Int[3]
	Field transformations:ArrayList<Transformation>[] = New ArrayList<Transformation>[TRANSFORM_COUNT]
	Field currentTransform:Transformation[] = New Transformation[TRANSFORM_COUNT]
	Field lastTime:Int = 0

	Field defaultX:Float = 0
	Field defaultY:Float = 0
	Field defaultScaleX:Float = 1
	Field defaultScaleY:Float = 1
	Field defaultRotation:Float = 0
	Field defaultAlpha:Float = 1
	Field defaultRed:Float = 255
	Field defaultGreen:Float = 255
	Field defaultBlue:Float = 255
	Field defaultHue:Float = 0
	Field defaultSaturation:Float = 1
	Field defaultLuminance:Float = 0.5

Public
	Method Add:Void(type:Int, tr:Transformation)
		If type < 0 Or type >= TRANSFORM_COUNT Then Throw New IllegalArgumentException("Invalid transformation type: "+type)
		If Not transformations[type] Then transformations[type] = New ArrayList<Transformation>
		transformations[type].Add(tr)
		transformations[type].Sort()
		tr.Update(lastTime)
	End

	Method Remove:Void(type:Int, tr:Transformation)
		If type < 0 Or type >= TRANSFORM_COUNT Then Throw New IllegalArgumentException("Invalid transformation type: "+type)
		If Not transformations[type] Then Return
		transformations[type].Remove(tr)
	End

	Method Clear:Void(type:Int)
		If type < 0 Or type >= TRANSFORM_COUNT Then Throw New IllegalArgumentException("Invalid transformation type: "+type)
		If Not transformations[type] Then Return
		transformations[type].Clear()
	End

	Method New(x#=0, y#=0, scaleX#=1, scaleY#=1, rotation#=0, alpha#=1, red#=255, green#=255, blue#=255, hue#=0.0, saturation#=1.0, luminance#=0.5, colorSpace%=COLORSPACE_RGB)
		defaultX = x
		defaultY = y
		defaultScaleX = scaleX
		defaultScaleY = scaleY
		defaultRotation = rotation
		defaultAlpha = alpha
		If colorSpace = COLORSPACE_RGB Then
			RGBtoHSL(red, green, blue, hslArray)
			hue = hslArray[0]
			saturation = hslArray[1]
			luminance = hslArray[2]
		ElseIf colorSpace = COLORSPACE_HSL Then
			HSLtoRGB(hue, saturation, luminance, rgbArray)
			red = rgbArray[0]
			green = rgbArray[1]
			blue = rgbArray[2]
		End
		defaultRed = red
		defaultGreen = green
		defaultBlue = blue
		defaultHue = hue
		defaultSaturation = saturation
		defaultLuminance = luminance
	End

	Method Update:Void(currentTime:Int)
		' store time for calls to Add
		lastTime = currentTime

		' clear out current transforms
		For Local i:Int = 0 Until currentTransform.Length
			currentTransform[i] = Null
		Next

		For Local i:Int = 0 Until transformations.Length
			If transformations[i] Then
				' these should be sorted
				For Local j:Int = 0 Until transformations[i].Size
					Local tr:Transformation = transformations[i].Get(j)
					tr.Update(currentTime)
					If currentTime >= tr.startTime Or Not currentTransform[i] And currentTime >= tr.firstStartTime Then
						currentTransform[i] = tr
					End
				Next
			End
		Next
	End

	Method GetCurrentTransformation:Transformation(type:Int)
		If type < 0 Or type >= TRANSFORM_COUNT Then Throw New IllegalArgumentException("Invalid transformation type: "+type)
		Return currentTransform[type]
	End

	' convenience methods

	Method CurrentScaleX:Float() Property
		Local tr:TransformationVector = TransformationVector(currentTransform[TRANSFORM_SCALE])
		If Not tr Then Return defaultScaleX
		Return tr.CurrentX
	End

	Method CurrentScaleY:Float() Property
		Local tr:TransformationVector = TransformationVector(currentTransform[TRANSFORM_SCALE])
		If Not tr Then Return defaultScaleY
		Return tr.CurrentY
	End

	Method CurrentAlpha:Float() Property
		Local tr:TransformationValue = TransformationValue(currentTransform[TRANSFORM_ALPHA])
		If Not tr Then Return defaultAlpha
		Return tr.CurrentValue
	End

	Method CurrentRed:Float() Property
		Local tr:TransformationColor = TransformationColor(currentTransform[TRANSFORM_COLOR])
		If Not tr Then Return defaultRed
		Return tr.CurrentRed
	End

	Method CurrentGreen:Float() Property
		Local tr:TransformationColor = TransformationColor(currentTransform[TRANSFORM_COLOR])
		If Not tr Then Return defaultGreen
		Return tr.CurrentGreen
	End

	Method CurrentBlue:Float() Property
		Local tr:TransformationColor = TransformationColor(currentTransform[TRANSFORM_COLOR])
		If Not tr Then Return defaultBlue
		Return tr.CurrentBlue
	End

	Method CurrentHue:Float() Property
		Local tr:TransformationColor = TransformationColor(currentTransform[TRANSFORM_COLOR])
		If Not tr Then Return defaultHue
		Return tr.CurrentHue
	End

	Method CurrentSaturation:Float() Property
		Local tr:TransformationColor = TransformationColor(currentTransform[TRANSFORM_COLOR])
		If Not tr Then Return defaultSaturation
		Return tr.CurrentSaturation
	End

	Method CurrentLuminance:Float() Property
		Local tr:TransformationColor = TransformationColor(currentTransform[TRANSFORM_COLOR])
		If Not tr Then Return defaultLuminance
		Return tr.CurrentLuminance
	End

	Method CurrentX:Float() Property
		Local tr:TransformationVector = TransformationVector(currentTransform[TRANSFORM_POSITION])
		If Not tr Then Return defaultX
		Return tr.CurrentX
	End

	Method CurrentY:Float() Property
		Local tr:TransformationVector = TransformationVector(currentTransform[TRANSFORM_POSITION])
		If Not tr Then Return defaultY
		Return tr.CurrentY
	End

	Method CurrentRotation:Float() Property
		Local tr:TransformationValue = TransformationValue(currentTransform[TRANSFORM_ROTATION])
		If Not tr Then Return defaultRotation
		Return tr.CurrentValue
	End

	Method Apply:Void()
		SetColor(CurrentRed, CurrentGreen, CurrentBlue)
		Translate(CurrentX, CurrentY)
		Scale(CurrentScaleX, CurrentScaleY)
		Rotate(CurrentRotation)
		SetAlpha(CurrentAlpha)
	End
End

Class Transformation Implements IComparable Abstract
Private
	Field loop:Bool
	Field loopDelay:Int
	Field easeType:Int
	Field firstStartTime:Int
	Field firstEndTime:Int
	Field startTime:Int
	Field endTime:Int
	Field currentTime:Int
	Field started:Bool
	Field finished:Bool
	Field needsRecalc:Bool = True

Public
	Method StartTime:Int() Property Return startTime End
	Method StartTime:Void(startTime:Int) Property Self.startTime = startTime; needsRecalc = True End
	Method EndTime:Int() Property Return endTime End
	Method EndTime:Void(endTime:Int) Property Self.endTime = endTime; needsRecalc = True End
	Method EaseType:Int() Property Return easeType End
	Method EaseType:Void(easeType:Int) Property Self.easeType = easeType End
	Method Loop:Bool() Property Return loop End
	Method Loop:Void(loop:Bool) Property Self.loop = loop End
	Method LoopDelay:Int() Property Return loopDelay End
	Method LoopDelay:Void(loopDelay:Int) Property Self.loopDelay = loopDelay End
	Method Started:Bool() Property Return started End
	Method Finished:Bool() Property Return finished End
	Method Duration:Int() Property Return endTime - startTime End

	Method New(startTime:Int, endTime:Int, easeType:Int=EASE_NONE, loop:Bool=False, loopDelay:Int=0)
		Self.startTime = startTime
		Self.endTime = endTime
		Self.firstStartTime = startTime
		Self.firstEndTime = endTime
		Self.easeType = easeType
		Self.loop = loop
		Self.loopDelay = loopDelay
	End

	Method Update:Void(currentTime:Int)
		Self.currentTime = currentTime
		If loop And endTime < currentTime Then
			Local duration:Int = endTime - startTime + loopDelay
			Local remainder:Int = currentTime - endTime
			startTime += (remainder / duration + 1) * duration
			endTime += (remainder / duration + 1) * duration
		End
		started = currentTime >= startTime
		finished = started And currentTime >= endTime And Not loop
		Recalc(True)
	End

	Method Compare:Int(other:Object)
		If Not Transformation(other) Then Return 1
		If other = Self Then Return 0
		Local o:Transformation = Transformation(other)
		If startTime > o.startTime Then Return 1
		If startTime < o.startTime Then Return -1
		If endTime > o.endTime Then Return 1
		If endTime < o.endTime Then Return -1
		If easeType > o.easeType Then Return 1
		If easeType < o.easeType Then Return -1
		If loop And Not o.loop Then Return 1
		If Not loop And o.loop Then Return -1
		If loopDelay > o.loopDelay Then Return 1
		If loopDelay < o.loopDelay Then Return -1
		If started And Not o.started Then Return 1
		If Not started And o.started Then Return -1
		If finished And Not o.finished Then Return 1
		If Not finished And o.finished Then Return -1
		Return 0
	End

	Method Equals:Bool(other:Object)
		Return Compare(other) = 0
	End

Private
	Method Recalc:Void(force:Bool=False)
		If Not needsRecalc And Not force Then Return
		needsRecalc = False
		DoRecalc()
	End

	Method DoRecalc:Void() Abstract

	Method Calculate:Float(startValue:Float, endValue:Float)
		' if we've never started, return the start value
		If currentTime <= firstStartTime Then Return startValue

		' if we're at the end or between loops, return the end value
		If currentTime >= endTime Or currentTime < startTime Or startTime = endTime Then Return endValue

		' how far through are we?
		Local progress:Float = Float(currentTime - startTime) / Float(endTime - startTime)

		Select easeType
			Case EASE_IN_DOUBLE
				Return Lerp(endValue, startValue, (1-progress)*(1-progress)*(1-progress)*(1-progress))
			Case EASE_IN
				Return Lerp(endValue, startValue, (1-progress)*(1-progress))
			Case EASE_IN_HALF
				Return Lerp(endValue, startValue, Pow(1-progress, 1.5))
			Case EASE_OUT
				Return Lerp(startValue, endValue, progress * progress)
			Case EASE_OUT_HALF
				Return Lerp(startValue, endValue, Pow(progress, 1.5))
			Case EASE_OUT_DOUBLE
				Return Lerp(startValue, endValue, progress*progress*progress*progress)
			Case EASE_IN_OUT
				Return startValue + (-2*(progress*progress*progress) + 3*(progress*progress)) * (endValue - startValue)
			Default
				Return Lerp(startValue, endValue, progress);
		End
	End

	Method Lerp:Float(startValue:Float, endValue:Float, progress:Float)
		Return startValue + (endValue-startValue) * progress
	End
End

Class TransformationColor Extends Transformation
Private
	Global hslArray:Float[] = New Float[3]
	Global rgbArray:Int[] = New Int[3]
	Field startH:Float
	Field startS:Float
	Field startL:Float
	Field startR:Int
	Field startG:Int
	Field startB:Int
	Field endH:Float
	Field endS:Float
	Field endL:Float
	Field endR:Int
	Field endG:Int
	Field endB:Int
	Field currentH:Float
	Field currentS:Float
	Field currentL:Float
	Field currentR:Int
	Field currentG:Int
	Field currentB:Int

Public
	Method StartRed:Int() Property Return startR End
	Method StartGreen:Int() Property Return startG End
	Method StartBlue:Int() Property Return startB End
	Method EndRed:Int() Property Return endR End
	Method EndGreen:Int() Property Return endG End
	Method EndBlue:Int() Property Return endB End
	Method StartHue:Int() Property Return startH End
	Method StartSaturation:Int() Property Return startS End
	Method StartLuminance:Int() Property Return startL End
	Method EndHue:Int() Property Return endH End
	Method EndSaturation:Int() Property Return endS End
	Method EndLuminance:Int() Property Return endL End
	Method CurrentRed:Int() Property Recalc(); Return currentR End
	Method CurrentGreen:Int() Property Recalc(); Return currentG End
	Method CurrentBlue:Int() Property Recalc(); Return currentB End
	Method CurrentHue:Int() Property Recalc(); Return currentH End
	Method CurrentSaturation:Int() Property Recalc(); Return currentS End
	Method CurrentLuminance:Int() Property Recalc(); Return currentL End

	Method New(start1:Float, start2:Float, start3:Float, end1:Float, end2:Float, end3:Float, startTime:Int, endTime:Int, easeType:Int=EASE_NONE, loop:Bool=False, loopDelay:Int=0, colorSpace:Int=COLORSPACE_RGB)
		Super.New(startTime, endTime, easeType, loop, loopDelay)
		If colorSpace = COLORSPACE_RGB Then
			SetStartRGB(Int(start1), Int(start2), Int(start3))
			SetEndRGB(Int(end1), Int(end2), Int(end3))
		ElseIf colorSpace = COLORSPACE_HSL Then
			SetStartHSL(start1, start2, start3)
			SetEndHSL(end1, end2, end3)
		Else
			Throw New IllegalArgumentException("Invalid colorspace: "+colorSpace)
		End
		needsRecalc = True
	End

	Method SetStartRGB:Void(startR:Int, startG:Int, startB:Int)
		Self.startR = Max(0,Min(255,startR))
		Self.startG = Max(0,Min(255,startG))
		Self.startB = Max(0,Min(255,startB))
		RecalcStartHSL()
		needsRecalc = True
	End

	Method SetEndRGB:Void(endR:Int, endG:Int, endB:Int)
		Self.endR = Max(0,Min(255,endR))
		Self.endG = Max(0,Min(255,endG))
		Self.endB = Max(0,Min(255,endB))
		RecalcEndHSL()
		needsRecalc = True
	End

	Method SetStartHSL:Void(startH:Float, startS:Float, startL:Float)
		Self.startH = Max(0.0,Min(1.0,startH))
		Self.startS = Max(0.0,Min(1.0,startS))
		Self.startL = Max(0.0,Min(1.0,startL))
		RecalcStartRGB()
		needsRecalc = True
	End

	Method SetEndHSL:Void(endH:Float, endS:Float, endL:Float)
		Self.endH = Max(0.0,Min(1.0,endH))
		Self.endS = Max(0.0,Min(1.0,endS))
		Self.endL = Max(0.0,Min(1.0,endL))
		RecalcEndRGB()
		needsRecalc = True
	End

Private
	Method RecalcStartRGB:Void()
		HSLtoRGB(startH, startS, startL, rgbArray)
		Self.startR = rgbArray[0]
		Self.startG = rgbArray[1]
		Self.startB = rgbArray[2]
	End

	Method RecalcEndRGB:Void()
		HSLtoRGB(endH, endS, endL, rgbArray)
		Self.endR = rgbArray[0]
		Self.endG = rgbArray[1]
		Self.endB = rgbArray[2]
	End

	Method RecalcStartHSL:Void()
		RGBtoHSL(startR, startG, startB, hslArray)
		Self.startH = hslArray[0]
		Self.startS = hslArray[1]
		Self.startL = hslArray[2]
	End

	Method RecalcEndHSL:Void()
		RGBtoHSL(endR, endG, endB, hslArray)
		Self.endH = hslArray[0]
		Self.endS = hslArray[1]
		Self.endL = hslArray[2]
	End

	Method DoRecalc:Void()
		currentH = Calculate(Self.startH, Self.endH)
		currentS = Calculate(Self.startS, Self.endS)
		currentL = Calculate(Self.startL, Self.endL)
		HSLtoRGB(currentH, currentS, currentL, rgbArray)
		currentR = rgbArray[0]
		currentG = rgbArray[1]
		currentB = rgbArray[2]
	End
End

Class TransformationValue Extends Transformation
Private
	Field startValue:Float
	Field endValue:Float
	Field currentValue:Float

Public
	Method CurrentValue:Float() Property Recalc(); Return currentValue End
	Method StartValue:Float() Property Return startValue End
	Method StartValue:Void(startValue:Float) Property Self.startValue = startValue; needsRecalc = True End
	Method EndValue:Float() Property Return endValue End
	Method EndValue:Void(endValue:Float) Property Self.endValue = endValue; needsRecalc = True End

	Method New(startValue:Float, endValue:Float, startTime:Int, endTime:Int, easeType:Int=EASE_NONE, loop:Bool=False, loopDelay:Int=0)
		Super.New(startTime, endTime, easeType, loop, loopDelay)
		Self.startValue = startValue
		Self.endValue = endValue
	End

Private
	Method DoRecalc:Void()
		currentValue = Calculate(startValue, endValue)
	End
End

Class TransformationVector Extends Transformation
Private
	Field startX:Float
	Field startY:Float
	Field endX:Float
	Field endY:Float
	Field currentX:Float
	Field currentY:Float

Public
	Method CurrentX:Float() Property Recalc(); Return currentX End
	Method CurrentY:Float() Property Recalc(); Return currentY End
	Method StartX:Float() Property Return startX End
	Method StartX:Void(startX:Float) Property Self.startX = startX; needsRecalc = True End
	Method StartY:Float() Property Return startY End
	Method StartY:Void(startY:Float) Property Self.startY = startY; needsRecalc = True End
	Method EndX:Float() Property Return endX End
	Method EndX:Void(endX:Float) Property Self.endX = endX; needsRecalc = True End
	Method EndY:Float() Property Return endY End
	Method EndY:Void(endY:Float) Property Self.endY = endY; needsRecalc = True End

	Method New(startX:Float, startY:Float, endX:Float, endY:Float, startTime:Int, endTime:Int, easeType:Int=EASE_NONE, loop:Bool=False, loopDelay:Int=0)
		Super.New(startTime, endTime, easeType, loop, loopDelay)
		Self.startX = startX
		Self.startY = startY
		Self.endX = endX
		Self.endY = endY
	End

Private
	Method DoRecalc:Void()
		currentX = Calculate(startX, endX)
		currentY = Calculate(startY, endY)
	End
End

error: pathspec 'src/diddy/transformation.monkey' did not match any file(s) known to git


Main functionality.

Main functionality.

Strict

Public

' Preprocessor related:
#If LANG = "cpp"
	#SIZEOF_NATIVE = True
#End

' Imports:
Import vector

' Constant variable(s):

' Standard type sizes (In bytes):
#If Not SIZEOF_NATIVE
	Const SizeOf_Integer:Int = 4 ' 8

	#If CPP_DOUBLE_PRECISION_FLOATS And LANG = "cpp" And TARGET <> "win8"
		Const SizeOf_FloatingPoint:Int = 8
	#Else
		Const SizeOf_FloatingPoint:Int = 4
	#End

	Const SizeOf_Boolean:Int = 1
#Else
	Const SizeOf_Integer:Int = SizeOf(0)
	Const SizeOf_FloatingPoint:Int = SizeOf(0.0)
	Const SizeOf_Boolean:Int = SizeOf(False)
#End

' External bindings:
#If SIZEOF_NATIVE
	Extern

	' Functions (Native):
	Function SizeOf:Int(I:Int)="(int)sizeof"
	Function SizeOf:Int(F:Float)="(int)sizeof"
	Function SizeOf:Int(B:Bool)="(int)sizeof"

	Public
#End

' Functions (Monkey):
Function IntSize:Int(Size:Int)
	If (Size > 1) Then
		If (Size > 4) Then
			Return 8
		Elseif (Size < 4) Then
			Return 2
		Else
			Return 4
		Endif
	Endif

	Return 1
End

#If Not SIZEOF_NATIVE
	Function SizeOf:Int(I:Int)
		Return SizeOf_Integer
	End

	Function SizeOf:Int(F:Float)
		Return SizeOf_FloatingPoint
	End

	Function SizeOf:Int(B:Bool)
		Return SizeOf_Boolean
	End
#End

Function SizeOf:Int(S:String)
	' Make the input-string upper-case.
	S = S.ToUpper()

	If (S.Find("INT") <> -1) Then
		Return SizeOf(0)
	Elseif (S.Find("FLOAT") <> -1) Then
		Return SizeOf(0.0)
	Elseif (S.Find("BOOL") <> -1) Then
		Return SizeOf(False)
	#Rem
		Elseif (S.Find("VEC") <> -1) Then
			Return Max(Int(S), 1)
	#End
	Endif

	' Return the default response.
	Return 1
End

error: pathspec 'sizeof.monkey' did not match any file(s) known to git


Added abstract Input class

Added abstract Input class

Strict

Class Input Abstract

Private
	Field _map:InputState[]
	Field _total:Int

Public
	Method New()
		_total = GetTotal()
		_map = _map.Resize(_total)

		Local i:Int = 0

		While (i < _total)
			_map = New InputState()
			i += 1
		Wend
	End Method

	Method Update:Void()
		Local i:Int = 0
		Local is:InputState

		While (i < _total)
			is = _map[i]

			If (GetState(i)) Then
				If (is.current > 0) Then
					is.current = 1
				Else
					is.current = 2
				End If
			Else
				If (is.current > 0) Then
					is.current = -1
				Else
					is.current = 0
				End If
			End If
		Wend
	End Method

	Method Pressed:Bool(key:Int)
		Return _map[key] = 1
	End Method

	Method JustPressed:Bool(key:Int)
		Return _map[key] = 2
	End Method

	Method JustReleased:Bool(key:Int)
		Return _map[key] = -1
	End Method

	Method Record:Stack<InputRecord>()
		Local data:Stack<InputRecord> = Null
		Local i:Int = 0
		Local is:InputState

		While (i < _total)
			is = _map[i]

			If (is.current = 0) Continue

			If (data = Null) Then
				data = New Stack<InputRecord>()
			End If

			data.Push(New InputRecord(i, is.current))

			i += 1
		Wend

		Return data
	End Method

	Method Playback:Void(record:Stack<InputRecord>)
		Local i:Int = 0
		Local l:Int = record.Length()
		Local ir:InputRecord

		While (i < l)
			ir = record[i]
			_map[ir.code].current = ir.value
			i += 1
		Wend
	End Method

	Method Any:Bool()
		Local i:Int = 0

		While (i < _total)
			If (_map[i].current > 0) Return True
			i += 1
		Wend

		Return False
	End Method

	Method Destroy:Void()
		_total = 0
	End Method

	Method GetTotal:Int() Abstract

	Method GetState:Bool(index:Int) Abstract

End Class

Class InputRecord

	Field code:Int
	Field value:Int

	Method New (code:Int, value:Int)
		Self.code = code
		Self.value = value
	End Method

End Class

Private
Class InputState

	Field current:Int
	Field last:Int

	Method New()
		current = -1
		last = -1
	End Method

End Class

error: pathspec 'system/input/input.monkey' did not match any file(s) known to git


new File

new File

added the GUI-Source to the maniac Framework

#Rem monkeydoc Module maniac.maniacSimpleGUI
	Simple GUI - Version 0.1.4 (alpha)  ~n
	Copyright (C) 2015  Stephan Duckerschein~n

	Here You can find some GUI Elements to use for your App.
	They can be used 'ad-hoc'-like. the have to be managed by the Programmer.

#End

#rem
	Work On:
		DropDown,RadioGroup,FileExplorer,ListView for Version 0.1.5

		- need Color Scheme
		- need Graphics Update

		- Buglist:
			ManiacButton -> Rolling Animation is not Ready yet
	VERSION:~n
	0.1.4	- added: ManiacCheckBox,DropDown,ListView, Dialog
	0.1.3	- added a ImageGallery-Class >> ToDo: some imageLoading Bugfixes. UpdateEventAsync testing around ...

	0.1.2:	- bugfixes Frame
			- added some setter
			- added "doWobble","doRoll" (instantEffects)
			- added "startAnimDrop","startAnimSlide" and "startAnimCircle"
			- updated ManiacButton Class
			- added a Slider Class

	Wishlist:
		 x Simple Button
		 x Textfield
		 x Slider
		 x Checkbox
		 x GalleryViewer
		DropDown
		RadioBox
		Docker
		Tabs

	Implemented Feature: GUI
		- Button
		- Textfield
		- Slider
		- GalleryViewer
#end

Import maniacDebug

public
Const TEXTFIELD_STYLE_STD:Int 			= 0
Const TEXTFIELD_STYLE_WITHBUTTON:Int 	= 1

#Rem monkeydoc
	This Class is a Textfield Gui Element.
	Version 1.1

	Example:

		Global tf:ManiacSimpleTextfield = new ManiacSimpleTextfield(100,100,300,32)
		Function Main:Int()
			New Example
			Return 0
		End Function

#End
Class ManiacTextfield
	Private
	Field maniacID:Int
	Field ID:Int
	Field inputString:String = ""
	Field X:Int,Y:Int
	Field W:Int,H:int

	Field Style:Int
	Field Focus:Int		'0 - Standard ohne gfx effects , 1 -

	Field bEditing:Bool = False

	Public
	Method New(_X:Float,_Y:Float,_Width:Float,_Height:Float,istyle:Int = TEXTFIELD_STYLE_STD)
		If MANIAC_DEBUG = True
			Maniac_Debug.addStoredBools()
			Maniac_Debug.addStoredInts(8)
			maniacID = Maniac_Debug.getNumberOfRegisteredObjects()
			Maniac_Debug.addRegisteredObject()
		Endif

		X 		= _X
		Y 		= _Y
		W 		= _Width
		H 		= _Height
		Style 	= istyle
	End Method

	Public
	Method Update:Int()
		If MANIAC_DEBUG = True
			Maniac_Debug.addTotCall()
		Endif
		'Maniac_Debug.addTotCalc(2)
		'Maniac_Debug.addTotDraws(2)
		'If bFull = True
			If TouchHit()
				If MOBox(X,Y,(W*0.15),(H*1.0))
					If bEditing = True
						bEditing = False
					Else
						bEditing = True
					Endif
				Endif
			Endif
		'Endif

		If bEditing = True
			Repeat
				Local char=GetChar()
		        If Not char Exit

		        If char>=32
		            inputString+=String.FromChar( char )
		        Endif

		        If char = CHAR_ENTER
					DisableKeyboard()
					Return 99
				Endif

		        If char = CHAR_BACKSPACE
					Local txtlength:Int = inputString.Length()
					Local txtchars:Int[] = inputString.ToChars
					inputString = ""
					For Local l:Int = 0 To txtlength-2
						inputString += String.FromChar(txtchars[l])
					Next
				Endif

			Forever
		Endif
	End Method

	Public
	Method Draw()
		If MANIAC_DEBUG = True
			Maniac_Debug.addTotCall()
			Maniac_Debug.addTotDraws(3)
		Endif
		SetAlpha 1
		SetColor 255,255,255
		DrawRect(X+W*0.15,Y,W-W*0.15,H)

		If bEditing = True
			SetColor 0,255,0
		Else
			SetColor 255,0,0
		Endif

		DrawImage MANIAC_IMG_EDITICON,X,Y,0,(W*0.15)/MANIAC_IMG_EDITICON.Width(),(H*1.0)/MANIAC_IMG_EDITICON.Height()

		SetColor 0,0,0
		MANIAC_FONT.Wrap(inputString,X+W*0.15,Y+H/2-ManiacFont.getH()/2,W,H,inputString.Length())

		If bEditing = True
			SetColor 0,255,0
		Else
			SetColor 255,0,0
		Endif
		Drw_Rect(X,Y,W,H,3)
	End Method

	Method drawFull()
		SetAlpha 1
		SetColor 255,255,255
		DrawRect(X+W*0.15,Y,W,H)

		If bEditing = True
			SetColor 0,255,0
		Else
			SetColor 255,0,0
		Endif

		DrawImage DUKE_IMG_EDITICON,X,Y,0,(W*0.15)/DUKE_IMG_EDITICON.Width(),(H*1.0)/DUKE_IMG_EDITICON.Height()

		SetColor 0,0,0
		DUKE_FONT.Wrap(inputString,X+W*0.15,Y,W,H,Duke_MessageCount)

		If bEditing = True
			SetColor 0,255,0
		Else
			SetColor 255,0,0
		Endif
		Duke_Drw_Rect(X,Y,W,H,3)
	End Method

	Method getText:String()
		Return inputString
	End Method

	Method setText(itext:String)
		inputString = itext
	End Method
End Class

Const ALIGNMENT_LEFT:Int = 1
Const ALIGNMENT_MIDDLE:Int = 2
Const ALIGNMENT_RIGHT:Int = 3

Const ANIM_DROP:Int 	= 1
Const ANIM_FADE:Int		= 2
Const ANIM_ROTATE:Int 	= 3
Const ANIM_ROLL:Int		= 4
Const ANIM_SLIDE:Int 	= 5
Const ANIM_CIRCLE:Int	= 6
Const ANIM_POPOUT:Int 	= 7

#Rem monkeydoc
	This Class is a Button Gui Element.
	Version 0.1
	Example:

		Global tB:ManiacButton = new ManiacButton(100,100,300,32)

		Function Main:Int()
			New Example
			Return 0
		End Function

#end
Class ManiacButton

	'Identificanitional Values
	Private
	Field ID:Int
	Field maniacID:Int
	Field MidX:Float,MidY:Float			'aktuelle Position des Buttons (Durch Animationen veränderbar
	Field oX:Float,oY:Float 		'Original X,Y << Das ist die Feste Position des Buttons
	Field Width:Float,Height:Float			'Breite und Höhe in Pxl

	'
	Field Caption:String		'Aufschrift
	Field CaptionColor:Int		'Color of the Caption
	Field Angle:Float 			'Winkel zur Horizontalen in °
	Field Alignment:Int			'ausrichtung des Textes (Left,Middle,Right)
	Field bTransparent:Bool = false

	'#### EFFECTS STUFF ####
	'Field

	'#### GLOW STUFF #####		Ready
	Field bGlow:Bool							'Wenn true, dann leuchtet der Button
	Field GlowHertz:Float 			= 0.5
	Field GlowAlpha:Float 						'Current Alpha for Glow Effect
	Field GlowAlphaFrom:Float		= 0.01		'Range for Alpha-Effekt.
	Field GlowAlphaTo:Float			= 0.3
	Field GlowStyle:Int				= 0			'0 - If Alpha reases max, it decreases from max ; 1 - if Alpha reaches max, it jumps to min
	Field bCurrGlowDirection:Bool 				'True - Raise, false - decrease
	Field GlowColor:Int
	Field GlowRangeRatioX:Float = 1.3
	Field GlowRangeRatioY:Float = 1.7

	'#### FRAME STUFF ######
	Field bFramed:Bool 		= True
	Field FrameColor:Int

	Field Color:Int 							'Integerwert einer Farbe aus der Maniac_Color Funktion

	'#### BUTTON MOUSEOVER STUFF #####
	Field bMO:Bool = False
	Field bMOResize:Bool 		= false
	Field bMOBrighter:Bool 		= false
	Field bMOWobble:Bool		= false
	Field AddWidthByMO:Int 		= 0
	Field AddHeightByMO:Int		= 0

	'##### BUTTON INACTIVE-ANIMATIONS #######
	Field bInactiveAnim:Bool = False
	Field bInactiveTime:Int
	Field InactiveAnim:Int
	Field LastActiveTime:Int

	'##### WOBBLEEFFEKT STUFF #####
	Field lastWobble:Int

	'##### ANIMATION STUFF #####
	Field bRunningAnimation:Bool 	= False
	Field AnimStartTime:int
	Field AnimTime:int

	'Tweener for position Stuff
	Field tweenY:Tween
	Field tweenX:Tween
	Field tweenAngle:Tween

	'Booleans for Effect
	Field AnimEffect:Int

	Public
	Method New(_MidX:Float,_MidY:Float,_Width:Float,_Height:Float,_Caption:String = "",_Alignment:Int = ALIGNMENT_MIDDLE,_Color:Int = COLOR_BLUE,_Glow:Bool = True,_GlowHertz:Float = 1,_Angle:Float = 0.0)
		If MANIAC_DEBUG = True
			Maniac_Debug.addStoredBools(9)
			Maniac_Debug.addStoredInts(12)
			Maniac_Debug.addStoredFloats(13)
			ID 		= Maniac_Debug.getNumberOfRegisteredObjects()
			Maniac_Debug.addRegisteredObject()
		Endif
		oX 		= _MidX
		oY		= _MidY
		MidX 	= _MidX
		MidY 	= _MidY
		Width 	= _Width
		Height 	= _Height
		Alignment =_Alignment
		Caption =	_Caption
		CaptionColor = _Color +6
		Color		= _Color
		bGlow 		= _Glow
		GlowHertz	= _GlowHertz
		GlowColor = _Color
		Angle = _Angle
		FrameColor = _Color +6
	End Method

	Method Draw()
		If MANIAC_DEBUG = True
			Maniac_Debug.addRenderedObject()
		Endif

		'##### GLOW EFFECT STUFF #####
		If bGlow = True
			Maniac_Color(GlowColor)
			SetAlpha GlowAlpha
			DrawImage MANIAC_IMG_FRAME_BLUR, MidX,MidY,Angle,Width*GlowRangeRatioX/MANIAC_IMG_FRAME_BLUR.Width(),Height*GlowRangeRatioY/MANIAC_IMG_FRAME_BLUR.Height()
			Maniac_Debug.addTotDraws(1)
		End If

		'##### BUTTON BACKGROUND #####
		Maniac_Color(Color)
		If bTransparent = True
			If bMO = True
				SetAlpha 1
				If bMOResize = True
					AddWidthByMO = 10
					AddHeightByMO = 10
				Else
					AddWidthByMO = 0
					AddHeightByMO = 0
				Endif
			Else
				AddWidthByMO = 0
				AddHeightByMO = 0
				SetAlpha 0.6
			Endif
		Else
			SetAlpha 1
			If bMO = True
				If bMOResize = True
					AddWidthByMO = 10
					AddHeightByMO = 10
				Else
					AddWidthByMO = 0
					AddHeightByMO = 0
				Endif
			Else
				AddWidthByMO = 0
				AddHeightByMO = 0
			Endif
		Endif
		DrawRect(MidX- (Width +AddWidthByMO/2)/2+2,MidY-(Height+AddHeightByMO/2)/2+2,Width+AddWidthByMO-4,Height+AddHeightByMO-4)
		Maniac_Debug.addTotDraws(1)
		'###### BUTTON FRAME ########
		If bFramed = True
			Maniac_Color(FrameColor)
			DrawImage MANIAC_IMG_FRAME_RAW , MidX,MidY,Angle,(Width+AddWidthByMO)/MANIAC_IMG_FRAME_RAW.Width(),(Height+AddHeightByMO)/MANIAC_IMG_FRAME_RAW.Height()
			Maniac_Debug.addTotDraws(1)
		Else

		Endif

		'##### DRAWING THE CAPTION TO THE BUTTON #####
		SetAlpha 1
		Maniac_Color(CaptionColor)
		Select Alignment
			Case ALIGNMENT_LEFT
				MANIAC_FONT.Wrap(Caption,MidX-Width/2,MidY-Height/5,Width,Height,Caption.Length())
				ResetMatrix()
			Case ALIGNMENT_MIDDLE
				Local l:Int = MANIAC_FONT.getW(Caption)
				MANIAC_FONT.Wrap(Caption,MidX-l/2+1,MidY-Height/5,Width,Height,Caption.Length())
				ResetMatrix()
			Case ALIGNMENT_RIGHT
				Local l:Int = MANIAC_FONT.getW(Caption)
				MANIAC_FONT.Wrap(Caption,MidX+Width/2-l,MidY-Height/5,Width,Height,Caption.Length())
				ResetMatrix()
		End Select

		If bTransparent = False
			If bMO = True
				If bMOBrighter = True
					SetAlpha 0.2
					SetColor 255,255,255
					DrawRect(MidX- (Width +AddWidthByMO/2)/2,MidY-(Height+AddHeightByMO/2)/2,Width+AddWidthByMO,Height+AddHeightByMO)
					Maniac_Debug.addTotDraws(1)
				Endif
			Else
				'SetAlpha 0.6
			Endif

		Endif

	End Method

	Method Update:Int()
		If MANIAC_DEBUG = True
			'Maniac_Debug.addCalc()
			Maniac_Debug.addCall()
		Endif

		'### Updating Glow Effect ###
		'this will have effect to all Animation & Non Animation stuff.
		If bGlow = True
			If bCurrGlowDirection = True
				GlowAlpha += EqToFPS(GlowHertz)
				If GlowAlpha >= GlowAlphaTo
					bCurrGlowDirection = False
				Endif
			Else
				GlowAlpha -= EqToFPS(GlowHertz)
				If GlowAlpha <= GlowAlphaFrom
					bCurrGlowDirection = true
				Endif
			Endif
		Endif

		'### Animation Effects ###
		If bRunningAnimation = True

			'Check if AnimationTime is Over
			If Millisecs() - AnimStartTime > AnimTime
				bRunningAnimation = False
			Endif

			'If not, calculate the next Position Stuff
			Select AnimEffect
				Case ANIM_DROP
					tweenY.Update()
					MidY = tweenY.Value()
				Case ANIM_FADE
				Case ANIM_ROTATE
				Case ANIM_ROLL
					tweenX.Update()
					tweenAngle.Update()
					Angle = tweenAngle.Value()
					MidX = tweenX.Value()

				Case ANIM_SLIDE
					tweenX.Update()
					MidX = tweenX.Value()

				Case ANIM_CIRCLE
					tweenY.Update()
					tweenX.Update()

					MidX = tweenX.Value()
					MidY = tweenY.Value()
			End Select

		Endif

		'### User Input Stuff like MouseOver, ClickOn etc. ###
		If MOBox(MidX-Width/2	, MidY-Height/2, Width, Height)
			bMO = True
			If bMOWobble = True
				doWobble()
			Endif
			If TouchHit()
				Return 99
			Endif
			Return 101
		Else
			bMO = False
			If bRunningAnimation = False
				resetPosition()
			Endif
		Endif
	End Method

	Method startAnim(_AnimType:Int,  fromX:Float ,toX:Float ,_AnimTime:Int = 1000,ias:Float = 720,iae:Float = 0)

	End Method

	Method startAnimDrop(_fromY:Float,_AnimTime:Int = 1500,_Style:String = "Bounce",_Ease:String = "Out")

		tweenY = ll_Tween(_Style,_Ease,_fromY,oY,_AnimTime )
		tweenY.Start()
		bRunningAnimation = True
		AnimStartTime = Millisecs()
		AnimTime = _AnimTime
		AnimEffect = ANIM_DROP
	End Method

	Method startAnimRoll(_fromX:Float,_AnimTime:Int = 3000,_NumberRounds:Float = 10,_Style:String = "Bounce",_Ease:String = "Out")
		tweenX = ll_Tween(_Style,_Ease,_fromX,oX,_AnimTime )
		tweenX.Start()
		tweenAngle = ll_Tween(_Style,_Ease,_NumberRounds*(360),0,_AnimTime )
		tweenAngle.Start()
		bRunningAnimation = True
		AnimStartTime = Millisecs()
		AnimTime = _AnimTime
		AnimEffect = ANIM_ROLL
	End Method

	Method startAnimSlide(_fromX:Float,_AnimTime:Int = 1500,_Style:String = "Bounce",_Ease:String = "Out")
		tweenX = ll_Tween(_Style,_Ease,_fromX,oX,_AnimTime )
		tweenX.Start()
		bRunningAnimation = True
		AnimStartTime = Millisecs()
		AnimTime = _AnimTime
		AnimEffect = ANIM_SLIDE
	End Method

	Method startAnimCircle(_fromX:Float,_fromY:Float,_AnimTime:Int = 5000)
		tweenX = New Tween(Tween.Sine.EaseOut,_fromX,oX,_AnimTime)
		tweenX.Start()
		tweenY = New Tween(Tween.Sine.EaseInOut,_fromY,oY,_AnimTime)
		tweenY.Start()
		bRunningAnimation = True
		AnimStartTime = Millisecs()
		AnimTime = _AnimTime
		AnimEffect = ANIM_CIRCLE
	End Method

	Method startAnimPopOut()

	End Method
	Method setAlignment(_Alignment:Int)

		'Checking for using right Alignment Convention, else set to ALIGNMENT_MIDDLE
		Select _Alignment
			Case ALIGNMENT_LEFT
				Alignment = _Alignment
			Case ALIGNMENT_MIDDLE
				Alignment = _Alignment
			Case ALIGNMENT_RIGHT
				Alignment = _Alignment
			Default
				Print "Alignment doesnt exist, Set To Middle!!!"
				Alignment =	ALIGNMENT_MIDDLE
		End Select
	End Method

	Method setCaption(_Caption:String,_Color:int)
		Caption = _Caption
		CaptionColor = _Color
	End Method

	Method setPosition(_X:float,_Y:float)
		MidX = _X
		MidY = _Y
	End Method

	Method setSize(_Width:Float,_Height:Float)
		Width = _Width
		Height =_Height
	End Method

	Method setAngle:Void(_Angle:Float)
		Angle = _Angle
	End Method

	#Rem monkeydoc
		This Method sets the current Glow Effect.

		to switch Glow effect off, just call

		Example:

			'To Switch Off, just call within OnUpdate()
			 objName.setGlow(false)

			 'To Specify the Glow effect, use the params:~n
			 _isGlowing << true - glow is active, else it doesnt render glow effect ~n
			 _GlowColor << use one of the Maniac preset Color Ints.
			 _GlowHertz << 1.0 means it raises 100% Alpha within 1 Second ; 0.5 means it need 2 Seconds

			 _GlowStyle	<< at the Moment just Style 0 implemented (Standard)

	#End
	Method setGlow(_isGlowing:Bool = True ,_GlowColor:Int = COLOR_WHITE ,_GlowHertz:Float = 1.0,_GlowAlphaFrom:Float = 0.2,_GlowAlphaTo:Float = 0.7,_GlowStyle:Int = 0)
		bGlow 		= _isGlowing
		GlowHertz	= _GlowHertz
		GlowColor 	= _GlowColor
		GlowAlphaFrom 	= _GlowAlphaFrom
		GlowAlphaTo 	= _GlowAlphaTo
		GlowStyle = _GlowStyle
	End Method

	Method setFrame(_isFramed:Bool = True,_FrameColor:Int = 0)
		bFramed = _isFramed
		FrameColor = _FrameColor
	End Method

	Method setMouseOverEffects(_isResizing:Bool= True ,_isBrightening:Bool=False,_isWobbling:Bool = false )
		bMOResize		= _isResizing
		bMOBrighter		= _isBrightening
		bMOWobble		= _isWobbling
	End Method

	Method setInactiveAnim()

	End Method

	Method doWobble(_ShakeDistance:Float = 3.5,_Hertz:Float = 60,_Strength:Float = 0.9)
		If MANIAC_DEBUG = True
			'Maniac_Debug.addCalc()
			Maniac_Debug.addCall()
		Endif
		If Millisecs()-lastWobble >= (1000 / _Hertz)
			lastWobble = Millisecs()
			MidX += Rnd(-_Strength,_Strength)
			MidY += Rnd(-_Strength,_Strength)

			If MidX > (oX+_ShakeDistance)
				MidX = oX+_ShakeDistance
			Endif
			If MidX < (oX-_ShakeDistance)
				MidX = oX-_ShakeDistance
			Endif
			If MidY > (oY+_ShakeDistance)
				MidY = oY+_ShakeDistance
			Endif
			If MidY < (oY-_ShakeDistance)
				MidY = oY-_ShakeDistance
			Endif
		Endif

	End Method

	#rem
		### This Method is deprecated!!! Please don't use it in Future. Use startAnimRoll instead It's just for backward compatibatibility ####
	#end
	Method doRoll(_AngleSpeed:Float)
		If MANIAC_DEBUG = True
			'Maniac_Debug.addCalc()
			Maniac_Debug.addCall()
		Endif
		Angle += EqToFPS(_AngleSpeed)
	End Method

	Method doRotate(_AngleSpeed:Float)
		If MANIAC_DEBUG = True
			Maniac_Debug.addCall()
		Endif
		Angle += EqToFPS(_AngleSpeed)
	End Method

	Method resetPosition()
		If MANIAC_DEBUG = True
			'Maniac_Debug.addCalc()
			Maniac_Debug.addCall()
		Endif
		MidX = oX
		MidY = oY
		Angle = 0
	End Method
End Class

#Rem monkeydoc
	This Class is a Slider Gui Element.
	Version 1.0 (a) Stable but unhandy
	Example:

		'This Example Shows how to use the Slider
		Global slider:ManiacSlider

		'... OnCreate
		slider =  new ManiacSlider(100,100,300,32,25,75)

		'... OnUpdate()
		slider.Update()
		local val:float = slider.getValue()

		'...OnRender()
		slider.Draw()

#End
Class ManiacSlider
	Private
	Field maniacID:Int
	Field X:Float,Y:Float,Width:Float,Height:Float

	Field SliderX:Float

	Field Value:Float
	Field ValueFrom:Float
	Field ValueTo:Float
	Field ValueStep:Float

	Field HoldPicker:Bool = True

	Public
	#Rem monkeydoc
		This is the Constructor for the Slider
		_X & _Y are topleft-Corner Koordinates in Pxl~n
		_Width & _Height are the rectangular size of the Slider in Pxl~n
		_ValueFrom - sets the lowest Return-Value
		_ValueTo	- sets the Maximum Return Value
	#End
	Method New(_X:Float,_Y:Float,_Width:Float,_Height:Float,_ValueFrom:Float = 0,_ValueTo:Float = 100)
		Maniac_Debug.addStoredBools()
		Maniac_Debug.addStoredInts()
		Maniac_Debug.addStoredFloats(9)
		maniacID = Maniac_Debug.getNumberOfRegisteredObjects()
		Maniac_Debug.addRegisteredObject()

		X = _X
		Y = _Y
		Width = _Width
		Height= _Height
		ValueFrom = _ValueFrom
		ValueTo = _ValueTo
		SliderX = _X + _Width*0.5
	End Method

	#Rem monkeydoc
		This Method returns the Current Value of Slider.
	#End
	Method getValue:Float()
		Maniac_Debug.addTotCall()
		Maniac_Debug.addTotCalc(2)
		'Maniac_Debug.addTotDraws()
		Local p:Float = (SliderX - X) / (X+Width-X)
		Local val:Float =  ValueFrom + (ValueTo-ValueFrom)*p

		Return val
	End Method

	#Rem monkeydoc
		This Method Draws the whole Slider with Picker.
	#End
	Method Draw()
		Maniac_Debug.addTotCall()
		'Maniac_Debug.addTotCalc(2)
		Maniac_Debug.addTotDraws(2)
		SetAlpha 1
		SetColor 255,255,255
		DrawImage MANIAC_IMG_SLIDERLINE,X,Y,0,Width/MANIAC_IMG_SLIDERLINE.Width(),Height/MANIAC_IMG_SLIDERLINE.Height()

		If HoldPicker = True
			SetColor 0,255,0
			DrawText "Value: " + getValue(),X,Y+Height
		Endif
		DrawImage MANIAC_IMG_SLIDERPICKER,SliderX,Y+Height*0.5,0,(Width*0.1)/MANIAC_IMG_SLIDERPICKER.Width(),(Height*1.2)/MANIAC_IMG_SLIDERPICKER.Height()
	End Method

	#Rem monkeydoc
		This Method Updates the Slider. Especially the Picker and his X-Value.
		It checks for User-Slider for its own.
	#End
	Method Update()
		Maniac_Debug.addTotCall()
		HoldPicker = False
		If TouchDown()
			If MOBox( SliderX-(Width*0.1)/2,  Y,  (Width*0.1), (Height*1.2))
				HoldPicker = True
				SliderX = MouseX()
				If SliderX >= X+Width
					SliderX = X+Width
				Endif
				If SliderX <= X
					SliderX = X
				Endif
			Endif
		Endif
	End Method
End Class

#Rem monkeydoc
	This Class is a GalleryViewer Gui Element.
	Version 0.1
	Example:

		Global tB:ManiacButton = new ManiacButton(100,100,300,32)

		Function Main:Int()
			New Example
			Return 0
		End Function

#End
Class ManiacGallery	Implements IOnLoadImageComplete
	Global loadedImages:Int =	0
	Global l:Int = 0

	Field arrImg:Image[500]
	Field maniacID:Int
	Field X:Float,Y:Float,Width:Float,Height:Float
	Field ViewMode:Int = 1
	Field dist:Int = 10
	Field imgW:Float,imgH:Float

	Field BtnRight:ManiacButton
	Field BtnLeft:ManiacButton
	Field BtnSwitchViewStyle:ManiacButton

	Field ScrolledImages:Int = 0

	Field tp:Int	= 0
	Field lastSwitch:Int
	Field switchIntervall:Int = 500

	Field Alpha:float

	Method New(_X:Float,_Y:Float,_Width:Float,_Height:Float,_loadPath:String = "GFX/")
		'arrImg[
		X = _X
		Y = _Y
		Width =_Width
		Height = _Height
		loadFromPath(_loadPath)
		Local bW:Float = DW*0.15
		Local bH:Float = DH*0.07
		imgW = ll_Width(_Width,3,dist)
		imgH = (_Height-bH)/2.5

		BtnLeft 			=  New ManiacButton(_X + bW/2 + _Width*0.02 ,_Y+_Height-bH/2, bW,	bH," << ",ALIGNMENT_MIDDLE,COLOR_BLUE,True,1.5)
		BtnRight 			=  New ManiacButton(_X + _Width - bW/2 - _Width*0.02 ,_Y+_Height-bH/2, bW,	bH," >> ",ALIGNMENT_MIDDLE,COLOR_BLUE,True,1.5)
		BtnSwitchViewStyle 	=  New ManiacButton(_X + _Width*0.5 ,_Y+_Height-bH/2, bW,	bH," Switch ",ALIGNMENT_MIDDLE,COLOR_BLUE,True,1.5)

	End Method

	Method loadFromPath:Void(_Path:String="monkey://external/" )
		'Local stdPath:String
		#rem
		If _Path.Contains("monkey://external/")

		Elseif _Path.Contains("monkey://data/")
		Elseif _Path.Contains("monkey://internal/")
			stdPath = "monkey://internal/"
		Else
			stdPath = "monkey://external/"+_Path
		Endif
		#end
		Print "Get Folder"
		Local arrStr:String[] = GetFolderFiles(_Path)
		Print "Found: " + arrStr.Length() + " files"
		l = arrStr.Length()
		#rem
		If arrStr.Length() > 0
			For Local j:Int = 0 Until loadedImages'arrStr.Length()
				Print "Loading Image " + arrStr[j] + " to arrImg["+(j)+"]"
				arrImg[j] = LoadImage()
			Next
		Endif
		#end
		For Local ls:Int = 0 Until l
			Print "load " + ls
			LoadImageAsync(arrStr[ls], 1, 0, Self)
		Next
	End Method

	Method Draw()
		Drw_Rect(X,Y,Width,Height,3)
		SetColor 255,255,255
		SetAlpha 1
		Select ViewMode
			Case 0	'3x2 overview
				Local i:Int = 0
				For Local x:Int = 0 To 2
					For Local y:Int = 0 To 1
						Drw_Rect(X+dist+x*(imgW+dist)  , Y+dist+y*(imgH+dist), imgW,imgH,2)
						'Print "i: " + i
						if arrImg[i+ScrolledImages] = Null
							DrawText "No Image",X+dist+x*(imgW+dist)  , Y+dist+y*(imgH+dist)
						Else
							DrawImage ( arrImg[i+ScrolledImages] , X+dist+x*(imgW+dist)  , Y+dist+y*(imgH+dist),0, imgW/arrImg[i+ScrolledImages].Width(), imgH/arrImg[i+ScrolledImages].Height() )
						Endif
						i +=1
					Next
				Next

			Case 1
				If arrImg[tp] <> Null
					SetAlpha 1
					DrawImage arrImg[tp], X,Y,0,Width*1/arrImg[tp].Width(),Height*0.87/arrImg[tp].Height()
				Endif
				If arrImg[tp+1] <> Null
					SetAlpha Alpha
					DrawImage arrImg[tp+1], X,Y,0,Width*1/arrImg[tp+1].Width(),Height*0.87/arrImg[tp+1].Height()
				Endif
		End Select

		BtnLeft.Draw()
		BtnRight.Draw()
		BtnSwitchViewStyle.Draw()

		DrawText("Mode: " + ViewMode+ " | View: " + tp + "/"+loadedImages , X +Width*0.5,Y)
	End Method

	Method Update:Int()

		If BtnLeft.Update() = 101 And gl_mousereleased
			if ScrolledImages <= 0

			Else
				ScrolledImages -= 1
			Endif
		Endif

		If BtnRight.Update() = 101 And gl_mousereleased
			If (ScrolledImages + 6) >= loadedImages

			else
				ScrolledImages += 1
			Endif
		Endif

		If BtnSwitchViewStyle.Update() = 101 And gl_mousereleased
			If ViewMode = 0
				ViewMode = 1
			Else
				ViewMode = 0
			Endif
		Endif

		Select ViewMode
			Case 0
			Case 1
				If Millisecs() - lastSwitch >= switchIntervall
					If (tp + 1) >= loadedImages
						tp = 0
					else
						tp +=1
					Endif
					Alpha = 0
					lastSwitch = Millisecs()
				Endif

				Alpha += EqToFPS(1.0/(switchIntervall/1000.0))' 0.02
		End Select
	End Method

	Method OnLoadImageComplete:Void(_image:Image, path:String, source:IAsyncEventSource)
		If _image <> Null
			arrImg[loadedImages] = _image
			loadedImages += 1
		Else
			Print "no image : "+loadedImages
		Endif

		#rem
		arrImg[loadedImages] = _image
		Print "Loaded Image id: " + loadedImages
		If arrImg[loadedImages] = Null
			Print "no image : "+loadedImages
		Else
			Maniac_Debug.addRegisteredGraphics()
		Endif
		loadedImages += 1
		#end
	End

	Method getNumberOfLoadedImages:Int()

	End Method

	Method getImageByID:Image(_ID:Int)

	End Method

End class

Class ManiacRadioGroup
	Field X:Int,Y:Int,Width:Int,Height:Int
	Field bFramed:Bool = true
	Field listElements:List<RadioElement>
	Field dist:Float = 8
	Field ActiveElementID:Int
	Field Caption:String

	Method New(x:Int,y:Int,w:Int,h:Int,caption:String = "")
		X = x
		Y = y
		Width = w
		Height = h
		Caption = caption
		listElements = New List<RadioElement>
	End Method

	Method Draw()
    For Local oRE:RadioElement = Eachin listElements
      oRE.Draw()
    Next
	End Method

	Method addChoice(_Caption:String,_Value:Int)
		listElements.AddLast(New RadioElement(_Caption,_Value))
		reOrder()
	End Method

	Private
	Method reOrder()

	End Method
End Class

Private
Class RadioElement
	Field Caption:String
	Field Value:Int
	Field X:Float,Y:Float,Width:Float,Height:Float

	Method New(_Caption:String,_Value:int)
		Caption =_Caption
		Value =_Value
	End Method

	Method Draw()

	End Method
End Class
public

#Rem monkeydoc
	This Class is a GalleryViewer Gui Element.
	Version 0.1
	Example:

		Global tB:ManiacButton = new ManiacButton(100,100,300,32)

		Function Main:Int()
			New Example
			Return 0
		End Function

#End
Class ManiacCheckBox
	Field maniacID:Int
	Field X:Float
	Field Y:Float
	Field Width:Float
	Field Height:Float
	Field bChecked:Bool
	Field Caption:String

	Method New(_X:Float,_Y:Float,_Width:Float,_Height:Float,_Caption:String="")
		Maniac_Debug.addStoredBools(1)
		Maniac_Debug.addStoredInts(1)
		Maniac_Debug.addStoredFloats(4)
		maniacID 		= Maniac_Debug.getNumberOfRegisteredObjects()
		Maniac_Debug.addRegisteredObject()
		X 		= _X
		Y		= _Y
		Width 	= _Width
		Height 	= _Height
		Caption =	_Caption
	End Method

	Method Draw()
		Drw_Rect(X,Y,Width,Height,2)

		If bChecked = True
			DrawImage MANIAC_IMG_CHECK ,X ,Y ,0 , Width/MANIAC_IMG_CHECK.Width() , Height/MANIAC_IMG_CHECK.Height()
		Endif
	End Method

	Method Update()
		If TouchHit()
		If MOBox(X,Y, Width, Height)
			If bChecked = True
				bChecked = False
			Else
				bChecked = True
			Endif
		Endif
		Endif
	End Method

	Method getChecked:Bool()
		Return bChecked
	End Method
End Class

Class ManiacFileExplorer

End Class

private
Class textElement
	Field Caption:String
	Field Line:Int

	Method New(_Caption:String="")
		Caption =_Caption
	End Method
	Method Draw(_X:Float,_Y:Float,_Width:Float,_Height:Float)
		MANIAC_FONT.Wrap(Caption,_X,_Y,_Width,_Height,Caption.Length())
	End Method
End Class

public
#Rem monkeydoc
	This Class is a DropDown Gui Element.
	Version 0.1

	Example:

		Global tf:ManiacSimpleTextfield = new ManiacSimpleTextfield(100,100,300,32)
		Function Main:Int()
			New Example
			Return 0
		End Function

#End
Class ManiacDropDown
	Field maniacID:Int
	Field X:Float
	Field Y:Float
	Field Width:Float
	Field Height:Float
	Field bOpened:Bool
	Field Caption:String

	Field showOpenHeader:Int	= 1		'0 - Always Show Caption, 1 - Show MouseOver Elements , 2 - Show Selected Element
	Field showCloseHeader:Int 	= 2
	Field bCloseOnSelected:Bool = True

	Field ShowLines:Int 	= 4
	Field ScrolledLines:Int = 0
	Field listTextElements:List<textElement>
	Field MOElement:Int
	Field SelectedElement:Int = 0

	Method New(_X:Float,_Y:Float,_Width:Float,_Height:Float,_Caption:String="")
		Maniac_Debug.addStoredBools(1)
		Maniac_Debug.addStoredInts(1)
		Maniac_Debug.addStoredFloats(4)
		maniacID 		= Maniac_Debug.getNumberOfRegisteredObjects()
		Maniac_Debug.addRegisteredObject()
		X 		= _X
		Y		= _Y
		Width 	= _Width
		Height 	= _Height
		Caption =	_Caption
		listTextElements = New List<textElement>
	End Method

	Method addLine(_Caption:String)
		Local oL:textElement = New textElement(_Caption)
		oL.Line = listTextElements.Count()

		listTextElements.AddLast(oL)

	End Method

	Method DrawText()
		For Local oL:textElement = Eachin listTextElements
			oL.Draw(X+5,Y+Height+oL.Line*(27+5),200,100)
		Next
	End Method

	Method Draw()

		If bOpened = True
			Drw_Rect(X,Y,Width,Height,2)
			Drw_Rect(X,Y+Height,Width,Height+ShowLines*(MANIAC_FONT.getH()+5),1)
			DrawText()

			Select showOpenHeader
				Case 0
					MANIAC_FONT.Wrap(Caption,X,Y,Width,Height,Caption.Length())
				Case 1
					MANIAC_FONT.Wrap(getTextByID(MOElement),X,Y,Width,Height,Caption.Length())
				Case 2
					MANIAC_FONT.Wrap(getTextByID(SelectedElement),X,Y,Width,Height,Caption.Length())
			End Select

			DrawImage MANIAC_IMG_DROPDOWN , X+Width*0.9,Y, 0 , (Width*0.1)/MANIAC_IMG_DROPDOWN.Width(),Height/MANIAC_IMG_DROPDOWN.Height()
		Else
			Drw_Rect(X,Y,Width,Height,2)

			Select showCloseHeader
				Case 0
					MANIAC_FONT.Wrap(Caption,X,Y,Width,Height,Caption.Length())
				Case 1
					MANIAC_FONT.Wrap(getTextByID(MOElement),X,Y,Width,Height,Caption.Length())
				Case 2
					MANIAC_FONT.Wrap(getTextByID(SelectedElement),X,Y,Width,Height,Caption.Length())
			End Select

			DrawImage MANIAC_IMG_DROPDOWN , X+Width*0.9,Y, 0 , (Width*0.1)/MANIAC_IMG_DROPDOWN.Width(),Height/MANIAC_IMG_DROPDOWN.Height()
		Endif
	End Method

	Method Update()
		If TouchHit()
		If MOBox(X+Width*0.9,Y, Width*0.1, Height)
			If bOpened = True
				bOpened = False
			Else
				bOpened = True
			Endif
		Endif
		Endif
		MOElement = -1
		If bOpened
			For Local i:Int = 0 Until ShowLines
				If MOBox(X,Y+Height+i*(27+5),Width,27)
					MOElement = i
					If TouchHit()
						SelectedElement = i
						If bCloseOnSelected = True
							bOpened = False
						Endif
					Endif
				Endif
			Next
		Endif
	End Method

	Method getTextByID:String(_ID:Int)
		Local i:Int = 0
		For Local oL:textElement = Eachin listTextElements
			If i = _ID
				Return oL.Caption
			Endif
			i +=1
		Next
	End Method

	Method getSelectedText:String()
		Local i:Int = 0
		For Local oL:textElement = Eachin listTextElements
			If i = SelectedElement
				Return oL.Caption
			Endif
			i +=1
		Next
	End Method

End Class

#Rem monkeydoc
	This Class is a ListView Gui Element.
	You can Add Lines of Strings and Scroll them within this View.
	Version 0.1

	Example:

		Global tf:ManiacSimpleTextfield = new ManiacSimpleTextfield(100,100,300,32)
		Function Main:Int()
			New Example
			Return 0
		End Function

#End
Class ManiacListView
	Field maniacID:Int
	Field X:Float,Y:Float,Width:Float,Height:Float
	Field listText:List<textElement>

	Field nrLines:Int
	Field ScrolledLine:Int = 0

	Method New(_X:Float,_Y:Float,_Width:Float,_Height:Float)
		nrLines = _Height/32
		X = _X
		Y = _Y
		Width =_Width
		Height = _Height
		listText = New List<textElement>
	End Method

	Method Draw()
		Drw_Rect(X,Y,Width,Height,2)

		For Local i:Int = 0 Until nrLines
			MANIAC_FONT.Wrap(getText(i+ScrolledLine),X+5,Y+5+i*(27+5),Width,Height,40)
		Next

		SetAlpha 1
		DrawImage MANIAC_IMG_ARROWDOWN,X,Y+Height+5,0,Width/MANIAC_IMG_ARROWDOWN.Width(),48.0/MANIAC_IMG_ARROWDOWN.Height()
	End Method

	Method Update()
		If TouchHit()
			If MOBox(X,Y+Height+5,Width,48)
				ScrolledLine +=1
			Endif
		Endif
	End Method

	Method addLine(_Line:String)
		Local oL:textElement = New textElement(_Line)
		listText.AddLast(oL)
	End Method

	Private
	Method getText:String(_ID:Int)
		Local i:Int = 0
		For Local oL:textElement = Eachin listText
			If i = _ID
				Return oL.Caption
			Endif
			i +=1
		Next
	End Method
End Class

Class ManiacDialog
	Field X:Float,Y:Float,Width:Float,Height:Float
	Field Question:String
	Field Alpha:Float = 0.8
	Field bVisible:Bool = True

	Field Btn_Ja:ManiacButton
	Field Btn_Nein:ManiacButton

	Method New(_X:Float,_Y:Float,_Width:Float,_Height:Float,_Question:String ="")
		X = _X
		Y = _Y
		Width =_Width
		Height = _Height
		Question = _Question

		Btn_Ja = New ManiacButton(X+_Width*0.75,Y+_Height*0.8,_Width*0.4,	_Height*0.25,"Ja",ALIGNMENT_MIDDLE,COLOR_BLUE,True,0.2)
		Btn_Nein = New ManiacButton(X+_Width*0.25,Y+_Height*0.8,_Width*0.4,	_Height*0.25,"Nein",ALIGNMENT_MIDDLE,COLOR_BLUE,True,0.2)
	End Method

	Method Draw()
		If bVisible = True
			SetColor 0,0,0
			SetAlpha Alpha
			DrawRect(X,Y,Width,Height)

			SetAlpha 1
			SetColor 255,255,255
			MANIAC_FONT.Wrap(Question,X+Width*0.05,Y+15,Width*0.9,Height,350)

			Btn_Ja.Draw()
			Btn_Nein.Draw()
		Endif
	End Method

	Method Update:Int()
		If Btn_Ja.Update() = 101
			Return 2
		Elseif Btn_Nein.Update() = 101
			Return 1
		Else
			Return 0
		Endif
	End Method

	Method setVisible(_bVisible:Bool = True)
		bVisible = _bVisible
	End Method
End Class

private
Class ManiacAnimRect
	'Identificanitional Values
	Field ID:Int
	Field maniacID:Int
	Field MidX:Float,MidY:Float			'aktuelle Position des Buttons (Durch Animationen veränderbar
	Field oX:Float,oY:Float 		'Original X,Y << Das ist die Feste Position des Buttons
	Field Width:Float,Height:Float			'Breite und Höhe in Pxl

	'
	Field Caption:String		'Aufschrift
	Field Angle:Float 			'Winkel zur Horizontalen in °
	Field Alignment:Int			'ausrichtung des Textes (Left,Middle,Right)

	Method setPosition(_X:float,_Y:float)
		MidX = _X
		MidY = _Y
	End Method

	Method setSize(_Width:Float,_Height:Float)
		Width = _Width
		Height =_Height
	End Method

End Class
Class ManiacSimpleTextfield
	Private
	Field ID:Int
	Field inputString:String = ""
	Field X:Int,Y:Int
	Field W:Int,H:int

	Field Style:Int
	Field Focus:Int		'0 - Standard ohne gfx effects , 1 -

	Field bEditing:Bool = False

	Public
	Method New(_X:Float,_Y:Float,_Width:Float,_Height:Float,istyle:Int = TEXTFIELD_STYLE_STD)
		ID 		= Maniac_Debug.getNumberOfRegisteredObjects()
		X 		= _X
		Y 		= _Y
		W 		= _Width
		H 		= _Height
		Style 	= istyle
		Maniac_Debug.addRegisteredObject()
	End Method

	Public
	Method update:Int()
		If bFull = True
			If TouchHit()
				If MOBox(X,Y,(W*0.15),(H*1.0))
					If bEditing = True
						bEditing = False
					Else
						bEditing = True
					Endif
				Endif
			Endif
		Endif

		If bEditing = True
			Repeat
				Local char=GetChar()
		        If Not char Exit

		        If char>=32
		            inputString+=String.FromChar( char )
		        Endif

		        If char = CHAR_ENTER
					DisableKeyboard()
					Return 99
				Endif

		        If char = CHAR_BACKSPACE
					Local txtlength:Int = inputString.Length()
					Local txtchars:Int[] = inputString.ToChars
					inputString = ""
					For Local l:Int = 0 To txtlength-2
						inputString += String.FromChar(txtchars[l])
					Next
				Endif

			Forever
		Endif
	End Method

	Public
	Method draw()
		DrawText inputString,X,Y
	End Method

	Method getText:String()
		Return inputString
	End Method

	Method setText(itext:String)
		inputString = itext
	End Method
End Class

error: pathspec 'maniac/maniacSimpleGUI.monkey' did not match any file(s) known to git


Added FlxState class

Added FlxState class

Strict

Import flxgroup

Class FlxState Extends FlxGroup

	Method Create:Void()

	End Method

End Class

error: pathspec 'flxstate.monkey' did not match any file(s) known to git


Added flxextern

Added flxextern

Strict

Import "native/flixel.${TARGET}.${LANG}"

Extern

#If LANG="cpp" Then
	Function SystemMillisecs:Int() = "flixel::systemMillisecs"
#Else
	Function SystemMillisecs:Int() = "flixel.systemMillisecs"
#End

Public

Interface FlxClass

	Method CreateInstance:FlxBasic()

	Method InstanceOf:Bool(object:FlxBasic)

End Interface

Interface FlxFunction

	Method Invoke:Void()

End Interface

error: pathspec 'flxextern.monkey' did not match any file(s) known to git