Skip to content

Commit

Permalink
alphabet data (literaly just softcoded offsets)
Browse files Browse the repository at this point in the history
Co-authored-by: Til <[email protected]>
  • Loading branch information
CrusherNotDrip and TechnikTil committed Jan 23, 2025
1 parent fadfcb8 commit 6e5d3d6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions assets/ui/fonts/alphabet/bold.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"offsets": []
}
9 changes: 9 additions & 0 deletions assets/ui/fonts/alphabet/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"offsets": [
{
"character": "-",
"x": 0,
"y": -12
}
]
}
19 changes: 19 additions & 0 deletions src/funkin/objects/ui/Alphabet.hx
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
package funkin.objects.ui;

import flixel.graphics.frames.FlxFramesCollection;
import funkin.structures.AlphabetStructure;
import haxe.Json;

class Alphabet extends FlxTypedSpriteGroup<AlphabetLetter>
{
/**
* Data for the current letter type.
*/
public var data:AlphabetStructure;

/**
* The text that this group displays.
*/
Expand All @@ -23,6 +30,8 @@ class Alphabet extends FlxTypedSpriteGroup<AlphabetLetter>
{
super(x, y);

data = cast Json.parse(Paths.content.json(letterType.getPath()));

this.letterType = letterType;
this.text = text;
}
Expand Down Expand Up @@ -99,6 +108,16 @@ class Alphabet extends FlxTypedSpriteGroup<AlphabetLetter>
letterSpr.setPosition(letterX, letterY + maxHeight - letterSpr.height);
add(letterSpr);

for (offsetObj in data.offsets)
{
if (offsetObj?.character == letter)
{
letterSpr.x += offsetObj?.x ?? 0;
letterSpr.y += offsetObj?.y ?? 0;
break;
}
}

letterX += Math.floor(letterSpr.width);
}
}
Expand Down

0 comments on commit 6e5d3d6

Please sign in to comment.