contributors menu
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
1739
|
||||
1742
|
||||
@@ -28,6 +28,22 @@ class GitHub {
|
||||
return [];
|
||||
}
|
||||
|
||||
public static function getContributors(user:String, repository:String, ?onError:Exception->Void):Array<GitHubContributor> {
|
||||
try {
|
||||
var url = 'https://api.github.com/repos/${user}/${repository}/contributors';
|
||||
|
||||
var data = Json.parse(__requestOnGitHubServers(url));
|
||||
if (!(data is Array))
|
||||
throw __parseGitHubException(data);
|
||||
|
||||
return data;
|
||||
} catch(e) {
|
||||
if (onError != null)
|
||||
onError(e);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters all releases gotten by `getReleases`
|
||||
* @param releases Releases
|
||||
@@ -38,7 +54,7 @@ class GitHub {
|
||||
public static inline function filterReleases(releases:Array<GitHubRelease>, keepPrereleases:Bool = true, keepDrafts:Bool = false)
|
||||
return [for(release in releases) if (release != null && (!release.prerelease || (release.prerelease && keepPrereleases)) && (!release.draft || (release.draft && keepDrafts))) release];
|
||||
|
||||
private static function __requestOnGitHubServers(url:String) {
|
||||
public static function __requestOnGitHubServers(url:String) {
|
||||
var h = new Http(url);
|
||||
h.setHeader("User-Agent", "request");
|
||||
var r = null;
|
||||
@@ -51,6 +67,19 @@ class GitHub {
|
||||
h.request(false);
|
||||
return r;
|
||||
}
|
||||
public static function __requestBytesOnGitHubServers(url:String) {
|
||||
var h = new Http(url);
|
||||
h.setHeader("User-Agent", "request");
|
||||
var r = null;
|
||||
h.onBytes = function(d) {
|
||||
r = d;
|
||||
}
|
||||
h.onError = function(e) {
|
||||
throw e;
|
||||
}
|
||||
h.request(false);
|
||||
return r;
|
||||
}
|
||||
private static function __parseGitHubException(obj:Dynamic):GitHubException {
|
||||
var msg:String = "(No message)";
|
||||
var url:String = "(No API url)";
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package funkin.github;
|
||||
|
||||
typedef GitHubContributor = {
|
||||
var login:String;
|
||||
var id:Int;
|
||||
var node_id:String;
|
||||
var avatar_url:String;
|
||||
var gravatar_id:String;
|
||||
var url:String;
|
||||
var html_url:String;
|
||||
var followers_url:String;
|
||||
var following_url:String;
|
||||
var gists_url:String;
|
||||
var starred_url:String;
|
||||
var subscriptions_url:String;
|
||||
var organizations_url:String;
|
||||
var repos_url:String;
|
||||
var events_url:String;
|
||||
var received_events_url:String;
|
||||
var type:String;
|
||||
var site_admin:Bool;
|
||||
var contributions:Int;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import funkin.options.Options;
|
||||
import funkin.system.Discord.DiscordClient;
|
||||
#end
|
||||
import flixel.FlxG;
|
||||
import funkin.menus.credits.CreditsMain;
|
||||
import flixel.FlxObject;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.FlxState;
|
||||
@@ -176,44 +177,37 @@ class MainMenuState extends MusicBeatState
|
||||
}
|
||||
|
||||
function selectItem() {
|
||||
if (optionShit[curSelected] == 'donate')
|
||||
{
|
||||
#if linux
|
||||
Sys.command('/usr/bin/xdg-open', ["https://ninja-muffin24.itch.io/funkin", "&"]);
|
||||
#else
|
||||
FlxG.openURL('https://ninja-muffin24.itch.io/funkin');
|
||||
#end
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedSomethin = true;
|
||||
CoolUtil.playMenuSFX(1);
|
||||
selectedSomethin = true;
|
||||
CoolUtil.playMenuSFX(1);
|
||||
|
||||
if (Options.flashingMenu) FlxFlicker.flicker(magenta, 1.1, 0.15, false);
|
||||
if (Options.flashingMenu) FlxFlicker.flicker(magenta, 1.1, 0.15, false);
|
||||
|
||||
menuItems.forEach(function(spr:FlxSprite)
|
||||
menuItems.forEach(function(spr:FlxSprite)
|
||||
{
|
||||
if (spr.ID != curSelected) return;
|
||||
FlxFlicker.flicker(spr, 1, Options.flashingMenu ? 0.06 : 0.15, false, false, function(flick:FlxFlicker)
|
||||
{
|
||||
if (spr.ID != curSelected) return;
|
||||
FlxFlicker.flicker(spr, 1, Options.flashingMenu ? 0.06 : 0.15, false, false, function(flick:FlxFlicker)
|
||||
var daChoice:String = optionShit[curSelected];
|
||||
|
||||
switch (daChoice)
|
||||
{
|
||||
var daChoice:String = optionShit[curSelected];
|
||||
case 'story mode':
|
||||
FlxG.switchState(new StoryMenuState());
|
||||
trace("Story Menu Selected");
|
||||
case 'freeplay':
|
||||
FlxG.switchState(new FreeplayState());
|
||||
|
||||
switch (daChoice)
|
||||
{
|
||||
case 'story mode':
|
||||
FlxG.switchState(new StoryMenuState());
|
||||
trace("Story Menu Selected");
|
||||
case 'freeplay':
|
||||
FlxG.switchState(new FreeplayState());
|
||||
trace("Freeplay Menu Selected");
|
||||
case 'donate':
|
||||
FlxG.switchState(new CreditsMain());
|
||||
|
||||
trace("Freeplay Menu Selected");
|
||||
trace("Donate Menu Selected");
|
||||
|
||||
case 'options':
|
||||
FlxG.switchState(new OptionsMenu(false));
|
||||
}
|
||||
});
|
||||
case 'options':
|
||||
FlxG.switchState(new OptionsMenu(false));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function changeItem(huh:Int = 0)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package funkin.menus.credits;
|
||||
|
||||
import flixel.FlxG;
|
||||
import openfl.display.BitmapData;
|
||||
import flixel.FlxSprite;
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
import funkin.github.GitHub;
|
||||
import funkin.menus.MainMenuState;
|
||||
|
||||
class CreditsCodename extends MusicBeatState {
|
||||
public override function create() {
|
||||
super.create();
|
||||
|
||||
var bg:FlxSprite = new FlxSprite(-80).loadAnimatedGraphic(Paths.image('menus/menuBGBlue'));
|
||||
bg.scrollFactor.set();
|
||||
bg.scale.set(1.15, 1.15);
|
||||
bg.updateHitbox();
|
||||
bg.screenCenter();
|
||||
bg.antialiasing = true;
|
||||
add(bg);
|
||||
|
||||
var contributors = GitHub.getContributors("YoshiCrafter29", "CodenameEngine", function(e) {
|
||||
trace(e);
|
||||
});
|
||||
trace(contributors);
|
||||
for(k=>c in contributors) {
|
||||
var bmap = BitmapData.fromBytes(GitHub.__requestBytesOnGitHubServers(c.avatar_url));
|
||||
|
||||
var spr = new FlxSprite(0, k * 50);
|
||||
spr.loadGraphic(FlxG.bitmap.add(bmap, false, 'GITHUB-USER:${c.login}'));
|
||||
spr.setUnstretchedGraphicSize(50, 50, false);
|
||||
add(spr);
|
||||
}
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
if (controls.BACK) {
|
||||
CoolUtil.playMenuSFX(2);
|
||||
FlxTransitionableState.skipNextTransIn = FlxTransitionableState.skipNextTransOut = true;
|
||||
FlxG.switchState(new MainMenuState());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package funkin.menus.credits;
|
||||
|
||||
import flixel.addons.transition.FlxTransitionableState;
|
||||
import funkin.options.OptionsScreen;
|
||||
import flixel.FlxG;
|
||||
import funkin.options.type.*;
|
||||
|
||||
class CreditsMain extends OptionsScreen {
|
||||
public override function create() {
|
||||
options = [
|
||||
// TODO: Custom Credits
|
||||
new TextOption("Codename Engine", "Select this to see all of the contributors of the engine!", function() {
|
||||
FlxTransitionableState.skipNextTransIn = FlxTransitionableState.skipNextTransOut = 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() {
|
||||
#if linux
|
||||
Sys.command('/usr/bin/xdg-open', ["https://ninja-muffin24.itch.io/funkin", "&"]);
|
||||
#else
|
||||
FlxG.openURL('https://ninja-muffin24.itch.io/funkin');
|
||||
#end
|
||||
})
|
||||
];
|
||||
super.create();
|
||||
}
|
||||
}
|
||||
@@ -150,7 +150,7 @@ class Conductor
|
||||
if (lastSongPos != (lastSongPos = FlxG.sound.music.time)) {
|
||||
// update conductor
|
||||
var timeUntilUpdate = -(lastSongPosTime - (lastSongPosTime = Lib.getTimer()));
|
||||
speed = FlxMath.bound(FlxMath.lerp(speed, timeUntilUpdate / (lastSongPos - lastPos), FlxMath.bound(Math.abs(speed - 1), 0, 1)), 0, 2);
|
||||
speed = FlxMath.bound(FlxMath.lerp(speed, timeUntilUpdate / (lastSongPos - lastPos), elapsed), 0.85, 1.15);
|
||||
songPosition = lastSongPos;
|
||||
} else {
|
||||
songPosition += elapsed * 1000 * speed;
|
||||
|
||||
Reference in New Issue
Block a user