Skip to content

Commit 9c2ef02

Browse files
Lasercarninjamuffin99
authored andcommitted
NuN GF
Adds a none/null option for the character selector dropdown Also fixes a few null references that happen when one or both characters are null in the playstate
1 parent 4187244 commit 9c2ef02

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

source/funkin/play/GameOverSubState.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class GameOverSubState extends MusicBeatSubState
144144
// Pluck Boyfriend from the PlayState and place him (in the same position) in the GameOverSubState.
145145
// We can then play the character's `firstDeath` animation.
146146
if (PlayState.instance.isMinimalMode) {}
147-
else
147+
else if (boyfriend != null)
148148
{
149149
boyfriend = PlayState.instance.currentStage.getBoyfriend(true);
150150
boyfriend.canPlayOtherAnims = true;

source/funkin/play/PlayState.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,8 +1127,8 @@ class PlayState extends MusicBeatSubState
11271127

11281128
if (!isMinimalMode)
11291129
{
1130-
iconP1.updatePosition();
1131-
iconP2.updatePosition();
1130+
if (iconP1 != null) iconP1.updatePosition();
1131+
if (iconP1 != null) iconP2.updatePosition();
11321132
}
11331133

11341134
// Transition to the game over substate.

source/funkin/play/stage/Stage.hx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ class Stage extends FlxSpriteGroup implements IPlayStateScriptedClass implements
801801

802802
public override function remove(Sprite:FlxSprite, Splice:Bool = false):FlxSprite
803803
{
804+
if (Sprite == null) return Sprite;
804805
var sprite:FlxSprite = cast Sprite;
805806
sprite.x -= x;
806807
sprite.y -= y;

source/funkin/ui/debug/charting/dialogs/ChartEditorCharacterIconSelectorMenu.hx

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import haxe.ui.containers.ScrollView;
1212
import haxe.ui.core.Screen;
1313
import flixel.tweens.FlxTween;
1414
import flixel.tweens.FlxEase;
15+
import haxe.ui.components.Button;
1516

1617
// @:nullSafety // TODO: Fix null safety when used with HaxeUI build macros.
1718
@:access(funkin.ui.debug.charting.ChartEditorState)
@@ -21,14 +22,23 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu
2122
public var charSelectScroll:ScrollView;
2223
public var charIconName:Label;
2324

25+
var currentCharButton:Button;
26+
2427
public function new(chartEditorState2:ChartEditorState, charType:CharacterType, lockPosition:Bool = false)
2528
{
2629
super(chartEditorState2);
2730

2831
initialize(charType, lockPosition);
2932
this.alpha = 0;
3033
this.y -= 10;
31-
FlxTween.tween(this, {alpha: 1, y: this.y + 10}, 0.2, {ease: FlxEase.quartOut});
34+
FlxTween.tween(this, {alpha: 1, y: this.y + 10}, 0.2,
35+
{
36+
ease: FlxEase.quartOut,
37+
onComplete: function(_) {
38+
// Just focus the button FFS. Idk why, but the scrollbar doesn't update until after the tween finishes with this????
39+
currentCharButton.focus = true;
40+
}
41+
});
3242
}
3343

3444
function initialize(charType:CharacterType, lockPosition:Bool)
@@ -70,13 +80,15 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu
7080
var charIds:Array<String> = CharacterDataParser.listCharacterIds();
7181
charIds.sort(SortUtil.alphabetically);
7282

83+
charIds.insert(0, ""); // Add none/null/NuN character option
84+
7385
var defaultText:String = '(choose a character)';
7486

7587
for (charIndex => charId in charIds)
7688
{
7789
var charData:CharacterData = CharacterDataParser.fetchCharacterData(charId);
7890

79-
var charButton = new haxe.ui.components.Button();
91+
var charButton = new Button();
8092
charButton.width = 70;
8193
charButton.height = 70;
8294
charButton.padding = 8;
@@ -85,15 +97,17 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu
8597
if (charId == currentCharId)
8698
{
8799
// Scroll to the character if it is already selected.
88-
charSelectScroll.hscrollPos = Math.floor(charIndex / 5) * 80;
89-
charButton.selected = true;
100+
charSelectScroll.vscrollPos = Math.floor(charIndex / 5) * 80;
101+
charButton.focus = true;
102+
103+
defaultText = (currentCharId != "") ? '${charData.name} [${charId}]' : 'None';
90104

91-
defaultText = '${charData.name} [${charId}]';
105+
currentCharButton = charButton;
92106
}
93107

94108
var LIMIT = 6;
95109
charButton.icon = haxe.ui.util.Variant.fromImageData(CharacterDataParser.getCharPixelIconAsset(charId));
96-
charButton.text = charData.name.length > LIMIT ? '${charData.name.substr(0, LIMIT)}.' : '${charData.name}';
110+
charButton.text = (charId != "") ? (charData.name.length > LIMIT ? '${charData.name.substr(0, LIMIT)}.' : '${charData.name}') : 'None';
97111

98112
charButton.onClick = _ -> {
99113
switch (charType)
@@ -104,12 +118,13 @@ class ChartEditorCharacterIconSelectorMenu extends ChartEditorBaseMenu
104118
default: throw 'Invalid charType: ' + charType;
105119
};
106120

121+
defaultText = (charId != "") ? '${charData.name} [${charId}]' : 'None';
107122
chartEditorState.healthIconsDirty = true;
108123
chartEditorState.refreshToolbox(ChartEditorState.CHART_EDITOR_TOOLBOX_METADATA_LAYOUT);
109124
};
110125

111126
charButton.onMouseOver = _ -> {
112-
charIconName.text = '${charData.name} [${charId}]';
127+
charIconName.text = (charId != "") ? '${charData.name} [${charId}]' : 'None';
113128
};
114129
charButton.onMouseOut = _ -> {
115130
charIconName.text = defaultText;

0 commit comments

Comments
 (0)