-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new objects, CustomNumericStepperUI and CustomCheckBoxUI
- Loading branch information
Showing
4 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<project xmlns="http://lime.software/project/1.0.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://lime.software/project/1.0.2 http://lime.software/xsd/project-1.0.2.xsd"> | ||
<assets path="assets/images" embed="true"/> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Void>; | ||
|
||
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Void>; | ||
|
||
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; | ||
} | ||
} |