From 6e93df0437886cbf942be2c9e727d1e859d416b6 Mon Sep 17 00:00:00 2001 From: Detoria <44783518+theDetourist@users.noreply.github.com> Date: Thu, 15 Apr 2021 12:28:13 -0300 Subject: [PATCH 01/17] offset desktop only pt.1 --- source/PauseSubState.hx | 113 +++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 53 deletions(-) diff --git a/source/PauseSubState.hx b/source/PauseSubState.hx index 29f0ffa..3533fe0 100644 --- a/source/PauseSubState.hx +++ b/source/PauseSubState.hx @@ -69,7 +69,10 @@ class PauseSubState extends MusicBeatSubstate perSongOffset = new FlxText(5, FlxG.height - 18, 0, "Additive Offset (Left, Right): " + PlayState.songOffset + " - Description - " + 'Adds value to global offset, per song.', 12); perSongOffset.scrollFactor.set(); perSongOffset.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); - add(perSongOffset); + + #if desktop + add(perSongOffset); + #end for (i in 0...menuItems.length) { @@ -106,59 +109,63 @@ class PauseSubState extends MusicBeatSubstate }else if (downP) { changeSelection(1); - }else if (leftP) - { - oldOffset = PlayState.songOffset; - PlayState.songOffset -= 1; - sys.FileSystem.rename(songPath + oldOffset + '.offset', songPath + PlayState.songOffset + '.offset'); - perSongOffset.text = "Additive Offset (Left, Right): " + PlayState.songOffset + " - Description - " + 'Adds value to global offset, per song.'; - - // Prevent loop from happening every single time the offset changes - if(!offsetChanged) - { - grpMenuShit.clear(); - - menuItems = ['Restart Song', 'Exit to menu']; - - for (i in 0...menuItems.length) - { - var songText:Alphabet = new Alphabet(0, (70 * i) + 30, menuItems[i], true, false); - songText.isMenuItem = true; - songText.targetY = i; - grpMenuShit.add(songText); - } - - changeSelection(); - - cameras = [FlxG.cameras.list[FlxG.cameras.list.length - 1]]; - offsetChanged = true; - } - }else if (rightP) - { - oldOffset = PlayState.songOffset; - PlayState.songOffset += 1; - sys.FileSystem.rename(songPath + oldOffset + '.offset', songPath + PlayState.songOffset + '.offset'); - perSongOffset.text = "Additive Offset (Left, Right): " + PlayState.songOffset + " - Description - " + 'Adds value to global offset, per song.'; - if(!offsetChanged) - { - grpMenuShit.clear(); - - menuItems = ['Restart Song', 'Exit to menu']; - - for (i in 0...menuItems.length) - { - var songText:Alphabet = new Alphabet(0, (70 * i) + 30, menuItems[i], true, false); - songText.isMenuItem = true; - songText.targetY = i; - grpMenuShit.add(songText); - } - - changeSelection(); - - cameras = [FlxG.cameras.list[FlxG.cameras.list.length - 1]]; - offsetChanged = true; - } } + + #if desktop + else if (leftP) + { + oldOffset = PlayState.songOffset; + PlayState.songOffset -= 1; + sys.FileSystem.rename(songPath + oldOffset + '.offset', songPath + PlayState.songOffset + '.offset'); + perSongOffset.text = "Additive Offset (Left, Right): " + PlayState.songOffset + " - Description - " + 'Adds value to global offset, per song.'; + + // Prevent loop from happening every single time the offset changes + if(!offsetChanged) + { + grpMenuShit.clear(); + + menuItems = ['Restart Song', 'Exit to menu']; + + for (i in 0...menuItems.length) + { + var songText:Alphabet = new Alphabet(0, (70 * i) + 30, menuItems[i], true, false); + songText.isMenuItem = true; + songText.targetY = i; + grpMenuShit.add(songText); + } + + changeSelection(); + + cameras = [FlxG.cameras.list[FlxG.cameras.list.length - 1]]; + offsetChanged = true; + } + }else if (rightP) + { + oldOffset = PlayState.songOffset; + PlayState.songOffset += 1; + sys.FileSystem.rename(songPath + oldOffset + '.offset', songPath + PlayState.songOffset + '.offset'); + perSongOffset.text = "Additive Offset (Left, Right): " + PlayState.songOffset + " - Description - " + 'Adds value to global offset, per song.'; + if(!offsetChanged) + { + grpMenuShit.clear(); + + menuItems = ['Restart Song', 'Exit to menu']; + + for (i in 0...menuItems.length) + { + var songText:Alphabet = new Alphabet(0, (70 * i) + 30, menuItems[i], true, false); + songText.isMenuItem = true; + songText.targetY = i; + grpMenuShit.add(songText); + } + + changeSelection(); + + cameras = [FlxG.cameras.list[FlxG.cameras.list.length - 1]]; + offsetChanged = true; + } + } + #end if (accepted) { From 7162b4dd86bdbcbe18c59258f0f7f1ece5a70130 Mon Sep 17 00:00:00 2001 From: Detoria <44783518+theDetourist@users.noreply.github.com> Date: Thu, 15 Apr 2021 12:29:28 -0300 Subject: [PATCH 02/17] offset desktop only pt.2 --- source/PlayState.hx | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/source/PlayState.hx b/source/PlayState.hx index 4409319..44c1dbd 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -39,10 +39,10 @@ import lime.utils.Assets; import openfl.display.BlendMode; import openfl.display.StageQuality; import openfl.filters.ShaderFilter; -import Sys; #if windows import Discord.DiscordClient; +import Sys; #end using StringTools; @@ -1230,23 +1230,26 @@ class PlayState extends MusicBeatState var playerCounter:Int = 0; // Per song offset check - var songPath = 'assets/data/' + PlayState.SONG.song.toLowerCase() + '/'; - for(file in sys.FileSystem.readDirectory(songPath)) - { - var path = haxe.io.Path.join([songPath, file]); - if(!sys.FileSystem.isDirectory(path)) + #if desktop + var songPath = 'assets/data/' + PlayState.SONG.song.toLowerCase() + '/'; + for(file in sys.FileSystem.readDirectory(songPath)) { - if(path.endsWith('.offset')) + var path = haxe.io.Path.join([songPath, file]); + if(!sys.FileSystem.isDirectory(path)) { - trace('Found offset file: ' + path); - songOffset = Std.parseFloat(file.substring(0, file.indexOf('.off'))); - break; - }else { - trace('Offset file not found. Creating one @: ' + songPath); - sys.io.File.saveContent(songPath + songOffset + '.offset', ''); + if(path.endsWith('.offset')) + { + trace('Found offset file: ' + path); + songOffset = Std.parseFloat(file.substring(0, file.indexOf('.off'))); + break; + }else { + trace('Offset file not found. Creating one @: ' + songPath); + sys.io.File.saveContent(songPath + songOffset + '.offset', ''); + } } } - } + #end + var daBeats:Int = 0; // Not exactly representative of 'daBeats' lol, just how much it has looped for (section in noteData) { @@ -3270,4 +3273,4 @@ class PlayState extends MusicBeatState } var curLight:Int = 0; -} \ No newline at end of file +} From 86d4e9da07455a30d993dce72d479d62b4e5cc8d Mon Sep 17 00:00:00 2001 From: Detoria <44783518+theDetourist@users.noreply.github.com> Date: Thu, 15 Apr 2021 12:30:26 -0300 Subject: [PATCH 03/17] windows only -> desktop --- source/PlayState.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/PlayState.hx b/source/PlayState.hx index 44c1dbd..3af5232 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -40,7 +40,7 @@ import openfl.display.BlendMode; import openfl.display.StageQuality; import openfl.filters.ShaderFilter; -#if windows +#if desktop import Discord.DiscordClient; import Sys; #end From fec5fa33c254405f6bce47cf6e6d2e79669dd9ae Mon Sep 17 00:00:00 2001 From: KadeDev Date: Thu, 15 Apr 2021 11:09:46 -0700 Subject: [PATCH 04/17] modcharts --- Error | 0 ModCharts.md | 267 ++++++++++++++++-- Project.xml | 4 +- source/ChartingState.hx | 98 +++++++ source/Main.hx | 4 + source/Note.hx | 7 +- source/Paths.hx | 10 + source/PauseSubState.hx | 6 + source/PlayState.hx | 590 +++++++++++++++++++++++++++++++++++++++- source/TitleState.hx | 4 + 10 files changed, 959 insertions(+), 31 deletions(-) create mode 100644 Error diff --git a/Error b/Error new file mode 100644 index 0000000..e69de29 diff --git a/ModCharts.md b/ModCharts.md index 908c9c1..571443c 100644 --- a/ModCharts.md +++ b/ModCharts.md @@ -1,4 +1,4 @@ -# Kade Engine Lua Mod Chart Documentation +Kade Engine Lua Mod Chart Documentation In the latest version of Kade Engine we introduced Mod Charts. Mod Charts are a way of changing gameplay without hard coded values, this is achieved by using the Lua Scripting language to create script files that run during runtime. @@ -20,10 +20,10 @@ end function update (elapsed) -- example https://twitter.com/KadeDeveloper/status/1382178179184422918 local currentBeat = (songPos / 1000)*(bpm/60) - for i=0,7 do - _G['strum'..i..'X'] = _G['defaultStrum'..i..'X'] + 32 * math.sin((currentBeat + i*0.25) * math.pi) - _G['strum'..i..'Y'] = _G['defaultStrum'..i..'Y'] + 32 * math.cos((currentBeat + i*0.25) * math.pi) - end + for i=0,7 do + setActorX(_G['defaultStrum'..i..'X'] + 32 * math.sin((currentBeat + i*0.25) * math.pi), i) + setActorY(_G['defaultStrum'..i..'Y'] + 32 * math.cos((currentBeat + i*0.25) * math.pi), i) + end end function beatHit (beat) @@ -31,7 +31,7 @@ function beatHit (beat) end function stepHit (step) - -- do nothing + -- do nothing end print("Mod Chart script loaded :)") @@ -41,9 +41,9 @@ Spinning Receptor Example ```lua function update (elapsed) - for i=0,7 do - _G['strum'..i..'Angle'] = _G['strum'..i..'Angle'] + 15 - end + for i=0,7 do + setActorAngle(getActorAngle(i) + 15, i) + end end ``` @@ -62,13 +62,15 @@ function update (elapsed) if curStep >= 352 and curStep < 400 then local currentBeat = (songPos / 1000)*(bpm/60) for i=0,7 do - _G['strum'..i..'X'] = _G['defaultStrum'..i..'X'] + 32 * math.sin((currentBeat + i*0.25) * math.pi) - _G['strum'..i..'Y'] = _G['defaultStrum'..i..'Y'] + 32 * math.cos((currentBeat + i*0.25) * math.pi) + setActorX(_G['defaultStrum'..i..'X'] + 32 * math.sin((currentBeat + i*0.25) * math.pi), i) + setActorY(_G['defaultStrum'..i..'Y'] + 32 * math.cos((currentBeat + i*0.25) * math.pi), i) end else - _G['strum'..i..'X'] = _G['defaultStrum'..i..'X'] - _G['strum'..i..'Y'] = _G['defaultStrum'..i..'Y'] - end + for i=0,7 do + setActorX(_G['defaultStrum'..i..'X'],i) + setActorX(_G['defaultStrum'..i..'Y'],i) + end + end end ``` @@ -77,10 +79,20 @@ Showing/Hiding receptors/the hud ```lua function start (song) showOnlyStrums = true -- remove all hud elements besides notes and strums - _G['strumLine1Visible'] = false -- remove the first line of strums (the ai notes) + for i=0,3 do -- fade out the first 4 receptors (the ai receptors) + tweenFadeIn(i,0,0.6) + end end ``` +Looping through all of the rendered notes + +```lua + for i = 0, getRenderedNotes() do -- sets all of the rendered notes to 0 0 on the x and y axsis + setRenderedNotePos(0,0,i) + end +``` + ### Available Hooks @@ -105,8 +117,6 @@ Kade Engine provides a list of global variables to be used in the lua scripting | bpm | Float | The current BPM of the song | | fpsCap | Int | The current FPS Cap (set by the player) | | downscroll | Bool | Whether the player is in downscroll or not | -| hudZoom | Float | The amount of zoom the Hud should be zoomed in/out | -| cameraZoom | Float | The amount of zoom the Main Camera should be zoomed in/out | | cameraAngle | Float | The angle that the Main Camera should be rotated | | camHudAngle | Float | The angle that the Hud should be rotated | | followXOffset | Float | The x offset to be added when the camera moves between a character | @@ -114,10 +124,227 @@ Kade Engine provides a list of global variables to be used in the lua scripting | showOnlyStrums | Bool | Whether to show the Hud and Strums or only the Strums | | strumLine1Visible | Bool | Whether to show the first strum line or not | | strumLine2Visible | Bool | Whether to show the secondstrum line or not | -| strum0-7X | Float | (0-7 is strum0,strum1,strum2,etc) get/set the X coordinate for the strum | -| strum0-7Y | Float | (0-7 is strum0,strum1,strum2,etc) get/set the Y coordinate for the strum | -| strum0-7Angle | Float | (0-7 is strum0,strum1,strum2,etc) get/set the Angle for the strum | | defaultStrum0-7X | Float | (0-7 is strum0,strum1,strum2,etc) get the default X coordinate for the strum | | defaultStrum0-7Y | Float | (0-7 is strum0,strum1,strum2,etc) get the default Y coordinate for the strum | | defaultStrum0-7Angle | Float | (0-7 is strum0,strum1,strum2,etc) get the default Angle for the strum | +| screenWidth | Int | The width of the current gamespace | +| screenHeight | Int | The height of the current gamespace | +| hudWidth | Int | The width of the hud | +| hudHeight | Int | The height of the hud | + + +## Functions + +Kade Engine exposes a lot of functions that let you modify elements in the game field. + + + +To get started every sprite has an id, and there are some id's that are accessible without creating one. + +These premade id's are the following: + +| Sprite Id | Value | +| :--------: | :--------------------------------------: | +| 0-7 | Represents Receptor 0-7 | +| boyfriend | Represents the Boyfriend Actor (player1) | +| dad | Represents the Dad Actor (player2) | +| girlfriend | Represents the Girlfriend Actor | + + + +### Sprites + +##### makeSprite(string SpritePath,string SpriteId,bool DrawBehind) + +Creates a sprite out of the specified image, returns the id you gave it. + +*Note: Sprite Path is normally the FILE NAME so if you have a file name of Image it'll go to assets/data/songName/Image.png so don't include the extension* + +### Hud/Camera + +##### setHudPosition(int x, int y) + +Set's the game hud's position in space. + +##### getHudX() + +Returns the hud's x position + +##### getHudY() + +Returns the hud's y position + +##### setCamPosition(int x, int y) + +Set's the current camera's position in space + +##### getCamX() + +Returns the current camera's x position + +##### getCamY() + +Returns the current camera's y position + +##### setCamZoom(int zoomAmount) + +Set's the current camera's zoom + +##### setHudZoom(int zoomAmount) + +Set's the hud's zoom + +### Actor's + +##### getRenderedNotes() + +Returns the amount of rendered notes. + +##### getRenderedNoteX(int id) + +Return's the x position of the rendered note id + +*Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* + +##### getRenderedNoteY(int id) + +Return's the y position of the rendered note id + +*Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* + +##### getRenderedNoteScaleX(int id) + +Return's the scale x of the rendered note id + +*Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* + +##### getRenderedNoteScaleY(int id) + +Return's the scale y of the rendered note id + +*Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* + +##### getRenderedNoteAlpha(int id) + +Return's the alpha of the rendered note id + +*Note: Rendered Notes id's are special in the way that they act. 0 = closest note to any receptor, last index = the farthest away from any receptor.* + +##### setRenderedNotePos(int x, int y, int id) + +Set's the position of the rendered note id + +*Note: Setting a Rendered Note's property will stop the note from updating it's alpha & x properties* + +##### setRenderedNoteAlpha(float alpha, int id) + +Set's the alpha of the rendered note id + +*Note: Setting a Rendered Note's property will stop the note from updating it's alpha & x properties* + +##### setRenderedNoteScale(float scale, int id) + +Set's the scale of the rendered note id + +*Note: Setting a Rendered Note's property will stop the note from updating it's alpha & x properties* + +##### setRenderedNoteScaleX(float scale, int id) + +Set's the scale x of the rendered note id + +*Note: Setting a Rendered Note's property will stop the note from updating it's alpha & x properties* + +##### setRenderedNoteScaleY(float scale, int id) + +Set's the scale y of the rendered note id + +*Note: Setting a Rendered Note's property will stop the note from updating it's alpha & x properties* + +##### getActorX(string/int id) + +Returns the x position for the sprite id + +##### getActorY(string/int id) + +Returns the y position for the sprite id + +##### getActorScaleX(string/int id) + +Returns the scale x for the sprite id + +##### getActorScaleY(string/int id) + +Returns the scale y for the sprite id + +##### getActorAlpha(string/int id) + +Returns the alpha for the sprite id + +##### getActorAngle(string/int id) + +Returns the angle for the sprite id + +##### setActorX(int x, string/int id) + +Set's the x position for the sprite id + +##### setActorY(int y, string/int id) + +Set's the y position for the sprite id + +##### setActorAlpha(float alpha, string/int id) + +Set's the alpha for the sprite id + +##### setActorAngle(int alpha, string/int id) + +Set's the angle for the sprite id + +##### setActorScale(float scale, string/int id) + +Set's the scale for the sprite id + +##### setActorScaleX(float x, string/int id) + +Set's the scale x for the sprite id + +##### setActorScaleY(float y, string/int id) + +Set's the scale y for the sprite id + +##### getActorWidth(string/int id) + +Returns the width for the sprite id + +##### getActorHeight(string/int id) + +Returns the height for the sprite id + +### Tweens + +*Note, On Complete functions are based by the function name (and they also well get called when the tween completes)* + +##### tweenPos(string/int id, int toX, int toY, float time, string onComplete) + +Smoothly tween into a x and y position + +##### tweenPosXAngle(string/int id, int toX, float toAngle, float time, string onComplete) + +Smoothly tween into a x position and angle + +##### tweenPosYAngle(string/int id, int toY, float toAngle, float time, string onComplete) + +Smoothly tween into a y position and angle + +##### tweenAngle(string/int id, float toAngle, float time, string onComplete) + +Smoothly tween into a angle + +##### tweenFadeIn(string/int id, float toAlpha, float time, string onComplete) + +Smoothly fade in to an alpha + +##### tweenFadeOut(string/int id, float toAlpha, float time, string onComplete) + +Smoothly fade out to an alpha \ No newline at end of file diff --git a/Project.xml b/Project.xml index 2b74dfc..e50ead4 100644 --- a/Project.xml +++ b/Project.xml @@ -2,7 +2,7 @@ - + @@ -117,6 +117,8 @@ + + diff --git a/source/ChartingState.hx b/source/ChartingState.hx index 6346c88..1ea9650 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -82,6 +82,9 @@ class ChartingState extends MusicBeatState var gridBlackLine:FlxSprite; var vocals:FlxSound; + var player2:Character = new Character(0,0, "dad"); + var player1:Boyfriend = new Boyfriend(0,0, "bf"); + var leftIcon:HealthIcon; var rightIcon:HealthIcon; @@ -365,6 +368,18 @@ class ChartingState extends MusicBeatState tab_group_note.add(applyLength); UI_box.addGroup(tab_group_note); + + /*player2 = new Character(0,gridBG.y, _song.player2); + player1 = new Boyfriend(player2.width * 0.2,gridBG.y + player2.height, _song.player1); + + player1.y = player1.y - player1.height; + + player2.setGraphicSize(Std.int(player2.width * 0.2)); + player1.setGraphicSize(Std.int(player1.width * 0.2)); + + UI_box.add(player1); + UI_box.add(player2);*/ + } function loadSong(daSong:String):Void @@ -559,6 +574,77 @@ class ChartingState extends MusicBeatState strumLine.y = getYfromStrum((Conductor.songPosition - sectionStartTime()) % (Conductor.stepCrochet * _song.notes[curSection].lengthInSteps)); + + /*curRenderedNotes.forEach(function(note:Note) { + if (strumLine.overlaps(note) && strumLine.y == note.y) // yandere dev type shit + { + if (_song.notes[curSection].mustHitSection) + { + trace('must hit ' + Math.abs(note.noteData)); + if (note.noteData < 4) + { + switch (Math.abs(note.noteData)) + { + case 2: + player1.playAnim('singUP', true); + case 3: + player1.playAnim('singRIGHT', true); + case 1: + player1.playAnim('singDOWN', true); + case 0: + player1.playAnim('singLEFT', true); + } + } + if (note.noteData >= 4) + { + switch (note.noteData) + { + case 6: + player2.playAnim('singUP', true); + case 7: + player2.playAnim('singRIGHT', true); + case 5: + player2.playAnim('singDOWN', true); + case 4: + player2.playAnim('singLEFT', true); + } + } + } + else + { + trace('hit ' + Math.abs(note.noteData)); + if (note.noteData < 4) + { + switch (Math.abs(note.noteData)) + { + case 2: + player2.playAnim('singUP', true); + case 3: + player2.playAnim('singRIGHT', true); + case 1: + player2.playAnim('singDOWN', true); + case 0: + player2.playAnim('singLEFT', true); + } + } + if (note.noteData >= 4) + { + switch (note.noteData) + { + case 6: + player1.playAnim('singUP', true); + case 7: + player1.playAnim('singRIGHT', true); + case 5: + player1.playAnim('singDOWN', true); + case 4: + player1.playAnim('singLEFT', true); + } + } + } + } + });*/ + if (curBeat % 4 == 0 && curStep >= 16 * (curSection + 1)) { trace(curStep); @@ -783,6 +869,18 @@ class ChartingState extends MusicBeatState updateGrid(); } + override function beatHit() + { + trace('beat'); + + super.beatHit(); + if (!player2.animation.curAnim.name.startsWith("sing")) + { + player2.playAnim('idle'); + } + player1.dance(); + } + function recalculateSteps():Int { var lastChange:BPMChangeEvent = { diff --git a/source/Main.hx b/source/Main.hx index 97d4320..48f0fc3 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -29,6 +29,9 @@ class Main extends Sprite public static function main():Void { + + // quick checks + Lib.current.addChild(new Main()); } @@ -82,6 +85,7 @@ class Main extends Sprite fpsCounter = new FPS(10, 3, 0xFFFFFF); addChild(fpsCounter); toggleFPS(FlxG.save.data.fps); + #end } diff --git a/source/Note.hx b/source/Note.hx index 699b9bc..72124eb 100644 --- a/source/Note.hx +++ b/source/Note.hx @@ -1,5 +1,6 @@ package; +import flixel.addons.effects.FlxSkewedSprite; import flixel.FlxG; import flixel.FlxSprite; import flixel.graphics.frames.FlxAtlasFrames; @@ -11,7 +12,7 @@ import polymod.format.ParseRules.TargetSignatureElement; using StringTools; -class Note extends FlxSprite +class Note extends FlxSkewedSprite { public var strumTime:Float = 0; @@ -21,7 +22,7 @@ class Note extends FlxSprite public var tooLate:Bool = false; public var wasGoodHit:Bool = false; public var prevNote:Note; - + public var modifiedByLua:Bool = false; public var sustainLength:Float = 0; public var isSustainNote:Bool = false; @@ -172,7 +173,7 @@ class Note extends FlxSprite prevNote.animation.play('redhold'); } - prevNote.scale.y *= Conductor.stepCrochet / 100 * 1.8 * FlxG.save.data.scrollSpeed; + prevNote.scale.y *= Conductor.stepCrochet / 50 * 1.5 * FlxG.save.data.scrollSpeed; prevNote.updateHitbox(); // prevNote.setGraphicSize(); } diff --git a/source/Paths.hx b/source/Paths.hx index dcd1477..9902b71 100644 --- a/source/Paths.hx +++ b/source/Paths.hx @@ -55,6 +55,16 @@ class Paths return getPath(file, type, library); } + inline static public function lua(key:String,?library:String) + { + return getPath('data/$key.lua', TEXT, library); + } + + inline static public function luaImage(key:String, ?library:String) + { + return getPath('data/$key.png', IMAGE, library); + } + inline static public function txt(key:String, ?library:String) { return getPath('data/$key.txt', TEXT, library); diff --git a/source/PauseSubState.hx b/source/PauseSubState.hx index 3533fe0..a335ffe 100644 --- a/source/PauseSubState.hx +++ b/source/PauseSubState.hx @@ -1,5 +1,6 @@ package; +import llua.Lua; import Controls.Control; import flixel.FlxG; import flixel.FlxSprite; @@ -179,6 +180,11 @@ class PauseSubState extends MusicBeatSubstate FlxG.resetState(); case "Exit to menu": PlayState.loadRep = false; + if (PlayState.lua != null) + { + Lua.close(PlayState.lua); + PlayState.lua = null; + } if (PlayState.offsetTesting) { PlayState.offsetTesting = false; diff --git a/source/PlayState.hx b/source/PlayState.hx index 3af5232..3cb3d8b 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -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 = []; 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, ?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 = v.split(','); + var array2 : Array = new Array(); + + for( vars in array ) { + array2.push(Std.parseFloat(vars)); + } + + return array2; + } else if( type.substr(4) == 'int' ) { + var array : Array = v.split(','); + var array2 : Array = new Array(); + + for( vars in array ) { + array2.push(Std.parseInt(vars)); + } + + return array2; + } else { + var array : Array = 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 = []; + + + + 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) diff --git a/source/TitleState.hx b/source/TitleState.hx index def04db..3afcf92 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -59,6 +59,10 @@ class TitleState extends MusicBeatState sys.FileSystem.createDirectory(Sys.getCwd() + "/assets/replays"); #end + @:privateAccess + { + trace("Loaded " + openfl.Assets.getLibrary("default").assetsLoaded + " assets (DEFAULT)"); + } PlayerSettings.init(); From 7f9cca019c82d63754ecff6d2288b542fe5ced05 Mon Sep 17 00:00:00 2001 From: KadeDev Date: Thu, 15 Apr 2021 11:10:49 -0700 Subject: [PATCH 05/17] actually lets not make this skewed --- source/Note.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Note.hx b/source/Note.hx index 72124eb..de7f8bd 100644 --- a/source/Note.hx +++ b/source/Note.hx @@ -12,7 +12,7 @@ import polymod.format.ParseRules.TargetSignatureElement; using StringTools; -class Note extends FlxSkewedSprite +class Note extends FlxSprite { public var strumTime:Float = 0; From 021f5777636833237559ea4eb05fe170b7d56a7b Mon Sep 17 00:00:00 2001 From: Kade M Date: Thu, 15 Apr 2021 11:11:43 -0700 Subject: [PATCH 06/17] update building --- BUILDING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/BUILDING.md b/BUILDING.md index 7c26efc..6b4c446 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -24,6 +24,7 @@ - `haxelib install flixel-ui` - `haxelib install hscript` - `haxelib install newgrounds` + - `haxelib install linc_luajit` - `haxelib git faxe https://github.com/uhrobots/faxe` - `haxelib git polymod https://github.com/larsiusprime/polymod.git` - `haxelib git discord_rpc https://github.com/Aidan63/linc_discord-rpc` From 9daf7ba36e414da8568705fec916728513b1a25d Mon Sep 17 00:00:00 2001 From: KadeDev Date: Thu, 15 Apr 2021 11:14:55 -0700 Subject: [PATCH 07/17] update appveyor's --- appveyor-linux.yml | 1 + appveyor-windows.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/appveyor-linux.yml b/appveyor-linux.yml index bc3bed6..6e9a95a 100644 --- a/appveyor-linux.yml +++ b/appveyor-linux.yml @@ -28,6 +28,7 @@ install: - haxelib git faxe https://github.com/uhrobots/faxe - haxelib git polymod https://github.com/larsiusprime/polymod.git - haxelib git discord_rpc https://github.com/Aidan63/linc_discord-rpc + - haxelib install linc_luajit - haxelib list - cd /home/appveyor/projects/kade-engine-linux diff --git a/appveyor-windows.yml b/appveyor-windows.yml index 801fd23..01bac78 100644 --- a/appveyor-windows.yml +++ b/appveyor-windows.yml @@ -32,6 +32,7 @@ install: - haxelib git faxe https://github.com/uhrobots/faxe - haxelib git polymod https://github.com/larsiusprime/polymod.git - haxelib git discord_rpc https://github.com/Aidan63/linc_discord-rpc + - haxelib install linc_luajit - haxelib list # No tests idk lol From 46c688d2e4ab40e51f5304af0c43e7005dc0f36f Mon Sep 17 00:00:00 2001 From: Kade M Date: Thu, 15 Apr 2021 11:54:48 -0700 Subject: [PATCH 08/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d911b31..3f6cc27 100644 --- a/README.md +++ b/README.md @@ -61,4 +61,4 @@ This game was made with love to Newgrounds and its community. Extra love to Tom # Other pages - [BUILDING.md](https://github.com/KadeDev/Kade-Engine/blob/master/BUILDING.md) - How to compile/build the game - + - [ModCharts.md](https://github.com/KadeDev/Kade-Engine/blob/master/ModCharts.md) - Mod Chart Documentation From 04cbd2b81d1c54a2d067b2f562cec712dd92bf3a Mon Sep 17 00:00:00 2001 From: Kade M Date: Thu, 15 Apr 2021 11:56:25 -0700 Subject: [PATCH 09/17] Update ModCharts.md --- ModCharts.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ModCharts.md b/ModCharts.md index 571443c..b40b405 100644 --- a/ModCharts.md +++ b/ModCharts.md @@ -1,4 +1,4 @@ -Kade Engine Lua Mod Chart Documentation +# Kade Engine Lua Mod Chart Documentation In the latest version of Kade Engine we introduced Mod Charts. Mod Charts are a way of changing gameplay without hard coded values, this is achieved by using the Lua Scripting language to create script files that run during runtime. @@ -347,4 +347,4 @@ Smoothly fade in to an alpha ##### tweenFadeOut(string/int id, float toAlpha, float time, string onComplete) -Smoothly fade out to an alpha \ No newline at end of file +Smoothly fade out to an alpha From 6f5969aadfc8843daf9c1ad79fd884edbb1f458e Mon Sep 17 00:00:00 2001 From: Kade M Date: Thu, 15 Apr 2021 11:57:09 -0700 Subject: [PATCH 10/17] Update ModCharts.md --- ModCharts.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ModCharts.md b/ModCharts.md index b40b405..b80b85e 100644 --- a/ModCharts.md +++ b/ModCharts.md @@ -2,7 +2,9 @@ In the latest version of Kade Engine we introduced Mod Charts. Mod Charts are a way of changing gameplay without hard coded values, this is achieved by using the Lua Scripting language to create script files that run during runtime. -All files **are located in** `assets/data/song/modchart.lua` +All files **are located in** `assets/data/song/` + +Modchart Lua File should be in `assets/data/song/modchart.lua` **exactly** Lua code will only be ran if that file exists. From 408aee0095c13bd79ca1bf7b35b879e6710207d5 Mon Sep 17 00:00:00 2001 From: KadeDev Date: Thu, 15 Apr 2021 13:26:38 -0700 Subject: [PATCH 11/17] modchart loading things --- source/PlayState.hx | 502 ++++++++++++++++++++++---------------------- 1 file changed, 253 insertions(+), 249 deletions(-) diff --git a/source/PlayState.hx b/source/PlayState.hx index 3cb3d8b..9f84f48 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -899,6 +899,255 @@ class PlayState extends MusicBeatState kadeEngineWatermark.cameras = [camHUD]; if (loadRep) replayTxt.cameras = [camHUD]; + + + + 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]))); + } + // if (SONG.song == 'South') // FlxG.camera.alpha = 0.7; // UI_camera.zoom = 1; @@ -1359,10 +1608,12 @@ class PlayState extends MusicBeatState // LUA SHIT + var songStarted = false; + function startSong():Void { startingSong = false; - + songStarted = true; previousFrameTime = FlxG.game.ticks; lastReportedPlayheadPosition = 0; @@ -1371,253 +1622,6 @@ class PlayState extends MusicBeatState 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(); @@ -2071,7 +2075,7 @@ class PlayState extends MusicBeatState perfectMode = false; #end - if (executeModchart && lua != null) + if (executeModchart && lua != null && songStarted) { setVar('songPos',Conductor.songPosition); setVar('hudZoom', camHUD.zoom); From 818b39ff2028d973e4aa9fe1bf637397a6fe7c04 Mon Sep 17 00:00:00 2001 From: KadeDev Date: Thu, 15 Apr 2021 15:07:08 -0700 Subject: [PATCH 12/17] linux build will work now --- source/Note.hx | 2 +- source/PlayState.hx | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/Note.hx b/source/Note.hx index de7f8bd..42a8fc7 100644 --- a/source/Note.hx +++ b/source/Note.hx @@ -173,7 +173,7 @@ class Note extends FlxSprite prevNote.animation.play('redhold'); } - prevNote.scale.y *= Conductor.stepCrochet / 50 * 1.5 * FlxG.save.data.scrollSpeed; + prevNote.scale.y *= Conductor.stepCrochet / 100 * 1.5 * FlxG.save.data.scrollSpeed; prevNote.updateHitbox(); // prevNote.setGraphicSize(); } diff --git a/source/PlayState.hx b/source/PlayState.hx index 9f84f48..ee426e6 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -55,8 +55,10 @@ import openfl.display.BlendMode; import openfl.display.StageQuality; import openfl.filters.ShaderFilter; -#if desktop +#if windows import Discord.DiscordClient; +#end +#if desktop import Sys; import sys.FileSystem; #end @@ -2592,7 +2594,7 @@ class PlayState extends MusicBeatState if (daNote.isSustainNote) - daNote.x += daNote.width / 2 + 7; + daNote.x += daNote.width / 2 + 17; //trace(daNote.y); // WIP interpolation shit? Need to fix the pause issue From f1197966ff0b0d706b06dc8a317328d724ffe724 Mon Sep 17 00:00:00 2001 From: Kade M Date: Thu, 15 Apr 2021 16:33:11 -0700 Subject: [PATCH 13/17] fixed loading --- source/PlayState.hx | 706 ++++++++++++++++++++++---------------------- 1 file changed, 355 insertions(+), 351 deletions(-) diff --git a/source/PlayState.hx b/source/PlayState.hx index ee426e6..f37ff99 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -204,6 +204,201 @@ class PlayState extends MusicBeatState private var executeModchart = false; + // LUA SHIT + + public static var lua:State = null; + + function callLua(func_name : String, args : Array, ?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 (getLuaErrorMessage(lua) != null) + trace(func_name + ' LUA CALL ERROR ' + Lua.tostring(lua,result)); + + 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 = v.split(','); + var array2 : Array = new Array(); + + for( vars in array ) { + array2.push(Std.parseFloat(vars)); + } + + return array2; + } else if( type.substr(4) == 'int' ) { + var array : Array = v.split(','); + var array2 : Array = new Array(); + + for( vars in array ) { + array2.push(Std.parseInt(vars)); + } + + return array2; + } else { + var array : Array = 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 = []; + + + + 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 + override public function create() { @@ -902,6 +1097,164 @@ class PlayState extends MusicBeatState if (loadRep) replayTxt.cameras = [camHUD]; + // if (SONG.song == 'South') + // FlxG.camera.alpha = 0.7; + // UI_camera.zoom = 1; + + // cameras = [FlxG.cameras.list[1]]; + startingSong = true; + + if (isStoryMode) + { + switch (curSong.toLowerCase()) + { + case "winter-horrorland": + var blackScreen:FlxSprite = new FlxSprite(0, 0).makeGraphic(Std.int(FlxG.width * 2), Std.int(FlxG.height * 2), FlxColor.BLACK); + add(blackScreen); + blackScreen.scrollFactor.set(); + camHUD.visible = false; + + new FlxTimer().start(0.1, function(tmr:FlxTimer) + { + remove(blackScreen); + FlxG.sound.play(Paths.sound('Lights_Turn_On')); + camFollow.y = -2050; + camFollow.x += 200; + FlxG.camera.focusOn(camFollow.getPosition()); + FlxG.camera.zoom = 1.5; + + new FlxTimer().start(0.8, function(tmr:FlxTimer) + { + camHUD.visible = true; + remove(blackScreen); + FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom}, 2.5, { + ease: FlxEase.quadInOut, + onComplete: function(twn:FlxTween) + { + startCountdown(); + } + }); + }); + }); + case 'senpai': + schoolIntro(doof); + case 'roses': + FlxG.sound.play(Paths.sound('ANGRY')); + schoolIntro(doof); + case 'thorns': + schoolIntro(doof); + default: + startCountdown(); + } + } + else + { + switch (curSong.toLowerCase()) + { + default: + startCountdown(); + } + } + + if (!loadRep) + rep = new Replay("na"); + + super.create(); + } + + function schoolIntro(?dialogueBox:DialogueBox):Void + { + var black:FlxSprite = new FlxSprite(-100, -100).makeGraphic(FlxG.width * 2, FlxG.height * 2, FlxColor.BLACK); + black.scrollFactor.set(); + add(black); + + var red:FlxSprite = new FlxSprite(-100, -100).makeGraphic(FlxG.width * 2, FlxG.height * 2, 0xFFff1b31); + red.scrollFactor.set(); + + var senpaiEvil:FlxSprite = new FlxSprite(); + senpaiEvil.frames = Paths.getSparrowAtlas('weeb/senpaiCrazy'); + senpaiEvil.animation.addByPrefix('idle', 'Senpai Pre Explosion', 24, false); + senpaiEvil.setGraphicSize(Std.int(senpaiEvil.width * 6)); + senpaiEvil.scrollFactor.set(); + senpaiEvil.updateHitbox(); + senpaiEvil.screenCenter(); + + if (SONG.song.toLowerCase() == 'roses' || SONG.song.toLowerCase() == 'thorns') + { + remove(black); + + if (SONG.song.toLowerCase() == 'thorns') + { + add(red); + } + } + + new FlxTimer().start(0.3, function(tmr:FlxTimer) + { + black.alpha -= 0.15; + + if (black.alpha > 0) + { + tmr.reset(0.3); + } + else + { + if (dialogueBox != null) + { + inCutscene = true; + + if (SONG.song.toLowerCase() == 'thorns') + { + add(senpaiEvil); + senpaiEvil.alpha = 0; + new FlxTimer().start(0.3, function(swagTimer:FlxTimer) + { + senpaiEvil.alpha += 0.15; + if (senpaiEvil.alpha < 1) + { + swagTimer.reset(); + } + else + { + senpaiEvil.animation.play('idle'); + FlxG.sound.play(Paths.sound('Senpai_Dies'), 1, false, null, true, function() + { + remove(senpaiEvil); + remove(red); + FlxG.camera.fade(FlxColor.WHITE, 0.01, true, function() + { + add(dialogueBox); + }, true); + }); + new FlxTimer().start(3.2, function(deadTime:FlxTimer) + { + FlxG.camera.fade(FlxColor.WHITE, 1.6, false); + }); + } + }); + } + else + { + add(dialogueBox); + } + } + else + startCountdown(); + + remove(black); + } + }); + } + + var startTimer:FlxTimer; + var perfectMode:Bool = false; + + function startCountdown():Void + { + inCutscene = false; + + generateStaticArrows(0); + generateStaticArrows(1); if (executeModchart) // dude I hate lua (jkjkjkjk) @@ -917,7 +1270,7 @@ class PlayState extends MusicBeatState if (result != 0) trace('COMPILE ERROR\n' + getLuaErrorMessage(lua)); - + // get some fukin globals up in here bois setVar("bpm", Conductor.bpm); @@ -1150,165 +1503,6 @@ class PlayState extends MusicBeatState trace('return: ' + Lua.tostring(lua,callLua('start', [PlayState.SONG.song]))); } - // if (SONG.song == 'South') - // FlxG.camera.alpha = 0.7; - // UI_camera.zoom = 1; - - // cameras = [FlxG.cameras.list[1]]; - startingSong = true; - - if (isStoryMode) - { - switch (curSong.toLowerCase()) - { - case "winter-horrorland": - var blackScreen:FlxSprite = new FlxSprite(0, 0).makeGraphic(Std.int(FlxG.width * 2), Std.int(FlxG.height * 2), FlxColor.BLACK); - add(blackScreen); - blackScreen.scrollFactor.set(); - camHUD.visible = false; - - new FlxTimer().start(0.1, function(tmr:FlxTimer) - { - remove(blackScreen); - FlxG.sound.play(Paths.sound('Lights_Turn_On')); - camFollow.y = -2050; - camFollow.x += 200; - FlxG.camera.focusOn(camFollow.getPosition()); - FlxG.camera.zoom = 1.5; - - new FlxTimer().start(0.8, function(tmr:FlxTimer) - { - camHUD.visible = true; - remove(blackScreen); - FlxTween.tween(FlxG.camera, {zoom: defaultCamZoom}, 2.5, { - ease: FlxEase.quadInOut, - onComplete: function(twn:FlxTween) - { - startCountdown(); - } - }); - }); - }); - case 'senpai': - schoolIntro(doof); - case 'roses': - FlxG.sound.play(Paths.sound('ANGRY')); - schoolIntro(doof); - case 'thorns': - schoolIntro(doof); - default: - startCountdown(); - } - } - else - { - switch (curSong.toLowerCase()) - { - default: - startCountdown(); - } - } - - if (!loadRep) - rep = new Replay("na"); - - super.create(); - } - - function schoolIntro(?dialogueBox:DialogueBox):Void - { - var black:FlxSprite = new FlxSprite(-100, -100).makeGraphic(FlxG.width * 2, FlxG.height * 2, FlxColor.BLACK); - black.scrollFactor.set(); - add(black); - - var red:FlxSprite = new FlxSprite(-100, -100).makeGraphic(FlxG.width * 2, FlxG.height * 2, 0xFFff1b31); - red.scrollFactor.set(); - - var senpaiEvil:FlxSprite = new FlxSprite(); - senpaiEvil.frames = Paths.getSparrowAtlas('weeb/senpaiCrazy'); - senpaiEvil.animation.addByPrefix('idle', 'Senpai Pre Explosion', 24, false); - senpaiEvil.setGraphicSize(Std.int(senpaiEvil.width * 6)); - senpaiEvil.scrollFactor.set(); - senpaiEvil.updateHitbox(); - senpaiEvil.screenCenter(); - - if (SONG.song.toLowerCase() == 'roses' || SONG.song.toLowerCase() == 'thorns') - { - remove(black); - - if (SONG.song.toLowerCase() == 'thorns') - { - add(red); - } - } - - new FlxTimer().start(0.3, function(tmr:FlxTimer) - { - black.alpha -= 0.15; - - if (black.alpha > 0) - { - tmr.reset(0.3); - } - else - { - if (dialogueBox != null) - { - inCutscene = true; - - if (SONG.song.toLowerCase() == 'thorns') - { - add(senpaiEvil); - senpaiEvil.alpha = 0; - new FlxTimer().start(0.3, function(swagTimer:FlxTimer) - { - senpaiEvil.alpha += 0.15; - if (senpaiEvil.alpha < 1) - { - swagTimer.reset(); - } - else - { - senpaiEvil.animation.play('idle'); - FlxG.sound.play(Paths.sound('Senpai_Dies'), 1, false, null, true, function() - { - remove(senpaiEvil); - remove(red); - FlxG.camera.fade(FlxColor.WHITE, 0.01, true, function() - { - add(dialogueBox); - }, true); - }); - new FlxTimer().start(3.2, function(deadTime:FlxTimer) - { - FlxG.camera.fade(FlxColor.WHITE, 1.6, false); - }); - } - }); - } - else - { - add(dialogueBox); - } - } - else - startCountdown(); - - remove(black); - } - }); - } - - var startTimer:FlxTimer; - var perfectMode:Bool = false; - - function startCountdown():Void - { - inCutscene = false; - - generateStaticArrows(0); - generateStaticArrows(1); - talking = false; startedCountdown = true; Conductor.songPosition = 0; @@ -1418,197 +1612,6 @@ 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, ?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 = v.split(','); - var array2 : Array = new Array(); - - for( vars in array ) { - array2.push(Std.parseFloat(vars)); - } - - return array2; - } else if( type.substr(4) == 'int' ) { - var array : Array = v.split(','); - var array2 : Array = new Array(); - - for( vars in array ) { - array2.push(Std.parseInt(vars)); - } - - return array2; - } else { - var array : Array = 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 = []; - - - - 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 var songStarted = false; @@ -2595,6 +2598,7 @@ class PlayState extends MusicBeatState if (daNote.isSustainNote) daNote.x += daNote.width / 2 + 17; + //trace(daNote.y); // WIP interpolation shit? Need to fix the pause issue From a0d8d26c4ad8788ca342550b876a27e3f95da852 Mon Sep 17 00:00:00 2001 From: KadeDev Date: Thu, 15 Apr 2021 17:53:55 -0700 Subject: [PATCH 14/17] modchart and version change --- CHANGELOG.md | 11 +++++++++++ source/MainMenuState.hx | 2 +- source/Note.hx | 3 ++- version.downloadMe | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2075c2..859ccc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ All notable changes will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.4.2] +### Changed +- Trails on notes are more consistent +- Title now shows "Friday Night Funkin' Kade Engine" +- **THIS UPDATE WILL RESET YOUR SAVE FOR KADE ENGINE**, so you gotta redo all of ur settings. + +### Added +- Lua Modchart support [(documentation located here)](https://github.com/KadeDev/Kade-Engine/blob/master/ModCharts.md) +- New option called watermarks which removes all watermarks from Kade Engine +- Chart spesfic offsets + ## [1.4.1] ### Fixed - Rating's and Accuracy calculation (they actually work now) diff --git a/source/MainMenuState.hx b/source/MainMenuState.hx index 55375d3..d57308b 100644 --- a/source/MainMenuState.hx +++ b/source/MainMenuState.hx @@ -38,7 +38,7 @@ class MainMenuState extends MusicBeatState public static var nightly:String = ""; - public static var kadeEngineVer:String = "1.4.1" + nightly; + public static var kadeEngineVer:String = "1.4.2" + nightly; public static var gameVer:String = "0.2.7.1"; var magenta:FlxSprite; diff --git a/source/Note.hx b/source/Note.hx index 42a8fc7..4b16f9a 100644 --- a/source/Note.hx +++ b/source/Note.hx @@ -173,7 +173,8 @@ class Note extends FlxSprite prevNote.animation.play('redhold'); } - prevNote.scale.y *= Conductor.stepCrochet / 100 * 1.5 * FlxG.save.data.scrollSpeed; + + prevNote.scale.y *= Conductor.stepCrochet / 100 * 1.8 * FlxG.save.data.scrollSpeed; prevNote.updateHitbox(); // prevNote.setGraphicSize(); } diff --git a/version.downloadMe b/version.downloadMe index 13175fd..c9929e3 100644 --- a/version.downloadMe +++ b/version.downloadMe @@ -1 +1 @@ -1.4.1 \ No newline at end of file +1.4.2 \ No newline at end of file From 71b786e71977ceb9954186fd303a281d1c897a0d Mon Sep 17 00:00:00 2001 From: Kade M Date: Thu, 15 Apr 2021 23:46:32 -0700 Subject: [PATCH 15/17] Scale broken :( --- ModCharts.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ModCharts.md b/ModCharts.md index b80b85e..c0cb350 100644 --- a/ModCharts.md +++ b/ModCharts.md @@ -251,13 +251,13 @@ Set's the scale of the rendered note id *Note: Setting a Rendered Note's property will stop the note from updating it's alpha & x properties* -##### setRenderedNoteScaleX(float scale, int id) +##### setRenderedNoteScaleX(float scale, int id) **Currently broken** Set's the scale x of the rendered note id *Note: Setting a Rendered Note's property will stop the note from updating it's alpha & x properties* -##### setRenderedNoteScaleY(float scale, int id) +##### setRenderedNoteScaleY(float scale, int id) **Currently broken** Set's the scale y of the rendered note id @@ -307,11 +307,11 @@ Set's the angle for the sprite id Set's the scale for the sprite id -##### setActorScaleX(float x, string/int id) +##### setActorScaleX(float x, string/int id) **Currently broken** Set's the scale x for the sprite id -##### setActorScaleY(float y, string/int id) +##### setActorScaleY(float y, string/int id) **Currently broken** Set's the scale y for the sprite id From 8d5d6f6e399c4e56168f4b4f3c1dedcd5b39f20f Mon Sep 17 00:00:00 2001 From: KadeDev Date: Fri, 16 Apr 2021 02:53:38 -0700 Subject: [PATCH 16/17] character loading is fixed --- source/Character.hx | 34 +++++++++++++++++----------------- source/TitleState.hx | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/source/Character.hx b/source/Character.hx index eb8158f..a4677aa 100644 --- a/source/Character.hx +++ b/source/Character.hx @@ -63,7 +63,7 @@ class Character extends FlxSprite playAnim('danceRight'); case 'gf-christmas': - tex = Paths.getSparrowAtlas('christmas/gfChristmas'); + tex = Paths.getSparrowAtlas('christmas/gfChristmas','week5'); frames = tex; animation.addByPrefix('cheer', 'GF Cheer', 24, false); animation.addByPrefix('singLEFT', 'GF left note', 24, false); @@ -94,7 +94,7 @@ class Character extends FlxSprite playAnim('danceRight'); case 'gf-car': - tex = Paths.getSparrowAtlas('gfCar'); + tex = Paths.getSparrowAtlas('gfCar','week4'); frames = tex; animation.addByIndices('singUP', 'GF Dancing Beat Hair blowing CAR', [0], "", 24, false); animation.addByIndices('danceLeft', 'GF Dancing Beat Hair blowing CAR', [30, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], "", 24, false); @@ -107,7 +107,7 @@ class Character extends FlxSprite playAnim('danceRight'); case 'gf-pixel': - tex = Paths.getSparrowAtlas('weeb/gfPixel'); + tex = Paths.getSparrowAtlas('weeb/gfPixel','week6'); frames = tex; animation.addByIndices('singUP', 'GF IDLE', [2], "", 24, false); animation.addByIndices('danceLeft', 'GF IDLE', [30, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], "", 24, false); @@ -140,7 +140,7 @@ class Character extends FlxSprite playAnim('idle'); case 'spooky': - tex = Paths.getSparrowAtlas('spooky_kids_assets'); + tex = Paths.getSparrowAtlas('spooky_kids_assets','week2'); frames = tex; animation.addByPrefix('singUP', 'spooky UP NOTE', 24, false); animation.addByPrefix('singDOWN', 'spooky DOWN note', 24, false); @@ -159,7 +159,7 @@ class Character extends FlxSprite playAnim('danceRight'); case 'mom': - tex = Paths.getSparrowAtlas('Mom_Assets'); + tex = Paths.getSparrowAtlas('Mom_Assets','week4'); frames = tex; animation.addByPrefix('idle', "Mom Idle", 24, false); @@ -179,7 +179,7 @@ class Character extends FlxSprite playAnim('idle'); case 'mom-car': - tex = Paths.getSparrowAtlas('momCar'); + tex = Paths.getSparrowAtlas('momCar','week4'); frames = tex; animation.addByPrefix('idle', "Mom Idle", 24, false); @@ -198,7 +198,7 @@ class Character extends FlxSprite playAnim('idle'); case 'monster': - tex = Paths.getSparrowAtlas('Monster_Assets'); + tex = Paths.getSparrowAtlas('Monster_Assets','week2'); frames = tex; animation.addByPrefix('idle', 'monster idle', 24, false); animation.addByPrefix('singUP', 'monster up note', 24, false); @@ -213,7 +213,7 @@ class Character extends FlxSprite addOffset("singDOWN", -30, -40); playAnim('idle'); case 'monster-christmas': - tex = Paths.getSparrowAtlas('christmas/monsterChristmas'); + tex = Paths.getSparrowAtlas('christmas/monsterChristmas','week5'); frames = tex; animation.addByPrefix('idle', 'monster idle', 24, false); animation.addByPrefix('singUP', 'monster up note', 24, false); @@ -228,7 +228,7 @@ class Character extends FlxSprite addOffset("singDOWN", -40, -94); playAnim('idle'); case 'pico': - tex = Paths.getSparrowAtlas('Pico_FNF_assetss'); + tex = Paths.getSparrowAtlas('Pico_FNF_assetss','week3'); frames = tex; animation.addByPrefix('idle', "Pico Idle Dance", 24); animation.addByPrefix('singUP', 'pico Up note0', 24, false); @@ -306,7 +306,7 @@ class Character extends FlxSprite flipX = true; case 'bf-christmas': - var tex = Paths.getSparrowAtlas('christmas/bfChristmas'); + var tex = Paths.getSparrowAtlas('christmas/bfChristmas','week5'); frames = tex; animation.addByPrefix('idle', 'BF idle dance', 24, false); animation.addByPrefix('singUP', 'BF NOTE UP0', 24, false); @@ -334,7 +334,7 @@ class Character extends FlxSprite flipX = true; case 'bf-car': - var tex = Paths.getSparrowAtlas('bfCar'); + var tex = Paths.getSparrowAtlas('bfCar','week4'); frames = tex; animation.addByPrefix('idle', 'BF idle dance', 24, false); animation.addByPrefix('singUP', 'BF NOTE UP0', 24, false); @@ -359,7 +359,7 @@ class Character extends FlxSprite flipX = true; case 'bf-pixel': - frames = Paths.getSparrowAtlas('weeb/bfPixel'); + frames = Paths.getSparrowAtlas('weeb/bfPixel','week6'); animation.addByPrefix('idle', 'BF IDLE', 24, false); animation.addByPrefix('singUP', 'BF UP NOTE', 24, false); animation.addByPrefix('singLEFT', 'BF LEFT NOTE', 24, false); @@ -392,7 +392,7 @@ class Character extends FlxSprite flipX = true; case 'bf-pixel-dead': - frames = Paths.getSparrowAtlas('weeb/bfPixelsDEAD'); + frames = Paths.getSparrowAtlas('weeb/bfPixelsDEAD','week6'); animation.addByPrefix('singUP', "BF Dies pixel", 24, false); animation.addByPrefix('firstDeath', "BF Dies pixel", 24, false); animation.addByPrefix('deathLoop', "Retry Loop", 24, true); @@ -410,7 +410,7 @@ class Character extends FlxSprite flipX = true; case 'senpai': - frames = Paths.getSparrowAtlas('weeb/senpai'); + frames = Paths.getSparrowAtlas('weeb/senpai','week6'); animation.addByPrefix('idle', 'Senpai Idle', 24, false); animation.addByPrefix('singUP', 'SENPAI UP NOTE', 24, false); animation.addByPrefix('singLEFT', 'SENPAI LEFT NOTE', 24, false); @@ -430,7 +430,7 @@ class Character extends FlxSprite antialiasing = false; case 'senpai-angry': - frames = Paths.getSparrowAtlas('weeb/senpai'); + frames = Paths.getSparrowAtlas('weeb/senpai','week6'); animation.addByPrefix('idle', 'Angry Senpai Idle', 24, false); animation.addByPrefix('singUP', 'Angry Senpai UP NOTE', 24, false); animation.addByPrefix('singLEFT', 'Angry Senpai LEFT NOTE', 24, false); @@ -450,7 +450,7 @@ class Character extends FlxSprite antialiasing = false; case 'spirit': - frames = Paths.getPackerAtlas('weeb/spirit'); + frames = Paths.getPackerAtlas('weeb/spirit','week6'); animation.addByPrefix('idle', "idle spirit_", 24, false); animation.addByPrefix('singUP', "up_", 24, false); animation.addByPrefix('singRIGHT', "right_", 24, false); @@ -471,7 +471,7 @@ class Character extends FlxSprite antialiasing = false; case 'parents-christmas': - frames = Paths.getSparrowAtlas('christmas/mom_dad_christmas_assets'); + frames = Paths.getSparrowAtlas('christmas/mom_dad_christmas_assets','week5'); animation.addByPrefix('idle', 'Parent Christmas Idle', 24, false); animation.addByPrefix('singUP', 'Parent Up Note Dad', 24, false); animation.addByPrefix('singDOWN', 'Parent Down Note Dad', 24, false); diff --git a/source/TitleState.hx b/source/TitleState.hx index 3afcf92..0097aaa 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -66,7 +66,7 @@ class TitleState extends MusicBeatState PlayerSettings.init(); - #if windows + #if desktop DiscordClient.initialize(); Application.current.onExit.add (function (exitCode) { From 15c515440bb2cc57d46d6813d52b1e125fff7850 Mon Sep 17 00:00:00 2001 From: KadeDev Date: Fri, 16 Apr 2021 12:36:53 -0700 Subject: [PATCH 17/17] fix html5 compile --- source/PauseSubState.hx | 16 ++++++------ source/PlayState.hx | 54 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 55 insertions(+), 15 deletions(-) diff --git a/source/PauseSubState.hx b/source/PauseSubState.hx index a335ffe..5e73f4b 100644 --- a/source/PauseSubState.hx +++ b/source/PauseSubState.hx @@ -1,6 +1,8 @@ package; +#if cpp import llua.Lua; +#end import Controls.Control; import flixel.FlxG; import flixel.FlxSprite; @@ -71,7 +73,7 @@ class PauseSubState extends MusicBeatSubstate perSongOffset.scrollFactor.set(); perSongOffset.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); - #if desktop + #if cpp add(perSongOffset); #end @@ -112,7 +114,7 @@ class PauseSubState extends MusicBeatSubstate changeSelection(1); } - #if desktop + #if cpp else if (leftP) { oldOffset = PlayState.songOffset; @@ -180,18 +182,14 @@ class PauseSubState extends MusicBeatSubstate FlxG.resetState(); case "Exit to menu": PlayState.loadRep = false; + #if cpp if (PlayState.lua != null) { Lua.close(PlayState.lua); PlayState.lua = null; } - if (PlayState.offsetTesting) - { - PlayState.offsetTesting = false; - FlxG.switchState(new OptionsMenu()); - } - else - FlxG.switchState(new MainMenuState()); + #end + FlxG.switchState(new MainMenuState()); } } diff --git a/source/PlayState.hx b/source/PlayState.hx index f37ff99..26a16a2 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -8,10 +8,16 @@ import flixel.graphics.FlxGraphic; import openfl.utils.AssetManifest; import openfl.utils.AssetLibrary; import flixel.system.FlxAssets; + +// Lua + +#if cpp import llua.Convert; import llua.Lua; import llua.State; import llua.LuaL; +#end + import lime.app.Application; import lime.media.AudioContext; import lime.media.AudioManager; @@ -58,7 +64,7 @@ import openfl.filters.ShaderFilter; #if windows import Discord.DiscordClient; #end -#if desktop +#if cpp import Sys; import sys.FileSystem; #end @@ -205,7 +211,9 @@ class PlayState extends MusicBeatState private var executeModchart = false; // LUA SHIT - + + #if cpp + public static var lua:State = null; function callLua(func_name : String, args : Array, ?type : String) : Dynamic @@ -396,7 +404,7 @@ class PlayState extends MusicBeatState #end return toBeCalled; } - + #end // LUA SHIT override public function create() @@ -1257,6 +1265,7 @@ class PlayState extends MusicBeatState generateStaticArrows(1); + #if cpp if (executeModchart) // dude I hate lua (jkjkjkjk) { 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]))); } + + #end talking = false; startedCountdown = true; Conductor.songPosition = 0; @@ -1707,7 +1718,7 @@ class PlayState extends MusicBeatState var playerCounter:Int = 0; // Per song offset check - #if desktop + #if cpp var songPath = 'assets/data/' + PlayState.SONG.song.toLowerCase() + '/'; for(file in sys.FileSystem.readDirectory(songPath)) { @@ -2080,6 +2091,7 @@ class PlayState extends MusicBeatState perfectMode = false; #end + #if cpp if (executeModchart && lua != null && songStarted) { setVar('songPos',Conductor.songPosition); @@ -2127,6 +2139,8 @@ class PlayState extends MusicBeatState } } + #end + if (currentFrames == FlxG.save.data.fpsCap) { for(i in 0...notesHitArray.length) @@ -2206,11 +2220,13 @@ class PlayState extends MusicBeatState DiscordClient.changePresence("Chart Editor", null, null, true); #end FlxG.switchState(new ChartingState()); + #if cpp if (lua != null) { Lua.close(lua); lua = null; } + #end } // 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) { - 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); 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) { - 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) { @@ -2646,11 +2680,13 @@ class PlayState extends MusicBeatState if (!loadRep) rep.SaveReplay(); + #if cpp if (executeModchart) { Lua.close(lua); lua = null; } + #end canPause = false; FlxG.sound.music.volume = 0; @@ -2686,11 +2722,13 @@ class PlayState extends MusicBeatState FlxG.switchState(new StoryMenuState()); + #if cpp if (lua != null) { Lua.close(lua); lua = null; } + #end // if () StoryMenuState.weekUnlocked[Std.int(Math.min(storyWeek + 1, StoryMenuState.weekUnlocked.length - 1))] = true; @@ -3710,11 +3748,13 @@ class PlayState extends MusicBeatState resyncVocals(); } + #if cpp if (executeModchart && lua != null) { setVar('curStep',curStep); callLua('stepHit',[curStep]); } + #end if (dad.curCharacter == 'spooky' && curStep % 4 == 2) { @@ -3747,11 +3787,13 @@ class PlayState extends MusicBeatState notes.sort(FlxSort.byY, FlxSort.DESCENDING); } + #if cpp if (executeModchart && lua != null) { setVar('curBeat',curBeat); callLua('beatHit',[curBeat]); } + #end if (SONG.notes[Math.floor(curStep / 16)] != null) {