Store only necessary data for GitHub credits
This commit is contained in:
@@ -21,4 +21,12 @@ typedef GitHubContributor = {
|
||||
var type:String;
|
||||
var site_admin:Bool;
|
||||
var contributions:Int;
|
||||
}
|
||||
|
||||
typedef CreditsGitHubContributor = {
|
||||
var login:String;
|
||||
var avatar_url:String;
|
||||
var html_url:String;
|
||||
var ?id:Int; // Not available in the avatar part
|
||||
var ?contributions:Int; // Not available in the avatar part
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package funkin.menus.credits;
|
||||
import flixel.text.FlxText;
|
||||
import flixel.util.FlxColor;
|
||||
import funkin.backend.system.github.GitHub;
|
||||
import funkin.backend.system.github.GitHubContributor.CreditsGitHubContributor;
|
||||
import funkin.options.PlayerSettings;
|
||||
import funkin.options.type.GithubIconOption;
|
||||
|
||||
@@ -80,7 +81,17 @@ class CreditsCodename extends funkin.options.OptionsScreen {
|
||||
funkin.backend.utils.NativeAPI.showMessageBox("Codename Engine Warning", errMsg, MSG_WARNING);
|
||||
});
|
||||
if(error) return false;
|
||||
Options.contributors = idk;
|
||||
if((idk is Array)) {
|
||||
var contributors:Array<CreditsGitHubContributor> = [];
|
||||
for(e in idk) contributors.push({
|
||||
login: e.login,
|
||||
avatar_url: e.avatar_url,
|
||||
html_url: e.html_url,
|
||||
id: e.id,
|
||||
contributions: e.contributions
|
||||
});
|
||||
Options.contributors = contributors;
|
||||
}
|
||||
Logs.trace('[CreditsCodename] Contributors list Updated!', VERBOSE);
|
||||
|
||||
var errorOnMain:Bool = false;
|
||||
|
||||
@@ -2,6 +2,7 @@ package funkin.menus.credits;
|
||||
|
||||
import funkin.options.OptionsScreen;
|
||||
import funkin.options.TreeMenu;
|
||||
import funkin.backend.system.github.GitHubContributor.CreditsGitHubContributor;
|
||||
import funkin.options.type.*;
|
||||
import haxe.xml.Access;
|
||||
import flixel.util.FlxColor;
|
||||
@@ -64,13 +65,14 @@ class CreditsMain extends TreeMenu {
|
||||
}
|
||||
|
||||
var username = node.getAtt("user");
|
||||
var user = { // Kind of forcing
|
||||
var user:CreditsGitHubContributor = { // Kind of forcing
|
||||
login: username,
|
||||
html_url: 'https://github.com/$username',
|
||||
avatar_url: 'https://github.com/$username.png'
|
||||
};
|
||||
var opt:GithubIconOption = new GithubIconOption(user, desc, null,
|
||||
node.has.customName ? node.att.customName : null, node.has.size ? Std.parseInt(node.att.size) : 96,
|
||||
node.has.customName ? node.att.customName : null,
|
||||
node.has.size ? Std.parseInt(node.att.size) : 96,
|
||||
node.has.portrait ? node.att.portrait.toLowerCase() == "false" ? false : true : true
|
||||
);
|
||||
if (node.has.color)
|
||||
|
||||
@@ -55,7 +55,7 @@ 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 contributors:Array<funkin.backend.system.github.GitHubContributor.CreditsGitHubContributor> = [];
|
||||
public static var mainDevs:Array<Int> = []; // IDs
|
||||
public static var lastUpdated:Null<Float>;
|
||||
|
||||
|
||||
@@ -5,10 +5,11 @@ import flixel.util.FlxColor;
|
||||
import funkin.backend.shaders.CustomShader;
|
||||
import funkin.backend.system.github.GitHub;
|
||||
import openfl.display.BitmapData;
|
||||
import funkin.backend.system.github.GitHubContributor.CreditsGitHubContributor;
|
||||
|
||||
class GithubIconOption extends TextOption
|
||||
{
|
||||
public var user(default, null):Dynamic; // Can possibly be GitHubUser or GitHubContributor
|
||||
public var user(default, null):CreditsGitHubContributor; // Can possibly be GitHubUser or GitHubContributor, but CreditsGitHubContributor has only the fields we need
|
||||
public var icon:GithubUserIcon = null;
|
||||
public var usePortrait(default, set) = true;
|
||||
|
||||
@@ -19,7 +20,7 @@ class GithubIconOption extends TextOption
|
||||
return usePortrait = value;
|
||||
}
|
||||
|
||||
public function new(user:Dynamic, desc:String, ?callback:Void->Void, ?customName:String, size:Int = 96, usePortrait:Bool = true, waitUntilLoad:Float = 0.25) {
|
||||
public function new(user:CreditsGitHubContributor, desc:String, ?callback:Void->Void, ?customName:String, size:Int = 96, usePortrait:Bool = true, waitUntilLoad:Float = 0.25) {
|
||||
super(customName == null ? user.login : customName, desc, callback == null ? function() CoolUtil.openURL(user.html_url) : callback);
|
||||
this.user = user;
|
||||
this.icon = new GithubUserIcon(user, size, waitUntilLoad);
|
||||
@@ -31,10 +32,10 @@ class GithubIconOption extends TextOption
|
||||
class GithubUserIcon extends FlxSprite
|
||||
{
|
||||
public var waitUntilLoad:Null<Float>;
|
||||
private var user:Dynamic;
|
||||
private var user:CreditsGitHubContributor;
|
||||
private var size:Int;
|
||||
|
||||
public override function new(user:Dynamic, size:Int = 96, waitUntilLoad:Float = 0.25) {
|
||||
public override function new(user:CreditsGitHubContributor, size:Int = 96, waitUntilLoad:Float = 0.25) {
|
||||
this.user = user;
|
||||
this.size = size;
|
||||
this.waitUntilLoad = waitUntilLoad;
|
||||
@@ -73,7 +74,7 @@ class GithubUserIcon extends FlxSprite
|
||||
}
|
||||
|
||||
if(planB) {
|
||||
if(unfLink) user = GitHub.getUser(user.login, function(e) Logs.traceColored([Logs.logText('Failed to download github user info for ${user.login}: ${CoolUtil.removeIP(e.message)}', RED)], ERROR)); // Api part - Nex
|
||||
if(unfLink) user = cast GitHub.getUser(user.login, function(e) Logs.traceColored([Logs.logText('Failed to download github user info for ${user.login}: ${CoolUtil.removeIP(e.message)}', RED)], ERROR)); // Api part - Nex
|
||||
try bytes = HttpUtil.requestBytes('${user.avatar_url}&size=$size')
|
||||
catch(e) Logs.traceColored([Logs.logText('Failed to download github pfp for ${user.login}: ${CoolUtil.removeIP(e.message)}', RED)], ERROR);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user