Adjusted menus (#179)
* Adjusted sprites' offsets * Cleaned title enter * Fixed coop text * Make descriptions actually work * Oops - Descriptions pt2 * Credits pt1 wip * Credits pt2 * Credits pt3 idk if i should remove anything else sensible aside the ip * Credits pt4 i'll stop for this pr editing the credits menu in the future i might improve it
This commit is contained in:
@@ -223,7 +223,7 @@ class FreeplayState extends MusicBeatState
|
||||
}
|
||||
|
||||
scoreText.text = "PERSONAL BEST:" + lerpScore;
|
||||
scoreBG.scale.set(Math.max(diffText.width, scoreText.width) + 8, (coopText.visible ? coopText.y + coopText.height : 66));
|
||||
scoreBG.scale.set(Math.max(Math.max(diffText.width, scoreText.width), coopText.width) + 8, (coopText.visible ? coopText.y + coopText.height : 66));
|
||||
scoreBG.updateHitbox();
|
||||
scoreBG.x = FlxG.width - scoreBG.width;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package funkin.menus;
|
||||
|
||||
import haxe.Json;
|
||||
import funkin.backend.FunkinText;
|
||||
// import funkin.menus.credits.CreditsMain;
|
||||
import funkin.menus.credits.CreditsMain;
|
||||
import flixel.FlxState;
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
import flixel.effects.FlxFlicker;
|
||||
@@ -174,10 +174,8 @@ class MainMenuState extends MusicBeatState
|
||||
trace("Freeplay Menu Selected");
|
||||
|
||||
case 'donate':
|
||||
/*
|
||||
FlxG.switchState(new CreditsMain());
|
||||
trace("Credits Menu Selected");
|
||||
*/
|
||||
|
||||
case 'options':
|
||||
FlxG.switchState(new OptionsMenu());
|
||||
|
||||
@@ -1,134 +1,69 @@
|
||||
package funkin.menus.credits;
|
||||
|
||||
import funkin.backend.FunkinText;
|
||||
import flixel.util.FlxColor;
|
||||
import funkin.backend.shaders.CustomShader;
|
||||
import funkin.options.type.TextOption;
|
||||
import funkin.options.OptionsScreen;
|
||||
import flixel.graphics.FlxGraphic;
|
||||
import openfl.display.BitmapData;
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
import funkin.backend.system.github.GitHub;
|
||||
import funkin.backend.system.github.GitHubContributor;
|
||||
import funkin.menus.MainMenuState;
|
||||
import funkin.options.type.PortraitOption;
|
||||
|
||||
using funkin.backend.utils.BitmapUtil;
|
||||
using StringTools;
|
||||
|
||||
class CreditsCodename extends OptionsScreen {
|
||||
public var contributorsSprites:Array<FlxSprite> = [];
|
||||
public var contributorsAvatars:Array<FlxGraphic> = [];
|
||||
public var contributorsColors:Array<FlxColor> = [];
|
||||
public var avatarLoadListId:Int = 0;
|
||||
public var contributors:Array<GitHubContributor>;
|
||||
|
||||
public var interpColor:FlxInterpolateColor;
|
||||
|
||||
public var errorMessage:String = "";
|
||||
|
||||
public override function create() {
|
||||
contributors = GitHub.getContributors("YoshiCrafter29", "CodenameEngine", function(e) {
|
||||
errorMessage = Std.string(e);
|
||||
});
|
||||
|
||||
|
||||
var totalContributions = 0;
|
||||
|
||||
for(c in contributors)
|
||||
totalContributions += c.contributions;
|
||||
|
||||
options = [for(c in contributors) new TextOption(
|
||||
c.login,
|
||||
'Total Contributions: ${c.contributions} / ${totalContributions} (${FlxMath.roundDecimal(c.contributions / totalContributions * 100, 2)}%) - Select to open GitHub account',
|
||||
function() {
|
||||
// open the link
|
||||
CoolUtil.openURL(c.html_url);
|
||||
})];
|
||||
|
||||
|
||||
super.create();
|
||||
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;
|
||||
spr.setUnstretchedGraphicSize(96, 96, false);
|
||||
spr.updateHitbox();
|
||||
spr.shader = new CustomShader('engine/circleProfilePicture');
|
||||
contributorsSprites.push(spr);
|
||||
add(spr);
|
||||
}
|
||||
|
||||
// asynchronous pfp loading
|
||||
Main.execAsync(function() {
|
||||
for(k=>c in contributors) {
|
||||
var bytes = GitHub.__requestBytesOnGitHubServers('${c.avatar_url}&size=96');
|
||||
var bmap = BitmapData.fromBytes(bytes);
|
||||
var color = bmap.getMostPresentSaturatedColor();
|
||||
contributorsAvatars.push(FlxG.bitmap.add(bmap, false, 'GITHUB-USER:${c.login}'));
|
||||
contributorsColors.push(color);
|
||||
if (destroyed) return;
|
||||
}
|
||||
});
|
||||
class CreditsCodename extends funkin.options.OptionsScreen {
|
||||
public override function new()
|
||||
{
|
||||
super("Codename Engine", "All the contributors of the engine! - Press RESET to update the list (One reset per 2 minutes).");
|
||||
checkUpdate();
|
||||
displayList();
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
if (funkin.options.PlayerSettings.solo.controls.RESET && checkUpdate()) {
|
||||
displayList();
|
||||
updateMenuDesc();
|
||||
}
|
||||
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];
|
||||
v.loadGraphic(contributorsAvatars[i]);
|
||||
v.setUnstretchedGraphicSize(96, 96, false);
|
||||
v.updateHitbox();
|
||||
}
|
||||
avatarLoadListId = contributorsAvatars.length;
|
||||
}
|
||||
|
||||
for(k=>spr in contributorsSprites) {
|
||||
var alpha = options[k];
|
||||
spr.x = alpha.x - 10;
|
||||
}
|
||||
|
||||
interpColor.fpsLerpTo(contributorsColors[curSelected], 0.0625);
|
||||
bg.color = interpColor.color;
|
||||
}
|
||||
|
||||
public override function destroy() {
|
||||
super.destroy();
|
||||
public function checkUpdate():Bool {
|
||||
var curTime:Float = Date.now().getTime();
|
||||
if(Options.lastUpdated != null && curTime < Options.lastUpdated + 120000) return false; // Fuck you Github rate limits - Nex_isDumb
|
||||
Options.lastUpdated = curTime;
|
||||
|
||||
var error:Bool = false;
|
||||
//Main.execAsync(function() {
|
||||
var idk = GitHub.getContributors("FNF-CNE-Devs", "CodenameEngine", function(e) {
|
||||
error = true;
|
||||
var errMsg:String = ~/\d+.\d+.\d+.\d+/.replace(e.message, "[Your IP]"); // Removing sensitive stuff - Nex_isDumb
|
||||
errMsg = 'Error while trying to download contributors list:\n$errMsg';
|
||||
|
||||
Logs.traceColored([Logs.logText(errMsg.replace('\n', ' '), RED)], ERROR);
|
||||
funkin.backend.utils.NativeAPI.showMessageBox("Codename Engine Warning", errMsg, MSG_WARNING);
|
||||
});
|
||||
//});
|
||||
if(error) return false;
|
||||
|
||||
Options.contributors = idk;
|
||||
trace('List Updated!');
|
||||
return true;
|
||||
}
|
||||
|
||||
public override function exit() {
|
||||
MusicBeatState.skipTransOut = true;
|
||||
FlxG.switchState(new CreditsMain());
|
||||
public function displayList() {
|
||||
//if (curSelected > Options.contributors.length - 1) changeSelection(-(curSelected - (Options.contributors.length - 1)));
|
||||
if (curSelected > Options.contributors.length - 1) curSelected = Options.contributors.length - 1;
|
||||
changeSelection(0, true);
|
||||
|
||||
while (members.length > 0) {
|
||||
members[0].destroy();
|
||||
remove(members[0], true);
|
||||
}
|
||||
|
||||
var totalContributions = 0;
|
||||
for(c in Options.contributors) totalContributions += c.contributions;
|
||||
for(c in Options.contributors) {
|
||||
var opt:PortraitOption = new PortraitOption(
|
||||
c.login,
|
||||
'Total Contributions: ${c.contributions} / ${totalContributions} (${FlxMath.roundDecimal(c.contributions / totalContributions * 100, 2)}%) - Select to open GitHub account',
|
||||
function() CoolUtil.openURL(c.html_url)
|
||||
);
|
||||
opt.loadFromGithub(c);
|
||||
add(opt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,23 +3,34 @@ package funkin.menus.credits;
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
import funkin.options.OptionsScreen;
|
||||
import funkin.options.type.*;
|
||||
import funkin.options.TreeMenu;
|
||||
|
||||
class CreditsMain extends TreeMenu {
|
||||
var editable:Array<OptionCategory> = [];
|
||||
var bg:FlxSprite;
|
||||
|
||||
class CreditsMain extends OptionsScreen {
|
||||
public override function create() {
|
||||
options = [
|
||||
bg = new FlxSprite(-80).loadAnimatedGraphic(Paths.image('menus/menuBGBlue'));
|
||||
// bg.scrollFactor.set();
|
||||
bg.scale.set(1.15, 1.15);
|
||||
bg.updateHitbox();
|
||||
bg.screenCenter();
|
||||
bg.scrollFactor.set();
|
||||
bg.antialiasing = true;
|
||||
add(bg);
|
||||
|
||||
var selectables:Array<OptionType> = [];
|
||||
for (s in editable) selectables.push(new TextOption(s.name, s.desc, function() {
|
||||
// TODO: Custom Credits
|
||||
new TextOption("Codename Engine", "Select this to see all of the contributors of the engine!", function() {
|
||||
MusicBeatState.skipTransIn = MusicBeatState.skipTransOut = true;
|
||||
FlxG.switchState(new CreditsCodename());
|
||||
}),
|
||||
new TextOption("Friday Night Funkin'", "Select this to open the itch.io page of the original game to donate!", function() {
|
||||
CoolUtil.openURL("https://ninja-muffin24.itch.io/funkin");
|
||||
})
|
||||
];
|
||||
}));
|
||||
selectables.push(new TextOption("Codename Engine", "Select this to see all the contributors of the engine!", function() {
|
||||
optionsTree.add(Type.createInstance(CreditsCodename, []));
|
||||
}));
|
||||
selectables.push(new TextOption("Friday Night Funkin'", "Select this to open the itch.io page of the original game to donate!", function() {
|
||||
CoolUtil.openURL("https://ninja-muffin24.itch.io/funkin");
|
||||
}));
|
||||
|
||||
main = new OptionsScreen('Credits', 'The people who made this possible!', selectables);
|
||||
super.create();
|
||||
}
|
||||
|
||||
public override function exit() {
|
||||
FlxG.switchState(new MainMenuState());
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,8 @@ class Options
|
||||
*/
|
||||
public static var freeplayLastSong:String = null;
|
||||
public static var freeplayLastDifficulty:String = "normal";
|
||||
public static var contributors:Array<funkin.backend.system.github.GitHubContributor> = [];
|
||||
public static var lastUpdated:Null<Float>;
|
||||
|
||||
// CHARTER
|
||||
public static var charterMetronomeEnabled:Bool = false;
|
||||
|
||||
@@ -54,15 +54,21 @@ class OptionsScreen extends FlxTypedSpriteGroup<OptionType> {
|
||||
onClose(this);
|
||||
}
|
||||
|
||||
public function changeSelection(sel:Int) {
|
||||
if (members.length <= 0 || sel == 0) return;
|
||||
public function changeSelection(sel:Int, force:Bool = false) {
|
||||
if (members.length <= 0 || (sel == 0 && !force)) return;
|
||||
|
||||
CoolUtil.playMenuSFX(SCROLL);
|
||||
|
||||
curSelected = FlxMath.wrap(curSelected + sel, 0, members.length-1);
|
||||
|
||||
for(o in members)
|
||||
members[curSelected].selected = true;
|
||||
updateMenuDesc();
|
||||
}
|
||||
|
||||
public function updateMenuDesc(?customTxt:String) {
|
||||
if (parent.treeParent == null) return;
|
||||
|
||||
var text:String = members[curSelected].desc;
|
||||
if (customTxt != null) text = customTxt;
|
||||
parent.treeParent.updateDesc(text);
|
||||
}
|
||||
|
||||
public dynamic function onClose(o:OptionsScreen) {}
|
||||
|
||||
@@ -2,6 +2,7 @@ package funkin.options;
|
||||
|
||||
class OptionsTree extends FlxTypedGroup<OptionsScreen> {
|
||||
public var lastMenu:OptionsScreen;
|
||||
public var treeParent:TreeMenu;
|
||||
public override function new() {
|
||||
super();
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ class TreeMenu extends MusicBeatState {
|
||||
optionsTree = new OptionsTree();
|
||||
optionsTree.onMenuChange = onMenuChange;
|
||||
optionsTree.onMenuClose = onMenuClose;
|
||||
optionsTree.treeParent = this;
|
||||
optionsTree.add(main);
|
||||
|
||||
|
||||
@@ -72,12 +73,18 @@ class TreeMenu extends MusicBeatState {
|
||||
t += '${o.name} > ';
|
||||
pathLabel.text = t;
|
||||
|
||||
pathDesc.text = optionsTree.members.last().desc;
|
||||
pathBG.scale.set(FlxG.width, pathDesc.y + pathDesc.height + 2);
|
||||
pathBG.updateHitbox();
|
||||
var idk:OptionsScreen = optionsTree.members.last();
|
||||
if (idk.members.length > 0) updateDesc(idk.members[idk.curSelected].desc);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateDesc(moreTxt:String = '') {
|
||||
pathDesc.text = optionsTree.members.last().desc;
|
||||
if (moreTxt != null && moreTxt.length > 0) pathDesc.text += '\n' + moreTxt;
|
||||
pathBG.scale.set(FlxG.width, pathDesc.y + pathDesc.height + 2);
|
||||
pathBG.updateHitbox();
|
||||
}
|
||||
|
||||
public function exit() {
|
||||
FlxG.switchState((lastState != null) ? Type.createInstance(lastState, []) : new MainMenuState());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package funkin.options.type;
|
||||
|
||||
import openfl.display.BitmapData;
|
||||
import flixel.graphics.FlxGraphic;
|
||||
import funkin.backend.shaders.CustomShader;
|
||||
import funkin.backend.system.github.GitHubContributor;
|
||||
import funkin.backend.system.github.GitHub;
|
||||
|
||||
class PortraitOption extends TextOption {
|
||||
public var portrait:FlxSprite = null;
|
||||
|
||||
public function new(name:String, desc:String, callback:Void->Void, ?graphic:FlxGraphic, size:Int = 96) {
|
||||
super(name, desc, callback);
|
||||
if (graphic != null) addPortrait(graphic, size);
|
||||
}
|
||||
|
||||
public function addPortrait(graphic:FlxGraphic, size:Int = 96) {
|
||||
if (portrait == null) {
|
||||
portrait = new FlxSprite();
|
||||
portrait.antialiasing = true;
|
||||
portrait.shader = new CustomShader('engine/circleProfilePicture');
|
||||
add(portrait);
|
||||
}
|
||||
portrait.loadGraphic(graphic);
|
||||
portrait.setUnstretchedGraphicSize(size, size, false);
|
||||
portrait.updateHitbox();
|
||||
portrait.setPosition(90 - portrait.width, 0);
|
||||
}
|
||||
|
||||
public function loadFromGithub(user:GitHubContributor, size:Int = 96) {
|
||||
//Main.execAsync(function() {
|
||||
var bytes = GitHub.__requestBytesOnGitHubServers('${user.avatar_url}&size=$size');
|
||||
var bmap = BitmapData.fromBytes(bytes);
|
||||
addPortrait(FlxG.bitmap.add(bmap, false, 'GITHUB-USER:${user.login}'), size);
|
||||
//});
|
||||
}
|
||||
}
|
||||
@@ -23,9 +23,7 @@ class TextOption extends OptionType {
|
||||
public override function onSelect() {
|
||||
super.onSelect();
|
||||
CoolUtil.playMenuSFX(CONFIRM);
|
||||
FlxFlicker.flicker(this, 1, Options.flashingMenu ? 0.06 : 0.15, true, false, function(t) {
|
||||
|
||||
});
|
||||
FlxFlicker.flicker(this, 1, Options.flashingMenu ? 0.06 : 0.15, true, false);
|
||||
selectCallback();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user