fixed tutorial and additional stuff

This commit is contained in:
Yoshman29
2023-02-22 01:13:40 +01:00
parent 766a49474d
commit 2158da173a
31 changed files with 206 additions and 130 deletions
+64 -85
View File
@@ -1,10 +1,17 @@
package funkin.chart;
import funkin.chart.ChartData;
import flixel.util.FlxColor;
import haxe.io.Path;
import funkin.system.Song.SwagSong;
import haxe.Json;
import openfl.utils.Assets;
#if sys
import sys.io.File;
import sys.FileSystem;
#end
using StringTools;
class Chart {
public static function loadChartMeta(songName:String, difficulty:String = "normal") {
@@ -90,7 +97,7 @@ class Chart {
}
if (Reflect.hasField(data, "codenameChart") && Reflect.field(data, "codenameChart") == true) {
return cast data;
base = data;
} else {
// base fnf chart parsing
var data:SwagSong = data;
@@ -168,7 +175,7 @@ class Chart {
time: daStrumTime,
id: daNoteData % 4,
type: daNoteType,
sustainLength: note[2]
sLen: note[2]
});
}
@@ -198,89 +205,61 @@ class Chart {
return chart.noteTypes.length;
}
}
}
typedef ChartData = {
public var strumLines:Array<ChartStrumLine>;
public var events:Array<ChartEvent>;
public var meta:ChartMetaData;
public var codenameChart:Bool;
public var stage:String;
public var scrollSpeed:Float;
public var fromMods:Bool;
public var noteTypes:Array<String>;
}
typedef ChartMetaData = {
public var name:String;
public var bpm:Float;
public var ?displayName:String;
public var ?beatsPerMesure:Float;
public var ?stepsPerBeat:Float;
public var ?needsVoices:Bool;
public var ?icon:String;
public var ?color:Dynamic;
public var ?difficulties:Array<String>;
public var ?coopAllowed:Bool;
public var ?opponentModeAllowed:Bool;
// NOT TO BE EXPORTED
public var ?parsedColor:FlxColor;
}
typedef ChartStrumLine = {
var characters:Array<String>;
var opponent:Bool;
var notes:Array<ChartNote>;
var position:String;
var ?strumLinePos:Float; // 0.25 = default opponent pos, 0.75 = default boyfriend pos
var ?visible:Null<Bool>;
}
typedef ChartNote = {
var time:Float; // time at which the note will be hit (ms)
var id:Int; // strum id of the note
var type:Int; // type (int) of the note
var sustainLength:Float; // sustain length of the note (ms)
}
typedef ChartEvent = {
var time:Float;
var type:ChartEventType;
var params:Array<Dynamic>;
}
@:enum
abstract ChartEventType(Int) from Int to Int {
/**
* CUSTOM EVENT
* Params:
* - Function Name (String)
* - Function Parameters...
*/
var CUSTOM = -1;
/**
* NO EVENT, MADE FOR UNKNOWN EVENTS / EVENTS THAT CANNOT BE PARSED
*/
var NONE = 0;
/**
* CAMERA MOVEMENT EVENT
* Params:
* - Target Strumline ID (Int)
*/
var CAM_MOVEMENT = 1;
/**
* BPM CHANGE EVENT
* Params:
* - Target BPM (Float)
* Saves the chart to the specific song folder path.
* @param songFolderPath Path to the song folder (ex: `mods/your mod/songs/song/`)
* @param chart Chart to save
* @param difficulty Name of the difficulty
* @param saveSettings
* @return Filtered chart used for saving.
*/
var BPM_CHANGE = 2;
/**
* ALT ANIM TOGGLE
* Params:
* - Strum Line which is going to be toggled (Int)
* - Whenever its going to be toggled or not (Bool)
*/
var ALT_ANIM_TOGGLE = 3;
public static function save(songFolderPath:String, chart:ChartData, difficulty:String = "normal", ?saveSettings:ChartSaveSettings):ChartData {
if (saveSettings == null) saveSettings = {};
var filteredChart = filterChartForSaving(chart, saveSettings.saveMetaInChart);
var meta = filteredChart.meta;
// idk how null reacts to it so better be sure
#if sys
if (!FileSystem.exists('${songFolderPath}\\charts\\'))
FileSystem.createDirectory('${songFolderPath}\\charts\\');
var chartPath = '${songFolderPath}\\charts\\${difficulty.trim()}.json';
var metaPath = '${songFolderPath}\\meta.json';
File.saveContent(chartPath, Json.stringify(filteredChart, null, saveSettings.prettyPrint == true ? "\t" : null));
if (saveSettings.overrideExistingMeta == true || !FileSystem.exists(metaPath))
File.saveContent(metaPath, Json.stringify(meta, null, saveSettings.prettyPrint == true ? "\t" : null));
#end
return filteredChart;
}
public static function filterChartForSaving(chart:ChartData, ?saveMetaInChart:Null<Bool>):ChartData {
var data = Reflect.copy(chart); // make a copy of the chart to leave the OG intact
if (saveMetaInChart != true) {
data.meta = null;
} else {
data.meta = Reflect.copy(chart.meta); // also make a copy of the metadata to leave the OG intact.
if (data.meta != null) data.meta.parsedColor = null;
}
data.fromMods = null;
var sortedData:Dynamic = {};
for(f in Reflect.fields(data)) {
var v = Reflect.field(data, f);
if (v != null)
Reflect.setField(sortedData, f, v);
}
return sortedData;
}
}
typedef ChartSaveSettings = {
var ?overrideExistingMeta:Bool;
var ?saveMetaInChart:Bool;
var ?prettyPrint:Bool;
}
+89
View File
@@ -0,0 +1,89 @@
package funkin.chart;
import flixel.util.FlxColor;
typedef ChartData = {
public var strumLines:Array<ChartStrumLine>;
public var events:Array<ChartEvent>;
public var meta:ChartMetaData;
public var codenameChart:Bool;
public var stage:String;
public var scrollSpeed:Float;
public var noteTypes:Array<String>;
public var ?fromMods:Bool;
}
typedef ChartMetaData = {
public var name:String;
public var bpm:Float;
public var ?displayName:String;
public var ?beatsPerMesure:Float;
public var ?stepsPerBeat:Float;
public var ?needsVoices:Bool;
public var ?icon:String;
public var ?color:Dynamic;
public var ?difficulties:Array<String>;
public var ?coopAllowed:Bool;
public var ?opponentModeAllowed:Bool;
// NOT TO BE EXPORTED
public var ?parsedColor:FlxColor;
}
typedef ChartStrumLine = {
var characters:Array<String>;
var opponent:Bool;
var notes:Array<ChartNote>;
var position:String;
var ?strumLinePos:Float; // 0.25 = default opponent pos, 0.75 = default boyfriend pos
var ?visible:Null<Bool>;
}
typedef ChartNote = {
var time:Float; // time at which the note will be hit (ms)
var id:Int; // strum id of the note
var type:Int; // type (int) of the note
var sLen:Float; // sustain length of the note (ms)
}
typedef ChartEvent = {
var time:Float;
var type:ChartEventType;
var params:Array<Dynamic>;
}
@:enum
abstract ChartEventType(Int) from Int to Int {
/**
* CUSTOM EVENT
* Params:
* - Function Name (String)
* - Function Parameters...
*/
var CUSTOM = -1;
/**
* NO EVENT, MADE FOR UNKNOWN EVENTS / EVENTS THAT CANNOT BE PARSED
*/
var NONE = 0;
/**
* CAMERA MOVEMENT EVENT
* Params:
* - Target Strumline ID (Int)
*/
var CAM_MOVEMENT = 1;
/**
* BPM CHANGE EVENT
* Params:
* - Target BPM (Float)
*/
var BPM_CHANGE = 2;
/**
* ALT ANIM TOGGLE
* Params:
* - Strum Line which is going to be toggled (Int)
* - Whenever its going to be toggled or not (Bool)
*/
var ALT_ANIM_TOGGLE = 3;
}
@@ -3,7 +3,6 @@ package funkin.cutscenes;
import flixel.system.FlxSound;
import flixel.FlxG;
import flixel.FlxCamera;
import openfl.utils.Assets;
import funkin.cutscenes.dialogue.*;
import haxe.xml.Access;
-1
View File
@@ -3,7 +3,6 @@ package funkin.cutscenes;
import flixel.FlxSprite;
import flixel.FlxG;
import flixel.FlxCamera;
import openfl.utils.Assets;
/**
* Substate made for video cutscenes. To use it in a scripted cutscene, call `startVideo`.
@@ -2,7 +2,6 @@ package funkin.cutscenes.dialogue;
import flixel.addons.text.FlxTypeText;
import flixel.text.FlxText;
import openfl.utils.Assets;
import flixel.FlxG;
import flixel.math.FlxPoint;
import haxe.xml.Access;
@@ -2,7 +2,6 @@ package funkin.cutscenes.dialogue;
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
import openfl.utils.Assets;
import haxe.xml.Access;
class DialogueCharacter extends FunkinSprite {
+9 -2
View File
@@ -14,7 +14,6 @@ import flixel.animation.FlxBaseAnimation;
import flixel.graphics.frames.FlxAtlasFrames;
import flixel.math.FlxRect;
import openfl.utils.Assets;
import haxe.xml.Access;
import haxe.Exception;
import haxe.io.Path;
@@ -258,9 +257,17 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
*/
public var danceOnBeat:Bool = true;
/**
* Interval at which the character will dance (higher number = slower dance)
*/
public var danceInterval:Int = 1;
public override function beatHit(curBeat:Int) {
script.call("beatHit", [curBeat]);
if (danceOnBeat && !__lockAnimThisFrame) {
if (danceInterval < 1)
danceInterval = 1;
if (danceOnBeat && curBeat % danceInterval == 0 && !__lockAnimThisFrame) {
tryDance();
}
}
-1
View File
@@ -1,7 +1,6 @@
package funkin.game;
import flixel.FlxSprite;
import openfl.utils.Assets;
class HealthIcon extends FlxSprite
{
+2 -2
View File
@@ -1,7 +1,7 @@
package funkin.game;
import funkin.chart.Chart.ChartNote;
import openfl.utils.Assets;
import funkin.chart.Chart;
import funkin.chart.ChartData;
import flixel.FlxG;
import flixel.FlxCamera;
import flixel.FlxSprite;
+10 -5
View File
@@ -1,6 +1,7 @@
package funkin.game;
import funkin.chart.Chart;
import funkin.chart.ChartData;
import funkin.game.SplashHandler;
import funkin.scripting.DummyScript;
import funkin.menus.StoryMenuState.WeekData;
@@ -234,7 +235,7 @@ class PlayState extends MusicBeatState
/**
* Interval at which Girlfriend dances.
*/
public var gfSpeed:Int = 1;
public var gfSpeed(get, set):Int;
/**
* Current health. Goes from 0 to maxHealth (defaults to 2)
@@ -937,7 +938,7 @@ class PlayState extends MusicBeatState
* Returns the Discord RPC icon.
*/
public inline function getIconRPC():String
return (dad != null ? (dad.icon != null ? dad.icon : dad.curCharacter) : null);
return SONG.meta.icon;
var __songPlaying:Bool = false;
var __wasAutoPause:Bool = false;
@@ -1579,9 +1580,6 @@ class PlayState extends MusicBeatState
iconP1.updateHitbox();
iconP2.updateHitbox();
if (gf != null && curBeat % gfSpeed == 0)
gf.tryDance();
scripts.call("beatHit", [curBeat]);
}
@@ -1629,6 +1627,13 @@ class PlayState extends MusicBeatState
return players[0];
private inline function get_playerStrums():StrumLine
return players[1];
private inline function get_gfSpeed():Int
return (players[2] != null && players[2].characters[0] != null) ? players[2].characters[0].danceInterval : 1;
private inline function set_gfSpeed(v:Int):Int {
if (players[2] != null && players[2].characters[0] != null)
players[2].characters[0].danceInterval = v;
return v;
}
}
class ComboRating {
-1
View File
@@ -1,7 +1,6 @@
package funkin.game;
import flixel.FlxG;
import openfl.utils.Assets;
import haxe.xml.Access;
import flixel.group.FlxGroup.FlxTypedGroup;
-1
View File
@@ -4,7 +4,6 @@ import funkin.options.Options;
import flixel.FlxG;
import flixel.FlxState;
import flixel.FlxSprite;
import openfl.utils.Assets;
import haxe.xml.Access;
import flixel.FlxBasic;
import flixel.math.FlxMath;
+5 -4
View File
@@ -2,7 +2,8 @@ package funkin.game;
import funkin.scripting.events.SimpleNoteEvent;
import funkin.system.Conductor;
import funkin.chart.Chart.ChartStrumLine;
import funkin.chart.Chart;
import funkin.chart.ChartData;
import funkin.system.Controls;
import funkin.scripting.events.StrumCreationEvent;
import flixel.group.FlxGroup.FlxTypedGroup;
@@ -65,12 +66,12 @@ class StrumLine extends FlxTypedGroup<Strum> {
if (strumLine.notes != null) for(note in strumLine.notes) {
notes.add(new Note(this, note, false));
if (note.sustainLength > Conductor.stepCrochet * 0.75) {
var len:Float = note.sustainLength;
if (note.sLen > Conductor.stepCrochet * 0.75) {
var len:Float = note.sLen;
var curLen:Float = 0;
while(len > 10) {
curLen = Math.min(len, Conductor.stepCrochet);
notes.add(new Note(this, note, true, curLen, note.sustainLength - len));
notes.add(new Note(this, note, true, curLen, note.sLen - len));
len -= curLen;
}
}
+2 -1
View File
@@ -7,9 +7,10 @@ import funkin.system.FunkinSprite;
import funkin.utils.*;
import funkin.system.Logs;
import funkin.game.PlayState;
import funkin.scripting.EventManager;
import openfl.utils.Assets;
using StringTools;
using funkin.utils.CoolUtil;
#end
+10 -1
View File
@@ -1,7 +1,7 @@
package funkin.menus;
import funkin.chart.Chart;
import funkin.chart.Chart.ChartMetaData;
import funkin.chart.ChartData;
import haxe.io.Path;
import flash.text.TextField;
import flixel.FlxG;
@@ -244,6 +244,9 @@ class FreeplayState extends MusicBeatState
FlxG.switchState(new MainMenuState());
}
if (FlxG.keys.justPressed.EIGHT && Sys.args().contains("-livereload"))
convertChart();
if (controls.ACCEPT && !dontPlaySongThisFrame)
select();
}
@@ -271,6 +274,12 @@ class FreeplayState extends MusicBeatState
FlxG.switchState(new PlayState());
}
public function convertChart() {
trace('Converting ${songs[curSelected].name} (${songs[curSelected].difficulties[curDifficulty]}) to Codename format...');
var chart = Chart.parse(songs[curSelected].name, songs[curSelected].difficulties[curDifficulty]);
Chart.save('${Main.pathBack}assets/songs/${songs[curSelected].name}', chart, songs[curSelected].difficulties[curDifficulty].toLowerCase());
}
/**
* Changes the current difficulty
* @param change How much to change.
-1
View File
@@ -7,7 +7,6 @@ import flixel.graphics.frames.FlxFramesCollection;
import flixel.group.FlxGroup.FlxTypedGroup;
import funkin.game.Highscore;
import flixel.tweens.FlxTween;
import openfl.utils.Assets;
import flixel.FlxG;
import flixel.math.FlxMath;
import flixel.util.FlxColor;
-1
View File
@@ -5,7 +5,6 @@ import funkin.menus.TitleState;
import funkin.system.Main;
import openfl.utils.AssetCache;
import flixel.util.FlxSignal.FlxTypedSignal;
import openfl.utils.Assets;
import openfl.utils.AssetManifest;
import openfl.utils.AssetLibrary;
import flixel.graphics.FlxGraphic;
-1
View File
@@ -4,7 +4,6 @@ import lime.app.Application;
import flixel.util.FlxDestroyUtil.IFlxDestroyable;
import flixel.FlxBasic;
import haxe.io.Path;
import openfl.utils.Assets;
/**
* Class used for scripting.
@@ -1,7 +1,6 @@
package funkin.system;
import funkin.mods.ModsAssetLibrary;
import openfl.utils.Assets;
import lime.utils.AssetLibrary;
class AssetsLibraryList extends AssetLibrary {
+1
View File
@@ -1,6 +1,7 @@
package funkin.system;
import funkin.chart.Chart;
import funkin.chart.ChartData;
import flixel.math.FlxMath;
import openfl.Lib;
import flixel.FlxState;
-1
View File
@@ -1,7 +1,6 @@
package funkin.system;
import flixel.FlxG;
import openfl.utils.Assets;
import haxe.io.Path;
import funkin.scripting.events.PlayAnimEvent.PlayAnimContext;
import funkin.interfaces.IOffsetCompatible;
+9 -9
View File
@@ -116,6 +116,14 @@ class Main extends Sprite
public static var audioDisconnected:Bool = false;
public static var changeID:Int = 0;
public static var pathBack = #if windows
"../../../../"
#elseif mac
"../../../../../../../"
#else
""
#end;
public static var startedFromSource:Bool = false;
private static var __threadCycle:Int = 0;
@@ -156,15 +164,7 @@ class Main extends Sprite
#end
#if sys
if (Sys.args().contains("-livereload")) {
var pathBack = #if windows
"../../../../"
#elseif mac
"../../../../../../../"
#else
""
#end;
if (startedFromSource = Sys.args().contains("-livereload")) {
#if USE_SOURCE_ASSETS
#if windows
trace("Used lime test windows. Switching into source assets.");
-1
View File
@@ -1,6 +1,5 @@
package funkin.ui;
import openfl.utils.Assets;
import openfl.utils.AssetLibrary;
import haxe.xml.Access;
import funkin.mods.LimeLibrarySymbol;
-1
View File
@@ -2,7 +2,6 @@ package funkin.utils;
import funkin.scripting.events.DiscordPresenceUpdateEvent;
import haxe.Json;
import openfl.utils.Assets;
import flixel.system.FlxSound;
#if DISCORD_RPC
import discord_rpc.DiscordRpc;
-1
View File
@@ -1,6 +1,5 @@
package funkin.utils;
import openfl.utils.Assets;
/**
* DOESNT SUPPORT CATEGORIES YET!!
-1
View File
@@ -1,6 +1,5 @@
package funkin.utils;
import openfl.utils.Assets;
import lime.app.Application;
/**