strumline bullshit

This commit is contained in:
Yoshman29
2023-04-08 23:17:48 +02:00
parent a28d70eb6b
commit fa53926f06
6 changed files with 139 additions and 27 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

+28 -14
View File
@@ -47,6 +47,8 @@ class Charter extends UIState {
public var conductorFollowerSpr:FlxSprite;
public var topLimit:FlxSprite;
public var strumlineInfoBG:FlxSprite;
public var hitsound:FlxSound;
public var metronome:FlxSound;
@@ -55,7 +57,7 @@ class Charter extends UIState {
/**
* ACTUAL CHART DATA
*/
public var strumLines:Array<CharterStrumline> = [];
public var strumLines:FlxTypedGroup<CharterStrumline> = new FlxTypedGroup<CharterStrumline>();
public var notesGroup:CharterNoteGroup = new CharterNoteGroup();
/**
@@ -327,6 +329,14 @@ class Charter extends UIState {
topLimit.color = 0xFF888888;
topLimit.blend = MULTIPLY;
strumlineInfoBG = new UISprite();
strumlineInfoBG.loadGraphic(Paths.image('editors/charter/strumline-info-bg'));
strumlineInfoBG.y = 23;
strumlineInfoBG.scrollFactor.set();
strumlineInfoBG.cameras = [charterCamera];
strumLines.cameras = [charterCamera];
// adds grid and notes so that they're ALWAYS behind the UI
add(gridBackdrop);
@@ -336,6 +346,8 @@ class Charter extends UIState {
add(topLimit);
add(conductorFollowerSpr);
add(selectionBox);
add(strumlineInfoBG);
add(strumLines);
// add the ui group
add(uiGroup);
// add the top menu last OUT of the ui group so that it stays on top
@@ -362,10 +374,7 @@ class Charter extends UIState {
notesGroup.add(n);
}
strumLines.push({
strumLine: strL,
hitsounds: true
});
strumLines.add(new CharterStrumline(strL));
}
}
@@ -509,9 +518,9 @@ class Charter extends UIState {
super.update(elapsed);
if (gridBackdrop.strumlinesAmount != (gridBackdrop.strumlinesAmount = strumLines.length)) {
if (gridBackdrop.strumlinesAmount != (gridBackdrop.strumlinesAmount = strumLines.length))
updateDisplaySprites();
}
sectionSeparator.spacing.y = (10 * Conductor.beatsPerMesure * Conductor.stepsPerBeat) - 1;
beatSeparator.spacing.y = (20 * Conductor.stepsPerBeat) - 1;
@@ -560,6 +569,16 @@ class Charter extends UIState {
topLimit.scale.set(gridBackdrop.strumlinesAmount * 4 * 40, Math.ceil(FlxG.height / charterCamera.zoom));
topLimit.updateHitbox();
topLimit.y = -topLimit.height;
strumlineInfoBG.scale.set(FlxG.width / charterCamera.zoom, 1);
strumlineInfoBG.updateHitbox();
strumlineInfoBG.screenCenter(X);
for(id=>str in strumLines.members) {
if (str == null) continue;
str.x = id * 40 * 4;
str.y = strumlineInfoBG.y;
}
}
var zoom:Float = 0;
@@ -731,7 +750,7 @@ class Charter extends UIState {
inline function _note_subtractsustain(t)
changeNoteSustain(-1);
#end
function changeNoteSustain(change:Float) {
@@ -779,7 +798,7 @@ class Charter extends UIState {
}
public inline function hitsoundsEnabled(id:Int)
return strumLines[Std.int(id / 4)] != null && strumLines[Std.int(id / 4)].hitsounds;
return strumLines.members[Std.int(id / 4)] != null && strumLines.members[Std.int(id / 4)].hitsounds;
}
enum CharterChange {
@@ -793,11 +812,6 @@ enum CharterCopyboardObject {
CNote(step:Float, id:Int, susLength:Float, type:Int);
}
typedef CharterStrumline = {
var strumLine:ChartStrumLine;
var hitsounds:Bool;
}
typedef NoteSustainChange = {
var note:CharterNote;
var before:Float;
@@ -0,0 +1,94 @@
package funkin.editors.charter;
import funkin.editors.ui.UIContextMenu.UIContextMenuOption;
import funkin.editors.ui.UITopMenu.UITopMenuButton;
import funkin.game.HealthIcon;
import funkin.chart.ChartData.ChartStrumLine;
class CharterStrumline extends UISprite {
public var strumLine:ChartStrumLine;
public var hitsounds:Bool = true;
var healthIcon:HealthIcon;
var button:CharterStrumlineButton;
public var curMenu:UIContextMenu = null;
public function new(strumLine:ChartStrumLine) {
super();
this.strumLine = strumLine;
scrollFactor.set(1, 0);
alpha = 0;
healthIcon = new HealthIcon(strumLine.characters != null ? strumLine.characters[0] : null);
healthIcon.scale.set(80 / 150, 80 / 150);
healthIcon.updateHitbox();
members.push(healthIcon);
button = new CharterStrumlineButton(this);
members.push(button);
}
public override function update(elapsed:Float) {
healthIcon.follow(this, ((40 * 4) - healthIcon.width) / 2, 0);
button.follow(this, 0, 95);
super.update(elapsed);
}
public function updateInfo() {
// todo
}
}
class CharterStrumlineButton extends UITopMenuButton {
var strLine:CharterStrumline;
public function new(parent:CharterStrumline) {
super(0, 95, null, "Strumline Options", []);
strLine = parent;
bWidth = 40 * 4;
this.label.fieldWidth = bWidth;
}
public override function update(elapsed:Float) {
super.update(elapsed);
alpha = FlxMath.lerp(1/3, 1, alpha);
}
public override function openContextMenu() {
contextMenu = [
{
label: "Player",
onSelect: function(_) {
strLine.strumLine.type = PLAYER;
},
icon: strLine.strumLine.type == PLAYER ? 1 : 0
},
{
label: "Opponent",
onSelect: function(_) {
strLine.strumLine.type = OPPONENT;
},
icon: strLine.strumLine.type == OPPONENT ? 1 : 0
},
{
label: "Additional",
onSelect: function(_) {
strLine.strumLine.type = ADDITIONAL;
},
icon: strLine.strumLine.type == ADDITIONAL ? 1 : 0
},
null,
{
label: "Hitsounds",
onSelect: function(_) {
strLine.hitsounds = !strLine.hitsounds;
},
icon: strLine.hitsounds ? 1 : 0
}
];
super.openContextMenu();
}
}
+5 -5
View File
@@ -11,7 +11,7 @@ class UISliceSprite extends UISprite {
public function new(x:Float, y:Float, w:Int, h:Int, path:String) {
super(x, y);
frames = CoolUtil.loadFrames(Paths.image(path));
resize(w, h);
}
@@ -33,7 +33,7 @@ class UISliceSprite extends UISprite {
public override function draw() {
var x:Float = this.x;
var y:Float = this.y;
var topleft:FlxFrame = frames.frames[framesOffset];
var top:FlxFrame = frames.frames[framesOffset + 1];
var topright:FlxFrame = frames.frames[framesOffset + 2];
@@ -50,7 +50,7 @@ class UISliceSprite extends UISprite {
setPosition(x, y);
__setSize(topleft.frame.width, topleft.frame.height);
super.drawSuper();
// TOP
if (bWidth > topleft.frame.width + topright.frame.width) {
frame = top;
@@ -71,7 +71,7 @@ class UISliceSprite extends UISprite {
setPosition(x, y + top.frame.height);
__setSize(middleleft.frame.width, bHeight - topleft.frame.height - bottomleft.frame.height);
super.drawSuper();
if (bWidth > middleleft.frame.width + middleright.frame.width) {
// MIDDLE
frame = middle;
@@ -92,7 +92,7 @@ class UISliceSprite extends UISprite {
setPosition(x, y + bHeight - bottom.frame.height);
__setSize(bottomleft.frame.width, bottomleft.frame.height);
super.drawSuper();
if (bWidth > bottomleft.frame.width + bottomright.frame.width) {
// BOTTOM
frame = bottom;
+11 -7
View File
@@ -25,10 +25,9 @@ class UITopMenu extends UISliceSprite {
anyMenuOpened = true;
break;
}
super.update(elapsed);
bWidth = FlxG.width;
}
}
@@ -39,7 +38,7 @@ class UITopMenuButton extends UISliceSprite {
public var parent:UITopMenu;
public var curMenu:UIContextMenu = null;
public function new(x:Float, y:Float, parent:UITopMenu, label:String, contextMenu:Array<UIContextMenuOption>) {
super(x, y, 0, 23, "editors/ui/menu-item");
this.contextMenu = contextMenu;
@@ -48,12 +47,12 @@ class UITopMenuButton extends UISliceSprite {
this.label = new UIText(4, 0, 0, label);
this.label.alignment = CENTER;
bWidth = this.label.frameWidth + 8;
bWidth = Std.int(this.label.fieldWidth = this.label.frameWidth + 8);
members.push(this.label);
}
public override function update(elapsed:Float) {
label.follow(this, 4, Std.int((bHeight - label.height) / 2));
label.follow(this, 0, Std.int((bHeight - label.height) / 2));
super.update(elapsed);
var opened = curMenu.contextMenuOpened();
@@ -67,10 +66,15 @@ class UITopMenuButton extends UISliceSprite {
if (curMenu.contextMenuOpened()) {
UIState.state.curContextMenu.preventOutOfBoxClickDeletion();
} else {
if (parent.anyMenuOpened || FlxG.mouse.justReleased) {
curMenu = UIState.state.openContextMenu(contextMenu, null, x, y + bHeight);
if ((parent != null && parent.anyMenuOpened) || FlxG.mouse.justReleased) {
openContextMenu();
}
}
}
}
public function openContextMenu() {
var screenPos = getScreenPosition(null, __lastDrawCameras[0] == null ? FlxG.camera : __lastDrawCameras[0]);
curMenu = UIState.state.openContextMenu(contextMenu, null, screenPos.x, screenPos.y + bHeight);
}
}
+1 -1
View File
@@ -19,7 +19,7 @@ class FunkinParentDisabler extends FlxBasic {
var __timers:Array<FlxTimer>;
var __sounds:Array<FlxSound>;
var __replaceUponDestroy:Bool;
public function new(replaceUponDestroy:Bool = true) {
public function new(replaceUponDestroy:Bool = false) {
super();
__replaceUponDestroy = replaceUponDestroy;
@:privateAccess {