goddamn it

This commit is contained in:
Yoshman29
2023-03-15 21:52:42 +01:00
parent d06812a662
commit abf595c9f6
5 changed files with 24 additions and 7 deletions
+3
View File
@@ -0,0 +1,3 @@
package funkin.editors;
using funkin.editors.ui.UIUtil;
+6 -1
View File
@@ -7,15 +7,19 @@ class UIButton extends UISprite {
public var bHeight:Int = 20;
public var callback:Void->Void = null;
public var field:UIText;
public function resize(w:Int, h:Int) {
bWidth = w;
bHeight = h;
field.fieldWidth = w;
}
public override function new(x:Float, y:Float, t:String, callback:Void->Void, w:Float = 120, h:Float = 20) {
public override function new(x:Float, y:Float, text:String, callback:Void->Void, w:Float = 120, h:Float = 20) {
super(x, y);
frames = CoolUtil.loadFrames(Paths.image('editors/ui/button'));
this.callback = callback;
members.push(field = new UIText(x, y, w, text));
}
public override function updateButton() {
@@ -33,6 +37,7 @@ class UIButton extends UISprite {
}
public override function draw() {
field.follow(this, 0, ((height - field.height) / 2));
var x:Float = this.x;
var y:Float = this.y;
var offset:Int = hovered ? (pressed ? 18 : 9) : 0;
+4 -6
View File
@@ -6,7 +6,7 @@ class UICheckbox extends UISprite {
public var checked:Bool = false;
public var onChecked:Bool->Void = null;
public var field:FunkinText;
public var field:UIText;
public var check:FlxSprite;
public function new(x:Float, y:Float, text:String, checked:Bool = false, w:Int = 0) {
@@ -17,7 +17,7 @@ class UICheckbox extends UISprite {
this.checked = checked;
field = new UIText(x, y, w, text, 14, false);
field = new UIText(x, y, w, text);
check = new FlxSprite().loadGraphicFromSprite(this);
check.animation.play("checkmark");
@@ -41,10 +41,8 @@ class UICheckbox extends UISprite {
}
public inline function updatePositions() {
check.cameras = field.cameras = cameras;
field.setPosition(x + 25, y);
check.setPosition(x, y);
check.follow(this);
field.follow(this, 25, 0);
}
public override function draw() {
+2
View File
@@ -1,5 +1,7 @@
package funkin.editors.ui;
import funkin.ui.FunkinText;
class UIText extends FunkinText {
// PUTTING THIS HERE IN CASE IMMA MAKE FUTURE CHANGES
public function new(x, y, w, text, size:Int = 14) {
+9
View File
@@ -0,0 +1,9 @@
package funkin.editors.ui;
class UIUtil {
public static inline function follow(spr:FlxSprite, target:FlxSprite, x:Float = 0, y:Float = 0) {
spr.cameras = target.cameras;
spr.setPosition(target.x + x, target.y + y);
spr.scrollFactor.set(target.scrollFactor.x, target.scrollFactor.y);
}
}