Skip to content

Commit

Permalink
i heart bugfixing
Browse files Browse the repository at this point in the history
  • Loading branch information
KoloInDaCrib committed Nov 9, 2024
1 parent 0446f42 commit f7b6fd9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 63 deletions.
19 changes: 9 additions & 10 deletions source/funkin/ui/debug/char/components/dialogs/AddAnimDialog.hx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class AddAnimDialog extends DefaultPageDialog
charAnimFramerate.pos = 24;
charAnimOffsetX.pos = charAnimOffsetY.pos = 0;

page.onDialogUpdate(this);
return;
}

Expand All @@ -59,6 +60,7 @@ class AddAnimDialog extends DefaultPageDialog
charAnimOffsetX.pos = (animData.offsets != null && animData.offsets.length == 2 ? animData.offsets[0] : 0);
charAnimOffsetY.pos = (animData.offsets != null && animData.offsets.length == 2 ? animData.offsets[1] : 0);

char.playAnimation(charAnimName.text);
page.onDialogUpdate(this);
}

Expand All @@ -81,10 +83,12 @@ class AddAnimDialog extends DefaultPageDialog
(shouldDoIndices ? indices : []), Std.int(charAnimFramerate.pos), charAnimLooped.selected, charAnimFlipX.selected, charAnimFlipY.selected);

if (!animAdded) return;
char.playAnimation(charAnimName.text);

cast(page, CharCreatorGameplayPage).ghostCharacter.addAnimation(charAnimName.text, charAnimPrefix.text, [charAnimOffsetX.pos, charAnimOffsetY.pos],
(shouldDoIndices ? indices : []), Std.int(charAnimFramerate.pos), charAnimLooped.selected, charAnimFlipX.selected, charAnimFlipY.selected);
if (linkedChar.generatedParams.importedCharacter == null)
{
cast(page, CharCreatorGameplayPage).ghostCharacter.addAnimation(charAnimName.text, charAnimPrefix.text, [charAnimOffsetX.pos, charAnimOffsetY.pos],
(shouldDoIndices ? indices : []), Std.int(charAnimFramerate.pos), charAnimLooped.selected, charAnimFlipX.selected, charAnimFlipY.selected);
}

updateDropdown();
charAnimDropdown.selectedIndex = charAnimDropdown.dataSource.size - 1;
Expand All @@ -94,17 +98,12 @@ class AddAnimDialog extends DefaultPageDialog
if ((charAnimName.text ?? "") == "") return;

if (!char.removeAnimation(charAnimName.text)) return;
cast(page, CharCreatorGameplayPage).ghostCharacter.removeAnimation(charAnimName.text);
if (linkedChar.generatedParams.importedCharacter == null) cast(page, CharCreatorGameplayPage).ghostCharacter.removeAnimation(charAnimName.text);

updateDropdown();
charAnimDropdown.selectedIndex = charAnimDropdown.dataSource.size - 1;

if (charAnimDropdown.selectedIndex == -1)
{
@:privateAccess
cast(page, CharCreatorGameplayPage).labelAnimName.text = "None";
return;
}
if (charAnimDropdown.selectedIndex == -1) return;

