MBHaxe/src/gui/GuiButtonText.hx
2022-11-20 19:31:10 +05:30

26 lines
601 B
Haxe

package gui;
import h3d.Vector;
import h2d.Tile;
class GuiButtonText extends GuiButton {
var txtCtrl:GuiText;
public var ratio = 0.25;
public function new(images:Array<Tile>, font:h2d.Font) {
super(images);
txtCtrl = new GuiText(font);
txtCtrl.position = new Vector();
txtCtrl.extent = this.extent;
txtCtrl.justify = Center;
txtCtrl.text.textColor = 0;
this.addChild(txtCtrl);
}
public function setExtent(extent:Vector) {
this.extent = extent;
txtCtrl.extent = extent;
txtCtrl.position.y = extent.y * ratio; // Weird ratio shit that makes it as centered as possible
}
}