fix html5 compile

This commit is contained in:
KadeDev 2021-04-16 12:36:53 -07:00
parent 3f6cd093b3
commit 15c515440b
2 changed files with 55 additions and 15 deletions

View File

@ -1,6 +1,8 @@
package; package;
#if cpp
import llua.Lua; import llua.Lua;
#end
import Controls.Control; import Controls.Control;
import flixel.FlxG; import flixel.FlxG;
import flixel.FlxSprite; import flixel.FlxSprite;
@ -71,7 +73,7 @@ class PauseSubState extends MusicBeatSubstate
perSongOffset.scrollFactor.set(); perSongOffset.scrollFactor.set();
perSongOffset.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); perSongOffset.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
#if desktop #if cpp
add(perSongOffset); add(perSongOffset);
#end #end
@ -112,7 +114,7 @@ class PauseSubState extends MusicBeatSubstate
changeSelection(1); changeSelection(1);
} }
#if desktop #if cpp
else if (leftP) else if (leftP)
{ {
oldOffset = PlayState.songOffset; oldOffset = PlayState.songOffset;
@ -180,18 +182,14 @@ class PauseSubState extends MusicBeatSubstate
FlxG.resetState(); FlxG.resetState();
case "Exit to menu": case "Exit to menu":
PlayState.loadRep = false; PlayState.loadRep = false;
#if cpp
if (PlayState.lua != null) if (PlayState.lua != null)
{ {
Lua.close(PlayState.lua); Lua.close(PlayState.lua);
PlayState.lua = null; PlayState.lua = null;
} }
if (PlayState.offsetTesting) #end
{ FlxG.switchState(new MainMenuState());
PlayState.offsetTesting = false;
FlxG.switchState(new OptionsMenu());
}
else
FlxG.switchState(new MainMenuState());
} }
} }

View File

