Merge branch 'new-editors' into zoro-charterstuffs

This commit is contained in:
TheZoroForce240
2024-08-28 11:01:33 +01:00
28 changed files with 222 additions and 84 deletions
+12
View File
@@ -105,6 +105,14 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
public override function update(elapsed:Float)
{
super.update(elapsed);
// hate how it looks like but hey at least its optimized and fast - Nex
if (!debugMode && isAnimFinished()) {
var name = getAnimName() + '-loop';
if (animation.exists(name))
playAnim(name, false, lastAnimContext);
}
if (animateAtlas != null)
animateAtlas.update(elapsed);
}
@@ -324,6 +332,10 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
return (animateAtlas != null) ? atlasPlayingAnim : animation.name;
}
public inline function isAnimReversed():Bool {
return animateAtlas != null ? animateAtlas.anim.reversed : animation.curAnim != null ? animation.curAnim.reversed : false;
}
public inline function removeAnimation(name:String) {
if (animateAtlas != null)
@:privateAccess animateAtlas.anim.animsMap.remove(name);
+85
View File
@@ -925,6 +925,91 @@ final class CoolUtil
return b ? 1 : 0;
#end
}
/**
* Converts a string of "1..3,5,7..9,8..5" into an array of numbers like [1,2,3,5,7,8,9,8,7,6,5]
* @param input String to parse
* @return Array of numbers
*/
public static function parseNumberRange(input:String):Array<Int> {
var result:Array<Int> = [];
var parts:Array<String> = input.split(",");
for (part in parts) {
part = part.trim();
var idx = part.indexOf("..");
if (idx != -1) {
var start = Std.parseInt(part.substring(0, idx).trim());
var end = Std.parseInt(part.substring(idx + 2).trim());
if(start == null || end == null) {
continue;
}
if (start < end) {
for (j in start...end + 1) {
result.push(j);
}
} else {
for (j in end...start + 1) {
result.push(start + end - j);
}
}
} else {
var num = Std.parseInt(part);
if (num != null) {
result.push(num);
}
}
}
return result;
}
/**
* Converts an array of numbers into a string of ranges.
* Example: [1,2,3,5,7,8,9,8,7,6,5] -> "1..3,5,7..9,8..5"
* @param numbers Array of numbers
* @return String representing the ranges
*/
public static function formatNumberRange(numbers:Array<Int>, seperator:String = ","):String {
if (numbers.length == 0) return "";
var result:Array<String> = [];
var i = 0;
while (i < numbers.length) {
var start = numbers[i];
var end = start;
var direction = 0; // 0: no sequence, 1: increasing, -1: decreasing
if (i + 1 < numbers.length) { // detect direction of sequence
if (numbers[i + 1] == end + 1) {
direction = 1;
} else if (numbers[i + 1] == end - 1) {
direction = -1;
}
}
if(direction != 0) {
while (i + 1 < numbers.length && (numbers[i + 1] == end + direction)) {
end = numbers[i + 1];
i++;
}
}
if (start == end) { // no direction
result.push('${start}');
} else if (start + direction == end) { // 1 step increment
result.push('${start},${end}');
} else { // store as range
result.push('${start}..${end}');
}
i++;
}
return result.join(seperator);
}
}
/**
+1 -8
View File
@@ -214,14 +214,7 @@ final class XMLUtil {
if (anim.has.y) animData.y = Std.parseFloat(anim.att.y).getDefault(animData.y);
if (anim.has.loop) animData.loop = anim.att.loop == "true";
if (anim.has.forced) animData.forced = anim.att.forced == "true";
if (anim.has.indices) {
var indicesSplit = anim.att.indices.split(",");
for(indice in indicesSplit) {
var i = Std.parseInt(indice.trim());
if (i != null)
animData.indices.push(i);
}
}
if (anim.has.indices) animData.indices = CoolUtil.parseNumberRange(anim.att.indices);
return animData;
}
@@ -117,15 +117,9 @@ class CharacterAnimButton extends UIButton {
loopedCheckbox.x += 8; loopedCheckbox.y += 6;
indicesTextBox = new UITextBox(nameTextBox.x, nameTextBox.y, animData.indices.getDefault([]).join(","), 278, 22, false, true);
indicesTextBox.onChange = (text:String) -> {
var indices:Array<Int> = [];
for(indice in text.split(",")) {
var i = Std.parseInt(indice.trim());
if (i != null) indices.push(i);
}
this.changeIndicies(indices);
indicesTextBox = new UITextBox(nameTextBox.x, nameTextBox.y, CoolUtil.formatNumberRange(animData.indices.getDefault([]), ", "), 278, 22, false, true);
indicesTextBox.onChange = (text:String) -> {
this.changeIndicies(CoolUtil.parseNumberRange(text));
}
members.push(indicesTextBox);
foldableButtons.push(indicesTextBox);
+3 -3
View File
@@ -1,7 +1,7 @@
package funkin.editors.charter;
// ! FUCK YOU CHUF (your biggest fan -lunar) <3
import flixel.FlxLayer;
//import flixel.FlxLayer;
import funkin.editors.extra.CameraHoverDummy;
import flixel.input.keyboard.FlxKey;
import flixel.math.FlxPoint;
@@ -89,7 +89,7 @@ class Charter extends UIState {
public static var clipboard:Array<CharterCopyboardObject> = [];
public static var waveformHandler:CharterWaveformHandler;
public var textLayer:FlxLayer;
//public var textLayer:FlxLayer;
public function new(song:String, diff:String, reload:Bool = true) {
super();
@@ -487,7 +487,7 @@ class Charter extends UIState {
// adds grid and notes so that they're ALWAYS behind the UI
add(gridBackdrops);
add(textLayer = new FlxLayer());
//add(textLayer = new FlxLayer());
add(eventsBackdrop);
add(addEventSpr);
add(eventsGroup);
+1 -1
View File
@@ -68,7 +68,7 @@ class CharterNote extends UISprite implements ICharterSelectable {
if(noteTypeTexts[v] == null || noteTypeTexts[v].graphic.isDestroyed) {
noteTypeTexts[v] = new UIText(x, y, 0, Std.string(v));
noteTypeTexts[v].exists = v != 0;
noteTypeTexts[v].layer = (Charter.instance != null) ? Charter.instance.textLayer : null;
//noteTypeTexts[v].layer = (Charter.instance != null) ? Charter.instance.textLayer : null;
}
typeText = noteTypeTexts[v];
+1 -1
View File
@@ -470,7 +470,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
offset.putWeak();
if (anim.indices.length > 0)
animXml.set("indices", anim.indices.join(","));
animXml.set("indices", CoolUtil.formatNumberRange(anim.indices));
xml.addChild(animXml);
}
+1 -1
View File
@@ -1266,7 +1266,7 @@ class PlayState extends MusicBeatState
if (Conductor.songPosition >= 0)
startSong();
}
} else {
} else if (FlxG.sound.music != null) {
var instTime = FlxG.sound.music.time;
var isOffsync = vocals.time != instTime || [for(strumLine in strumLines.members) strumLine.vocals.time != instTime].contains(true);
__vocalOffsetViolation = Math.max(0, __vocalOffsetViolation + (isOffsync ? elapsed : -elapsed / 2));
+1 -1
View File
@@ -162,7 +162,7 @@ class MainMenuState extends MusicBeatState
{
case 'story mode': FlxG.switchState(new StoryMenuState());
case 'freeplay': FlxG.switchState(new FreeplayState());
case 'donate': FlxG.switchState(new CreditsMain());
case 'donate', 'credits': FlxG.switchState(new CreditsMain()); // kept donate for not breaking scripts, if you dont want donate to bring you to the credits menu, thats easy softcodable - Nex
case 'options': FlxG.switchState(new OptionsMenu());
}
});
+17 -11
View File
@@ -4,9 +4,11 @@ import funkin.options.OptionsScreen;
import funkin.options.TreeMenu;
import funkin.options.type.*;
import haxe.xml.Access;
import flixel.util.FlxColor;
class CreditsMain extends TreeMenu {
var bg:FlxSprite;
var items:Array<OptionType> = [];
public override function create() {
bg = new FlxSprite(-80).loadGraphic(Paths.image('menus/menuBGBlue'));
@@ -18,7 +20,6 @@ class CreditsMain extends TreeMenu {
bg.antialiasing = true;
add(bg);
var selectables:Array<OptionType> = [];
var xmlPath = Paths.xml('config/credits');
for(source in [funkin.backend.assets.AssetsLibraryList.AssetSource.SOURCE, funkin.backend.assets.AssetsLibraryList.AssetSource.MODS]) {
if (Paths.assetsTree.existsSpecific(xmlPath, "TEXT", source)) {
@@ -31,17 +32,17 @@ class CreditsMain extends TreeMenu {
if (access != null)
for(c in parseCreditsFromXML(access, source))
selectables.push(c);
items.push(c);
}
}
selectables.push(new TextOption("Codename Engine >", "Select this to see all the contributors of the engine!", function() {
items.push(new TextOption("Codename Engine >", "Select this to see all the contributors of the engine!", function() {
optionsTree.add(Type.createInstance(CreditsCodename, []));
}));
selectables.push(new TextOption("Friday Night Funkin'", "Select this to open the itch.io page of the original game to donate!", function() {
items.push(new TextOption("Friday Night Funkin'", "Select this to open the itch.io page of the original game to donate!", function() {
CoolUtil.openURL("https://ninja-muffin24.itch.io/funkin");
}));
main = new OptionsScreen('Credits', 'The people who made this possible!', selectables);
main = new OptionsScreen('Credits', 'The people who made this possible!', items);
super.create();
DiscordUtil.call("onMenuLoaded", ["Credits Menu"]);
@@ -68,11 +69,13 @@ class CreditsMain extends TreeMenu {
html_url: 'https://github.com/$username',
avatar_url: 'https://github.com/$username.png'
};
credsMenus.push(new GithubIconOption(user, desc, null,
var opt:GithubIconOption = new GithubIconOption(user, desc, null,
node.has.customName ? node.att.customName : null, node.has.size ? Std.parseInt(node.att.size) : 96,
node.has.portrait ? node.att.portrait.toLowerCase() == "false" ? false : true : true
));
);
if (node.has.color)
@:privateAccess opt.__text.color = FlxColor.fromString(node.att.color);
credsMenus.push(opt);
} else {
if (!node.has.name) {
Logs.trace("[CreditsMain] A credit node requires a name attribute.", WARNING);
@@ -82,11 +85,14 @@ class CreditsMain extends TreeMenu {
switch(node.name) {
case "credit":
credsMenus.push(new PortraitOption(name, desc, function() if(node.has.url) CoolUtil.openURL(node.att.url),
var opt:PortraitOption = new PortraitOption(name, desc, function() if(node.has.url) CoolUtil.openURL(node.att.url),
node.has.icon && Paths.assetsTree.existsSpecific(Paths.image('credits/${node.att.icon}'), "IMAGE", source) ?
FlxG.bitmap.add(Paths.image('credits/${node.att.icon}')) : null, node.has.size ? Std.parseInt(node.att.size) : 96,
node.has.portrait ? node.att.portrait.toLowerCase() == "false" ? false : true : true
));
);
if (node.has.color)
@:privateAccess opt.__text.color = FlxColor.fromString(node.att.color);
credsMenus.push(opt);
case "menu":
credsMenus.push(new TextOption(name + " >", desc, function() {
@@ -98,4 +104,4 @@ class CreditsMain extends TreeMenu {
return credsMenus;
}
}
}