Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Commit

Permalink
ALMOST done
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Nov 8, 2023
1 parent 26ddc34 commit 184105d
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 42 deletions.
10 changes: 5 additions & 5 deletions source/funkin/states/editors/ChartingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ class ChartingState extends MusicBeatState {

public var selectedEvent:Array<Dynamic> = null;
public var selectedEventObject(default, set):ChartEvent = null;
public var eventID:Int = 0;

function set_selectedEventObject(value) {
if (value != null && selectedEventObject != null && value != selectedEventObject) {
value.blend = ADD;
Expand All @@ -388,21 +390,19 @@ class ChartingState extends MusicBeatState {
return selectedEventObject = value;
}

public var eventID:Int = 0;

public function addEvent() {
var strumTime:Float = getYtime(noteTile.y + GRID_SIZE) + sectionTime - Conductor.stepCrochet;
eventID = 0;
tabs.setCurEvent(ChartTabs.curEvent); // Update values
var event:Array<Dynamic> = [strumTime, ChartTabs.curEvent, convertEventValues(ChartTabs.curEventValues)];
tabs.setCurEvent(ChartTabs.curEventDatas[eventID].name); // Update values
var event:Array<Dynamic> = [strumTime, ChartTabs.curEventDatas[eventID].name, convertEventValues(ChartTabs.curEventDatas[eventID].values)];
SONG.notes[sectionIndex].sectionEvents.push(event);
selectedEvent = event;
selectedEventObject = eventsGrid.drawObject(event);
}

public function updateEvent(id:Int = 0, newValue:Dynamic) {
if (selectedEvent == null || selectedEventObject == null) return;
var values = selectedEvent[2].copy();
final values = selectedEvent[2].copy();
values[id] = newValue;
selectedEvent[2] = values;
selectedEventObject.data[eventID].values = selectedEvent[2].copy();
Expand Down
16 changes: 13 additions & 3 deletions source/funkin/states/editors/chart/ChartGridBase.hx
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ class ChartEventGrid extends ChartGridBase {

class ChartEvent extends FlxTypedSpriteGroup<Dynamic> {
public var data:Array<Event> = [];
public var names:Array<String> = [];

public var sprite:FlxSpriteExt;
public var text:FunkinText;

Expand Down Expand Up @@ -380,11 +382,19 @@ class ChartEvent extends FlxTypedSpriteGroup<Dynamic> {
public function init(strumTime:Float, names:Array<Dynamic>, values:Array<Array<Dynamic>>, position:FlxPoint) {
setPosition(position.x,position.y);
this.strumTime = strumTime;

FlxArrayUtil.clearArray(data);
for (i in 0...names.length) {
if (data[i] == null) data.push(new Event(strumTime, names[i], values[i]));
else data[i].set(strumTime, names[i], values[i]);
FlxArrayUtil.clearArray(this.names);

for (i in 0...values.length) {
if (data[i] == null) data.push(new Event(strumTime, names[i] ?? "NULL", values[i]));
else data[i].set(strumTime, names[i] ?? "NULL", values[i]);
}

for (i in data) {
names.push(i.name);
}

updateText();
loadSettings();
}
Expand Down
75 changes: 41 additions & 34 deletions source/funkin/states/editors/chart/ChartTabs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -310,34 +310,34 @@ class ChartTabs extends FlxUITabMenu {
var eventDescription:FlxText;
public var eventValueTab:EventTab = null;

public static var curEvent:String = '';
public static var curEventValues:Array<Dynamic>;
public static var curEventDatas:Array<{name:String, values:Array<Dynamic>}> = [];
public static var curEventNames:Array<String> = [];

public function setCurEvent(event:String) {
curEvent = event;
curEventValues = eventValueTab == null ? EventUtil.getEventData(event).values.copy() : eventValueTab.getValues().copy();
curEventNames[eventID()] = event;
curEventDatas[eventID()] = {
name: event,
values: eventValueTab == null ? EventUtil.getEventData(event).values.copy() : eventValueTab.getValues().copy()
}
updateEventTxt();
}

var curEvents:Array<String> = [
"test1",
"test2",
"test3",
"test4"
];

var eventListTxt:FlxText;
var eventLeft:FlxUIButton;
var eventAdd:FlxUIButton;
var eventRemove:FlxUIButton;
var eventRight:FlxUIButton;

inline function getEventID() {
return ChartingState.instance.eventID;
}
inline function eventID() return ChartingState.instance.eventID;
inline function eventObj() return ChartingState.instance.selectedEventObject;

var initEvent:String = "NULL_EVENT";

public function updateEventTxt() {
eventListTxt.text = "[ " + (getEventID() + 1) + " / " + curEvents.length + " ] " + (curEvents[getEventID()] ?? "NULL_EVENT");
eventListTxt.text = "[ " +
(eventID() + 1) + " / " +
(curEventNames.length) + " ] " +
(curEventNames[eventID()] ?? "NULL_EVENT");
}

function addEventUI():Void {
Expand All @@ -349,39 +349,46 @@ class ChartTabs extends FlxUITabMenu {
eventListTxt.alignment = RIGHT;

eventLeft = new FlxUIButton(10,10, "<", function () {
ChartingState.instance.eventID = FlxMath.wrap(ChartingState.instance.eventID - 1, 0, curEvents.length - 1);
ChartingState.instance.eventID = FlxMath.wrap(ChartingState.instance.eventID - 1, 0, curEventDatas.length - 1);
updateEventTxt();
});

eventAdd = new FlxUIButton(eventLeft.x + 25,eventLeft.y, "+", function () {
if (curEvents.length < 16) {
curEvents.push("testNew");
ChartingState.instance.eventID = curEvents.length - 1;
if (curEventDatas.length < 16) {
final e:String = eventsDropDown.selectedLabel;
curEventNames.push(e);
curEventDatas.push({
name: e,
values: eventValueTab == null ? EventUtil.getEventData(e).values.copy() : eventValueTab.getValues().copy()
});
ChartingState.instance.eventID = curEventDatas.length - 1;
updateEventTxt();
}
});
eventAdd.color = FlxColor.LIME;
eventAdd.label.color = FlxColor.WHITE;

eventRemove = new FlxUIButton(eventLeft.x + (25*2),eventLeft.y, "-", function () {
if (curEvents.length > 1) {
curEvents.remove(curEvents[getEventID()]);
ChartingState.instance.eventID = curEvents.length - 1;
if (curEventDatas.length > 1) {
curEventDatas.remove(curEventDatas[eventID()]);
curEventNames.remove(curEventNames[eventID()]);

ChartingState.instance.eventID = curEventDatas.length - 1;
updateEventTxt();
}
});
eventRemove.color = FlxColor.RED;
eventRemove.label.color = FlxColor.WHITE;

eventRight = new FlxUIButton(eventLeft.x + (25*3),eventLeft.y, ">", function () {
ChartingState.instance.eventID = FlxMath.wrap(getEventID() + 1, 0, curEvents.length - 1);
ChartingState.instance.eventID = FlxMath.wrap(eventID() + 1, 0, curEventDatas.length - 1);
updateEventTxt();
});

var types:Array<String> = EventUtil.eventsArray.copy();
eventsDropDown = new FlxUIDropDownMenu(10, 50, FlxUIDropDownMenu.makeStrIdLabelArray(types, true), function(type:String) {
var newEvent = types[Std.parseInt(type)];
if (curEvent != newEvent) {
if (curEventDatas[eventID()].name != newEvent) {
var eventData = EventUtil.getEventData(newEvent);
var _defValues = eventData.values.copy();
eventDescription.text = eventData.description;
Expand All @@ -396,26 +403,26 @@ class ChartTabs extends FlxUITabMenu {
i.resize(20,20);
}
tab_group_event.add(eventListTxt);
updateEventTxt();

eventDescription = new FlxText(eventsDropDown.x,eventsDropDown.y+25,125,"Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
eventDescription = new FlxText(eventsDropDown.x,eventsDropDown.y + 25, 125, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
tab_group_event.add(eventDescription);

tab_group_event.add(new FlxText(eventsDropDown.x, eventsDropDown.y - 15, 0, 'Event:'));
tab_group_event.add(eventsDropDown);

var initEvent = types[0];
if (initEvent != null) {
setCurEvent(initEvent);
eventsDropDown.selectedLabel = initEvent;
eventDescription.text = EventUtil.getEventData(initEvent).description;
}

postCreateFuncs.push(function () {
eventValueTab = new EventTab(150, 50, curEventValues);
initEvent = types[0];
if (initEvent != null) {
setCurEvent(initEvent);
eventsDropDown.selectedLabel = initEvent;
eventDescription.text = EventUtil.getEventData(initEvent).description;
}

eventValueTab = new EventTab(150, 50, curEventDatas[eventID()].values);
eventValueTab.updateFunc = function (id:Int, value:Dynamic)
ChartingState.instance.updateEvent(id, value);
tab_group_event.add(eventValueTab);
updateEventTxt();
});

addGroup(tab_group_event);
Expand Down

0 comments on commit 184105d

Please sign in to comment.