Skip to content

Commit

Permalink
Revert "keycount stuff for charter"
Browse files Browse the repository at this point in the history
This reverts commit 19ba28c.
  • Loading branch information
charlesisfeline authored Aug 1, 2024
1 parent 4a74d40 commit 4913dbf
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 75 deletions.
53 changes: 5 additions & 48 deletions source/funkin/editors/charter/Charter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ class Charter extends UIState {
public static var clipboard:Array<CharterCopyboardObject> = [];
public static var waveformHandler:CharterWaveformHandler;

public static var keyCount = 4;

public function new(song:String, diff:String, reload:Bool = true) {
super();
if (song != null) {
Expand Down Expand Up @@ -297,17 +295,6 @@ class Charter extends UIState {
label: 'Low Detail Waveforms',
onSelect: _view_switchWaveformDetail,
icon: Options.charterLowDetailWaveforms ? 1 : 0
},
null,
{
label: "Decrease grid width",
keybind: [CONTROL, LBRACKET],
onSelect: _view_decrease_keycount
},
{
label: "Increase grid width",
keybind: [CONTROL, RBRACKET],
onSelect: _view_increase_keycount
}
]
},
Expand Down Expand Up @@ -795,7 +782,7 @@ class Charter extends UIState {
n.snappedToStrumline = false;
n.setPosition(n.fullID * 40 + (mousePos.x - dragStartPos.x), n.step * 40 + (mousePos.y - dragStartPos.y));
n.y = FlxMath.bound(n.y, 0, (__endStep*40) - n.height);
n.x = FlxMath.bound(n.x, 0, ((strumLines.members.length * Charter.keyCount)-1) * 40);
n.x = FlxMath.bound(n.x, 0, ((strumLines.members.length * 4)-1) * 40);
n.cursor = HAND;
}, function (e:CharterEvent) {
e.y = e.step * 40 + (mousePos.y - dragStartPos.y) - 17;
Expand Down Expand Up @@ -824,7 +811,7 @@ class Charter extends UIState {
if (s is CharterNote) {
var note:CharterNote = cast s;
if (note.fullID + changePoint.y < 0) boundedChange.y += Math.abs(note.fullID + changePoint.y);
if (note.fullID + changePoint.y > (strumLines.members.length*Charter.keyCount)-1) boundedChange.y -= (note.fullID + changePoint.y) - ((strumLines.members.length*Charter.keyCount)-1);
if (note.fullID + changePoint.y > (strumLines.members.length*4)-1) boundedChange.y -= (note.fullID + changePoint.y) - ((strumLines.members.length*4)-1);
}

s.handleDrag(boundedChange);
Expand Down Expand Up @@ -857,7 +844,7 @@ class Charter extends UIState {
gridActionType = BOX_SELECTION;

var id = Math.floor(mousePos.x / 40);
var mouseOnGrid = id >= 0 && id < Charter.keyCount * gridBackdrops.strumlinesAmount && mousePos.y >= 0;
var mouseOnGrid = id >= 0 && id < 4 * gridBackdrops.strumlinesAmount && mousePos.y >= 0;

if (FlxG.mouse.justReleased) {
for (n in selection) n.selected = false;
Expand All @@ -867,7 +854,7 @@ class Charter extends UIState {
var note = new CharterNote();
note.updatePos(
FlxMath.bound(FlxG.keys.pressed.SHIFT ? ((mousePos.y-20) / 40) : quantStep(mousePos.y/40), 0, __endStep-1),
id % Charter.keyCount, 0, noteType, strumLines.members[Std.int(id/Charter.keyCount)]
id % 4, 0, noteType, strumLines.members[Std.int(id/4)]
);
notesGroup.add(note);
selection = [note];
Expand Down Expand Up @@ -1170,7 +1157,7 @@ class Charter extends UIState {
gridBackdrops.conductorSprY = lerp(gridBackdrops.conductorSprY, curStepFloat * 40, __firstFrame ? 1 : 1/3);
}
charterCamera.scroll.set(
((((40*Charter.keyCount) * gridBackdrops.strumlinesAmount) - FlxG.width) / 2),
((((40*4) * gridBackdrops.strumlinesAmount) - FlxG.width) / 2),
gridBackdrops.conductorSprY - (FlxG.height * 0.5)
);

Expand Down Expand Up @@ -1624,11 +1611,6 @@ class Charter extends UIState {
t.icon = (Options.charterLowDetailWaveforms = !Options.charterLowDetailWaveforms) ? 1 : 0;
for (shader in waveformHandler.waveShaders) shader.data.lowDetail.value = [Options.charterLowDetailWaveforms];
}

inline function _view_increase_keycount(_)
changeKeyCount(keyCount+1);
inline function _view_decrease_keycount(_)
changeKeyCount(keyCount-1);

inline function _snap_increasesnap(_) changequant(1);
inline function _snap_decreasesnap(_) changequant(-1);
Expand Down Expand Up @@ -1683,33 +1665,8 @@ class Charter extends UIState {
if (note.step > Conductor.curMeasure*Conductor.getMeasureLength() && note.step < (Conductor.curMeasure+1)*Conductor.getMeasureLength()) note
];
}

#end

function changeKeyCount(newKeyCount:Int = 4) {
if (newKeyCount < 1) newKeyCount = 1;

if (keyCount != newKeyCount) {

keyCount = newKeyCount;

var gridBackdropIndex = members.indexOf(gridBackdrops);

remove(gridBackdrops);
gridBackdrops.destroy();

gridBackdrops = new CharterBackdropGroup(strumLines);
gridBackdrops.notesGroup = notesGroup;
insert(gridBackdropIndex, gridBackdrops);

@:privateAccess
gridBackdropDummy.parent = gridBackdrops;
gridBackdrops.cameras = [Charter.instance.charterCamera];
gridBackdrops.createGrids(PlayState.SONG.strumLines.length);
refreshBPMSensitive();
}
}

function changeNoteSustain(change:Float) {
if (selection.length <= 0 || change == 0 || gridActionType != NONE) return;

Expand Down
22 changes: 11 additions & 11 deletions source/funkin/editors/charter/CharterBackdropGroup.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ class CharterBackdropGroup extends FlxTypedGroup<CharterBackdrop> {
super();
this.strumLineGroup = strumLineGroup;

__gridGraphic = FlxG.bitmap.create(40*Charter.keyCount, 160, 0xFF272727, true);
__gridGraphic = FlxG.bitmap.create(160, 160, 0xFF272727, true);
__gridGraphic.bitmap.lock();

// Checkerboard
for(y in 0...4)
for(x in 0...Math.ceil(Charter.keyCount/2)) __gridGraphic.bitmap.fillRect(new Rectangle(40*((x*2)+(y%2)), 40*y, 40, 40), 0xFF545454);
for(x in 0...2) __gridGraphic.bitmap.fillRect(new Rectangle(40*((x*2)+(y%2)), 40*y, 40, 40), 0xFF545454);

// Edges
__gridGraphic.bitmap.fillRect(new Rectangle(0, 0, 1, 160), 0xFFDDDDDD);
__gridGraphic.bitmap.fillRect(new Rectangle((40*Charter.keyCount)-1, 0, 1, 160), 0xFFDDDDDD);
__gridGraphic.bitmap.fillRect(new Rectangle(159, 0, 1, 160), 0xFFDDDDDD);
__gridGraphic.bitmap.unlock();
}

Expand Down Expand Up @@ -68,7 +68,7 @@ class CharterBackdropGroup extends FlxTypedGroup<CharterBackdrop> {

grid.notesGroup.clear();
notesGroup.forEach((n) -> {
var onStr:Bool = (n.snappedToStrumline ? n.strumLineID : Std.int(FlxMath.bound((n.x+n.width)/(40*Charter.keyCount), 0, strumLineGroup.members.length-1))) == i;
var onStr:Bool = (n.snappedToStrumline ? n.strumLineID : Std.int(FlxMath.bound((n.x+n.width)/(40*4), 0, strumLineGroup.members.length-1))) == i;
if(n.exists && n.visible && onStr)
grid.notesGroup.add(n);
});
Expand Down Expand Up @@ -148,7 +148,7 @@ class CharterBackdrop extends FlxTypedGroup<Dynamic> {
sep.makeSolid(1, 1, -1);
sep.alpha = 0.5;
sep.scrollFactor.set(1, 1);
sep.scale.set((Charter.keyCount * 40), sep == sectionSeparator ? 4 : 2);
sep.scale.set((4 * 40), sep == sectionSeparator ? 4 : 2);
sep.updateHitbox();
}
add(beatSeparator);
Expand All @@ -159,15 +159,15 @@ class CharterBackdrop extends FlxTypedGroup<Dynamic> {
bottomSeparator.makeSolid(1, 1, -1);
bottomSeparator.alpha = 0.5;
bottomSeparator.scrollFactor.set(1, 1);
bottomSeparator.scale.set(Charter.keyCount * 40, 4);
bottomSeparator.scale.set(4 * 40, 4);
bottomSeparator.updateHitbox();
add(bottomSeparator);

topSeparator = new FlxSprite(0, -2);
topSeparator.makeSolid(1, 1, -1);
topSeparator.alpha = 0.5;
topSeparator.scrollFactor.set(1, 1);
topSeparator.scale.set(Charter.keyCount * 40, 4);
topSeparator.scale.set(4 * 40, 4);
topSeparator.updateHitbox();
add(topSeparator);

Expand All @@ -186,7 +186,7 @@ class CharterBackdrop extends FlxTypedGroup<Dynamic> {

// Follower
conductorFollowerSpr = new FlxSprite(0, 0).makeSolid(1, 1, -1);
conductorFollowerSpr.scale.set(Charter.keyCount * 40, 4);
conductorFollowerSpr.scale.set(4 * 40, 4);
conductorFollowerSpr.updateHitbox();
add(conductorFollowerSpr);
}
Expand All @@ -209,17 +209,17 @@ class CharterBackdrop extends FlxTypedGroup<Dynamic> {
sectionSeparator.spacing.y = (10 * Conductor.beatsPerMeasure * Conductor.stepsPerBeat) - 1;
beatSeparator.spacing.y = (20 * Conductor.stepsPerBeat) - 1;

topLimit.scale.set(Charter.keyCount * 40, Math.ceil(FlxG.height / cameras[0].zoom));
topLimit.scale.set(4 * 40, Math.ceil(FlxG.height / cameras[0].zoom));
topLimit.updateHitbox();
topLimit.y = -topLimit.height;

bottomLimit.scale.set(Charter.keyCount * 40, Math.ceil(FlxG.height / cameras[0].zoom));
bottomLimit.scale.set(4 * 40, Math.ceil(FlxG.height / cameras[0].zoom));
bottomLimit.updateHitbox();

waveformSprite.visible = waveformSprite.shader != null;
if (waveformSprite.shader == null) return;

waveformSprite.scale.set(Charter.keyCount * 40, FlxG.height * (1/cameras[0].zoom));
waveformSprite.scale.set(160, FlxG.height * (1/cameras[0].zoom));
waveformSprite.updateHitbox();

waveformSprite.y = (cameras[0].scroll.y+FlxG.height/2)-(waveformSprite.height/2);
Expand Down
8 changes: 4 additions & 4 deletions source/funkin/editors/charter/CharterNote.hx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CharterNote extends UISprite implements ICharterSelectable {

public var fullID(get, never):Int; // instead of %4 get fullID (for mousepos stuff)
public function get_fullID():Int
return (strumLineID * Charter.keyCount) + id;
return (strumLineID * 4) + id;

public function updatePos(step:Float, id:Int, susLength:Float = 0, ?type:Int = 0, ?strumLine:CharterStrumline = null) {
this.step = step;
Expand Down Expand Up @@ -175,14 +175,14 @@ class CharterNote extends UISprite implements ICharterSelectable {

public function handleDrag(change:FlxPoint) {
var newStep = FlxMath.bound(step + change.x, 0, Charter.instance.__endStep-1);
var newID:Int = Std.int(FlxMath.bound(fullID + Std.int(change.y), 0, (Charter.instance.strumLines.members.length*Charter.keyCount)-1));
var newID:Int = Std.int(FlxMath.bound(fullID + Std.int(change.y), 0, (Charter.instance.strumLines.members.length*4)-1));

updatePos(newStep, newID % Charter.keyCount, susLength, type, Charter.instance.strumLines.members[Std.int(newID/Charter.keyCount)]);
updatePos(newStep, newID % 4, susLength, type, Charter.instance.strumLines.members[Std.int(newID/4)]);
}

public override function draw() {
if (snappedToStrumline)
x = (strumLine != null ? strumLine.x : 0) + (id % Charter.keyCount) * 40;
x = (strumLine != null ? strumLine.x : 0) + (id % 4) * 40;

drawMembers();
drawSuper();
Expand Down
4 changes: 2 additions & 2 deletions source/funkin/editors/charter/CharterNoteHoverer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CharterNoteHoverer extends CharterNote {
switch (Charter.instance.gridActionType) {
case NONE:
var inBoundsY:Bool = (__mousePos.y > 0 && __mousePos.y < (Charter.instance.__endStep)*40);
if ((__mousePos.x > 0 && __mousePos.x < Charter.instance.gridBackdrops.strumlinesAmount * 40 * Charter.keyCount && inBoundsY) && showHoverer) {
if ((__mousePos.x > 0 && __mousePos.x < Charter.instance.gridBackdrops.strumlinesAmount * 160 && inBoundsY) && showHoverer) {
step = FlxMath.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;
angle = switch(animation.curAnim.curFrame = (id % 4)) {
Expand Down Expand Up @@ -53,7 +53,7 @@ class CharterNoteHoverer extends CharterNote {
y -= ((draggingNote.step + verticalChange)
- Charter.instance.quantStepRounded(draggingNote.step+verticalChange, verticalChange > 0 ? 0.35 : 0.65));
y *= 40;
var newID:Int = Std.int(FlxMath.bound(draggingNote.fullID + horizontalChange, 0, (Charter.instance.strumLines.members.length*Charter.keyCount)-1));
var newID:Int = Std.int(FlxMath.bound(draggingNote.fullID + horizontalChange, 0, (Charter.instance.strumLines.members.length*4)-1));
x = (id=newID) * 40; y = FlxMath.bound(y, 0, (Charter.instance.__endStep*40) - height);

angle = switch(animation.curAnim.curFrame = (draggingNote.id % 4)) {
Expand Down
8 changes: 4 additions & 4 deletions source/funkin/editors/charter/CharterStrumLineGroup.hx
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ class CharterStrumLineGroup extends FlxTypedGroup<CharterStrumline> {
}

for (i=>strum in members)
if (strum != null && !strum.dragging) strum.x = CoolUtil.fpsLerp(strum.x, 40*Charter.keyCount * i, 0.225);
if (strum != null && !strum.dragging) strum.x = CoolUtil.fpsLerp(strum.x, 160 * i, 0.225);

if (Charter.instance.eventsBackdrop != null && members[0] != null)
Charter.instance.eventsBackdrop.x = members[0].button.x - Charter.instance.eventsBackdrop.width;
if (Charter.instance.strumlineLockButton != null && members[0] != null)
Charter.instance.strumlineLockButton.x = members[0].x - (40*Charter.keyCount);
Charter.instance.strumlineLockButton.x = members[0].x - (40*4);
if (Charter.instance.strumlineAddButton != null && members[Std.int(Math.max(0, members.length-1))] != null)
Charter.instance.strumlineAddButton.x = members[members.length-1].x + (40*Charter.keyCount);
Charter.instance.strumlineAddButton.x = members[members.length-1].x + (40*4);

if ((FlxG.mouse.justReleased || !draggable) && isDragging)
finishDrag();
Expand All @@ -52,7 +52,7 @@ class CharterStrumLineGroup extends FlxTypedGroup<CharterStrumline> {

public function snapStrums() {
for (i=>strum in members)
if (strum != null && !strum.dragging) strum.x = (40*Charter.keyCount) * i;
if (strum != null && !strum.dragging) strum.x = 160 * i;
}

public function orderStrumline(strumLine:CharterStrumline, newID:Int) {
Expand Down
8 changes: 4 additions & 4 deletions source/funkin/editors/charter/CharterStrumline.hx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class CharterStrumline extends UISprite {
public override function update(elapsed:Float) {
if (FlxG.keys.justPressed.K) draggable = !draggable;

healthIcons.follow(this, ((40 * Charter.keyCount) - healthIcons.width) / 2, 7 + (__healthYOffset = FlxMath.lerp(__healthYOffset, draggable ? 8 : 0, 1/20)));
healthIcons.follow(this, ((40 * 4) - healthIcons.width) / 2, 7 + (__healthYOffset = FlxMath.lerp(__healthYOffset, draggable ? 8 : 0, 1/20)));

draggingSprite.selectable = draggable;
UIState.state.updateSpriteRect(draggingSprite);
Expand All @@ -91,7 +91,7 @@ class CharterStrumline extends UISprite {
draggingSprite.scale.set(dragScale, dragScale);
draggingSprite.updateHitbox();

draggingSprite.follow(this, ((Charter.keyCount*40)/2) - (draggingSprite.width/2), 6 + (__draggingYOffset = FlxMath.lerp(__draggingYOffset, draggable ? 3 : 0, 1/12)));
draggingSprite.follow(this, (160/2) - (draggingSprite.width/2), 6 + (__draggingYOffset = FlxMath.lerp(__draggingYOffset, draggable ? 3 : 0, 1/12)));
var fullAlpha:Float = UIState.state.isOverlapping(draggingSprite, @:privateAccess draggingSprite.__rect) || dragging ? 0.9 : 0.35;
draggingSprite.alpha = FlxMath.lerp(draggingSprite.alpha, draggable ? fullAlpha : 0, 1/12);
button.follow(this, 0, 95);
Expand Down Expand Up @@ -125,13 +125,13 @@ class CharterStrumlineOptions extends UITopMenuButton {
public function new(parent:CharterStrumline) {
super(0, 95, null, "Options ↓", []);
strLine = parent;
bWidth = 40 * 4;
this.label.fieldWidth = bWidth;
}

public override function update(elapsed:Float) {
super.update(elapsed);
alpha = FlxMath.lerp(1/20, 1, alpha); // so that instead of 0% it is 33% visible
bWidth = 40 * Charter.keyCount;
this.label.fieldWidth = bWidth;
}

public override function openContextMenu() {
Expand Down
3 changes: 1 addition & 2 deletions source/funkin/editors/charter/CharterStrumlineButton.hx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ class CharterStrumlineButton extends UISprite {
public var textColorLerp:Float = 1;

public override function update(elapsed:Float) {
button.follow(this, ((40 * Charter.keyCount) - button.width) / 2, 20+buttonYOffset);
button.follow(this, ((40 * 4) - button.width) / 2, 20+buttonYOffset);
text.follow(this, 0, 84);
text.fieldWidth = (40 * Charter.keyCount);

shakeTimer -= elapsed;
if (shakeTimer > 0)
Expand Down

0 comments on commit 4913dbf

Please sign in to comment.