Skip to content

Commit

Permalink
Made it possible to compile for html5 (WIP))
Browse files Browse the repository at this point in the history
  • Loading branch information
NeeEoo committed Aug 19, 2023
1 parent 8224293 commit b184a48
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 14 deletions.
6 changes: 3 additions & 3 deletions assets/shaders/engine/editorBlurFast.frag
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ float uBrightness = 0.6;

vec4 getColor(vec2 pos) {
vec2 ps = (pos);
if (ps.x < 0) ps.x = 0;
if (ps.x < 0.0) ps.x = 0.0;
//else if (ps.x > 1.0 - (1.0 / iResolution.x)) ps.x = 1.0 - (1.0 / iResolution.x);
else if (ps.x > 1.0) return vec4(0.0);
if (ps.y < 0) ps.y = 0;
if (ps.y < 0.0) ps.y = 0.0;
//else if (ps.y > 1.0 - (1.0 / iResolution.y)) return ps.y = 1.0 - (1.0 / iResolution.y);
else if (ps.y > 1.0) return vec4(0.0);
return flixel_texture2D(bitmap, (ps));
Expand Down Expand Up @@ -42,7 +42,7 @@ vec2 random(vec2 p) {
void main() {
vec2 camPos = (openfl_TextureCoordv);
//vec2 camPos = openfl_TextureCoordv;
if (camPos.x < 0 || camPos.x > 1 || camPos.y < 0 || camPos.y > 1)
if (camPos.x < 0.0 || camPos.x > 1.0 || camPos.y < 0.0 || camPos.y > 1.0)
return;

//vec4 color = getColor(camPos);
Expand Down
7 changes: 4 additions & 3 deletions project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@
<!-- Comment this out to disable updates !-->
<!-- <define name="UPDATE_CHECKING" unless="web || hl || neko"/> -->

<!-- Fixes thing with hl -->
<!-- Fixes thing with macros -->
<define name="HL" if="hl"/>
<define name="SYS" if="desktop"/>

<!-- Comment this out to disable Discord RPC !-->
<define name="DISCORD_RPC" unless="web || hl || neko"/>
Expand Down Expand Up @@ -144,10 +145,10 @@
<haxedef name="SOFTCODED_STATES" />

<!-- Comment this out to use the default OpenFL assets system for the assets/ folder. !-->
<haxedef name="USE_ADAPTED_ASSETS" />
<haxedef name="USE_ADAPTED_ASSETS" unless="web" />

<!-- Comment this out to disable support for custom ndlls. !-->
<haxedef name="NDLLS_SUPPORTED" />
<haxedef name="NDLLS_SUPPORTED" unless="web" />

<!-- Comment this out to disable support for custom extended classes (data/classes). !-->
<define name="SOFTCODED_CLASSES" />
Expand Down
4 changes: 3 additions & 1 deletion source/funkin/backend/assets/ModdableAssetsFolder.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package funkin.backend.assets;

import lime.utils.AssetLibrary;

#if sys
/**
* Used to prevent crashes
*/
Expand Down Expand Up @@ -36,4 +37,5 @@ class ModdableAssetsFolder extends ModsFolderLibrary {
_parsedAsset = asset.substr(prefix.length);
return true;
}
}
}
#end
2 changes: 1 addition & 1 deletion source/funkin/backend/system/CommandLineHandler.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package funkin.backend.system;

import sys.FileSystem;
#if sys
import sys.FileSystem;
class CommandLineHandler {
public static function parseCommandLine(cmd:Array<String>) {
var i:Int = 0;
Expand Down
2 changes: 1 addition & 1 deletion source/funkin/backend/system/Conductor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Conductor
/**
* Offset of the song
*/
public static var songOffset:Float = 0;
public static var songOffset:Float = 0;

/**
* Current step
Expand Down
2 changes: 1 addition & 1 deletion source/funkin/backend/system/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Main extends Sprite

addChild(game = new FunkinGame(gameWidth, gameHeight, MainState, Options.framerate, Options.framerate, skipSplash, startFullscreen));

#if !mobile
#if (!mobile && !web)
addChild(framerateSprite = new funkin.backend.system.framerate.Framerate());
framerateSprite.scaleX = framerateSprite.scaleY = stage.window.scale;
SystemInfo.init();
Expand Down
5 changes: 3 additions & 2 deletions source/funkin/backend/system/macros/ScriptsMacro.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ class ScriptsMacro {
"flixel.addons.plugin", "flixel.addons.text", "flixel.addons.tile", "flixel.addons.transition",
"flixel.addons.util",
// OTHER LIBRARIES & STUFF
"funkin",
"away3d", "flx3d",
#if VIDEO_CUTSCENES "hxcodec.flixel", "hxcodec.openfl", "hxcodec.lime", #end
// BASE HAXE
"DateTools", "EReg", "Lambda", "StringBuf", "haxe.crypto", "haxe.display", "haxe.exceptions", "haxe.extern", "scripting"
])
Compiler.include(inc);

for(inc in [#if sys "sys", #end "openfl.net", "funkin.backend.system.net"]) {
for(inc in [#if SYS "sys", "openfl.net", "funkin.backend.system.net" #end]) {
#if !HL
Compiler.include(inc);
#else
Expand All @@ -37,6 +36,8 @@ class ScriptsMacro {
#end
}

Compiler.include("funkin", #if !UPDATE_CHECKING ['funkin.backend.system.updating'] #end);

// FOR ABSTRACTS
Compiler.addGlobalMetadata('haxe.xml', '@:build(hscript.UsingHandler.build())');
Compiler.addGlobalMetadata('haxe.CallStack', '@:build(hscript.UsingHandler.build())');
Expand Down
2 changes: 2 additions & 0 deletions source/funkin/backend/utils/NativeAPI.hx
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ class NativeAPI {
var bg = cast(backgroundColor, Int);
Windows.setConsoleColors((bg * 16) + fg);
#else
#if sys
Sys.print("\x1b[0m");
if(foregroundColor != NONE)
Sys.print("\x1b[" + Std.int(consoleColorToANSI(foregroundColor)) + "m");
if(backgroundColor != NONE)
Sys.print("\x1b[" + Std.int(consoleColorToANSI(backgroundColor) + 10) + "m");
#end
#end
}

public static function consoleColorToANSI(color:ConsoleColor) {
Expand Down
1 change: 0 additions & 1 deletion source/funkin/editors/character/CharacterSelection.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import funkin.backend.chart.Chart;
import funkin.options.type.TextOption;
import funkin.options.type.IconOption;
import funkin.options.OptionsScreen;
import sys.FileSystem;

class CharacterSelection extends EditorTreeMenu
{
Expand Down
5 changes: 4 additions & 1 deletion source/funkin/options/Options.hx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ class Options
public static var hitWindow:Float = 250;
public static var songOffset:Float = 0;
public static var framerate:Int = 120;
public static var gpuOnlyBitmaps:Bool = #if mac false #else true #end; // causes issues on mac
public static var gpuOnlyBitmaps:Bool =
#if mac false
#elseif !web false
#else true #end; // causes issues on mac

public static var lastLoadedMod:String = null;

Expand Down

0 comments on commit b184a48

Please sign in to comment.