Skip to content

Commit

Permalink
finally can remove the web preload bullshit from project xml
Browse files Browse the repository at this point in the history
libraries can suck me cock
  • Loading branch information
MaybeMaru committed Apr 15, 2024
1 parent 3904d8e commit b60ceec
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 37 deletions.
20 changes: 0 additions & 20 deletions Project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@
<!--If to enable custom classes support in Hscript-->
<define name="CUSTOM_CLASSES" />

<!--Web stuff, ill remove later probably-->
<define name="PRELOAD_ALL" unless="web" />
<define name="NO_PRELOAD_ALL" if="web"/>

<!-- _____________________________ Path Settings ____________________________ -->

<set name="BUILD_DIR" value="export/debug" if="debug" />
Expand All @@ -68,28 +64,12 @@
<classpath name="source" />

<assets path="assets/preload" rename="assets"/>

<section if="PRELOAD_ALL">
<library name="songs" preload="true" />
<library name="shared" preload="true" />
<library name="weeks" preload="true" />
</section>

<section if="NO_PRELOAD_ALL">
<library name="songs" preload="false" />
<library name="shared" preload="false" />
<library name="weeks" preload="false" />
</section>

<assets path="assets/songs"/>
<assets path="assets/shared"/>
<assets path="assets/weeks"/>
<assets path="assets/fonts"/>
<assets path="assets/videos"/>

<!--<assets path="assets/songs" library="songs"/>
<assets path="assets/shared" library="shared"/>
<assets path="assets/weeks" library="weeks"/>-->

<assets path='example_mods' rename='mods' embed='false' if="MODS_ALLOWED"/>
<assets path='art/readme.txt' rename='do NOT readme.txt' if="desktop" />
Expand Down
9 changes: 5 additions & 4 deletions source/FPS_Mem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ class FPS_Mem extends TextField

static inline var memDiv:Float = 1 / 1024 / 1024 * 100;
static inline function formatBytes(bytes:Float):Float {
return
#if web FlxMath.roundDecimal( #end
Math.round(bytes * memDiv) * 0.01
#if web , 2 ) #end ;
#if web
return FlxMath.roundDecimal(Math.round(bytes * memDiv) * 0.01, 2 );
#else
return Math.round(bytes * memDiv) * 0.01;
#end
}

var memPeak:Float = 0;
Expand Down
4 changes: 4 additions & 0 deletions source/funkin/states/LoadingState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class LoadingState extends MusicBeatState
songAssets.push(inst);
if (Paths.exists(voices, MUSIC))
songAssets.push(voices);
#else
#if web
//TODO: may need to make a custom loading screen for web
#end
#end
}

Expand Down
1 change: 0 additions & 1 deletion source/funkin/util/CoolUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class CoolUtil {

inline public static function getFileContent(path:String):String {
#if desktop
path = Paths.removeAssetLib(path);
if (FileSystem.exists(path))
return File.getContent(path);
#else
Expand Down
6 changes: 1 addition & 5 deletions source/funkin/util/Paths.hx
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,12 @@ class Paths

inline static public function exists(file:String, type:AssetType):Bool {
#if desktop
return FileSystem.exists(removeAssetLib(file));
return FileSystem.exists(file);
#else
return OpenFlAssets.exists(file, type);
#end
}

inline static public function removeAssetLib(path:String):String {
return #if desktop path.contains(':') ? path.split(':')[1] : #end path;
}

// Returns [file Mod, file Name]
inline static public function getFileMod(dir:String):Array<String> {
var dirParts = dir.split('/');
Expand Down
18 changes: 11 additions & 7 deletions source/funkin/util/backend/AssetManager.hx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ class LodGraphic extends FlxGraphic
imageFrame.frame.sourceSize *= lodScale;
}

override function set_bitmap(value:BitmapData):BitmapData {
override function set_bitmap(value:BitmapData):BitmapData
{
if (value != null)
{
bitmap = value;
Expand Down Expand Up @@ -344,6 +345,11 @@ class AssetManager
}

var bitmap = __getFileBitmap(path);

#if web
if (bitmap == null) // Testing fail safe while i figure this shit out
bitmap = new BitmapData(5,5,false,FlxColor.MAGENTA);
#end

return __cacheFromBitmap(key, bitmap, staticAsset, lodLevel, useTexture);
}
Expand Down Expand Up @@ -410,9 +416,8 @@ class AssetManager
@:noCompletion
static inline function __getFileBitmap(path:String):BitmapData {
#if desktop
var desktopPath = Paths.removeAssetLib(path);
if (!desktopPath.startsWith('assets'))
return BitmapData.fromFile(desktopPath);
if (!path.startsWith('assets'))
return BitmapData.fromFile(path);
#end

return OpenFlAssets.getBitmapData(path, true);
Expand Down Expand Up @@ -452,9 +457,8 @@ class AssetManager
@:noCompletion
static inline function __getFileSound(path:String):Sound {
#if desktop
var desktopPath = Paths.removeAssetLib(path);
if (!desktopPath.startsWith('assets'))
return Sound.fromFile(desktopPath);
if (!path.startsWith('assets'))
return Sound.fromFile(path);
#end

return getLimeAssetsSound(path);
Expand Down
2 changes: 2 additions & 0 deletions source/funkin/util/song/Conductor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,12 @@ class Conductor
public static var songPitch:Float = 1;

public static function setPitch(pitch:Float = 1, forceVar:Bool = true, forceTime:Bool = true):Void {
#if !web // idk im workin on it
pitch = FlxMath.bound(pitch, 0.25, 2);
songPitch = (forceVar) ? pitch : songPitch;
FlxG.timeScale = (forceTime) ? pitch : FlxG.timeScale;
inst.pitch = pitch;
if (hasVocals) vocals.pitch = pitch;
#end
}
}

0 comments on commit b60ceec

Please sign in to comment.