@ -8,10 +8,16 @@ import flixel.graphics.FlxGraphic;
import openfl.utils.AssetManifest; import openfl.utils.AssetManifest;
import openfl.utils.AssetLibrary; import openfl.utils.AssetLibrary;
import flixel.system.FlxAssets; import flixel.system.FlxAssets;
// Lua
#if cpp
import llua.Convert; import llua.Convert;
import llua.Lua; import llua.Lua;
import llua.State; import llua.State;
import llua.LuaL; import llua.LuaL;
#end
import lime.app.Application; import lime.app.Application;
import lime.media.AudioContext; import lime.media.AudioContext;
import lime.media.AudioManager; import lime.media.AudioManager;
@ -58,7 +64,7 @@ import openfl.filters.ShaderFilter;
#if windows #if windows
import Discord.DiscordClient; import Discord.DiscordClient;
#end #end
#if desktop #if cpp
import Sys; import Sys;
import sys.FileSystem; import sys.FileSystem;
#end #end
@ -205,7 +211,9 @@ class PlayState extends MusicBeatState
private var executeModchart = false; private var executeModchart = false;
// LUA SHIT // LUA SHIT
#if cpp
public static var lua:State = null; public static var lua:State = null;
function callLua(func_name : String, args : Array<Dynamic>, ?type : String) : Dynamic function callLua(func_name : String, args : Array<Dynamic>, ?type : String) : Dynamic
@ -396,7 +404,7 @@ class PlayState extends MusicBeatState
#end #end
return toBeCalled; return toBeCalled;
} }
#end
// LUA SHIT // LUA SHIT
override public function create() override public function create()
@ -1257,6 +1265,7 @@ class PlayState extends MusicBeatState
generateStaticArrows(1); generateStaticArrows(1);
#if cpp
if (executeModchart) // dude I hate lua (jkjkjkjk) if (executeModchart) // dude I hate lua (jkjkjkjk)
{ {
trace('opening a lua state (because we are cool :))'); trace('opening a lua state (because we are cool :))');
@ -1503,6 +1512,8 @@ class PlayState extends MusicBeatState
trace('return: ' + Lua.tostring(lua,callLua('start', [PlayState.SONG.song]))); trace('return: ' + Lua.tostring(lua,callLua('start', [PlayState.SONG.song])));
} }
#end
talking = false; talking = false;
startedCountdown = true; startedCountdown = true;
Conductor.songPosition = 0; Conductor.songPosition = 0;
@ -1707,7 +1718,7 @@ class PlayState extends MusicBeatState
var playerCounter:Int = 0; var playerCounter:Int = 0;
// Per song offset check // Per song offset check
#if desktop #if cpp
var songPath = 'assets/data/' + PlayState.SONG.song.toLowerCase() + '/'; var songPath = 'assets/data/' + PlayState.SONG.song.toLowerCase() + '/';
for(file in sys.FileSystem.readDirectory(songPath)) for(file in sys.FileSystem.readDirectory(songPath))
{ {
@ -2080,6 +2091,7 @@ class PlayState extends MusicBeatState
perfectMode = false; perfectMode = false;
#end #end
#if cpp
if (executeModchart && lua != null && songStarted) if (executeModchart && lua != null && songStarted)
{ {
setVar('songPos',Conductor.songPosition); setVar('songPos',Conductor.songPosition);
@ -2127,6 +2139,8 @@ class PlayState extends MusicBeatState
} }
} }
#end
if (currentFrames == FlxG.save.data.fpsCap) if (currentFrames == FlxG.save.data.fpsCap)
{ {
for(i in 0...notesHitArray.length) for(i in 0...notesHitArray.length)
@ -2206,11 +2220,13 @@ class PlayState extends MusicBeatState
DiscordClient.changePresence("Chart Editor", null, null, true); DiscordClient.changePresence("Chart Editor", null, null, true);
#end #end
FlxG.switchState(new ChartingState()); FlxG.switchState(new ChartingState());
#if cpp
if (lua != null) if (lua != null)
{ {
Lua.close(lua); Lua.close(lua);
lua = null; lua = null;
} }
#end
} }
// FlxG.watch.addQuick('VOL', vocals.amplitudeLeft); // FlxG.watch.addQuick('VOL', vocals.amplitudeLeft);
@ -2393,7 +2409,16 @@ class PlayState extends MusicBeatState
if (camFollow.x != dad.getMidpoint().x + 150 && !PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection) if (camFollow.x != dad.getMidpoint().x + 150 && !PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection)
{ {
camFollow.setPosition(dad.getMidpoint().x + 150 + (lua != null ? getVar("followXOffset", "float") : 0), dad.getMidpoint().y - 100 + (lua != null ? getVar("followYOffset", "float") : 0)); var offsetX = 0;
var offsetY = 0;
#if cpp
if (lua != null)
{
offsetX = getVar("followXOffset", "float");
offsetY = getVar("followYOffset", "float");
}
#end
camFollow.setPosition(dad.getMidpoint().x + 150 + offsetX, dad.getMidpoint().y - 100 + offsetY);
// camFollow.setPosition(lucky.getMidpoint().x - 120, lucky.getMidpoint().y + 210); // camFollow.setPosition(lucky.getMidpoint().x - 120, lucky.getMidpoint().y + 210);
switch (dad.curCharacter) switch (dad.curCharacter)
@ -2419,7 +2444,16 @@ class PlayState extends MusicBeatState
if (PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection && camFollow.x != boyfriend.getMidpoint().x - 100) if (PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection && camFollow.x != boyfriend.getMidpoint().x - 100)
{ {
camFollow.setPosition(boyfriend.getMidpoint().x - 100 + (lua != null ? getVar("followXOffset", "float") : 0), boyfriend.getMidpoint().y - 100 + (lua != null ? getVar("followYOffset", "float") : 0)); var offsetX = 0;
var offsetY = 0;
#if cpp
if (lua != null)
{
offsetX = getVar("followXOffset", "float");
offsetY = getVar("followYOffset", "float");
}
#end
camFollow.setPosition(boyfriend.getMidpoint().x - 100 + offsetX, boyfriend.getMidpoint().y - 100 + offsetY);
switch (curStage) switch (curStage)
{ {
@ -2646,11 +2680,13 @@ class PlayState extends MusicBeatState
if (!loadRep) if (!loadRep)
rep.SaveReplay(); rep.SaveReplay();
#if cpp
if (executeModchart) if (executeModchart)
{ {
Lua.close(lua); Lua.close(lua);
lua = null; lua = null;
} }
#end
canPause = false; canPause = false;
FlxG.sound.music.volume = 0; FlxG.sound.music.volume = 0;
@ -2686,11 +2722,13 @@ class PlayState extends MusicBeatState
FlxG.switchState(new StoryMenuState()); FlxG.switchState(new StoryMenuState());
#if cpp
if (lua != null) if (lua != null)
{ {
Lua.close(lua); Lua.close(lua);
lua = null; lua = null;
} }
#end
// if () // if ()
StoryMenuState.weekUnlocked[Std.int(Math.min(storyWeek + 1, StoryMenuState.weekUnlocked.length - 1))] = true; StoryMenuState.weekUnlocked[Std.int(Math.min(storyWeek + 1, StoryMenuState.weekUnlocked.length - 1))] = true;
@ -3710,11 +3748,13 @@ class PlayState extends MusicBeatState
resyncVocals(); resyncVocals();
} }
#if cpp
if (executeModchart && lua != null) if (executeModchart && lua != null)
{ {
setVar('curStep',curStep); setVar('curStep',curStep);
callLua('stepHit',[curStep]); callLua('stepHit',[curStep]);
} }
#end
if (dad.curCharacter == 'spooky' && curStep % 4 == 2) if (dad.curCharacter == 'spooky' && curStep % 4 == 2)
{ {
@ -3747,11 +3787,13 @@ class PlayState extends MusicBeatState
notes.sort(FlxSort.byY, FlxSort.DESCENDING); notes.sort(FlxSort.byY, FlxSort.DESCENDING);
} }
#if cpp
if (executeModchart && lua != null) if (executeModchart && lua != null)
{ {
setVar('curBeat',curBeat); setVar('curBeat',curBeat);
callLua('beatHit',[curBeat]); callLua('beatHit',[curBeat]);
} }
#end
if (SONG.notes[Math.floor(curStep / 16)] != null) if (SONG.notes[Math.floor(curStep / 16)] != null)
{ {