From b1349c09b946d358e6b8bd97d99b82e8ad8657fa Mon Sep 17 00:00:00 2001 From: Yoshman29 <81191621+YoshiCrafter29@users.noreply.github.com> Date: Wed, 22 Feb 2023 03:05:37 +0100 Subject: [PATCH] Fix for #80 --- buildnumber.txt | 2 +- .../funkin/menus/credits/CreditsCodename.hx | 36 ++++++++++++++++++- source/funkin/options/OptionsScreen.hx | 6 ++-- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/buildnumber.txt b/buildnumber.txt index c88f845d..614185b2 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -2373 \ No newline at end of file +2384 \ No newline at end of file diff --git a/source/funkin/menus/credits/CreditsCodename.hx b/source/funkin/menus/credits/CreditsCodename.hx index 309e9c26..f9c5d4b9 100644 --- a/source/funkin/menus/credits/CreditsCodename.hx +++ b/source/funkin/menus/credits/CreditsCodename.hx @@ -1,5 +1,6 @@ package funkin.menus.credits; +import funkin.ui.FunkinText; import flixel.util.FlxColor; import funkin.shaders.CustomShader; import flixel.math.FlxMath; @@ -25,12 +26,15 @@ class CreditsCodename extends OptionsScreen { public var interpColor:FlxInterpolateColor; + public var errorMessage:String = ""; + public override function create() { contributors = GitHub.getContributors("YoshiCrafter29", "CodenameEngine", function(e) { - trace(e); + errorMessage = Std.string(e); }); + var totalContributions = 0; for(c in contributors) @@ -49,7 +53,29 @@ class CreditsCodename extends OptionsScreen { interpColor = new FlxInterpolateColor(bg.color); } + public override function changeSelection(change:Int) { + if (contributors.length <= 0) + return; + super.changeSelection(change); + } + public override function createAdditional() { + if (contributors.length <= 0) { + var t = new FunkinText(0, 0, FlxG.width, 'Could not load engine contributors.\nMake sure you\'re connected to the Internet.\n\n${errorMessage}\n\nPress BACK to go back.', 40, true); + t.alignment = CENTER; + t.borderSize *= 1.75; + t.screenCenter(); + + var bg = new FlxSprite(0, 0).makeGraphic(1, 1, 0xFF000000); + bg.alpha = 0.5; + bg.scale.set(FlxG.width - 80, t.height + 40); + bg.updateHitbox(); + bg.screenCenter(); + add(bg); + add(t); + return; + } + for(k=>c in contributors) { var spr = new FlxSprite(0, (OptionsScreen.optionHeight * (k+0.5)) - 48); spr.antialiasing = true; @@ -75,6 +101,13 @@ class CreditsCodename extends OptionsScreen { public override function update(elapsed:Float) { super.update(elapsed); + + if (contributors.length <= 0) { + if (controls.BACK) + exit(); + return; + } + if (avatarLoadListId < contributorsAvatars.length) { for(i in avatarLoadListId...contributorsAvatars.length) { var v = contributorsSprites[i]; @@ -99,6 +132,7 @@ class CreditsCodename extends OptionsScreen { } public override function exit() { + FlxTransitionableState.skipNextTransOut = true; FlxG.switchState(new CreditsMain()); } } \ No newline at end of file diff --git a/source/funkin/options/OptionsScreen.hx b/source/funkin/options/OptionsScreen.hx index 9a9bc5e9..07e3235d 100644 --- a/source/funkin/options/OptionsScreen.hx +++ b/source/funkin/options/OptionsScreen.hx @@ -85,15 +85,15 @@ class OptionsScreen extends MusicBeatState { options[curSelected].onSelect(); } if (controls.BACK) { - Options.applySettings(); Options.save(); + Options.applySettings(); exit(); } FlxG.camera.scroll.x = lerp(FlxG.camera.scroll.x, scrollDest.x, 0.25); FlxG.camera.scroll.y = lerp(FlxG.camera.scroll.y, scrollDest.y, 0.25); for(option in options) { - var angle = Math.cos((option.y + (optionHeight / 2) - (FlxG.camera.scroll.y + (FlxG.height / 2))) / (FlxG.height * 1.25) * Math.PI); + var angle = Math.cos((option.y + (optionHeight / 2) - (FlxG.camera.scroll.y + ((FlxG.height - descBG.height) / 2))) / (FlxG.height * 1.25) * Math.PI); option.x = -50 + (Math.abs(angle) * 150); } @@ -115,7 +115,7 @@ class OptionsScreen extends MusicBeatState { for(e in options) e.selected = false; options[curSelected].selected = true; - scrollDest.set(-50, -(FlxG.height / 2) + ((curSelected + 0.5) * optionHeight)); + scrollDest.set(-50, -((FlxG.height - descBG.height) / 2) + ((curSelected + 0.5) * optionHeight)); updateDesc(); } }