Skip to content

Commit 626c649

Browse files
committed
fix some alphabet related stuffs
1 parent c5098e0 commit 626c649

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

src/funkin/objects/ui/Alphabet.hx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ class Alphabet extends FlxTypedSpriteGroup<AlphabetLetter>
8383
var letterX:Float = 0;
8484
var letterY:Float = 0;
8585

86+
_lastTextWidth = 0;
87+
8688
var splitText:Array<String> = text.split('');
8789

8890
for (i in 0...text.length)
@@ -110,7 +112,7 @@ class Alphabet extends FlxTypedSpriteGroup<AlphabetLetter>
110112
letterSpr.revive();
111113
}
112114

113-
if (letterX + Math.floor(letterSpr.width) >= fieldWidth)
115+
if (letterX + Math.floor(letterSpr.width) >= fieldWidth && fieldWidth > 0)
114116
{
115117
letterX = 0;
116118
letterY += maxHeight;
@@ -132,7 +134,9 @@ class Alphabet extends FlxTypedSpriteGroup<AlphabetLetter>
132134

133135
letterX += Math.floor(letterSpr.width);
134136
}
137+
_lastTextWidth = Math.max(_lastTextWidth, letterX);
135138
}
139+
_lastTextHeight = letterY + maxHeight;
136140
}
137141

138142
function makeLetterSpr(letter:String, x:Float = 0, y:Float = 0):AlphabetLetter
@@ -148,6 +152,23 @@ class Alphabet extends FlxTypedSpriteGroup<AlphabetLetter>
148152
letter.kill();
149153
});
150154
}
155+
var _lastTextWidth:Float = 0;
156+
var _lastTextHeight:Float = 0;
157+
158+
override function get_width():Float
159+
{
160+
return _lastTextWidth;
161+
}
162+
163+
override function get_height():Float
164+
{
165+
return _lastTextHeight;
166+
}
167+
168+
override public function updateHitbox():Void
169+
{
170+
FlxG.log.notice('[ALPHABET] updateHitbox is not available on Alphabet objects.');
171+
}
151172
}
152173

153174
class AlphabetLetter extends FunkinSprite

src/funkin/states/ui/OptionsState.hx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ class OptionsState extends FunkinState
185185
categoryArrow = new FunkinSprite().loadTexture('ui/options/arrow');
186186
add(categoryArrow);
187187

188-
categoryName = new Alphabet(456, 269, '', BOLD);
188+
categoryName = new Alphabet(456, 269, '', FlxG.width, BOLD);
189189
add(categoryName);
190190

191-
categoryDescription = new Alphabet(0, 456, '', DEFAULT);
191+
categoryDescription = new Alphabet(0, 456, '', FlxG.width, DEFAULT);
192192
categoryDescription.scale.set(0.7, 0.7);
193193
categoryDescription.updateHitbox();
194194
add(categoryDescription);
@@ -274,7 +274,9 @@ class OptionsState extends FunkinState
274274
spr.alpha = 0.6;
275275

276276
categoryName.text = categories[curSelected].name;
277+
categoryName.screenCenter(X);
277278
categoryDescription.text = categories[curSelected].description;
279+
categoryDescription.screenCenter(X);
278280

279281
categoryGroup.members[curSelected].alpha = 1;
280282
lerpXPosArrow = categoryGroup.members[curSelected].getGraphicMidpoint().x - (categoryArrow.width / 2);

0 commit comments

Comments
 (0)