bright-gpu-74537
12/18/2020, 3:21 PMhaxe
class FancyLabel extends Label {
public function applyMarkup(plainString:String, markupString:String) {
var format1 = new FlxTextFormat(0xE6E600, false, false, 0xFF8000);
var format2 = new FlxTextFormat(0xFFAE5E, false, false, 0xFF8000);
var format3 = new FlxTextFormat(0x008040, false, false, null);
var format4 = new FlxTextFormat(0x0080C0, false, false, null);
var format5 = new FlxTextFormat(0x00E6E6, false, false, null);
var format6 = new FlxTextFormat(0x0080FF, false, false, 0xFFFFFF);
this.text = plainString;
this.getTextDisplay().tf.setBorderStyle(FlxTextBorderStyle.OUTLINE, FlxColor.WHITE, 2);
this.getTextDisplay().tf.applyMarkup(markupString, [
new FlxTextFormatMarkerPair(format1, "<y>"),
new FlxTextFormatMarkerPair(format2, "_"),
new FlxTextFormatMarkerPair(format3, "$"),
new FlxTextFormatMarkerPair(format4, "^"),
new FlxTextFormatMarkerPair(format5, "!"),
new FlxTextFormatMarkerPair(format6, ":")
]);
}
}bright-gpu-74537
12/18/2020, 3:22 PMbright-gpu-74537
12/18/2020, 3:23 PMhaxe
var fancy = new FancyLabel();
fancy.styleString = "font-size: 24px";
fancy.applyMarkup("Formatted via applyMarkup()", "<y>Forma<y>_tted_ $v$^i^!a! apply:Markup():");bright-gpu-74537
12/18/2020, 3:24 PMbright-gpu-74537
12/18/2020, 3:34 PMbright-gpu-74537
12/18/2020, 3:34 PMhaxe
class FancyLabel extends Label {
public override function set_text(value:String):String {
var s = StringTools.replace(value, "<y>", "");
s = StringTools.replace(s, "_", "");
s = StringTools.replace(s, "$", "");
s = StringTools.replace(s, "^", "");
s = StringTools.replace(s, "!", "");
s = StringTools.replace(s, ":", "");
super.set_text(s);
var format1 = new FlxTextFormat(0xE6E600, false, false, 0xFF8000);
var format2 = new FlxTextFormat(0xFFAE5E, false, false, 0xFF8000);
var format3 = new FlxTextFormat(0x008040, false, false, null);
var format4 = new FlxTextFormat(0x0080C0, false, false, null);
var format5 = new FlxTextFormat(0x00E6E6, false, false, null);
var format6 = new FlxTextFormat(0x0080FF, false, false, 0xFFFFFF);
this.getTextDisplay().tf.setBorderStyle(FlxTextBorderStyle.OUTLINE, FlxColor.WHITE, 2);
this.getTextDisplay().tf.applyMarkup(value, [
new FlxTextFormatMarkerPair(format1, "<y>"),
new FlxTextFormatMarkerPair(format2, "_"),
new FlxTextFormatMarkerPair(format3, "$"),
new FlxTextFormatMarkerPair(format4, "^"),
new FlxTextFormatMarkerPair(format5, "!"),
new FlxTextFormatMarkerPair(format6, ":")
]);
return value;
}
}bright-gpu-74537
12/18/2020, 3:47 PMhaxe
class FancyLabel extends Label {
public var textBorder:Dynamic; // just for ease / prototype
public override function set_text(value:String):String {
var s = value;
for (m in _markers) {
s = StringTools.replace(s, m.marker, "");
}
super.set_text(s);
if (textBorder != null) {
this.getTextDisplay().tf.setBorderStyle(textBorder.style, textBorder.color, textBorder.size);
}
this.getTextDisplay().tf.applyMarkup(value, _markers);
return value;
}
private var _markers:Array<FlxTextFormatMarkerPair> = [];
public function addFormatMarker(marker:FlxTextFormatMarkerPair) {
_markers.push(marker);
}
}
usage:
haxe
var fancy = new FancyLabel();
fancy.styleString = "font-size: 24px";
fancy.textBorder = {
style: FlxTextBorderStyle.OUTLINE,
color: FlxColor.WHITE,
size: 2
}
fancy.addFormatMarker(new FlxTextFormatMarkerPair(new FlxTextFormat(0xE6E600, false, false, 0xFF8000), "<y>"));
fancy.addFormatMarker(new FlxTextFormatMarkerPair(new FlxTextFormat(0xFFAE5E, false, false, 0xFF8000), "_"));
fancy.addFormatMarker(new FlxTextFormatMarkerPair(new FlxTextFormat(0x008040, false, false, null), "$"));
fancy.addFormatMarker(new FlxTextFormatMarkerPair(new FlxTextFormat(0x0080C0, false, false, null), "^"));
fancy.addFormatMarker(new FlxTextFormatMarkerPair(new FlxTextFormat(0x00E6E6, false, false, null), "!"));
fancy.addFormatMarker(new FlxTextFormatMarkerPair(new FlxTextFormat(0x0080FF, false, false, 0xFFFFFF), ":"));
fancy.text = "<y>Forma<y>_tted_ $v$^i^!a! apply:Markup():";
mainView.addComponentAt(fancy, 0);most-caravan-45834
12/18/2020, 4:11 PMmost-caravan-45834
12/18/2020, 4:12 PMmost-caravan-45834
12/19/2020, 4:25 AMbright-gpu-74537
12/19/2020, 7:38 AMresource is the css property, but im not 100% if that is animatable or not... if it isnt it should be easy to make it sobright-gpu-74537
12/19/2020, 7:47 AMbright-gpu-74537
12/19/2020, 8:29 AMbright-gpu-74537
12/19/2020, 8:30 AMhtml
<style>
@keyframes animateIconButton {
0% { icon: "img/image_[[0]].png"; }
100% { icon: "img/image_[[54]].png"; }
}
@keyframes animateImage {
0% { resource: "img/image_[[0]].png"; }
100% { resource: "img/image_[[54]].png"; }
}
#animatedIconButton {
icon: "img/image_0.png"
}
#animatedIconButton:hover {
animation: animateIconButton 1s linear 0s infinite forward forwards;
}
#animatedImage {
resource: "img/image_0.png";
animation: animateImage 1s linear 0s infinite forward forwards;
}
</style>
<hbox>
<button id="animatedIconButton" text="Animated Icon" />
<image id="animatedImage" />
</hbox>orange-van-60470
12/19/2020, 10:21 AMorange-van-60470
12/19/2020, 10:22 AMbright-gpu-74537
12/19/2020, 10:22 AMbright-gpu-74537
12/19/2020, 10:22 AMorange-van-60470
12/19/2020, 10:23 AMorange-van-60470
12/19/2020, 10:23 AMbright-gpu-74537
12/19/2020, 10:24 AMbright-gpu-74537
12/19/2020, 10:24 AMbright-gpu-74537
12/19/2020, 10:24 AMorange-van-60470
12/19/2020, 10:26 AMorange-van-60470
12/19/2020, 10:27 AMbright-gpu-74537
12/19/2020, 10:27 AMorange-van-60470
12/19/2020, 10:34 AMorange-van-60470
12/19/2020, 10:38 AMorange-van-60470
12/19/2020, 10:39 AMbright-gpu-74537
12/19/2020, 10:39 AM