diff --git a/assets/images/check_mark.png b/assets/images/check_mark.png new file mode 100644 index 0000000..b5ca287 Binary files /dev/null and b/assets/images/check_mark.png differ diff --git a/include.xml b/include.xml new file mode 100644 index 0000000..5407379 --- /dev/null +++ b/include.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/me/customs/ui/CustomCheckBoxUI.hx b/me/customs/ui/CustomCheckBoxUI.hx new file mode 100644 index 0000000..bbf28a9 --- /dev/null +++ b/me/customs/ui/CustomCheckBoxUI.hx @@ -0,0 +1,64 @@ +package me.customs.ui; + +import flixel.FlxG; +import flixel.FlxSprite; +import flixel.text.FlxText; +import flixel.util.FlxColor; +import flixel.group.FlxSpriteGroup; +import flixel.FlxObject; + +class CustomCheckBoxUI extends FlxSpriteGroup +{ + var checkBox:FlxSprite; + public var checkSign:FlxSprite; + var text:FlxText; + + public var checked:Bool; + public var callback:Void -> Null; + + public function new(x:Float, y:Float, width:Int = 20, height:Int = 20, label:String, size:Int) + { + super(x, y); + + checkBox = new FlxSprite().makeGraphic(width, height, 0xFFFFFFFF); + add(checkBox); + + checkSign = new FlxSprite().loadGraphic('assets/images/check_mark.png'); + checkSign.setGraphicSize(width, height); + add(checkSign); + + text = new FlxText(25, 2, 0, label, size); + text.setFormat("VCR OSD Mono", size, FlxColor.WHITE, LEFT); + add(text); + + //centerOnSprite(text, checkBox, false, true); + } + + public override function update(elapsed:Float) + { + super.update(elapsed); + + if(FlxG.mouse.overlaps(this)) + { + if(FlxG.mouse.justPressed) + { + clickCheck(); + } + } + } + + public function clickCheck() + { + checked = !checked; + trace('CHECKED: ' + checked); + + checkSign.visible = checked; + if(callback != null) callback(); + } + + public function updateCheck() + { + checkSign.visible = checked; + if(callback != null) callback(); + } +} \ No newline at end of file diff --git a/me/customs/ui/CustomNumericStepperUI.hx b/me/customs/ui/CustomNumericStepperUI.hx new file mode 100644 index 0000000..63e5731 --- /dev/null +++ b/me/customs/ui/CustomNumericStepperUI.hx @@ -0,0 +1,73 @@ +package me.customs.ui; + +import flixel.FlxG; +import flixel.FlxSprite; +import flixel.text.FlxText; +import flixel.util.FlxColor; +import flixel.group.FlxSpriteGroup; +import flixel.math.FlxMath; +import me.customs.ui.CustomButton; + +class CustomNumericStepperUI extends FlxSpriteGroup +{ + var bg:FlxSprite; + var text:FlxText; + public var button_plus:CustomButton; + public var button_minus:CustomButton; + + public var maxValue:Float = 400; + public var minValue:Float = 1; + public var value:Float; + public var callback:Void -> Null; + + public var stepSize:Float; + + public function new(x:Float, y:Float, _stepSize:Float, initialValue:Float) + { + super(x, y); + + value = initialValue; + + stepSize = _stepSize; + + bg = new FlxSprite().makeGraphic(40, 20, 0xFFFFFFFF); + add(bg); + + text = new FlxText(0, 2, 0, "" + value, 16); + text.setFormat("VCR OSD Mono", 16, FlxColor.BLACK, CENTER); + add(text); + + button_plus = new CustomButton(50, 0, 20, 20, 0xFF000000, '+', 16, 0xFFFFFFFF, onPressButtonPlus); + add(button_plus); + + button_minus = new CustomButton(80, 0, 20, 20, 0xFF000000, '-', 16, 0xFFFFFFFF, onPressButtonMinus); + add(button_minus); + } + + function onPressButtonPlus():Void + { + if(value < maxValue) + { + value += stepSize; + FlxMath.roundDecimal(value, 1); + if(callback != null) callback(); + updateText(); + } + } + + function onPressButtonMinus():Void + { + if(value > minValue) + { + value -= stepSize; + FlxMath.roundDecimal(value, 1); + if(callback != null) callback(); + updateText(); + } + } + + public function updateText() + { + text.text = "" + value; + } +} \ No newline at end of file