Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Custom noteskin support #2509

Merged
merged 2 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added art/flashFiles/FNF_Circles_NOTE_Assets.fla
Binary file not shown.
Binary file added assets/shared/images/noteskins/Circles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions assets/shared/images/noteskins/Circles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<TextureAtlas imagePath="Circles.png">
<!-- Created with Adobe Animate version 16.0.0.112 -->
<!-- http://www.adobe.com/products/animate.html -->
<SubTexture name="arrowDOWN0000" x="2" y="2" width="152" height="152"/>
<SubTexture name="arrowLEFT0000" x="2" y="2" width="152" height="152"/>
<SubTexture name="arrowRIGHT0000" x="2" y="2" width="152" height="152"/>
<SubTexture name="arrowUP0000" x="2" y="2" width="152" height="152"/>
<SubTexture name="blue alone0000" x="156" y="2" width="152" height="152"/>
<SubTexture name="blue hold0000" x="310" y="2" width="50" height="44"/>
<SubTexture name="blue tail0000" x="362" y="2" width="50" height="64"/>
<SubTexture name="down confirm0000" x="414" y="2" width="174" height="173"/>
<SubTexture name="down confirm0001" x="414" y="2" width="174" height="173"/>
<SubTexture name="down confirm0002" x="590" y="2" width="160" height="160" frameX="-3" frameY="-9" frameWidth="174" frameHeight="173"/>
<SubTexture name="down confirm0003" x="590" y="2" width="160" height="160" frameX="-3" frameY="-9" frameWidth="174" frameHeight="173"/>
<SubTexture name="down press0000" x="752" y="2" width="134" height="134" frameX="-2" frameY="-2" frameWidth="139" frameHeight="139"/>
<SubTexture name="down press0001" x="752" y="2" width="134" height="134" frameX="-2" frameY="-2" frameWidth="139" frameHeight="139"/>
<SubTexture name="down press0002" x="888" y="2" width="139" height="139"/>
<SubTexture name="down press0003" x="888" y="2" width="139" height="139"/>
<SubTexture name="green alone0000" x="1029" y="2" width="152" height="152"/>
<SubTexture name="green hold0000" x="1183" y="2" width="50" height="44"/>
<SubTexture name="green tail0000" x="1235" y="2" width="50" height="64"/>
<SubTexture name="left confirm0000" x="1287" y="2" width="165" height="167"/>
<SubTexture name="left confirm0001" x="1287" y="2" width="165" height="167"/>
<SubTexture name="left confirm0002" x="1454" y="2" width="160" height="160" frameX="-3" frameY="-3" frameWidth="165" frameHeight="167"/>
<SubTexture name="left confirm0003" x="1454" y="2" width="160" height="160" frameX="-3" frameY="-3" frameWidth="165" frameHeight="167"/>
<SubTexture name="left press0000" x="1616" y="2" width="134" height="134" frameX="-3" frameY="-2" frameWidth="140" frameHeight="139"/>
<SubTexture name="left press0001" x="1616" y="2" width="134" height="134" frameX="-3" frameY="-2" frameWidth="140" frameHeight="139"/>
<SubTexture name="left press0002" x="1752" y="2" width="140" height="139"/>
<SubTexture name="left press0003" x="1752" y="2" width="140" height="139"/>
<SubTexture name="purple alone0000" x="1894" y="2" width="152" height="152"/>
<SubTexture name="purple hold0000" x="2" y="177" width="50" height="44"/>
<SubTexture name="purple tail0000" x="54" y="177" width="50" height="64"/>
<SubTexture name="red alone0000" x="106" y="177" width="152" height="152"/>
<SubTexture name="red hold0000" x="260" y="177" width="50" height="44"/>
<SubTexture name="red tail0000" x="312" y="177" width="50" height="64"/>
<SubTexture name="right confirm0000" x="364" y="177" width="170" height="171"/>
<SubTexture name="right confirm0001" x="364" y="177" width="170" height="171"/>
<SubTexture name="right confirm0002" x="536" y="177" width="159" height="160" frameX="-6" frameY="-4" frameWidth="170" frameHeight="171"/>
<SubTexture name="right confirm0003" x="536" y="177" width="159" height="160" frameX="-6" frameY="-4" frameWidth="170" frameHeight="171"/>
<SubTexture name="right press0000" x="697" y="177" width="134" height="134" frameX="-2" frameY="-2" frameWidth="139" frameHeight="139"/>
<SubTexture name="right press0001" x="697" y="177" width="134" height="134" frameX="-2" frameY="-2" frameWidth="139" frameHeight="139"/>
<SubTexture name="right press0002" x="833" y="177" width="139" height="139"/>
<SubTexture name="right press0003" x="833" y="177" width="139" height="139"/>
<SubTexture name="up confirm0000" x="974" y="177" width="168" height="168"/>
<SubTexture name="up confirm0001" x="974" y="177" width="168" height="168"/>
<SubTexture name="up confirm0002" x="1144" y="177" width="158" height="158" frameX="-5" frameY="-5" frameWidth="168" frameHeight="168"/>
<SubTexture name="up confirm0003" x="1144" y="177" width="158" height="158" frameX="-5" frameY="-5" frameWidth="168" frameHeight="168"/>
<SubTexture name="up press0000" x="1304" y="177" width="134" height="134" frameX="-2" frameY="-2" frameWidth="139" frameHeight="139"/>
<SubTexture name="up press0001" x="1304" y="177" width="134" height="134" frameX="-2" frameY="-2" frameWidth="139" frameHeight="139"/>
<SubTexture name="up press0002" x="1440" y="177" width="139" height="139"/>
<SubTexture name="up press0003" x="1440" y="177" width="139" height="139"/>
</TextureAtlas>
3 changes: 3 additions & 0 deletions source/Caching.hx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class Caching extends MusicBeatState

