|
|
|
@ -1,5 +1,20 @@
|
|
|
|
|
package;
|
|
|
|
|
|
|
|
|
|
import openfl.geom.Matrix;
|
|
|
|
|
import openfl.display.BitmapData;
|
|
|
|
|
import openfl.utils.AssetType;
|
|
|
|
|
import lime.graphics.Image;
|
|
|
|
|
import flixel.graphics.FlxGraphic;
|
|
|
|
|
import openfl.utils.AssetManifest;
|
|
|
|
|
import openfl.utils.AssetLibrary;
|
|
|
|
|
import flixel.system.FlxAssets;
|
|
|
|
|
import llua.Convert;
|
|
|
|
|
import llua.Lua;
|
|
|
|
|
import llua.State;
|
|
|
|
|
import llua.LuaL;
|
|
|
|
|
import lime.app.Application;
|
|
|
|
|
import lime.media.AudioContext;
|
|
|
|
|
import lime.media.AudioManager;
|
|
|
|
|
import openfl.Lib;
|
|
|
|
|
import Section.SwagSection;
|
|
|
|
|
import Song.SwagSong;
|
|
|
|
@ -43,6 +58,7 @@ import openfl.filters.ShaderFilter;
|
|
|
|
|
#if desktop
|
|
|
|
|
import Discord.DiscordClient;
|
|
|
|
|
import Sys;
|
|
|
|
|
import sys.FileSystem;
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
using StringTools;
|
|
|
|
@ -72,6 +88,7 @@ class PlayState extends MusicBeatState
|
|
|
|
|
var halloweenLevel:Bool = false;
|
|
|
|
|
|
|
|
|
|
var songLength:Float = 0;
|
|
|
|
|
var kadeEngineWatermark:FlxText;
|
|
|
|
|
|
|
|
|
|
#if windows
|
|
|
|
|
// Discord RPC variables
|
|
|
|
@ -129,7 +146,6 @@ class PlayState extends MusicBeatState
|
|
|
|
|
|
|
|
|
|
public static var offsetTesting:Bool = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var notesHitArray:Array<Date> = [];
|
|
|
|
|
var currentFrames:Int = 0;
|
|
|
|
|
|
|
|
|
@ -184,6 +200,8 @@ class PlayState extends MusicBeatState
|
|
|
|
|
// Per song additive offset
|
|
|
|
|
public static var songOffset:Float = 0;
|
|
|
|
|
|
|
|
|
|
private var executeModchart = false;
|
|
|
|
|
|
|
|
|
|
override public function create()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
@ -200,6 +218,15 @@ class PlayState extends MusicBeatState
|
|
|
|
|
repPresses = 0;
|
|
|
|
|
repReleases = 0;
|
|
|
|
|
|
|
|
|
|
#if sys
|
|
|
|
|
executeModchart = FileSystem.exists(Paths.lua(PlayState.SONG.song.toLowerCase() + "/modchart"));
|
|
|
|
|
#end
|
|
|
|
|
#if !cpp
|
|
|
|
|
executeModchart = false; // FORCE disable for non cpp targets
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
trace('Mod chart: ' + executeModchart + " - " + Paths.lua(PlayState.SONG.song.toLowerCase() + "/modchart"));
|
|
|
|
|
|
|
|
|
|
#if windows
|
|
|
|
|
// Making difficulty text for Discord Rich Presence.
|
|
|
|
|
switch (storyDifficulty)
|
|
|
|
@ -823,7 +850,7 @@ class PlayState extends MusicBeatState
|
|
|
|
|
add(healthBar);
|
|
|
|
|
|
|
|
|
|
// Add Kade Engine watermark
|
|
|
|
|
var kadeEngineWatermark = new FlxText(4,healthBarBG.y + 50,0,SONG.song + " " + (storyDifficulty == 2 ? "Hard" : storyDifficulty == 1 ? "Normal" : "Easy") + (Main.watermarks ? " - KE " + MainMenuState.kadeEngineVer : ""), 16);
|
|
|
|
|
kadeEngineWatermark = new FlxText(4,healthBarBG.y + 50,0,SONG.song + " " + (storyDifficulty == 2 ? "Hard" : storyDifficulty == 1 ? "Normal" : "Easy") + (Main.watermarks ? " - KE " + MainMenuState.kadeEngineVer : ""), 16);
|
|
|
|
|
kadeEngineWatermark.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE,FlxColor.BLACK);
|
|
|
|
|
kadeEngineWatermark.scrollFactor.set();
|
|
|
|
|
add(kadeEngineWatermark);
|
|
|
|
@ -1140,6 +1167,198 @@ class PlayState extends MusicBeatState
|
|
|
|
|
var lastReportedPlayheadPosition:Int = 0;
|
|
|
|
|
var songTime:Float = 0;
|
|
|
|
|
|
|
|
|
|
// LUA SHIT
|
|
|
|
|
|
|
|
|
|
public static var lua:State = null;
|
|
|
|
|
|
|
|
|
|
function callLua(func_name : String, args : Array<Dynamic>, ?type : String) : Dynamic
|
|
|
|
|
{
|
|
|
|
|
var result : Any = null;
|
|
|
|
|
|
|
|
|
|
Lua.getglobal(lua, func_name);
|
|
|
|
|
|
|
|
|
|
for( arg in args ) {
|
|
|
|
|
Convert.toLua(lua, arg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = Lua.pcall(lua, args.length, 1, 0);
|
|
|
|
|
|
|
|
|
|
if( result == null) {
|
|
|
|
|
return null;
|
|
|
|
|
} else {
|
|
|
|
|
return convert(result, type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getType(l, type):Any
|
|
|
|
|
{
|
|
|
|
|
return switch Lua.type(l,type) {
|
|
|
|
|
case t if (t == Lua.LUA_TNIL): null;
|
|
|
|
|
case t if (t == Lua.LUA_TNUMBER): Lua.tonumber(l, type);
|
|
|
|
|
case t if (t == Lua.LUA_TSTRING): (Lua.tostring(l, type):String);
|
|
|
|
|
case t if (t == Lua.LUA_TBOOLEAN): Lua.toboolean(l, type);
|
|
|
|
|
case t: throw 'you don goofed up. lua type error ($t)';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getReturnValues(l) {
|
|
|
|
|
var lua_v:Int;
|
|
|
|
|
var v:Any = null;
|
|
|
|
|
while((lua_v = Lua.gettop(l)) != 0) {
|
|
|
|
|
var type:String = getType(l,lua_v);
|
|
|
|
|
v = convert(lua_v, type);
|
|
|
|
|
Lua.pop(l, 1);
|
|
|
|
|
}
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function convert(v : Any, type : String) : Dynamic { // I didn't write this lol
|
|
|
|
|
if( Std.is(v, String) && type != null ) {
|
|
|
|
|
var v : String = v;
|
|
|
|
|
if( type.substr(0, 4) == 'array' ) {
|
|
|
|
|
if( type.substr(4) == 'float' ) {
|
|
|
|
|
var array : Array<String> = v.split(',');
|
|
|
|
|
var array2 : Array<Float> = new Array();
|
|
|
|
|
|
|
|
|
|
for( vars in array ) {
|
|
|
|
|
array2.push(Std.parseFloat(vars));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return array2;
|
|
|
|
|
} else if( type.substr(4) == 'int' ) {
|
|
|
|
|
var array : Array<String> = v.split(',');
|
|
|
|
|
var array2 : Array<Int> = new Array();
|
|
|
|
|
|
|
|
|
|
for( vars in array ) {
|
|
|
|
|
array2.push(Std.parseInt(vars));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return array2;
|
|
|
|
|
} else {
|
|
|
|
|
var array : Array<String> = v.split(',');
|
|
|
|
|
return array;
|
|
|
|
|
}
|
|
|
|
|
} else if( type == 'float' ) {
|
|
|
|
|
return Std.parseFloat(v);
|
|
|
|
|
} else if( type == 'int' ) {
|
|
|
|
|
return Std.parseInt(v);
|
|
|
|
|
} else if( type == 'bool' ) {
|
|
|
|
|
if( v == 'true' ) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getLuaErrorMessage(l) {
|
|
|
|
|
var v:String = Lua.tostring(l, -1);
|
|
|
|
|
Lua.pop(l, 1);
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setVar(var_name : String, object : Dynamic){
|
|
|
|
|
// trace('setting variable ' + var_name + ' to ' + object);
|
|
|
|
|
|
|
|
|
|
Lua.pushnumber(lua,object);
|
|
|
|
|
Lua.setglobal(lua, var_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getVar(var_name : String, type : String) : Dynamic {
|
|
|
|
|
var result : Any = null;
|
|
|
|
|
|
|
|
|
|
// trace('getting variable ' + var_name + ' with a type of ' + type);
|
|
|
|
|
|
|
|
|
|
Lua.getglobal(lua, var_name);
|
|
|
|
|
result = Convert.fromLua(lua,-1);
|
|
|
|
|
Lua.pop(lua,1);
|
|
|
|
|
|
|
|
|
|
if( result == null ) {
|
|
|
|
|
return null;
|
|
|
|
|
} else {
|
|
|
|
|
var result = convert(result, type);
|
|
|
|
|
//trace(var_name + ' result: ' + result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getActorByName(id:String):Dynamic
|
|
|
|
|
{
|
|
|
|
|
// pre defined names
|
|
|
|
|
switch(id)
|
|
|
|
|
{
|
|
|
|
|
case 'boyfriend':
|
|
|
|
|
return boyfriend;
|
|
|
|
|
case 'girlfriend':
|
|
|
|
|
return gf;
|
|
|
|
|
case 'dad':
|
|
|
|
|
return dad;
|
|
|
|
|
}
|
|
|
|
|
// lua objects or what ever
|
|
|
|
|
if (luaSprites.get(id) == null)
|
|
|
|
|
return strumLineNotes.members[Std.parseInt(id)];
|
|
|
|
|
return luaSprites.get(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static var luaSprites:Map<String,FlxSprite> = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function makeLuaSprite(spritePath:String,toBeCalled:String, drawBehind:Bool)
|
|
|
|
|
{
|
|
|
|
|
#if sys
|
|
|
|
|
var data:BitmapData = BitmapData.fromFile(Sys.getCwd() + "assets/data/" + PlayState.SONG.song.toLowerCase() + '/' + spritePath + ".png");
|
|
|
|
|
|
|
|
|
|
var sprite:FlxSprite = new FlxSprite(0,0);
|
|
|
|
|
var imgWidth:Float = FlxG.width / data.width;
|
|
|
|
|
var imgHeight:Float = FlxG.height / data.height;
|
|
|
|
|
var scale:Float = imgWidth <= imgHeight ? imgWidth : imgHeight;
|
|
|
|
|
|
|
|
|
|
// Cap the scale at x1
|
|
|
|
|
if (scale > 1)
|
|
|
|
|
{
|
|
|
|
|
scale = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sprite.makeGraphic(Std.int(data.width * scale),Std.int(data.width * scale),FlxColor.TRANSPARENT);
|
|
|
|
|
|
|
|
|
|
var data2:BitmapData = sprite.pixels.clone();
|
|
|
|
|
var matrix:Matrix = new Matrix();
|
|
|
|
|
matrix.identity();
|
|
|
|
|
matrix.scale(scale, scale);
|
|
|
|
|
data2.fillRect(data2.rect, FlxColor.TRANSPARENT);
|
|
|
|
|
data2.draw(data, matrix, null, null, null, true);
|
|
|
|
|
sprite.pixels = data2;
|
|
|
|
|
|
|
|
|
|
luaSprites.set(toBeCalled,sprite);
|
|
|
|
|
// and I quote:
|
|
|
|
|
// shitty layering but it works!
|
|
|
|
|
if (drawBehind)
|
|
|
|
|
{
|
|
|
|
|
remove(gf);
|
|
|
|
|
remove(boyfriend);
|
|
|
|
|
remove(dad);
|
|
|
|
|
}
|
|
|
|
|
add(sprite);
|
|
|
|
|
if (drawBehind)
|
|
|
|
|
{
|
|
|
|
|
add(gf);
|
|
|
|
|
add(boyfriend);
|
|
|
|
|
add(dad);
|
|
|
|
|
}
|
|
|
|
|
#end
|
|
|
|
|
return toBeCalled;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// LUA SHIT
|
|
|
|
|
|
|
|
|
|
function startSong():Void
|
|
|
|
|
{
|
|
|
|
|
startingSong = false;
|
|
|
|
@ -1148,8 +1367,257 @@ class PlayState extends MusicBeatState
|
|
|
|
|
lastReportedPlayheadPosition = 0;
|
|
|
|
|
|
|
|
|
|
if (!paused)
|
|
|
|
|
{
|
|
|
|
|
FlxG.sound.playMusic(Paths.inst(PlayState.SONG.song), 1, false);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (executeModchart) // dude I hate lua (jkjkjkjk)
|
|
|
|
|
{
|
|
|
|
|
trace('opening a lua state (because we are cool :))');
|
|
|
|
|
lua = LuaL.newstate();
|
|
|
|
|
LuaL.openlibs(lua);
|
|
|
|
|
trace("Lua version: " + Lua.version());
|
|
|
|
|
trace("LuaJIT version: " + Lua.versionJIT());
|
|
|
|
|
Lua.init_callbacks(lua);
|
|
|
|
|
|
|
|
|
|
var result = LuaL.dofile(lua, Paths.lua(PlayState.SONG.song.toLowerCase() + "/modchart")); // execute le file
|
|
|
|
|
|
|
|
|
|
if (result != 0)
|
|
|
|
|
trace('COMPILE ERROR\n' + getLuaErrorMessage(lua));
|
|
|
|
|
|
|
|
|
|
// get some fukin globals up in here bois
|
|
|
|
|
|
|
|
|
|
setVar("bpm", Conductor.bpm);
|
|
|
|
|
setVar("fpsCap", FlxG.save.data.fpsCap);
|
|
|
|
|
setVar("downscroll", FlxG.save.data.downscroll);
|
|
|
|
|
|
|
|
|
|
setVar("curStep", 0);
|
|
|
|
|
setVar("curBeat", 0);
|
|
|
|
|
|
|
|
|
|
setVar("hudZoom", camHUD.zoom);
|
|
|
|
|
setVar("cameraZoom", FlxG.camera.zoom);
|
|
|
|
|
|
|
|
|
|
setVar("cameraAngle", FlxG.camera.angle);
|
|
|
|
|
setVar("camHudAngle", camHUD.angle);
|
|
|
|
|
|
|
|
|
|
setVar("followXOffset",0);
|
|
|
|
|
setVar("followYOffset",0);
|
|
|
|
|
|
|
|
|
|
setVar("showOnlyStrums", false);
|
|
|
|
|
setVar("strumLine1Visible", true);
|
|
|
|
|
setVar("strumLine2Visible", true);
|
|
|
|
|
|
|
|
|
|
setVar("screenWidth",FlxG.width);
|
|
|
|
|
setVar("screenHeight",FlxG.height);
|
|
|
|
|
setVar("hudWidth", camHUD.width);
|
|
|
|
|
setVar("hudHeight", camHUD.height);
|
|
|
|
|
|
|
|
|
|
// callbacks
|
|
|
|
|
|
|
|
|
|
// sprites
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"makeSprite", makeLuaSprite));
|
|
|
|
|
|
|
|
|
|
Lua_helper.add_callback(lua,"destroySprite", function(id:String) {
|
|
|
|
|
var sprite = luaSprites.get(id);
|
|
|
|
|
if (sprite == null)
|
|
|
|
|
return false;
|
|
|
|
|
remove(sprite);
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// hud/camera
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"setHudPosition", function (x:Int, y:Int) {
|
|
|
|
|
camHUD.x = x;
|
|
|
|
|
camHUD.y = y;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getHudX", function () {
|
|
|
|
|
return camHUD.x;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getHudY", function () {
|
|
|
|
|
return camHUD.y;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"setCamPosition", function (x:Int, y:Int) {
|
|
|
|
|
FlxG.camera.x = x;
|
|
|
|
|
FlxG.camera.y = y;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getCameraX", function () {
|
|
|
|
|
return FlxG.camera.x;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getCameraY", function () {
|
|
|
|
|
return FlxG.camera.y;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"setCamZoom", function(zoomAmount:Int) {
|
|
|
|
|
FlxG.camera.zoom = zoomAmount;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"setHudZoom", function(zoomAmount:Int) {
|
|
|
|
|
camHUD.zoom = zoomAmount;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
// actors
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getRenderedNotes", function() {
|
|
|
|
|
return notes.length;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getRenderedNoteX", function(id:Int) {
|
|
|
|
|
return notes.members[id].x;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getRenderedNoteY", function(id:Int) {
|
|
|
|
|
return notes.members[id].y;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getRenderedNoteScaleX", function(id:Int) {
|
|
|
|
|
return notes.members[id].scale.x;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getRenderedNoteScaleY", function(id:Int) {
|
|
|
|
|
return notes.members[id].scale.y;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getRenderedNoteAlpha", function(id:Int) {
|
|
|
|
|
return notes.members[id].alpha;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"setRenderedNotePos", function(x:Int,y:Int, id:Int) {
|
|
|
|
|
notes.members[id].modifiedByLua = true;
|
|
|
|
|
notes.members[id].x = x;
|
|
|
|
|
notes.members[id].y = y;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"setRenderedNoteAlpha", function(alpha:Float, id:Int) {
|
|
|
|
|
notes.members[id].modifiedByLua = true;
|
|
|
|
|
notes.members[id].alpha = alpha;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"setRenderedNoteScale", function(scale:Float, id:Int) {
|
|
|
|
|
notes.members[id].modifiedByLua = true;
|
|
|
|
|
notes.members[id].setGraphicSize(Std.int(notes.members[id].width * scale));
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"setRenderedNoteScaleX", function(scale:Float, id:Int) {
|
|
|
|
|
notes.members[id].modifiedByLua = true;
|
|
|
|
|
notes.members[id].scale.x = scale;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"setRenderedNoteScaleY", function(scale:Float, id:Int) {
|
|
|
|
|
notes.members[id].modifiedByLua = true;
|
|
|
|
|
notes.members[id].scale.y = scale;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"setActorX", function(x:Int,id:String) {
|
|
|
|
|
getActorByName(id).x = x;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"setActorAlpha", function(alpha:Int,id:String) {
|
|
|
|
|
getActorByName(id).alpha = alpha;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"setActorY", function(y:Int,id:String) {
|
|
|
|
|
getActorByName(id).y = y;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"setActorAngle", function(angle:Int,id:String) {
|
|
|
|
|
getActorByName(id).angle = angle;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"setActorScale", function(scale:Float,id:String) {
|
|
|
|
|
getActorByName(id).setGraphicSize(Std.int(getActorByName(id).width * scale));
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"setActorScaleX", function(scale:Float,id:String) {
|
|
|
|
|
getActorByName(id).scale.x = scale;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"setActorScaleY", function(scale:Float,id:String) {
|
|
|
|
|
getActorByName(id).scale.y = scale;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getActorWidth", function (id:String) {
|
|
|
|
|
return getActorByName(id).width;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getActorHeight", function (id:String) {
|
|
|
|
|
return getActorByName(id).height;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getActorAlpha", function(id:String) {
|
|
|
|
|
return getActorByName(id).alpha;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getActorAngle", function(id:String) {
|
|
|
|
|
return getActorByName(id).angle;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getActorX", function (id:String) {
|
|
|
|
|
return getActorByName(id).x;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getActorY", function (id:String) {
|
|
|
|
|
return getActorByName(id).y;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getActorScaleX", function (id:String) {
|
|
|
|
|
return getActorByName(id).scale.x;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
trace(Lua_helper.add_callback(lua,"getActorScaleY", function (id:String) {
|
|
|
|
|
return getActorByName(id).scale.y;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
// tweens
|
|
|
|
|
|
|
|
|
|
Lua_helper.add_callback(lua,"tweenPos", function(id:String, toX:Int, toY:Int, time:Float, onComplete:String) {
|
|
|
|
|
FlxTween.tween(getActorByName(id), {x: toX, y: toY}, time, {ease: FlxEase.cubeIn, onComplete: function(flxTween:FlxTween) { if (onComplete != '' && onComplete != null) {callLua(onComplete,[id]);}}});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Lua_helper.add_callback(lua,"tweenPosXAngle", function(id:String, toX:Int, toAngle:Float, time:Float, onComplete:String) {
|
|
|
|
|
FlxTween.tween(getActorByName(id), {x: toX, angle: toAngle}, time, {ease: FlxEase.cubeIn, onComplete: function(flxTween:FlxTween) { if (onComplete != '' && onComplete != null) {callLua(onComplete,[id]);}}});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Lua_helper.add_callback(lua,"tweenPosYAngle", function(id:String, toY:Int, toAngle:Float, time:Float, onComplete:String) {
|
|
|
|
|
FlxTween.tween(getActorByName(id), {y: toY, angle: toAngle}, time, {ease: FlxEase.cubeIn, onComplete: function(flxTween:FlxTween) { if (onComplete != '' && onComplete != null) {callLua(onComplete,[id]);}}});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Lua_helper.add_callback(lua,"tweenAngle", function(id:String, toAngle:Int, time:Float, onComplete:String) {
|
|
|
|
|
FlxTween.tween(getActorByName(id), {angle: toAngle}, time, {ease: FlxEase.cubeIn, onComplete: function(flxTween:FlxTween) { if (onComplete != '' && onComplete != null) {callLua(onComplete,[id]);}}});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Lua_helper.add_callback(lua,"tweenFadeIn", function(id:String, toAlpha:Int, time:Float, onComplete:String) {
|
|
|
|
|
FlxTween.tween(getActorByName(id), {alpha: toAlpha}, time, {ease: FlxEase.circIn, onComplete: function(flxTween:FlxTween) { if (onComplete != '' && onComplete != null) {callLua(onComplete,[id]);}}});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Lua_helper.add_callback(lua,"tweenFadeOut", function(id:String, toAlpha:Int, time:Float, onComplete:String) {
|
|
|
|
|
FlxTween.tween(getActorByName(id), {alpha: toAlpha}, time, {ease: FlxEase.circOut, onComplete: function(flxTween:FlxTween) { if (onComplete != '' && onComplete != null) {callLua(onComplete,[id]);}}});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (i in 0...strumLineNotes.length) {
|
|
|
|
|
var member = strumLineNotes.members[i];
|
|
|
|
|
trace(strumLineNotes.members[i].x + " " + strumLineNotes.members[i].y + " " + strumLineNotes.members[i].angle + " | strum" + i);
|
|
|
|
|
//setVar("strum" + i + "X", Math.floor(member.x));
|
|
|
|
|
setVar("defaultStrum" + i + "X", Math.floor(member.x));
|
|
|
|
|
//setVar("strum" + i + "Y", Math.floor(member.y));
|
|
|
|
|
setVar("defaultStrum" + i + "Y", Math.floor(member.y));
|
|
|
|
|
//setVar("strum" + i + "Angle", Math.floor(member.angle));
|
|
|
|
|
setVar("defaultStrum" + i + "Angle", Math.floor(member.angle));
|
|
|
|
|
trace("Adding strum" + i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
trace('calling start function');
|
|
|
|
|
|
|
|
|
|
trace('return: ' + Lua.tostring(lua,callLua('start', [PlayState.SONG.song])));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FlxG.sound.music.onComplete = endSong;
|
|
|
|
|
vocals.play();
|
|
|
|
|
|
|
|
|
@ -1249,7 +1717,6 @@ class PlayState extends MusicBeatState
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
var daBeats:Int = 0; // Not exactly representative of 'daBeats' lol, just how much it has looped
|
|
|
|
|
for (section in noteData)
|
|
|
|
|
{
|
|
|
|
@ -1604,6 +2071,53 @@ class PlayState extends MusicBeatState
|
|
|
|
|
perfectMode = false;
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
if (executeModchart && lua != null)
|
|
|
|
|
{
|
|
|
|
|
setVar('songPos',Conductor.songPosition);
|
|
|
|
|
setVar('hudZoom', camHUD.zoom);
|
|
|
|
|
setVar('cameraZoom',FlxG.camera.zoom);
|
|
|
|
|
callLua('update', [elapsed]);
|
|
|
|
|
|
|
|
|
|
/*for (i in 0...strumLineNotes.length) {
|
|
|
|
|
var member = strumLineNotes.members[i];
|
|
|
|
|
member.x = getVar("strum" + i + "X", "float");
|
|
|
|
|
member.y = getVar("strum" + i + "Y", "float");
|
|
|
|
|
member.angle = getVar("strum" + i + "Angle", "float");
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
FlxG.camera.angle = getVar('cameraAngle', 'float');
|
|
|
|
|
camHUD.angle = getVar('camHudAngle','float');
|
|
|
|
|
|
|
|
|
|
if (getVar("showOnlyStrums",'bool'))
|
|
|
|
|
{
|
|
|
|
|
healthBarBG.visible = false;
|
|
|
|
|
kadeEngineWatermark.visible = false;
|
|
|
|
|
healthBar.visible = false;
|
|
|
|
|
iconP1.visible = false;
|
|
|
|
|
iconP2.visible = false;
|
|
|
|
|
scoreTxt.visible = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
healthBarBG.visible = true;
|
|
|
|
|
kadeEngineWatermark.visible = true;
|
|
|
|
|
healthBar.visible = true;
|
|
|
|
|
iconP1.visible = true;
|
|
|
|
|
iconP2.visible = true;
|
|
|
|
|
scoreTxt.visible = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var p1 = getVar("strumLine1Visible",'bool');
|
|
|
|
|
var p2 = getVar("strumLine2Visible",'bool');
|
|
|
|
|
|
|
|
|
|
for (i in 0...4)
|
|
|
|
|
{
|
|
|
|
|
strumLineNotes.members[i].visible = p1;
|
|
|
|
|
if (i <= playerStrums.length)
|
|
|
|
|
playerStrums.members[i].visible = p2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentFrames == FlxG.save.data.fpsCap)
|
|
|
|
|
{
|
|
|
|
|
for(i in 0...notesHitArray.length)
|
|
|
|
@ -1683,6 +2197,11 @@ class PlayState extends MusicBeatState
|
|
|
|
|
DiscordClient.changePresence("Chart Editor", null, null, true);
|
|
|
|
|
#end
|
|
|
|
|
FlxG.switchState(new ChartingState());
|
|
|
|
|
if (lua != null)
|
|
|
|
|
{
|
|
|
|
|
Lua.close(lua);
|
|
|
|
|
lua = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FlxG.watch.addQuick('VOL', vocals.amplitudeLeft);
|
|
|
|
@ -1717,7 +2236,15 @@ class PlayState extends MusicBeatState
|
|
|
|
|
|
|
|
|
|
#if debug
|
|
|
|
|
if (FlxG.keys.justPressed.EIGHT)
|
|
|
|
|
{
|
|
|
|
|
FlxG.switchState(new AnimationDebug(SONG.player2));
|
|
|
|
|
if (lua != null)
|
|
|
|
|
{
|
|
|
|
|
Lua.close(lua);
|
|
|
|
|
lua = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
if (startingSong)
|
|
|
|
@ -1857,7 +2384,7 @@ class PlayState extends MusicBeatState
|
|
|
|
|
|
|
|
|
|
if (camFollow.x != dad.getMidpoint().x + 150 && !PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection)
|
|
|
|
|
{
|
|
|
|
|
camFollow.setPosition(dad.getMidpoint().x + 150, dad.getMidpoint().y - 100);
|
|
|
|
|
camFollow.setPosition(dad.getMidpoint().x + 150 + (lua != null ? getVar("followXOffset", "float") : 0), dad.getMidpoint().y - 100 + (lua != null ? getVar("followYOffset", "float") : 0));
|
|
|
|
|
// camFollow.setPosition(lucky.getMidpoint().x - 120, lucky.getMidpoint().y + 210);
|
|
|
|
|
|
|
|
|
|
switch (dad.curCharacter)
|
|
|
|
@ -1883,7 +2410,7 @@ class PlayState extends MusicBeatState
|
|
|
|
|
|
|
|
|
|
if (PlayState.SONG.notes[Std.int(curStep / 16)].mustHitSection && camFollow.x != boyfriend.getMidpoint().x - 100)
|
|
|
|
|
{
|
|
|
|
|
camFollow.setPosition(boyfriend.getMidpoint().x - 100, boyfriend.getMidpoint().y - 100);
|
|
|
|
|
camFollow.setPosition(boyfriend.getMidpoint().x - 100 + (lua != null ? getVar("followXOffset", "float") : 0), boyfriend.getMidpoint().y - 100 + (lua != null ? getVar("followYOffset", "float") : 0));
|
|
|
|
|
|
|
|
|
|
switch (curStage)
|
|
|
|
|
{
|
|
|
|
@ -2003,7 +2530,7 @@ class PlayState extends MusicBeatState
|
|
|
|
|
{
|
|
|
|
|
if (SONG.song != 'Tutorial')
|
|
|
|
|
camZooming = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var altAnim:String = "";
|
|
|
|
|
|
|
|
|
|
if (SONG.notes[Math.floor(curStep / 16)] != null)
|
|
|
|
@ -2029,6 +2556,8 @@ class PlayState extends MusicBeatState
|
|
|
|
|
if (SONG.needsVoices)
|
|
|
|
|
vocals.volume = 1;
|
|
|
|
|
|
|
|
|
|
daNote.active = false;
|
|
|
|
|
|
|
|
|
|
daNote.kill();
|
|
|
|
|
notes.remove(daNote, true);
|
|
|
|
|
daNote.destroy();
|
|
|
|
@ -2038,6 +2567,29 @@ class PlayState extends MusicBeatState
|
|
|
|
|
daNote.y = (strumLine.y - (Conductor.songPosition - daNote.strumTime) * (-0.45 * FlxMath.roundDecimal(FlxG.save.data.scrollSpeed == 1 ? SONG.speed : FlxG.save.data.scrollSpeed, 2)));
|
|
|
|
|
else
|
|
|
|
|
daNote.y = (strumLine.y - (Conductor.songPosition - daNote.strumTime) * (0.45 * FlxMath.roundDecimal(FlxG.save.data.scrollSpeed == 1 ? SONG.speed : FlxG.save.data.scrollSpeed, 2)));
|
|
|
|
|
|
|
|
|
|
if (daNote.mustPress && !daNote.modifiedByLua)
|
|
|
|
|
{
|
|
|
|
|
daNote.visible = playerStrums.members[Math.floor(Math.abs(daNote.noteData))].visible;
|
|
|
|
|
daNote.x = playerStrums.members[Math.floor(Math.abs(daNote.noteData))].x;
|
|
|
|
|
if (!daNote.isSustainNote)
|
|
|
|
|
daNote.angle = playerStrums.members[Math.floor(Math.abs(daNote.noteData))].angle;
|
|
|
|
|
daNote.alpha = playerStrums.members[Math.floor(Math.abs(daNote.noteData))].alpha;
|
|
|
|
|
}
|
|
|
|
|
else if (!daNote.wasGoodHit && !daNote.modifiedByLua)
|
|
|
|
|
{
|
|
|
|
|
daNote.visible = strumLineNotes.members[Math.floor(Math.abs(daNote.noteData))].visible;
|
|
|
|
|
daNote.x = strumLineNotes.members[Math.floor(Math.abs(daNote.noteData))].x;
|
|
|
|
|
if (!daNote.isSustainNote)
|
|
|
|
|
daNote.angle = strumLineNotes.members[Math.floor(Math.abs(daNote.noteData))].angle;
|
|
|
|
|
daNote.alpha = strumLineNotes.members[Math.floor(Math.abs(daNote.noteData))].alpha;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (daNote.isSustainNote)
|
|
|
|
|
daNote.x += daNote.width / 2 + 7;
|
|
|
|
|
|
|
|
|
|
//trace(daNote.y);
|
|
|
|
|
// WIP interpolation shit? Need to fix the pause issue
|
|
|
|
|
// daNote.y = (strumLine.y - (songTime - daNote.strumTime) * (0.45 * PlayState.SONG.speed));
|
|
|
|
@ -2084,6 +2636,12 @@ class PlayState extends MusicBeatState
|
|
|
|
|
if (!loadRep)
|
|
|
|
|
rep.SaveReplay();
|
|
|
|
|
|
|
|
|
|
if (executeModchart)
|
|
|
|
|
{
|
|
|
|
|
Lua.close(lua);
|
|
|
|
|
lua = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
canPause = false;
|
|
|
|
|
FlxG.sound.music.volume = 0;
|
|
|
|
|
vocals.volume = 0;
|
|
|
|
@ -2118,6 +2676,12 @@ class PlayState extends MusicBeatState
|
|
|
|
|
|
|
|
|
|
FlxG.switchState(new StoryMenuState());
|
|
|
|
|
|
|
|
|
|
if (lua != null)
|
|
|
|
|
{
|
|
|
|
|
Lua.close(lua);
|
|
|
|
|
lua = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if ()
|
|
|
|
|
StoryMenuState.weekUnlocked[Std.int(Math.min(storyWeek + 1, StoryMenuState.weekUnlocked.length - 1))] = true;
|
|
|
|
|
|
|
|
|
@ -3136,6 +3700,12 @@ class PlayState extends MusicBeatState
|
|
|
|
|
resyncVocals();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (executeModchart && lua != null)
|
|
|
|
|
{
|
|
|
|
|
setVar('curStep',curStep);
|
|
|
|
|
callLua('stepHit',[curStep]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dad.curCharacter == 'spooky' && curStep % 4 == 2)
|
|
|
|
|
{
|
|
|
|
|
// dad.dance();
|
|
|
|
@ -3167,6 +3737,12 @@ class PlayState extends MusicBeatState
|
|
|
|
|
notes.sort(FlxSort.byY, FlxSort.DESCENDING);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (executeModchart && lua != null)
|
|
|
|
|
{
|
|
|
|
|
setVar('curBeat',curBeat);
|
|
|
|
|
callLua('beatHit',[curBeat]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (SONG.notes[Math.floor(curStep / 16)] != null)
|
|
|
|
|
{
|
|
|
|
|
if (SONG.notes[Math.floor(curStep / 16)].changeBPM)
|
|
|
|
|