Merge remote-tracking branch 'upstream/main'
This commit is contained in:
@@ -27,6 +27,7 @@ class Options
|
||||
public static var antialiasing:Bool = true;
|
||||
public static var volume:Float = 1;
|
||||
public static var week6PixelPerfect:Bool = true;
|
||||
public static var gameplayShaders:Bool = true;
|
||||
public static var colorHealthBar:Bool = true;
|
||||
public static var lowMemoryMode:Bool = false;
|
||||
public static var betaUpdates:Bool = false;
|
||||
@@ -54,7 +55,9 @@ class Options
|
||||
public static var contributors:Array<funkin.backend.system.github.GitHubContributor> = [];
|
||||
public static var lastUpdated:Null<Float>;
|
||||
|
||||
// CHARTER
|
||||
/**
|
||||
* CHARTER
|
||||
*/
|
||||
public static var charterMetronomeEnabled:Bool = false;
|
||||
public static var charterShowSections:Bool = true;
|
||||
public static var charterShowBeats:Bool = true;
|
||||
|
||||
@@ -23,6 +23,10 @@ class AppearanceOptions extends OptionsScreen {
|
||||
"Pixel Perfect Effect",
|
||||
"If checked, Week 6 will have a pixel perfect effect to it enabled, aligning every pixel on the screen.",
|
||||
"week6PixelPerfect"));
|
||||
add(new Checkbox(
|
||||
"Gameplay Shaders",
|
||||
"If unchecked, gameplay shaders (visual effects like Thorns's Chromatic Aberration) wont be loaded; this may be helpful on weak devices.",
|
||||
"gameplayShaders"));
|
||||
add(new Checkbox(
|
||||
"Flashing Menu",
|
||||
"If unchecked, will disable menu flashing when you select an option in the Main Menu, and other flashes will be slower.",
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package funkin.options.type;
|
||||
|
||||
import openfl.display.BitmapData;
|
||||
import flixel.graphics.FlxGraphic;
|
||||
import funkin.backend.shaders.CustomShader;
|
||||
import funkin.backend.system.github.GitHub;
|
||||
import flixel.util.FlxColor;
|
||||
|
||||
class GithubIconOption extends TextOption
|
||||
{
|
||||
public var user(default, null):Dynamic; // Can possibly be GitHubUser or GitHubContributor - Nex_isDumb
|
||||
public var icon:GithubUserIcon = null;
|
||||
public var usePortrait(default, set) = true;
|
||||
|
||||
public function set_usePortrait(value:Bool)
|
||||
{
|
||||
if (icon == null) return usePortrait = false;
|
||||
icon.shader = (value ? new CustomShader('engine/circleProfilePicture') : null);
|
||||
return usePortrait = value;
|
||||
}
|
||||
|
||||
public function new(user:Dynamic, desc:String, ?callback:Void->Void, ?customName:String, size:Int = 96, usePortrait:Bool = true) {
|
||||
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.usePortrait = usePortrait;
|
||||
add(icon);
|
||||
}
|
||||
}
|
||||
|
||||
class GithubUserIcon extends FlxSprite
|
||||
{
|
||||
private var loading:Bool = false;
|
||||
private var user:Dynamic;
|
||||
private var size:Int;
|
||||
|
||||
public override function new(user:Dynamic, size:Int = 96) {
|
||||
this.user = user;
|
||||
this.size = size;
|
||||
super();
|
||||
makeGraphic(size, size, FlxColor.TRANSPARENT);
|
||||
antialiasing = true;
|
||||
}
|
||||
|
||||
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_isDumb
|
||||
if(!loading) {
|
||||
loading = true;
|
||||
Main.execAsync(function() {
|
||||
var key:String = 'GITHUB-USER:${user.login}';
|
||||
var bmap:Dynamic = FlxG.bitmap.get(key);
|
||||
|
||||
if(bmap == null) {
|
||||
trace('Downloading avatar: ${user.login}');
|
||||
var unfLink:Bool = StringTools.endsWith(user.avatar_url, '.png');
|
||||
var planB:Bool = true;
|
||||
|
||||
var bytes = null;
|
||||
if(unfLink) {
|
||||
try bytes = GitHub.__requestBytesOnGitHubServers('${user.avatar_url}?size=$size')
|
||||
catch(e) Logs.traceColored([Logs.logText('Failed to download github pfp for ${user.login}: ${CoolUtil.removeIP(e.message)} - (Retrying using the api..)', RED)], ERROR);
|
||||
|
||||
if(bytes != null) {
|
||||
bmap = BitmapData.fromBytes(bytes);
|
||||
planB = false;
|
||||
}
|
||||
}
|
||||
|
||||
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_isDumb
|
||||
try bytes = GitHub.__requestBytesOnGitHubServers('${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);
|
||||
|
||||
if(bytes != null) bmap = BitmapData.fromBytes(bytes);
|
||||
}
|
||||
|
||||
if(bmap != null) try {
|
||||
mutex.acquire(); // Avoiding critical section - Nex_isDumb
|
||||
var leGraphic:FlxGraphic = FlxG.bitmap.add(bmap, false, key);
|
||||
leGraphic.persist = true;
|
||||
updateDaFunni(leGraphic);
|
||||
bmap = null;
|
||||
mutex.release();
|
||||
} catch(e) {
|
||||
Logs.traceColored([Logs.logText('Failed to update the pfp for ${user.login}: ${e.message}', RED)], ERROR);
|
||||
}
|
||||
} else {
|
||||
mutex.acquire();
|
||||
updateDaFunni(bmap);
|
||||
mutex.release();
|
||||
}
|
||||
});
|
||||
}
|
||||
super.drawComplex(camera);
|
||||
}
|
||||
|
||||
public inline function updateDaFunni(graphic:FlxGraphic) {
|
||||
loadGraphic(graphic);
|
||||
this.setUnstretchedGraphicSize(size, size, false);
|
||||
updateHitbox();
|
||||
x += 90 - width;
|
||||
}
|
||||
}
|
||||
@@ -24,5 +24,4 @@ class OptionType extends FlxSpriteGroup {
|
||||
super.update(elapsed);
|
||||
alpha = (selected ? 1 : 0.6);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +1,21 @@
|
||||
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) {
|
||||
public function new(name:String, desc:String, callback:Void->Void, ?graphic:FlxGraphic, size:Int = 96, usePortrait:Bool = true) {
|
||||
super(name, desc, callback);
|
||||
if (graphic != null) addPortrait(graphic, size);
|
||||
if (graphic != null) addPortrait(graphic, size, usePortrait);
|
||||
}
|
||||
|
||||
public function addPortrait(graphic:FlxGraphic, size:Int = 96) {
|
||||
public function addPortrait(graphic:FlxGraphic, size:Int = 96, usePortrait:Bool = true) {
|
||||
if (portrait == null) {
|
||||
portrait = new FlxSprite();
|
||||
portrait.antialiasing = true;
|
||||
portrait.shader = new CustomShader('engine/circleProfilePicture');
|
||||
if(usePortrait) portrait.shader = new CustomShader('engine/circleProfilePicture');
|
||||
add(portrait);
|
||||
}
|
||||
portrait.loadGraphic(graphic);
|
||||
@@ -26,12 +23,4 @@ class PortraitOption extends TextOption {
|
||||
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);
|
||||
//});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user