KadeEngineData.initSave();

// It doesn't reupdate the list before u restart rn lmao
NoteskinHelpers.updateNoteskins();

FlxG.sound.muteKeys = [FlxKey.fromString(FlxG.save.data.muteBind)];
FlxG.sound.volumeDownKeys = [FlxKey.fromString(FlxG.save.data.volDownBind)];
FlxG.sound.volumeUpKeys = [FlxKey.fromString(FlxG.save.data.volUpBind)];
Expand Down
2 changes: 1 addition & 1 deletion source/DiffOverview.hx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class DiffOverview extends FlxSubState
{
// FlxG.log.add(i);
var babyArrow:StaticArrow = new StaticArrow(-10, strumLine.y);
babyArrow.frames = Paths.getSparrowAtlas('noteskins/' + FlxG.save.data.noteskin);
babyArrow.frames = NoteskinHelpers.generateNoteskinSprite(FlxG.save.data.noteskin);
for (j in 0...4)
{
babyArrow.animation.addByPrefix(dataColor[j], 'arrow' + dataSuffix[j]);
Expand Down
2 changes: 1 addition & 1 deletion source/GameplayCustomizeState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class GameplayCustomizeState extends MusicBeatState
{
// FlxG.log.add(i);
var babyArrow:FlxSprite = new FlxSprite(0, strumLine.y);
babyArrow.frames = Paths.getSparrowAtlas('noteskins/' + FlxG.save.data.noteskin, 'shared');
babyArrow.frames = NoteskinHelpers.generateNoteskinSprite(FlxG.save.data.noteskin);
babyArrow.animation.addByPrefix('green', 'arrowUP');
babyArrow.animation.addByPrefix('blue', 'arrowDOWN');
babyArrow.animation.addByPrefix('purple', 'arrowLEFT');
Expand Down
6 changes: 5 additions & 1 deletion source/KadeEngineData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ class KadeEngineData
FlxG.save.data.laneTransparency = 0.5;

if (FlxG.save.data.noteskin == null)
FlxG.save.data.noteskin = "Arrows";
FlxG.save.data.noteskin = 0;

// Gonna make this an option on another PR
if (FlxG.save.data.overrideNoteskins == null)
FlxG.save.data.overrideNoteskins = false;

var gamepad:FlxGamepad = FlxG.gamepads.lastActive;

Expand Down
4 changes: 2 additions & 2 deletions source/Note.hx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Note extends FlxSprite

if (inCharter)
{
frames = Paths.getSparrowAtlas('noteskins/' + FlxG.save.data.noteskin);
frames = NoteskinHelpers.generateNoteskinSprite(FlxG.save.data.noteskin);

for (i in 0...4)
{
Expand Down Expand Up @@ -168,7 +168,7 @@ class Note extends FlxSprite
setGraphicSize(Std.int(width * PlayState.daPixelZoom));
updateHitbox();
default:
frames = Paths.getSparrowAtlas('noteskins/' + FlxG.save.data.noteskin);
frames = NoteskinHelpers.generateNoteskinSprite(FlxG.save.data.noteskin);

for (i in 0...4)
{
Expand Down
66 changes: 66 additions & 0 deletions source/NoteskinHelpers.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#if FEATURE_FILESYSTEM
import sys.FileSystem;
import sys.io.File;
#end
import openfl.display.BitmapData;
import flixel.FlxSprite;
import flixel.graphics.FlxGraphic;
import flixel.graphics.frames.FlxAtlasFrames;
import flixel.FlxG;

using StringTools;

class NoteskinHelpers
{
public static var noteskinArray = [];
public static var xmlData = [];

public static function updateNoteskins()
{
noteskinArray = [];
xmlData = [];
#if FEATURE_FILESYSTEM
var count:Int = 0;
for (i in FileSystem.readDirectory(FileSystem.absolutePath("assets/shared/images/noteskins")))
{
if (i.endsWith(".xml"))
{
xmlData.push(sys.io.File.getContent(FileSystem.absolutePath("assets/shared/images/noteskins") + "/" + i));
continue;
}

if (!i.endsWith(".png"))
continue;
noteskinArray.push(i.replace(".png", ""));
}
#else
noteskinArray = ["Arrows", "Circles"];
#end

return noteskinArray;
}

public static function getNoteskins()
{
return noteskinArray;
}

public static function getNoteskinByID(id:Int)
{
return noteskinArray[id];
}

static public function generateNoteskinSprite(id:Int)
{
#if FEATURE_FILESYSTEM
// TODO: Make this use OpenFlAssets.
var path = FileSystem.absolutePath("assets/shared/images/noteskins") + "/" + getNoteskinByID(id);
var data:BitmapData = BitmapData.fromFile(path + ".png");

return FlxAtlasFrames.fromSparrow(FlxGraphic.fromBitmapData(data), xmlData[id]);
// return Paths.getSparrowAtlas('noteskins/' + NoteskinHelpers.getNoteskinByID(FlxG.save.data.noteskin), "shared");
#else
return Paths.getSparrowAtlas('noteskins/' + NoteskinHelpers.getNoteskinByID(FlxG.save.data.noteskin), "shared");
#end
}
}
23 changes: 23 additions & 0 deletions source/Options.hx
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,29 @@ class MiddleScrollOption extends Option
}
}

class NoteskinOption extends Option
{
public function new(desc:String)
{
super();
description = desc;
}

public override function press():Bool
{
FlxG.save.data.noteskin++;
if (FlxG.save.data.noteskin > NoteskinHelpers.getNoteskins().length - 1)
FlxG.save.data.noteskin = 0;
display = updateDisplay();
return true;
}

private override function updateDisplay():String
{
return NoteskinHelpers.getNoteskinByID(FlxG.save.data.noteskin) + " noteskin";
}
}

class HealthBarOption extends Option
{
public function new(desc:String)
Expand Down
1 change: 1 addition & 0 deletions source/OptionsMenu.hx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class OptionsMenu extends MusicBeatState
new CustomizeGameplay("Drag and drop gameplay modules to your prefered positions!")
]),
new OptionCategory("Appearance", [
new NoteskinOption("Change your current noteskin"),
new EditorRes("Not showing the editor grid will greatly increase editor performance"),
new DistractionsAndEffectsOption("Toggle stage distractions that can hinder your gameplay."),
new CamZoomOption("Toggle the camera zoom in-game."),
Expand Down
4 changes: 2 additions & 2 deletions source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ class PlayState extends MusicBeatState
if (PlayStateChangeables.Optimize && player == 0)
continue;

if (SONG.noteStyle == null)
if (SONG.noteStyle == null && FlxG.save.data.overrideNoteskins)
{
switch (storyWeek)
{
Expand Down Expand Up @@ -1777,7 +1777,7 @@ class PlayState extends MusicBeatState
}

default:
babyArrow.frames = Paths.getSparrowAtlas('noteskins/' + FlxG.save.data.noteskin);
babyArrow.frames = NoteskinHelpers.generateNoteskinSprite(FlxG.save.data.noteskin);
for (j in 0...4)
{
babyArrow.animation.addByPrefix(dataColor[j], 'arrow' + dataSuffix[j]);
Expand Down