var anim:String = charAnimDropdown.value.text;
char.playAnimation(anim);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ImportDataDialog extends DefaultWizardDialog
{
var check = new OptionBox();
check.text = id;
check.componentGroup = "characterData";
check.selected = (id == selectedData);
check.onChange = _ -> {
selectedData = id;
Expand All @@ -55,6 +56,7 @@ class ImportDataDialog extends DefaultWizardDialog
{
var check = new OptionBox();
check.text = id;
check.componentGroup = "playerData";
check.selected = (id == selectedPlayer);
check.onChange = _ -> {
selectedPlayer = id;
Expand All @@ -81,6 +83,8 @@ class ImportDataDialog extends DefaultWizardDialog
else
params.importedCharacter = null;

if (params.importedCharacter != null) params.renderType = CharacterRegistry.parseCharacterData(params.importedCharacter)?.renderType ?? Sparrow;

// same shit for the player, though it's currently not my priority

return true;
Expand Down
22 changes: 13 additions & 9 deletions source/funkin/ui/debug/char/pages/CharCreatorGameplayPage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,27 @@ class CharCreatorGameplayPage extends CharCreatorDefaultPage
dialogMap.set(Ghost, new GhostSettingsDialog(this));
dialogMap.set(Health, new HealthIconDialog(this, currentCharacter));

var animDialog = cast(dialogMap[Animation], AddAnimDialog);
animDialog.updateDropdown();
generateUI();
}

override public function onDialogUpdate(dialog:DefaultPageDialog)
{
if (dialog == dialogMap[Animation])
if (wizardParams.importedCharacter != null)
{
var animDialog = cast(dialogMap[Animation], AddAnimDialog);
animDialog.updateDropdown();

labelAnimName.text = animDialog.charAnimDropdown.selectedItem.text;
labelAnimOffsetX.text = "" + currentCharacter.getAnimationData(labelAnimName.text).offsets[0];
labelAnimOffsetY.text = "" + currentCharacter.getAnimationData(labelAnimName.text).offsets[1];
animDialog.charAnimDropdown.selectedIndex = 0;
currentCharacter.playAnimation(currentCharacter.animations[0].name);
}
}

override public function update(elapsed:Float)
{
labelAnimName.text = currentCharacter.getCurrentAnimation() ?? "None";
labelAnimOffsetX.text = "" + (currentCharacter.getAnimationData(currentCharacter.getCurrentAnimation())?.offsets[0] ?? 0);
labelAnimOffsetY.text = "" + (currentCharacter.getAnimationData(currentCharacter.getCurrentAnimation())?.offsets[1] ?? 0);

super.update(elapsed);
}

public function stageBeatHit()
{
for (spr in stageProps)
Expand Down
44 changes: 0 additions & 44 deletions source/funkin/ui/debug/char/pages/CharCreatorSelectPage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -37,55 +37,25 @@ class CharCreatorSelectPage extends CharCreatorDefaultPage
nametag = new FlxSprite();
add(nametag);

nametag.scrollFactor.set();

initCursors();
initSounds();

initLocks();

FlxTween.color(cursor, 0.2, 0xFFFFFF00, 0xFFFFCC00, {type: PINGPONG});

// FlxG.debugger.track(cursor);

var fadeShaderFilter:ShaderFilter = new ShaderFilter(fadeShader);
FlxG.camera.filters = [fadeShaderFilter];

var temp:FlxSprite = new FlxSprite();
temp.loadGraphic(Paths.image('charSelect/placement'));
add(temp);
temp.alpha = 0.0;

// FlxG.debugger.track(temp, "tempBG");

transitionGradient = new FlxSprite(0, 0).loadGraphic(Paths.image('freeplay/transitionGradient'));
transitionGradient.scale.set(1280, 1);
transitionGradient.flipY = true;
transitionGradient.updateHitbox();
FlxTween.tween(transitionGradient, {y: -720}, 1, {ease: FlxEase.expoOut});
add(transitionGradient);

fadeShader.fade(0.0, 1.0, 0.8, {ease: FlxEase.quadOut});

var blackScreen = new FunkinSprite().makeSolidColor(FlxG.width * 2, FlxG.height * 2, 0xFF000000);
blackScreen.x = -(FlxG.width * 0.5);
blackScreen.y = -(FlxG.height * 0.5);
add(blackScreen);
}

function initBackground()
{
var bg:FlxSprite = new FlxSprite(-153, -140);
bg.loadGraphic(Paths.image('charSelect/charSelectBG'));
bg.scrollFactor.set(0.1, 0.1);
add(bg);

var crowd:FlxAtlasSprite = new FlxAtlasSprite(0, 0, Paths.animateAtlas("charSelect/crowd"));
crowd.anim.play();
crowd.anim.onComplete.add(function() {
crowd.anim.play();
});
crowd.scrollFactor.set(0.3, 0.3);
add(crowd);

var stageSpr:FlxSprite = new FlxSprite(-40, 391);
Expand All @@ -96,7 +66,6 @@ class CharCreatorSelectPage extends CharCreatorDefaultPage

var curtains:FlxSprite = new FlxSprite(-47, -49);
curtains.loadGraphic(Paths.image('charSelect/curtains'));
curtains.scrollFactor.set(1.4, 1.4);
add(curtains);

var barthing = new FlxAtlasSprite(0, 0, Paths.animateAtlas("charSelect/barThing"));
Expand All @@ -105,7 +74,6 @@ class CharCreatorSelectPage extends CharCreatorDefaultPage
barthing.anim.play("");
});
barthing.blend = BlendMode.MULTIPLY;
barthing.scrollFactor.set(0, 0);
add(barthing);

var charLight:FlxSprite = new FlxSprite(800, 250);
Expand All @@ -124,7 +92,6 @@ class CharCreatorSelectPage extends CharCreatorDefaultPage
speakers.anim.onComplete.add(function() {
speakers.anim.play("");
});
speakers.scrollFactor.set(1.8, 1.8);
add(speakers);

var fgBlur:FlxSprite = new FlxSprite(-125, 170);
Expand All @@ -149,10 +116,6 @@ class CharCreatorSelectPage extends CharCreatorDefaultPage
var chooseDipshit = new FlxSprite(426, -13);
chooseDipshit.loadGraphic(Paths.image('charSelect/chooseDipshit'));
add(chooseDipshit);

chooseDipshit.scrollFactor.set();
dipshitBacking.scrollFactor.set();
dipshitBlur.scrollFactor.set();
}

var cursor:FlxSprite;
Expand Down Expand Up @@ -185,14 +148,12 @@ class CharCreatorSelectPage extends CharCreatorDefaultPage
cursorDarkBlue.blend = BlendMode.SCREEN;

cursorConfirmed = new FlxSprite(0, 0);
cursorConfirmed.scrollFactor.set();
cursorConfirmed.frames = Paths.getSparrowAtlas("charSelect/charSelectorConfirm");
cursorConfirmed.animation.addByPrefix("idle", "cursor ACCEPTED instance 1", 24, true);
cursorConfirmed.visible = false;
add(cursorConfirmed);

cursorDenied = new FlxSprite(0, 0);
cursorDenied.scrollFactor.set();
cursorDenied.frames = Paths.getSparrowAtlas("charSelect/charSelectorDenied");
cursorDenied.animation.addByPrefix("idle", "cursor DENIED instance 1", 24, false);
cursorDenied.visible = false;
Expand All @@ -201,10 +162,6 @@ class CharCreatorSelectPage extends CharCreatorDefaultPage
grpCursors.add(cursorDarkBlue);
grpCursors.add(cursorBlue);
grpCursors.add(cursor);

cursor.scrollFactor.set();
cursorBlue.scrollFactor.set();
cursorDarkBlue.scrollFactor.set();
}

var selectSound:FunkinSound;
Expand Down Expand Up @@ -263,7 +220,6 @@ class CharCreatorSelectPage extends CharCreatorDefaultPage
}

updateIconPositions();
grpIcons.scrollFactor.set();

for (index => member in grpIcons.members)
{
Expand Down
2 changes: 2 additions & 0 deletions source/funkin/util/MouseUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@ class MouseUtil
public static function mouseWheelZoom():Void
{
if (FlxG.mouse.wheel != 0) FlxG.camera.zoom += FlxG.mouse.wheel * (0.1 * FlxG.camera.zoom);
while (FlxG.camera.zoom < 0.11)
FlxG.camera.zoom -= FlxG.mouse.wheel * (0.1 * FlxG.camera.zoom); // floating point error fix
}
}

0 comments on commit f7b6fd9

Please sign in to comment.