contributors menu done
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
#pragma header
|
||||
|
||||
// shader used in GitHub credits
|
||||
|
||||
void main() {
|
||||
float len = length(openfl_TextureCoordv - vec2(0.5, 0.5));
|
||||
float r = 0.5 - (1.0 / openfl_TextureSize.x);
|
||||
vec4 c = flixel_texture2D(bitmap, openfl_TextureCoordv);
|
||||
vec4 color = mix(vec4(0, 0, 0, 0.5), c, c.a);
|
||||
gl_FragColor = color * clamp(1 - ((len - r) * openfl_TextureSize.x), 0, 1);
|
||||
}
|
||||
+1
-1
@@ -1 +1 @@
|
||||
2246
|
||||
2253
|
||||
@@ -1,19 +1,25 @@
|
||||
package funkin.menus.credits;
|
||||
|
||||
import funkin.shaders.CustomShader;
|
||||
import flixel.math.FlxMath;
|
||||
import funkin.options.type.TextOption;
|
||||
import funkin.options.OptionsScreen;
|
||||
import flixel.graphics.FlxGraphic;
|
||||
import flixel.FlxG;
|
||||
import openfl.display.BitmapData;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
import funkin.github.GitHub;
|
||||
import funkin.github.GitHubContributor;
|
||||
import funkin.menus.MainMenuState;
|
||||
|
||||
class CreditsCodename extends MusicBeatState {
|
||||
class CreditsCodename extends OptionsScreen {
|
||||
public var contributorsSprites:Array<FlxSprite> = [];
|
||||
public var contributorsAvatars:Array<FlxGraphic> = [];
|
||||
public var avatarLoadListId:Int = 0;
|
||||
public var contributors:Array<GitHubContributor>;
|
||||
|
||||
public override function create() {
|
||||
super.create();
|
||||
|
||||
var bg:FlxSprite = new FlxSprite(-80).loadAnimatedGraphic(Paths.image('menus/menuBGBlue'));
|
||||
bg.scrollFactor.set();
|
||||
@@ -23,20 +29,42 @@ class CreditsCodename extends MusicBeatState {
|
||||
bg.antialiasing = true;
|
||||
add(bg);
|
||||
|
||||
var contributors = GitHub.getContributors("YoshiCrafter29", "CodenameEngine", function(e) {
|
||||
contributors = GitHub.getContributors("YoshiCrafter29", "CodenameEngine", function(e) {
|
||||
trace(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();
|
||||
}
|
||||
|
||||
public override function createAdditional() {
|
||||
for(k=>c in contributors) {
|
||||
var spr = new FlxSprite(0, k * 50);
|
||||
var spr = new FlxSprite(0, k * 96);
|
||||
spr.antialiasing = true;
|
||||
spr.setUnstretchedGraphicSize(50, 50, false);
|
||||
spr.setUnstretchedGraphicSize(96, 96, false);
|
||||
spr.updateHitbox();
|
||||
spr.shader = new CustomShader('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=64');
|
||||
var bytes = GitHub.__requestBytesOnGitHubServers('${c.avatar_url}&size=96');
|
||||
var bmap = BitmapData.fromBytes(bytes);
|
||||
contributorsAvatars.push(FlxG.bitmap.add(bmap, false, 'GITHUB-USER:${c.login}'));
|
||||
if (destroyed) return;
|
||||
@@ -46,19 +74,21 @@ class CreditsCodename extends MusicBeatState {
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
if (controls.BACK) {
|
||||
CoolUtil.playMenuSFX(CANCEL);
|
||||
FlxTransitionableState.skipNextTransIn = FlxTransitionableState.skipNextTransOut = true;
|
||||
FlxG.switchState(new MainMenuState());
|
||||
}
|
||||
if (avatarLoadListId < contributorsAvatars.length) {
|
||||
for(i in avatarLoadListId...contributorsAvatars.length) {
|
||||
var v = contributorsSprites[i];
|
||||
v.loadGraphic(contributorsAvatars[i]);
|
||||
v.setUnstretchedGraphicSize(50, 50, false);
|
||||
v.setUnstretchedGraphicSize(96, 96, false);
|
||||
v.updateHitbox();
|
||||
}
|
||||
avatarLoadListId = contributorsAvatars.length;
|
||||
}
|
||||
|
||||
for(k=>spr in contributorsSprites) {
|
||||
var alpha = options[k];
|
||||
spr.x = alpha.x - 10;
|
||||
spr.y = alpha.y - ((alpha.height - spr.height) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
public override function destroy() {
|
||||
|
||||
@@ -14,11 +14,7 @@ class CreditsMain extends OptionsScreen {
|
||||
FlxG.switchState(new CreditsCodename());
|
||||
}),
|
||||
new TextOption("Friday Night Funkin'", "Select this to open the itch.io page of the original game to donate!", function() {
|
||||
#if linux
|
||||
Sys.command('/usr/bin/xdg-open', ["https://ninja-muffin24.itch.io/funkin", "&"]);
|
||||
#else
|
||||
FlxG.openURL('https://ninja-muffin24.itch.io/funkin');
|
||||
#end
|
||||
CoolUtil.openURL("https://ninja-muffin24.itch.io/funkin");
|
||||
})
|
||||
];
|
||||
super.create();
|
||||
|
||||
@@ -51,6 +51,14 @@ class OptionsScreen extends MusicBeatState {
|
||||
bg.antialiasing = true;
|
||||
add(bg);
|
||||
|
||||
|
||||
for(k=>option in options) {
|
||||
option.setPosition(k * 20, 10 + (k * optionHeight));
|
||||
add(option);
|
||||
}
|
||||
|
||||
createAdditional();
|
||||
|
||||
descText = new FunkinText(0, 0);
|
||||
descText.alignment = CENTER;
|
||||
descText.scrollFactor.set();
|
||||
@@ -65,14 +73,10 @@ class OptionsScreen extends MusicBeatState {
|
||||
add(descDrop);
|
||||
|
||||
descText.antialiasing = descDrop.antialiasing = true;
|
||||
|
||||
for(k=>option in options) {
|
||||
option.setPosition(k * 20, 10 + (k * optionHeight));
|
||||
add(option);
|
||||
}
|
||||
changeSelection(1);
|
||||
}
|
||||
|
||||
public function createAdditional() {}
|
||||
public var scrollDest:FlxPoint = FlxPoint.get(0, 0);
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
|
||||
@@ -401,6 +401,14 @@ class CoolUtil
|
||||
array.push(a);
|
||||
return array;
|
||||
}
|
||||
|
||||
public static function openURL(url:String) {
|
||||
#if linux
|
||||
Sys.command('/usr/bin/xdg-open', [url, "&"]);
|
||||
#else
|
||||
FlxG.openURL(url);
|
||||
#end
|
||||
}
|
||||
}
|
||||
|
||||
enum abstract CoolSfx(Int) from Int {
|
||||
|
||||
Reference in New Issue
Block a user