Optimized type texts to use less bitmaps
This commit is contained in:
@@ -65,12 +65,17 @@ class CharterDeleteAnim extends CharterNote {
|
||||
sustainSpr.updateHitbox(); sustainSpr.follow(this, 15, 20);
|
||||
sustainSpr.exists = deleteData.note.susLength != 0; sustainSpr.alpha = .8;
|
||||
|
||||
typeText.text = Std.string(deleteData.note.type);
|
||||
typeText.exists = deleteData.note.type != 0; typeText.alpha = .4;
|
||||
typeText.follow(this, 20 - (typeText.frameWidth/2), 20 - (typeText.frameHeight/2));
|
||||
type = deleteData.note.type;
|
||||
typeAlpha = .4;
|
||||
//typeText.text = Std.string(deleteData.note.type);
|
||||
//typeText.exists = deleteData.note.type != 0; typeAlpha = .4;
|
||||
//typeText.follow(this, 20 - (typeText.frameWidth/2), 20 - (typeText.frameHeight/2));
|
||||
|
||||
for (member in [this, sustainSpr, typeText])
|
||||
member.alpha *= FlxEase.quadInOut(deleteData.time/deleteTime);
|
||||
var mult = FlxEase.quadInOut(deleteData.time/deleteTime);
|
||||
|
||||
for (member in [this, sustainSpr])
|
||||
member.alpha *= mult;
|
||||
typeAlpha *= mult;
|
||||
|
||||
super.draw();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ class CharterNote extends UISprite implements ICharterSelectable {
|
||||
public var selected:Bool = false;
|
||||
public var draggable:Bool = true;
|
||||
|
||||
static var noteTypeTexts:Array<UIText> = [];
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
|
||||
@@ -42,7 +44,7 @@ class CharterNote extends UISprite implements ICharterSelectable {
|
||||
sustainSpr.scale.set(10, 0);
|
||||
members.push(sustainSpr);
|
||||
|
||||
typeText = new UIText(x, y, 0, Std.string(type));
|
||||
this.type = 0;
|
||||
|
||||
cursor = sustainSpr.cursor = CLICK;
|
||||
moves = false;
|
||||
@@ -56,7 +58,21 @@ class CharterNote extends UISprite implements ICharterSelectable {
|
||||
public var step:Float;
|
||||
public var id:Int;
|
||||
public var susLength:Float;
|
||||
public var type:Int;
|
||||
public var type(default, set):Null<Int> = null;
|
||||
public var typeVisible:Bool = true;
|
||||
public var typeAlpha:Float = 1;
|
||||
|
||||
function set_type(v:Null<Int>) {
|
||||
if(v != this.type) {
|
||||
if(noteTypeTexts[v] == null || noteTypeTexts[v].graphic.isDestroyed) {
|
||||
noteTypeTexts[v] = new UIText(x, y, 0, Std.string(v));
|
||||
noteTypeTexts[v].exists = v != 0;
|
||||
}
|
||||
|
||||
typeText = noteTypeTexts[v];
|
||||
}
|
||||
return this.type = v;
|
||||
}
|
||||
|
||||
public var strumLine:CharterStrumline;
|
||||
public var strumLineID(get, default):Int = -1;
|
||||
@@ -76,9 +92,8 @@ class CharterNote extends UISprite implements ICharterSelectable {
|
||||
this.type = type;
|
||||
if (strumLine != null) this.strumLine = strumLine;
|
||||
|
||||
typeText.exists = type != 0;
|
||||
typeText.text = Std.string(this.type);
|
||||
typeText.follow(this, 20 - (typeText.frameWidth/2), 20 - (typeText.frameHeight/2));
|
||||
//
|
||||
//typeText.text = Std.string(this.type);
|
||||
|
||||
y = step * 40;
|
||||
|
||||
@@ -140,9 +155,6 @@ class CharterNote extends UISprite implements ICharterSelectable {
|
||||
sustainDraggable = UIState.state.isOverlapping(sustainSpr, @:privateAccess sustainSpr.__rect);
|
||||
}
|
||||
|
||||
if (typeText.exists)
|
||||
typeText.follow(this, 20 - (typeText.frameWidth/2), 20 - (typeText.frameHeight/2));
|
||||
|
||||
if (__passed != (__passed = step < Conductor.curStepFloat)) {
|
||||
if (__passed && FlxG.sound.music.playing && Charter.instance.hitsoundsEnabled(strumLineID))
|
||||
Charter.instance.hitsound.replay();
|
||||
@@ -150,7 +162,7 @@ class CharterNote extends UISprite implements ICharterSelectable {
|
||||
|
||||
if (strumLine != null) {
|
||||
sustainSpr.alpha = alpha = !strumLine.strumLine.visible ? (__passed ? 0.2 : 0.4) : (__passed ? 0.6 : 1);
|
||||
typeText.alpha = !strumLine.strumLine.visible ? (__passed ? 0.4 : 0.6) : (__passed ? 0.8 : 1);
|
||||
typeAlpha = !strumLine.strumLine.visible ? (__passed ? 0.4 : 0.6) : (__passed ? 0.8 : 1);
|
||||
}
|
||||
|
||||
colorTransform.redMultiplier = colorTransform.greenMultiplier = colorTransform.blueMultiplier = selected ? 0.75 : 1;
|
||||
@@ -182,6 +194,10 @@ class CharterNote extends UISprite implements ICharterSelectable {
|
||||
|
||||
drawMembers();
|
||||
drawSuper();
|
||||
if(typeText.exists && typeText.visible) typeText.draw();
|
||||
if(typeText.exists && typeText.visible && typeVisible) {
|
||||
typeText.alpha = typeAlpha;
|
||||
typeText.follow(this, 20 - (typeText.frameWidth/2), 20 - (typeText.frameHeight/2));
|
||||
typeText.draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ class CharterNoteHoverer extends CharterNote {
|
||||
super();
|
||||
|
||||
snappedToStrumline = selectable = autoAlpha = false; visible = sustainSpr.visible = false;
|
||||
@:privateAccess __animSpeed = 1.25; typeText.visible = false; alpha = 0.4;
|
||||
@:privateAccess __animSpeed = 1.25; typeVisible = false; alpha = 0.4;
|
||||
}
|
||||
|
||||
@:noCompletion var __mousePos:FlxPoint = FlxPoint.get();
|
||||
@@ -19,7 +19,7 @@ class CharterNoteHoverer extends CharterNote {
|
||||
var inBoundsY:Bool = (__mousePos.y > 0 && __mousePos.y < (Charter.instance.__endStep)*40);
|
||||
if ((__mousePos.x > 0 && __mousePos.x < Charter.instance.gridBackdrops.strumlinesAmount * 160 && inBoundsY) && showHoverer) {
|
||||
step = CoolUtil.bound(FlxG.keys.pressed.SHIFT ? ((__mousePos.y-20) / 40) : Charter.instance.quantStep(__mousePos.y/40), 0, Charter.instance.__endStep-1);
|
||||
id = Math.floor(__mousePos.x / 40); y = step * 40; x = id * 40; visible = true; sustainSpr.visible = typeText.visible = false;
|
||||
id = Math.floor(__mousePos.x / 40); y = step * 40; x = id * 40; visible = true; sustainSpr.visible = typeVisible = false;
|
||||
angle = switch(animation.curAnim.curFrame = (id % 4)) {
|
||||
case 0: -90;
|
||||
case 1: 180;
|
||||
@@ -30,9 +30,9 @@ class CharterNoteHoverer extends CharterNote {
|
||||
} else
|
||||
visible = false;
|
||||
case NOTE_DRAG:
|
||||
visible = sustainSpr.visible = typeText.visible = true; __doAnim = false;
|
||||
visible = sustainSpr.visible = typeVisible = true; __doAnim = false;
|
||||
default:
|
||||
visible = sustainSpr.visible = typeText.visible = false; __doAnim = false;
|
||||
visible = sustainSpr.visible = typeVisible = false; __doAnim = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user