This commit is contained in:
Yoshman29
2023-03-20 17:08:30 +01:00
parent 8f542c11e9
commit b140ab4345
4 changed files with 177 additions and 97 deletions
+1 -1
View File
@@ -1 +1 @@
2673
2677
+144 -96
View File
@@ -1,5 +1,6 @@
package funkin.editors.charter;
import funkin.editors.charter.CharterBackdrop.CharterBackdropDummy;
import funkin.system.Conductor;
import funkin.chart.*;
import funkin.chart.ChartData;
@@ -24,92 +25,11 @@ class Charter extends UIState {
private var gridColor1:FlxColor = 0xFF272727; // white
private var gridColor2:FlxColor = 0xFF545454; // gray
public var topMenu:Array<UIContextMenuOption> = [
{
label: "File",
childs: [
{
label: "New"
},
null,
{
label: "Exit",
onSelect: function() {
FlxG.switchState(new CharterSelection());
}
}
]
},
{
label: "Edit",
childs: [
{
label: "Undo"
},
{
label: "Redo"
},
null,
{
label: "Cut"
},
{
label: "Copy"
},
{
label: "Paste"
},
null,
{
label: "Delete"
}
]
},
{
label: "Chart",
childs: [
{
label: "Playtest"
},
{
label: "Playtest here"
},
null,
{
label: "Playtest as opponent"
},
{
label: "Playtest as opponent here"
},
null,
{
label: "Edit metadata information"
}
]
},
{
label: "Playback",
childs: [
{
label: "Play/Pause"
},
null,
{
label: "Go back a section"
},
{
label: "Go forward a section"
},
null,
{
label: "Go back to the start"
}
]
}
];
public var topMenu:Array<UIContextMenuOption>;
public var topMenuSpr:UITopMenu;
public var gridBackdrop:CharterBackdrop;
public var gridBackdropDummy:CharterBackdropDummy;
/**
* ACTUAL CHART DATA
@@ -125,6 +45,8 @@ class Charter extends UIState {
// camera for the ui
public var uiCamera:FlxCamera;
public var selection:Array<CharterNote> = [];
public function new(song:String, diff:String) {
super();
__song = song;
@@ -133,6 +55,90 @@ class Charter extends UIState {
public override function create() {
super.create();
topMenu = [
{
label: "File",
childs: [
{
label: "New"
},
null,
{
label: "Exit",
onSelect: _file_exit
}
]
},
{
label: "Edit",
childs: [
{
label: "Undo"
},
{
label: "Redo"
},
null,
{
label: "Cut"
},
{
label: "Copy"
},
{
label: "Paste"
},
null,
{
label: "Delete",
onSelect: _edit_delete
}
]
},
{
label: "Chart",
childs: [
{
label: "Playtest"
},
{
label: "Playtest here"
},
null,
{
label: "Playtest as opponent"
},
{
label: "Playtest as opponent here"
},
null,
{
label: "Edit metadata information"
}
]
},
{
label: "Playback",
childs: [
{
label: "Play/Pause"
},
null,
{
label: "Go back a section"
},
{
label: "Go forward a section"
},
null,
{
label: "Go back to the start"
}
]
}
];
trace('Entering Charter for song $__song with difficulty $__diff.');
@@ -142,10 +148,11 @@ class Charter extends UIState {
FlxG.cameras.add(uiCamera);
gridBackdrop = new CharterBackdrop();
// gridBackdrop.setPosition(-78, 1);
gridBackdrop = new CharterBackdrop();
notesGroup.cameras = gridBackdrop.cameras = [charterCamera];
add(gridBackdropDummy = new CharterBackdropDummy(gridBackdrop));
topMenuSpr = new UITopMenu(topMenu);
topMenuSpr.cameras = uiGroup.cameras = [uiCamera];
@@ -177,20 +184,61 @@ class Charter extends UIState {
}
public override function update(elapsed:Float) {
// TODO: do optimization like NoteGroup
notesGroup.forEach(function(n) {
n.selected = false;
if (n.hovered) {
if (FlxG.mouse.justReleased) {
if (FlxG.keys.pressed.CONTROL)
selection.push(n);
else
selection = [n];
}
if (FlxG.mouse.justReleasedRight) {
openContextMenu(topMenu[1].childs);
}
}
});
for(n in selection)
n.selected = true;
super.update(elapsed);
gridBackdrop.strumlinesAmount = 3;
// TODO: remove this bs!!
if (controls.BACK)
FlxG.switchState(new funkin.menus.MainMenuState());
if (controls.LEFT)
FlxG.camera.scroll.x -= 100 * elapsed;
if (controls.RIGHT)
FlxG.camera.scroll.x += 100 * elapsed;
if (controls.UP)
FlxG.camera.scroll.y -= 100 * elapsed;
if (controls.DOWN)
FlxG.camera.scroll.y += 100 * elapsed;
// TODO: canTypeText in case an ui input element is focused
if (true) {
if (controls.LEFT)
FlxG.camera.scroll.x -= 100 * elapsed;
if (controls.RIGHT)
FlxG.camera.scroll.x += 100 * elapsed;
if (controls.UP)
FlxG.camera.scroll.y -= 100 * elapsed;
if (controls.DOWN)
FlxG.camera.scroll.y += 100 * elapsed;
if (FlxG.keys.justPressed.DELETE)
_edit_delete();
}
}
public function deleteNote(note:CharterNote):CharterNote {
notesGroup.remove(note, true);
note.kill();
note.destroy();
return null;
}
// TOP MENU OPTIONS
#if REGION
function _file_exit() {
FlxG.switchState(new CharterSelection());
}
function _edit_delete() {
if (selection == null) return;
for(s in selection)
deleteNote(s);
}
#end
}
@@ -28,4 +28,26 @@ class CharterBackdrop extends FlxBackdrop {
}
x = ogX;
}
}
class CharterBackdropDummy extends UISprite {
var parent:CharterBackdrop;
public function new(parent:CharterBackdrop) {
super();
this.parent = parent;
cameras = parent.cameras;
}
public override function updateButton() {
__rect.x = parent.x;
__rect.y = 0 - (FlxG.height * (1 - (1 / FlxG.camera.zoom)));
__rect.width = parent.frameWidth * parent.scale.x * parent.strumlinesAmount;
__rect.height = FlxG.height / FlxG.camera.zoom;
UIState.state.updateRectButtonHandler(this, __rect, onHovered);
}
public override function draw() {
@:privateAccess
__lastDrawCameras = [for(c in cameras) c];
}
}
@@ -7,6 +7,8 @@ import flixel.util.FlxColor;
class CharterNote extends UISprite {
var angleTween:FlxTween;
public var selected:Bool = false;
public function new() {
super();
antialiasing = true;
@@ -16,6 +18,8 @@ class CharterNote extends UISprite {
this.setUnstretchedGraphicSize(40, 40, false);
angle = 45; // green-red inbetween
cursor = BUTTON;
}
public function updatePos(step:Float, id:Int, susLength:Float = 0, type:Int = 0) {
@@ -34,4 +38,10 @@ class CharterNote extends UISprite {
return ((Math.sin(t * Math.PI) * 0.35) * 3 * t * Math.sqrt(1 - t)) + t;
}});
}
public override function update(elapsed:Float) {
super.update(elapsed);
colorTransform.redMultiplier = colorTransform.greenMultiplier = colorTransform.blueMultiplier = selected ? 0.75 : 1;
colorTransform.redOffset = colorTransform.greenOffset = colorTransform.blueOffset = selected ? 96 : 0;
}
}