fixed 3d and fonts

This commit is contained in:
Yoshman29
2023-04-02 14:06:22 +02:00
parent be2a504a83
commit 9c615caddc
9 changed files with 21 additions and 49 deletions
+1 -2
View File
@@ -143,8 +143,7 @@
<haxedef name="DISCORD_RPC" if="DISCORD_RPC" />
<haxedef name="SHOW_BUILD_ON_FPS" if="SHOW_BUILD_ON_FPS" />
<haxedef name="SOFTCODED_CLASSES" if="SOFTCODED_CLASSES" />
<haxeflag name="--macro" value="funkin.macros.StdDeprecationsRemover.init()" />
<!-- _______________________________ Libraries ______________________________ -->
+1 -1
View File
@@ -77,7 +77,7 @@ class Flx3DCamera extends FlxCamera {
var material:TextureMaterial = null;
if (texturePath != null)
material = new TextureMaterial(Cast.bitmapTexture(texturePath), smoothTexture);
material = new TextureMaterial(Cast.bitmapTexture(Assets.getBitmapData(texturePath, true, false)), smoothTexture);
return loadData(model, context, switch(Path.extension(assetPath).toLowerCase()) {
case "dae": new DAEParser();
+1 -1
View File
@@ -52,7 +52,7 @@ class Flx3DView extends FlxView3D {
var material:TextureMaterial = null;
if (texturePath != null)
material = new TextureMaterial(Cast.bitmapTexture(texturePath), smoothTexture);
material = new TextureMaterial(Cast.bitmapTexture(Assets.getBitmapData(texturePath, true, false)), smoothTexture);
return loadData(model, context, switch(Path.extension(assetPath).toLowerCase()) {
case "dae": new DAEParser();
+1 -1
View File
@@ -1044,7 +1044,7 @@ class PlayState extends MusicBeatState
// accuracyTxt.addFormat(accFormat, accuracyTxt.text.length - rating.rating.length, accuracyTxt.text.length);
if (FlxG.keys.justPressed.ENTER && startedCountdown && canPause)
if (controls.PAUSE && startedCountdown && canPause)
pauseGame();
if (canAccessDebugMenus) {
@@ -1,31 +0,0 @@
package funkin.macros;
#if macro
import haxe.macro.Expr;
import haxe.macro.Context;
import haxe.macro.Compiler;
/**
* Removes all deprecations errors related to `Std.is`
* Written by Yoshman29 to keep you sane.
* Feel free to use this macro on your mod.
*
* Line to add in project.xml:
* `<haxeflag name="--macro" value="funkin.macros.StdDeprecationsRemover.init()" />`
*/
class StdDeprecationsRemover {
public static function init() {
Compiler.addGlobalMetadata('Std', '@:build(funkin.macros.StdDeprecationsRemover.build())');
}
public static function build():Array<Field> {
var fields:Array<Field> = Context.getBuildFields();
for(f in fields)
if (f.name == "is")
f.meta = [for(e in f.meta) if (e.name != ":deprecated") e];
return fields;
}
}
#end
+11
View File
@@ -10,6 +10,9 @@ import openfl.utils.AssetLibrary;
import flixel.graphics.FlxGraphic;
import flixel.util.FlxSignal.FlxTypedSignal;
import lime.text.Font;
import openfl.text.Font as OpenFLFont;
#if MOD_SUPPORT
import sys.FileSystem;
#end
@@ -91,6 +94,14 @@ class ModsFolder {
return AssetLibrary.fromManifest(assets);
}
public static function registerFont(font:Font) {
var openflFont = new OpenFLFont();
@:privateAccess
openflFont.__fromLimeFont(font);
OpenFLFont.registerFont(openflFont);
return font;
}
public static function prepareModLibrary(libName:String, lib:ModsAssetLibrary, force:Bool = false) {
var openLib = prepareLibrary(libName, force);
lib.prefix = 'assets/';
+1 -2
View File
@@ -60,8 +60,7 @@ class ModsFolderLibrary extends AssetLibrary implements ModsAssetLibrary {
return null;
var path = getAssetPath();
editedTimes[id] = FileSystem.stat(path).mtime.getTime();
var e = Font.fromFile(path);
return e;
return ModsFolder.registerFont(Font.fromFile(path));
}
public override function getImage(id:String):Image {
+1 -8
View File
@@ -58,14 +58,7 @@ class ZipFolderLibrary extends AssetLibrary implements ModsAssetLibrary {
}
public override function getFont(id:String):Font {
__parseAsset(id);
var font = Font.fromBytes(unzip(assets[_parsedAsset]));
var openflFont = new OpenFLFont();
@:privateAccess
openflFont.__fromLimeFont(font);
OpenFLFont.registerFont(openflFont);
return font;
return ModsFolder.registerFont(Font.fromBytes(unzip(assets[_parsedAsset])));
}
public override function getImage(id:String):Image {
__parseAsset(id);
+4 -3
View File
@@ -88,16 +88,17 @@ class Assets
@usage var bitmap = new Bitmap (Assets.getBitmapData ("image.png"));
@param id The ID or asset path for the bitmap
@param useCache (Optional) Whether to allow use of the asset cache (Default: true)
@param useCache Whenever the image should be immediately pushed to GPU.
@return A new BitmapData object
**/
public static function getBitmapData(id:String, useCache:Bool = true):BitmapData
public static function getBitmapData(id:String, useCache:Bool = true, pushToGPU:Bool = true):BitmapData
{
#if (lime && tools && !display)
if (useCache && cache.enabled && cache.hasBitmapData(id))
{
var bitmapData = cache.getBitmapData(id);
if (isValidBitmapData(bitmapData))
if (isValidBitmapData(bitmapData) && (pushToGPU || bitmapData.readable))
{
return bitmapData;
}
@@ -111,7 +112,7 @@ class Assets
var bitmapData = image.src;
#else
var bitmapData:BitmapData = null;
if (!Main.forceGPUOnlyBitmapsOff && Options.gpuOnlyBitmaps) {
if (pushToGPU && !Main.forceGPUOnlyBitmapsOff && Options.gpuOnlyBitmaps) {
bitmapData = new OptimizedBitmapData(0, 0, true, 0);
bitmapData.__fromImage(image);
} else {