some stuff needs fixing
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package funkin.options;
|
||||
|
||||
import flixel.effects.FlxFlicker;
|
||||
import funkin.system.Controls;
|
||||
import funkin.options.Options;
|
||||
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
import flixel.group.FlxGroup.FlxTypedGroup;
|
||||
@@ -61,6 +63,7 @@ class KeybindsOptions extends MusicBeatState {
|
||||
];
|
||||
|
||||
public var curSelected:Int = -1;
|
||||
public var canSelect:Bool = true;
|
||||
public var alphabets:FlxTypedGroup<KeybindSetting>;
|
||||
public var bg:FlxSprite;
|
||||
public var coloredBG:FlxSprite;
|
||||
@@ -141,13 +144,32 @@ class KeybindsOptions extends MusicBeatState {
|
||||
} else
|
||||
coloredBG.alpha = lerp(coloredBG.alpha, 0, 0.0625);
|
||||
|
||||
changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0));
|
||||
|
||||
super.update(elapsed);
|
||||
if (canSelect) {
|
||||
changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0));
|
||||
if (controls.BACK) {
|
||||
FlxTransitionableState.skipNextTransIn = true;
|
||||
FlxTransitionableState.skipNextTransOut = true;
|
||||
FlxG.switchState(new OptionsMenu());
|
||||
controls.setKeyboardScheme(Solo);
|
||||
return;
|
||||
}
|
||||
|
||||
if (controls.BACK) {
|
||||
FlxTransitionableState.skipNextTransIn = true;
|
||||
FlxTransitionableState.skipNextTransOut = true;
|
||||
FlxG.switchState(new OptionsMenu());
|
||||
if (controls.ACCEPT) {
|
||||
if (alphabets.members[curSelected] != null) {
|
||||
canSelect = false;
|
||||
CoolUtil.playMenuSFX(1);
|
||||
FlxFlicker.flicker(alphabets.members[curSelected], 0.4, 0.1, true, false, function(t) {
|
||||
alphabets.members[curSelected].changeKeybind(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (alphabets.members[curSelected].changingKeybind < 0)
|
||||
canSelect = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function changeSelection(change:Int) {
|
||||
@@ -176,10 +198,14 @@ class KeybindSetting extends FlxTypedSpriteGroup<FlxSprite> {
|
||||
public var bind2:Alphabet;
|
||||
public var icon:FlxSprite;
|
||||
|
||||
public var changingKeybind:Int = -1;
|
||||
public var value:String;
|
||||
|
||||
public var option1:Null<FlxKey>;
|
||||
public var option2:Null<FlxKey>;
|
||||
public function new(x:Float, y:Float, name:String, value:String, ?sparrowIcon:String, ?sparrowAnim:String) {
|
||||
super();
|
||||
this.value = value;
|
||||
title = new Alphabet(0, 0, name, true);
|
||||
title.setPosition(100, 0);
|
||||
add(title);
|
||||
@@ -219,13 +245,37 @@ class KeybindSetting extends FlxTypedSpriteGroup<FlxSprite> {
|
||||
setPosition(x, y);
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
if (changingKeybind >= 0) {
|
||||
var key:FlxKey = FlxG.keys.firstJustReleased();
|
||||
if (cast(key, Int) <= 0) return;
|
||||
if (key == ESCAPE && !FlxG.keys.pressed.SHIFT) {
|
||||
changingKeybind = -1;
|
||||
return;
|
||||
}
|
||||
if (changingKeybind == 0) {
|
||||
option1 = key;
|
||||
Reflect.setField(Options, 'P1_$value', [option1]);
|
||||
} else {
|
||||
option2 = key;
|
||||
Reflect.setField(Options, 'P2_$value', [option2]);
|
||||
}
|
||||
changingKeybind = -1;
|
||||
updateText();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function changeKeybind(p2:Bool = false) {
|
||||
FlxG.state.persistentDraw = true;
|
||||
FlxG.state.persistentUpdate = true;
|
||||
|
||||
changingKeybind = p2 ? 1 : 0;
|
||||
}
|
||||
|
||||
public function updateText() {
|
||||
// TODO: Fix Alphabet!!
|
||||
@:privateAccess
|
||||
bind1._finalText = '${CoolUtil.keyToString(option1)}';
|
||||
@:privateAccess
|
||||
bind2._finalText = '${CoolUtil.keyToString(option2)}';
|
||||
bind1.addText();
|
||||
bind2.addText();
|
||||
bind1.text = '${CoolUtil.keyToString(option1)}';
|
||||
bind2.text = '${CoolUtil.keyToString(option2)}';
|
||||
}
|
||||
}
|
||||
@@ -71,8 +71,7 @@ class Alphabet extends FlxSpriteGroup
|
||||
{
|
||||
super(x, y);
|
||||
|
||||
_finalText = text;
|
||||
this.text = text;
|
||||
_finalText = this.text = text;
|
||||
isBold = bold;
|
||||
|
||||
var alphabetPath = Paths.xml("alphabet");
|
||||
@@ -117,24 +116,20 @@ class Alphabet extends FlxSpriteGroup
|
||||
var xPos:Float = 0;
|
||||
for (character in splitWords)
|
||||
{
|
||||
if (character == " " || character == "-")
|
||||
lastWasSpace = true;
|
||||
lastWasSpace = character == " ";
|
||||
|
||||
if (lastSprite != null)
|
||||
xPos = lastSprite.x + lastSprite.width - x;
|
||||
|
||||
if (lastWasSpace)
|
||||
{
|
||||
xPos += 40;
|
||||
lastWasSpace = false;
|
||||
}
|
||||
|
||||
var letter:AlphaCharacter = new AlphaCharacter(xPos, 0);
|
||||
if (isBold)
|
||||
letter.createBold(character);
|
||||
else
|
||||
letter.createLetter(character);
|
||||
|
||||
// anim not found
|
||||
if (!letter.visible)
|
||||
xPos += 40;
|
||||
add(letter);
|
||||
|
||||
lastSprite = letter;
|
||||
@@ -251,6 +246,8 @@ class Alphabet extends FlxSpriteGroup
|
||||
|
||||
override function update(elapsed:Float)
|
||||
{
|
||||
super.update(elapsed);
|
||||
|
||||
if (isMenuItem)
|
||||
{
|
||||
var scaledY = FlxMath.remapToRange(targetY, 0, 1, 0, 1.3);
|
||||
@@ -259,7 +256,15 @@ class Alphabet extends FlxSpriteGroup
|
||||
x = CoolUtil.fpsLerp(x, (targetY * 20) + 90, 0.16);
|
||||
}
|
||||
|
||||
super.update(elapsed);
|
||||
if (text != _finalText) {
|
||||
_finalText = text;
|
||||
for(e in members)
|
||||
e.destroy();
|
||||
@:privateAccess
|
||||
group.members = [];
|
||||
lastSprite = null;
|
||||
addText();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user