optimized EVEN MORE the cne credits menu
fully asynced and looks better :D
This commit is contained in:
@@ -75,10 +75,12 @@ class Update {
|
||||
// vswhere.exe its used to find any visual studio related installations on the system, including full visual studio ide installations, visual studio build tools installations, and other related components - Nex
|
||||
if (Compiler.getBuildTarget().toLowerCase() == "windows" && new Process('"C:/Program Files (x86)/Microsoft Visual Studio/Installer/vswhere.exe" -property catalog_productDisplayVersion').exitCode(true) == 1) {
|
||||
prettyPrint("Installing Microsoft Visual Studio Community (Dependency)");
|
||||
|
||||
// thanks to @crowplexus for these two lines! - Nex
|
||||
Sys.command("curl -# -O https://download.visualstudio.microsoft.com/download/pr/3105fcfe-e771-41d6-9a1c-fc971e7d03a7/8eb13958dc429a6e6f7e0d6704d43a55f18d02a253608351b6bf6723ffdaf24e/vs_Community.exe");
|
||||
Sys.command("vs_Community.exe --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.19041 -p");
|
||||
FileSystem.deleteFile("vs_Community.exe");
|
||||
|
||||
FileSystem.deleteFile("vs_Community.exe");
|
||||
prettyPrint('If it didn\'t say it before: Because of this component if you want to compile you have to restart the device.');
|
||||
Sys.print("Do you wish to do it now [y/n]? ");
|
||||
if(Sys.stdin().readLine().toLowerCase() == "y") Sys.command("shutdown /r /t 0 /f");
|
||||
|
||||
@@ -63,7 +63,7 @@ class HttpUtil
|
||||
{
|
||||
// 301: Moved Permanently, 302: Found (Moved Temporarily), 307: Temporary Redirect, 308: Permanent Redirect - Nex
|
||||
case 301 | 302 | 307 | 308:
|
||||
trace("Redirected with status code: " + status);
|
||||
Logs.traceColored([Logs.logText('[Connection Status] ', BLUE), Logs.logText('Redirected with status code: ', YELLOW), Logs.logText('$status', GREEN)], WARNING);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package funkin.menus.credits;
|
||||
|
||||
import funkin.options.PlayerSettings;
|
||||
import flixel.util.FlxColor;
|
||||
import funkin.backend.system.github.GitHub;
|
||||
import funkin.options.type.GithubIconOption;
|
||||
import flixel.text.FlxText;
|
||||
@@ -9,44 +11,74 @@ using StringTools;
|
||||
class CreditsCodename extends funkin.options.OptionsScreen {
|
||||
public var error:Bool = false;
|
||||
public var author:String = "FNF-CNE-Devs";
|
||||
public var mainDevCol:FlxColor = 0xFF9C35D5;
|
||||
public var minContrCol:FlxColor = 0xFFB4A7DA;
|
||||
public var totalContributions:Int = 0;
|
||||
|
||||
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();
|
||||
tryUpdating(true);
|
||||
}
|
||||
|
||||
// blame the secondary threads if the code has to look this bad - Nex
|
||||
private var _canReset:Bool = true;
|
||||
private var _downloadingSteps:Int = 0;
|
||||
public override function update(elapsed:Float) {
|
||||
if (funkin.options.PlayerSettings.solo.controls.RESET && checkUpdate()) {
|
||||
super.update(elapsed);
|
||||
|
||||
if (_downloadingSteps == 2) {
|
||||
_downloadingSteps = 0;
|
||||
_canReset = true;
|
||||
displayList();
|
||||
} else if (_downloadingSteps == 1) {
|
||||
_downloadingSteps = 0;
|
||||
_canReset = true;
|
||||
updateMenuDesc();
|
||||
}
|
||||
super.update(elapsed);
|
||||
else if(_canReset && PlayerSettings.solo.controls.RESET) tryUpdating();
|
||||
}
|
||||
|
||||
public function tryUpdating(forceDisplaying:Bool = false) {
|
||||
updateMenuDesc("Downloading List...");
|
||||
_canReset = false;
|
||||
Main.execAsync(function() {
|
||||
if(checkUpdate() || forceDisplaying) _downloadingSteps = 2;
|
||||
else _downloadingSteps = 1;
|
||||
});
|
||||
}
|
||||
|
||||
public override function updateMenuDesc(?txt:String) {
|
||||
if(!_canReset) return;
|
||||
super.updateMenuDesc(txt);
|
||||
parent.treeParent.pathDesc.applyMarkup(parent.treeParent.pathDesc.text, [new FlxTextFormatMarkerPair(new FlxTextFormat(0xFF9C35D5), "*")]);
|
||||
updateMarkup();
|
||||
}
|
||||
|
||||
public function updateMarkup() {
|
||||
if(parent == null || parent.treeParent == null) return;
|
||||
var text:String = parent.treeParent.pathDesc.text;
|
||||
parent.treeParent.pathDesc.text = "";
|
||||
parent.treeParent.pathDesc.applyMarkup(text, [
|
||||
new FlxTextFormatMarkerPair(new FlxTextFormat(mainDevCol), '*'),
|
||||
new FlxTextFormatMarkerPair(new FlxTextFormat(FlxColor.interpolate(minContrCol, mainDevCol, Options.contributors[curSelected].contributions / totalContributions)), '~')
|
||||
]);
|
||||
}
|
||||
|
||||
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
|
||||
if(Options.lastUpdated != null && curTime < Options.lastUpdated + 120000) return false; // Fuck you Github rate limits - Nex
|
||||
Options.lastUpdated = curTime;
|
||||
|
||||
error = false;
|
||||
//Main.execAsync(function() {
|
||||
var idk = GitHub.getContributors(author, "CodenameEngine", function(e) {
|
||||
error = true;
|
||||
var errMsg:String = 'Error while trying to download contributors list:\n${CoolUtil.removeIP(e.message)}';
|
||||
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!');
|
||||
trace('Contributors list Updated!');
|
||||
|
||||
var errorOnMain:Bool = false;
|
||||
var idk2 = GitHub.getOrganizationMembers(author, function(e) {
|
||||
@@ -55,7 +87,10 @@ class CreditsCodename extends funkin.options.OptionsScreen {
|
||||
Logs.traceColored([Logs.logText(errMsg.replace('\n', ' '), RED)], ERROR);
|
||||
funkin.backend.utils.NativeAPI.showMessageBox("Codename Engine Warning", errMsg, MSG_WARNING);
|
||||
});
|
||||
if(!errorOnMain) Options.mainDevs = [for(m in idk2) m.id];
|
||||
if(!errorOnMain) {
|
||||
Options.mainDevs = [for(m in idk2) m.id];
|
||||
trace('Main Devs list Updated!');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -70,13 +105,17 @@ class CreditsCodename extends funkin.options.OptionsScreen {
|
||||
remove(members[0], true);
|
||||
}
|
||||
|
||||
var totalContributions = 0;
|
||||
totalContributions = 0;
|
||||
for(c in Options.contributors) totalContributions += c.contributions;
|
||||
for(c in Options.contributors) {
|
||||
var desc:String = 'Total Contributions: ${c.contributions} / ${totalContributions} (${FlxMath.roundDecimal(c.contributions / totalContributions * 100, 2)}%) - Select to open GitHub account';
|
||||
if(Options.mainDevs.contains(c.id)) desc += " *- Public member of the main Devs!*";
|
||||
var opt:GithubIconOption = new GithubIconOption(c, desc);
|
||||
var opt:GithubIconOption = new GithubIconOption(c, 'Total Contributions: ~${c.contributions}~ / *${totalContributions}* (~${FlxMath.roundDecimal(c.contributions / totalContributions * 100, 2)}%~) - Select to open GitHub account');
|
||||
if(Options.mainDevs.contains(c.id)) {
|
||||
opt.desc += " *- Public member of the main Devs!*";
|
||||
@:privateAccess opt.__text.color = mainDevCol;
|
||||
}
|
||||
add(opt);
|
||||
}
|
||||
|
||||
updateMenuDesc();
|
||||
}
|
||||
}
|
||||
@@ -70,11 +70,8 @@ class OptionsScreen extends FlxTypedSpriteGroup<OptionType> {
|
||||
}
|
||||
|
||||
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);
|
||||
if (parent == null || parent.treeParent == null) return;
|
||||
parent.treeParent.updateDesc(customTxt != null ? customTxt : members[curSelected].desc);
|
||||
}
|
||||
|
||||
public dynamic function onClose(o:OptionsScreen) {}
|
||||
|
||||
@@ -19,10 +19,10 @@ 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) {
|
||||
public function new(user:Dynamic, 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);
|
||||
this.icon = new GithubUserIcon(user, size, waitUntilLoad);
|
||||
this.usePortrait = usePortrait;
|
||||
add(icon);
|
||||
}
|
||||
@@ -30,22 +30,28 @@ class GithubIconOption extends TextOption
|
||||
|
||||
class GithubUserIcon extends FlxSprite
|
||||
{
|
||||
private var loading:Bool = false;
|
||||
public var waitUntilLoad:Null<Float>;
|
||||
private var user:Dynamic;
|
||||
private var size:Int;
|
||||
|
||||
public override function new(user:Dynamic, size:Int = 96) {
|
||||
public override function new(user:Dynamic, size:Int = 96, waitUntilLoad:Float = 0.25) {
|
||||
this.user = user;
|
||||
this.size = size;
|
||||
this.waitUntilLoad = waitUntilLoad;
|
||||
super();
|
||||
makeGraphic(size, size, FlxColor.TRANSPARENT);
|
||||
antialiasing = true;
|
||||
}
|
||||
|
||||
override function update(elapsed:Float) {
|
||||
if(waitUntilLoad > 0) waitUntilLoad -= elapsed;
|
||||
super.update(elapsed);
|
||||
}
|
||||
|
||||
final mutex = new sys.thread.Mutex();
|
||||
override function drawComplex(camera:FlxCamera):Void { // Making the image downlaod only if the player actually sees it on the screeeeen - Nex
|
||||
if(!loading) {
|
||||
loading = true;
|
||||
if(waitUntilLoad <= 0) {
|
||||
waitUntilLoad = null;
|
||||
Main.execAsync(function() {
|
||||
var key:String = 'GITHUB-USER:${user.login}';
|
||||
var bmap:Dynamic = FlxG.bitmap.get(key);
|
||||
|
||||
Reference in New Issue
Block a user