From fc17c1daebcadff09d17caf29c12236591d24971 Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Thu, 9 Sep 2021 16:32:30 -0400 Subject: [PATCH 01/17] Remove additional Newgrounds references. --- source/DiffOverview.hx | 1 - source/KeyBindMenu.hx | 1 - source/MainMenuState.hx | 1 - source/ResultsScreen.hx | 1 - 4 files changed, 4 deletions(-) diff --git a/source/DiffOverview.hx b/source/DiffOverview.hx index 2a11393c99..5d648446a5 100644 --- a/source/DiffOverview.hx +++ b/source/DiffOverview.hx @@ -23,7 +23,6 @@ import flixel.util.FlxSort; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.util.FlxColor; -import io.newgrounds.NG; import lime.app.Application; import lime.utils.Assets; import flixel.math.FlxMath; diff --git a/source/KeyBindMenu.hx b/source/KeyBindMenu.hx index 12d1a5e35f..c7b3075575 100644 --- a/source/KeyBindMenu.hx +++ b/source/KeyBindMenu.hx @@ -19,7 +19,6 @@ import flixel.text.FlxText; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.util.FlxColor; -import io.newgrounds.NG; import lime.app.Application; import lime.utils.Assets; import flixel.math.FlxMath; diff --git a/source/MainMenuState.hx b/source/MainMenuState.hx index 53c3cb0e48..8d098e71ee 100644 --- a/source/MainMenuState.hx +++ b/source/MainMenuState.hx @@ -13,7 +13,6 @@ import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.util.FlxColor; import flixel.util.FlxTimer; -import io.newgrounds.NG; import lime.app.Application; #if desktop diff --git a/source/ResultsScreen.hx b/source/ResultsScreen.hx index d286eb2ec1..c10ef87df3 100644 --- a/source/ResultsScreen.hx +++ b/source/ResultsScreen.hx @@ -23,7 +23,6 @@ import flixel.text.FlxText; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.util.FlxColor; -import io.newgrounds.NG; import lime.app.Application; import lime.utils.Assets; import flixel.math.FlxMath; From e8da9e9ef53601001b93c7fd4b31610091eb0c7b Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Thu, 9 Sep 2021 18:53:15 -0400 Subject: [PATCH 02/17] Attempt 1 at fixing Github CI --- .github/workflows/windows.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 38c970df52..0b45d69bbe 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -35,7 +35,6 @@ jobs: haxelib run lime setup flixel haxelib run lime setup haxelib install flixel-tools - haxelib run flixel-tools setup -y # Can't do this since it asks [y/n] even with -y argument! Stupid haxelib install flixel-addons haxelib install flixel-ui haxelib install hscript @@ -45,7 +44,8 @@ jobs: haxelib git discord_rpc https://github.com/Aidan63/linc_discord-rpc haxelib git extension-webm https://github.com/KadeDev/extension-webm haxelib run lime rebuild extension-webm windows - haxelib install linc_luajit + haxelib git linc_luajit https://github.com/nebulazorua/linc_luajit.git + haxelib git hxvm-luajit https://github.com/nebulazorua/hxvm-luajit haxelib install actuate haxelib list haxelib run lime build windows From 5cc3e739e728334d1b1a2f19160c549412cc6184 Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Thu, 9 Sep 2021 19:17:58 -0400 Subject: [PATCH 03/17] Update Haxe version in windows.yml --- .github/workflows/windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 0b45d69bbe..956406e864 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/checkout@v2 - uses: krdlab/setup-haxe@v1 with: - haxe-version: 4.0.5 + haxe-version: 4.1.5 # Runs a set of commands using the runners shell - name: script run line haha run: | From 3172527de4ddf0467994e448634797544ba7ec58 Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Thu, 9 Sep 2021 19:23:41 -0400 Subject: [PATCH 04/17] Rework CI to add new target. --- .github/workflows/html5.yml | 55 +++++++++++++++++++++++++++++++++++ .github/workflows/windows.yml | 3 +- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/html5.yml diff --git a/.github/workflows/html5.yml b/.github/workflows/html5.yml new file mode 100644 index 0000000000..84014b9c88 --- /dev/null +++ b/.github/workflows/html5.yml @@ -0,0 +1,55 @@ +# This is a basic workflow to help you get started with Actions + +name: HTML5 Build CI + +# Controls when the workflow will run +on: push + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + - uses: krdlab/setup-haxe@v1 + with: + haxe-version: 4.1.5 + # Runs a set of commands using the runners shell + - name: script run line haha + run: | + cinst haxe --version 4.1.5 -y + RefreshEnv + mkdir "%HAXELIB_ROOT%" + haxelib setup "%HAXELIB_ROOT%" + Install project dependencies + haxelib install lime 7.9.0 + RefreshEnv + haxelib install openfl + haxelib install flixel + haxelib run lime setup flixel + haxelib run lime setup + haxelib install flixel-tools + haxelib install flixel-addons + haxelib install flixel-ui + haxelib install hscript + haxelib install flixel-addons + 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 git extension-webm https://github.com/KadeDev/extension-webm + haxelib run lime rebuild extension-webm linux + haxelib git linc_luajit https://github.com/nebulazorua/linc_luajit.git + haxelib git hxvm-luajit https://github.com/nebulazorua/hxvm-luajit + haxelib install actuate + haxelib list + haxelib run lime build html5 + + - uses: actions/upload-artifact@v2 + with: + name: Windows Build + path: export/release/windows/bin diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 956406e864..589bff1bc2 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,6 +1,6 @@ # This is a basic workflow to help you get started with Actions -name: CI +name: Windows Build CI # Controls when the workflow will run on: push @@ -22,7 +22,6 @@ jobs: # Runs a set of commands using the runners shell - name: script run line haha run: | - cinst neko --version 2.3.0 -y cinst haxe --version 4.1.5 -y RefreshEnv mkdir "%HAXELIB_ROOT%" From f2912217d607c7fd8aae4804182104afebef9823 Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Thu, 9 Sep 2021 19:38:55 -0400 Subject: [PATCH 05/17] Fix to HTML5 target and add Linux target --- .github/workflows/html5.yml | 4 ++- .github/workflows/linux.yml | 57 +++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/linux.yml diff --git a/.github/workflows/html5.yml b/.github/workflows/html5.yml index 84014b9c88..48495fe8cd 100644 --- a/.github/workflows/html5.yml +++ b/.github/workflows/html5.yml @@ -22,7 +22,9 @@ jobs: # Runs a set of commands using the runners shell - name: script run line haha run: | - cinst haxe --version 4.1.5 -y + add-apt-repository ppa:haxe/releases -y + apt-get update + apt-get install haxe -y RefreshEnv mkdir "%HAXELIB_ROOT%" haxelib setup "%HAXELIB_ROOT%" diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000000..a873c3b625 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,57 @@ +# This is a basic workflow to help you get started with Actions + +name: Linux Build CI + +# Controls when the workflow will run +on: push + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + - uses: krdlab/setup-haxe@v1 + with: + haxe-version: 4.1.5 + # Runs a set of commands using the runners shell + - name: script run line haha + run: | + add-apt-repository ppa:haxe/releases -y + apt-get update + apt-get install haxe -y + RefreshEnv + mkdir "%HAXELIB_ROOT%" + haxelib setup "%HAXELIB_ROOT%" + Install project dependencies + haxelib install lime 7.9.0 + RefreshEnv + haxelib install openfl + haxelib install flixel + haxelib run lime setup flixel + haxelib run lime setup + haxelib install flixel-tools + haxelib install flixel-addons + haxelib install flixel-ui + haxelib install hscript + haxelib install flixel-addons + 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 git extension-webm https://github.com/KadeDev/extension-webm + haxelib run lime rebuild extension-webm linux + haxelib git linc_luajit https://github.com/nebulazorua/linc_luajit.git + haxelib git hxvm-luajit https://github.com/nebulazorua/hxvm-luajit + haxelib install actuate + haxelib list + haxelib run lime build linux + + - uses: actions/upload-artifact@v2 + with: + name: Windows Build + path: export/release/windows/bin From e43491cf936dd7db6c2e455c6fb7664748f66cf0 Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Thu, 9 Sep 2021 19:58:32 -0400 Subject: [PATCH 06/17] Add sudo to linux commands --- .github/workflows/html5.yml | 6 +++--- .github/workflows/linux.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/html5.yml b/.github/workflows/html5.yml index 48495fe8cd..c12ce3c693 100644 --- a/.github/workflows/html5.yml +++ b/.github/workflows/html5.yml @@ -22,9 +22,9 @@ jobs: # Runs a set of commands using the runners shell - name: script run line haha run: | - add-apt-repository ppa:haxe/releases -y - apt-get update - apt-get install haxe -y + sudo add-apt-repository ppa:haxe/releases -y + sudo apt-get update + sudo apt-get install haxe -y RefreshEnv mkdir "%HAXELIB_ROOT%" haxelib setup "%HAXELIB_ROOT%" diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a873c3b625..2b22b94240 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -22,9 +22,9 @@ jobs: # Runs a set of commands using the runners shell - name: script run line haha run: | - add-apt-repository ppa:haxe/releases -y - apt-get update - apt-get install haxe -y + sudo add-apt-repository ppa:haxe/releases -y + sudo apt-get update + sudo apt-get install haxe -y RefreshEnv mkdir "%HAXELIB_ROOT%" haxelib setup "%HAXELIB_ROOT%" From 99fe19d68d23187452ea24e3185d9cf293e218d1 Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Thu, 9 Sep 2021 20:16:48 -0400 Subject: [PATCH 07/17] Remove invalid command. --- .github/workflows/html5.yml | 2 -- .github/workflows/linux.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/.github/workflows/html5.yml b/.github/workflows/html5.yml index c12ce3c693..09ed92d437 100644 --- a/.github/workflows/html5.yml +++ b/.github/workflows/html5.yml @@ -25,12 +25,10 @@ jobs: sudo add-apt-repository ppa:haxe/releases -y sudo apt-get update sudo apt-get install haxe -y - RefreshEnv mkdir "%HAXELIB_ROOT%" haxelib setup "%HAXELIB_ROOT%" Install project dependencies haxelib install lime 7.9.0 - RefreshEnv haxelib install openfl haxelib install flixel haxelib run lime setup flixel diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 2b22b94240..a64e9ba5cc 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -25,12 +25,10 @@ jobs: sudo add-apt-repository ppa:haxe/releases -y sudo apt-get update sudo apt-get install haxe -y - RefreshEnv mkdir "%HAXELIB_ROOT%" haxelib setup "%HAXELIB_ROOT%" Install project dependencies haxelib install lime 7.9.0 - RefreshEnv haxelib install openfl haxelib install flixel haxelib run lime setup flixel From 8799633c3078d51e68c925387a0673be2f8ae541 Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Thu, 9 Sep 2021 20:27:01 -0400 Subject: [PATCH 08/17] Remove comment line. --- .github/workflows/html5.yml | 1 - .github/workflows/linux.yml | 1 - .github/workflows/windows.yml | 1 - 3 files changed, 3 deletions(-) diff --git a/.github/workflows/html5.yml b/.github/workflows/html5.yml index 09ed92d437..65cd824f7f 100644 --- a/.github/workflows/html5.yml +++ b/.github/workflows/html5.yml @@ -27,7 +27,6 @@ jobs: sudo apt-get install haxe -y mkdir "%HAXELIB_ROOT%" haxelib setup "%HAXELIB_ROOT%" - Install project dependencies haxelib install lime 7.9.0 haxelib install openfl haxelib install flixel diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a64e9ba5cc..a642cd077b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -27,7 +27,6 @@ jobs: sudo apt-get install haxe -y mkdir "%HAXELIB_ROOT%" haxelib setup "%HAXELIB_ROOT%" - Install project dependencies haxelib install lime 7.9.0 haxelib install openfl haxelib install flixel diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 589bff1bc2..8e28227f47 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -26,7 +26,6 @@ jobs: RefreshEnv mkdir "%HAXELIB_ROOT%" haxelib setup "%HAXELIB_ROOT%" - Install project dependencies haxelib install lime 7.9.0 RefreshEnv haxelib install openfl From 331d87d1e83616c39fccd949c864bd517368ca53 Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Thu, 9 Sep 2021 20:37:48 -0400 Subject: [PATCH 09/17] Add 32-bit libraries. --- .github/workflows/html5.yml | 2 +- .github/workflows/linux.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/html5.yml b/.github/workflows/html5.yml index 65cd824f7f..c99a897a9e 100644 --- a/.github/workflows/html5.yml +++ b/.github/workflows/html5.yml @@ -24,7 +24,7 @@ jobs: run: | sudo add-apt-repository ppa:haxe/releases -y sudo apt-get update - sudo apt-get install haxe -y + sudo apt-get install gcc-multilib haxe -y mkdir "%HAXELIB_ROOT%" haxelib setup "%HAXELIB_ROOT%" haxelib install lime 7.9.0 diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index a642cd077b..746e515396 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -24,7 +24,7 @@ jobs: run: | sudo add-apt-repository ppa:haxe/releases -y sudo apt-get update - sudo apt-get install haxe -y + sudo apt-get install gcc-multilib haxe -y mkdir "%HAXELIB_ROOT%" haxelib setup "%HAXELIB_ROOT%" haxelib install lime 7.9.0 From aa0f0ebd034f883ae28afaa76c6e56492fd8a9f2 Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Thu, 9 Sep 2021 21:13:46 -0400 Subject: [PATCH 10/17] Add more 32-bit stuff. --- .github/workflows/html5.yml | 2 +- .github/workflows/linux.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/html5.yml b/.github/workflows/html5.yml index c99a897a9e..be6abb7699 100644 --- a/.github/workflows/html5.yml +++ b/.github/workflows/html5.yml @@ -24,7 +24,7 @@ jobs: run: | sudo add-apt-repository ppa:haxe/releases -y sudo apt-get update - sudo apt-get install gcc-multilib haxe -y + sudo apt-get install gcc-multilib g++-multilib haxe -y mkdir "%HAXELIB_ROOT%" haxelib setup "%HAXELIB_ROOT%" haxelib install lime 7.9.0 diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 746e515396..9b9a74181c 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -24,7 +24,7 @@ jobs: run: | sudo add-apt-repository ppa:haxe/releases -y sudo apt-get update - sudo apt-get install gcc-multilib haxe -y + sudo apt-get install gcc-multilib g++-multilib haxe -y mkdir "%HAXELIB_ROOT%" haxelib setup "%HAXELIB_ROOT%" haxelib install lime 7.9.0 From c6f0d0ea9150a1dec51b683bce11e6a503c76194 Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Thu, 9 Sep 2021 22:42:44 -0400 Subject: [PATCH 11/17] I need to use a fork of the fork until my PR gets merged. --- .github/workflows/html5.yml | 4 ++-- .github/workflows/linux.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/html5.yml b/.github/workflows/html5.yml index be6abb7699..e711678bcd 100644 --- a/.github/workflows/html5.yml +++ b/.github/workflows/html5.yml @@ -42,8 +42,8 @@ jobs: haxelib git discord_rpc https://github.com/Aidan63/linc_discord-rpc haxelib git extension-webm https://github.com/KadeDev/extension-webm haxelib run lime rebuild extension-webm linux - haxelib git linc_luajit https://github.com/nebulazorua/linc_luajit.git - haxelib git hxvm-luajit https://github.com/nebulazorua/hxvm-luajit + haxelib git linc_luajit https://github.com/MasterEric/linc_luajit.git + haxelib git hxvm-luajit https://github.com/nebulazorua/hxvm-luajit.git haxelib install actuate haxelib list haxelib run lime build html5 diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 9b9a74181c..af85d6d826 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -42,8 +42,8 @@ jobs: haxelib git discord_rpc https://github.com/Aidan63/linc_discord-rpc haxelib git extension-webm https://github.com/KadeDev/extension-webm haxelib run lime rebuild extension-webm linux - haxelib git linc_luajit https://github.com/nebulazorua/linc_luajit.git - haxelib git hxvm-luajit https://github.com/nebulazorua/hxvm-luajit + haxelib git linc_luajit https://github.com/MasterEric/linc_luajit.git + haxelib git hxvm-luajit https://github.com/nebulazorua/hxvm-luajit.git haxelib install actuate haxelib list haxelib run lime build linux From 2c1505c23a58c542134007a1b9c83ddb3d7bb7d7 Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Fri, 10 Sep 2021 00:06:55 -0400 Subject: [PATCH 12/17] HTML5/Linux build fixes. Added VSCode launch configs. --- .github/workflows/linux.yml | 4 +- .gitignore | 4 +- .vscode/launch.json | 33 + .vscode/settings.json | 46 + .vscode/tasks.json | 56 +- Project.xml | 2 +- source/ChartingState.hx | 27 +- source/LuaClass.hx | 3689 ++++++++++++++++++----------------- source/PlayState.hx | 19 +- source/Waveform.hx | 8 - source/WaveformTestState.hx | 4 + 11 files changed, 2088 insertions(+), 1804 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index af85d6d826..bdd9a4fa42 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -50,5 +50,5 @@ jobs: - uses: actions/upload-artifact@v2 with: - name: Windows Build - path: export/release/windows/bin + name: Linux Build + path: export/release/linux/bin diff --git a/.gitignore b/.gitignore index 8e2966de9d..1fe2d30330 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1 @@ -export/ -.vscode/ -assets/preload/data/milf/modchart.lua +export/ \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..23080b9c64 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,33 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Windows (Debug)", + "type": "hxcpp", + "preLaunchTask": "Build Windows (Debug)", + "request": "launch", + "program": "${workspaceFolder}/export/debug/windows/bin/Kade Engine.exe" + }, + { + "name": "Windows (Release)", + "type": "hxcpp", + "preLaunchTask": "Build Windows (Release)", + "request": "launch", + "program": "${workspaceFolder}/export/debug/windows/bin/Kade Engine.exe" + }, + { + "name": "HTML5 (Debug)", + "request": "launch", + "preLaunchTask": "Build HTML5 (Debug)", + "type": "node-terminal", + "command": "npx live-server \"${workspaceFolder}/export/debug/html5/bin/\"" + }, + { + "name": "HTML5 (Release)", + "request": "launch", + "preLaunchTask": "Build HTML5 (Release)", + "type": "node-terminal", + "command": "npx live-server \"${workspaceFolder}/export/release/html5/bin/\"" + }, + ], +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..10160415cb --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,46 @@ +{ + "lime.targetConfigurations": [ + { + "label": "Build Windows (Debug)", + "target": "windows", + "args": [ + "-debug" + ] + }, + { + "label": "Build Windows (Release)", + "target": "windows", + "args": [ + "-release" + ] + }, + { + "label": "Build Linux (Debug)", + "target": "linux", + "args": [ + "-debug" + ] + }, + { + "label": "Build Linux (Release)", + "target": "linux", + "args": [ + "-release" + ] + }, + { + "label": "Build HTML5 (Debug)", + "target": "html5", + "args": [ + "-debug" + ] + }, + { + "label": "Build HTML5 (Release)", + "target": "html5", + "args": [ + "-release" + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 0930c09c67..75ca12c717 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,21 +1,45 @@ { "version": "2.0.0", "tasks": [ - { - "type": "lime", - "command": "test", - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "type": "lime", - "command": "build", - "group": { - "kind": "build", - "isDefault": true - } - } + { + "label": "Build Windows (Debug)", + "type": "lime", + "targetConfiguration": "Build Windows (Debug)", + "command": "build", + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "Build Windows (Release)", + "type": "lime", + "targetConfiguration": "Build Windows (Release)", + "command": "build", + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "Build HTML5 (Debug)", + "type": "lime", + "targetConfiguration": "Build HTML5 (Debug)", + "command": "build", + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "Build HTML5 (Release)", + "type": "lime", + "targetConfiguration": "Build HTML5 (Release)", + "command": "build", + "group": { + "kind": "build", + "isDefault": true + } + } ] } diff --git a/Project.xml b/Project.xml index 3bb076cb35..2ff478dd6d 100644 --- a/Project.xml +++ b/Project.xml @@ -126,7 +126,7 @@ - + diff --git a/source/ChartingState.hx b/source/ChartingState.hx index a4e7e25f07..74f373be80 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -172,10 +172,11 @@ class ChartingState extends MusicBeatState if (PlayState.SONG != null) { - if (PlayState.isSM) - _song = Song.conversionChecks(Song.loadFromJsonRAW(File.getContent(PlayState.pathToSm + "/converted.json"))); - else - { + if (PlayState.isSM) { + #if desktop + _song = Song.conversionChecks(Song.loadFromJsonRAW(File.getContent(PlayState.pathToSm + "/converted.json"))); + #end + } else { var songFormat = StringTools.replace(PlayState.SONG.song, " ", "-"); switch (songFormat) { @@ -1481,9 +1482,12 @@ class ChartingState extends MusicBeatState FlxG.sound.playMusic(Paths.inst(daSong), 0.6); #end - if (PlayState.isSM) - _song = Song.conversionChecks(Song.loadFromJsonRAW(File.getContent(PlayState.pathToSm + "/converted.json"))); - else + if (PlayState.isSM) { + #if desktop + _song = Song.conversionChecks(Song.loadFromJsonRAW(File.getContent(PlayState.pathToSm + "/converted.json"))); + #end + } + else { var songFormat = StringTools.replace(PlayState.SONG.song, " ", "-"); switch (songFormat) @@ -1844,6 +1848,8 @@ class ChartingState extends MusicBeatState { @:privateAccess { + #if desktop + // The __backend.handle attribute is only available on native. lime.media.openal.AL.sourcef(FlxG.sound.music._channel.__source.__backend.handle, lime.media.openal.AL.PITCH, speed); try { @@ -1855,9 +1861,10 @@ class ChartingState extends MusicBeatState } } catch (e) - { - // trace("failed to pitch vocals (probably cuz they don't exist)"); - } + { + // trace("failed to pitch vocals (probably cuz they don't exist)"); + } + #end } } } diff --git a/source/LuaClass.hx b/source/LuaClass.hx index 375054d1f4..bce1861fb5 100644 --- a/source/LuaClass.hx +++ b/source/LuaClass.hx @@ -1,3 +1,4 @@ +#if desktop import flixel.FlxG; import llua.Convert; import llua.Lua; @@ -7,9 +8,11 @@ import flixel.util.FlxAxes; import flixel.FlxSprite; import lime.app.Application; import openfl.Lib; +#if sys import sys.io.File; -import flash.display.BitmapData; import sys.FileSystem; +#end +import flash.display.BitmapData; import flixel.graphics.frames.FlxAtlasFrames; import flixel.FlxCamera; import flixel.tweens.FlxEase; @@ -18,1772 +21,1936 @@ import haxe.DynamicAccess; // completely yoinked from andromeda (thats what you get for stealing my callback inputs you fuckers /j) -typedef LuaProperty = { - var defaultValue:Any; - var getter:(State,Any)->Int; - var setter:State->Int; +typedef LuaProperty = +{ + var defaultValue:Any; + var getter:(State, Any) -> Int; + var setter:State->Int; } -class LuaStorage { - public static var ListOfCameras:Array = []; - public static var objectProperties:Map> = []; - public static var objects:Map = []; +class LuaStorage +{ + public static var ListOfCameras:Array = []; + public static var objectProperties:Map> = []; + public static var objects:Map = []; } -class LuaClass { - public var properties:Map = []; - public var methods:MapInt> > = []; - public var className:String = "BaseClass"; - private static var state:State; - public var addToGlobal:Bool=true; - public function Register(l:State){ - Lua.newtable(l); - state=l; - LuaStorage.objectProperties[className]=this.properties; - - var classIdx = Lua.gettop(l); - Lua.pushvalue(l,classIdx); - if(addToGlobal) - Lua.setglobal(l,className); - - for (k in methods.keys()){ - Lua.pushcfunction(l,methods[k]); - Lua.setfield(l,classIdx,k); - } - - LuaL.newmetatable(l,className + "Metatable"); - var mtIdx = Lua.gettop(l); - Lua.pushstring(l, "__index"); - Lua.pushcfunction(l,cpp.Callable.fromStaticFunction(index)); +class LuaClass +{ + public var properties:Map = []; + public var methods:MapInt>> = []; + public var className:String = "BaseClass"; + + private static var state:State; + + public var addToGlobal:Bool = true; + + public function Register(l:State) + { + Lua.newtable(l); + state = l; + LuaStorage.objectProperties[className] = this.properties; + + var classIdx = Lua.gettop(l); + Lua.pushvalue(l, classIdx); + if (addToGlobal) + Lua.setglobal(l, className); + + for (k in methods.keys()) + { + Lua.pushcfunction(l, methods[k]); + Lua.setfield(l, classIdx, k); + } + + LuaL.newmetatable(l, className + "Metatable"); + var mtIdx = Lua.gettop(l); + Lua.pushstring(l, "__index"); + Lua.pushcfunction(l, cpp.Callable.fromStaticFunction(index)); + Lua.settable(l, mtIdx); + + Lua.pushstring(l, "__newindex"); + Lua.pushcfunction(l, cpp.Callable.fromStaticFunction(newindex)); + Lua.settable(l, mtIdx); + + for (k in properties.keys()) + { + Lua.pushstring(l, k + "PropertyData"); + Convert.toLua(l, properties[k].defaultValue); + Lua.settable(l, mtIdx); + } + Lua.pushstring(l, "_CLASSNAME"); + Lua.pushstring(l, className); Lua.settable(l, mtIdx); - Lua.pushstring(l, "__newindex"); - Lua.pushcfunction(l,cpp.Callable.fromStaticFunction(newindex)); + Lua.pushstring(l, "__metatable"); + Lua.pushstring(l, "This metatable is locked."); Lua.settable(l, mtIdx); - - for (k in properties.keys()){ - Lua.pushstring(l,k + "PropertyData"); - Convert.toLua(l,properties[k].defaultValue); - Lua.settable(l,mtIdx); - } - Lua.pushstring(l,"_CLASSNAME"); - Lua.pushstring(l,className); - Lua.settable(l,mtIdx); - - Lua.pushstring(l,"__metatable"); - Lua.pushstring(l,"This metatable is locked."); - Lua.settable(l,mtIdx); - - Lua.setmetatable(l,classIdx); - - }; - - - public static function index(l:StatePointer):Int{ - var l = state; - var index = Lua.tostring(l,-1); - if(Lua.getmetatable(l,-2)!=0){ - var mtIdx = Lua.gettop(l); - Lua.pushstring(l,index + "PropertyData"); - Lua.rawget(l,mtIdx); - var data:Any = Convert.fromLua(l,-1); - if(data!=null){ - Lua.pushstring(l,"_CLASSNAME"); - Lua.rawget(l,mtIdx); - var clName = Lua.tostring(l,-1); - if(LuaStorage.objectProperties[clName]!=null && LuaStorage.objectProperties[clName][index]!=null){ - return LuaStorage.objectProperties[clName][index].getter(l,data); - } - }; - }else{ - // TODO: throw an error! - }; - return 0; - } - - public static function newindex(l:StatePointer):Int{ - var l = state; - var index = Lua.tostring(l,2); - if(Lua.getmetatable(l,1)!=0){ - var mtIdx = Lua.gettop(l); - Lua.pushstring(l,index + "PropertyData"); - Lua.rawget(l,mtIdx); - var data:Any = Convert.fromLua(l,-1); - if(data!=null){ - Lua.pushstring(l,"_CLASSNAME"); - Lua.rawget(l,mtIdx); - var clName = Lua.tostring(l,-1); - if(LuaStorage.objectProperties[clName]!=null && LuaStorage.objectProperties[clName][index]!=null){ - Lua.pop(l,2); - return LuaStorage.objectProperties[clName][index].setter(l); - } - }; - }else{ - // TODO: throw an error! - }; - return 0; - } - - public static function SetProperty(l:State,tableIndex:Int,key:String,value:Any){ - Lua.pushstring(l,key + "PropertyData"); - Convert.toLua(l,value); - Lua.settable(l,tableIndex ); - - Lua.pop(l,2); - } - - public static function DefaultSetter(l:State){ - var key = Lua.tostring(l,2); - - Lua.pushstring(l,key + "PropertyData"); - Lua.pushvalue(l,3); - Lua.settable(l,4); - - Lua.pop(l,2); - }; - public function new(){} + + Lua.setmetatable(l, classIdx); + }; + + public static function index(l:StatePointer):Int + { + var l = state; + var index = Lua.tostring(l, -1); + if (Lua.getmetatable(l, -2) != 0) + { + var mtIdx = Lua.gettop(l); + Lua.pushstring(l, index + "PropertyData"); + Lua.rawget(l, mtIdx); + var data:Any = Convert.fromLua(l, -1); + if (data != null) + { + Lua.pushstring(l, "_CLASSNAME"); + Lua.rawget(l, mtIdx); + var clName = Lua.tostring(l, -1); + if (LuaStorage.objectProperties[clName] != null && LuaStorage.objectProperties[clName][index] != null) + { + return LuaStorage.objectProperties[clName][index].getter(l, data); + } + }; + } + else + { + // TODO: throw an error! + }; + return 0; + } + + public static function newindex(l:StatePointer):Int + { + var l = state; + var index = Lua.tostring(l, 2); + if (Lua.getmetatable(l, 1) != 0) + { + var mtIdx = Lua.gettop(l); + Lua.pushstring(l, index + "PropertyData"); + Lua.rawget(l, mtIdx); + var data:Any = Convert.fromLua(l, -1); + if (data != null) + { + Lua.pushstring(l, "_CLASSNAME"); + Lua.rawget(l, mtIdx); + var clName = Lua.tostring(l, -1); + if (LuaStorage.objectProperties[clName] != null && LuaStorage.objectProperties[clName][index] != null) + { + Lua.pop(l, 2); + return LuaStorage.objectProperties[clName][index].setter(l); + } + }; + } + else + { + // TODO: throw an error! + }; + return 0; + } + + public static function SetProperty(l:State, tableIndex:Int, key:String, value:Any) + { + Lua.pushstring(l, key + "PropertyData"); + Convert.toLua(l, value); + Lua.settable(l, tableIndex); + + Lua.pop(l, 2); + } + + public static function DefaultSetter(l:State) + { + var key = Lua.tostring(l, 2); + + Lua.pushstring(l, key + "PropertyData"); + Lua.pushvalue(l, 3); + Lua.settable(l, 4); + + Lua.pop(l, 2); + }; + + public function new() + { + } +} + +class LuaNote extends LuaClass +{ // again, stolen from andromeda but improved a lot for better thinking interoperability (I made that up) + private static var state:State; + + public var note:Note; + + public function new(connectedNote:Note, index:Int) + { + super(); + className = "note_" + index; + + note = connectedNote; + + properties = [ + "alpha" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedNote.alpha); + return 1; + }, + setter: SetNumProperty + }, + + "angle" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedNote.angle); + return 1; + }, + setter: function(l:State):Int + { + // 1 = self + // 2 = key + // 3 = value + // 4 = metatable + if (Lua.type(l, 3) != Lua.LUA_TNUMBER) + { + LuaL.error(l, "invalid argument #3 (number expected, got " + Lua.typename(l, Lua.type(l, 3)) + ")"); + return 0; + } + + var angle = Lua.tonumber(l, 3); + connectedNote.modAngle = angle; + + LuaClass.DefaultSetter(l); + return 0; + } + }, + + "strumTime" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedNote.strumTime); + return 1; + }, + setter: function(l:State):Int + { + // 1 = self + // 2 = key + // 3 = value + // 4 = metatable + // mf you can't modify this shit + return 0; + } + }, + + "data" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedNote.noteData); + return 1; + }, + setter: SetNumProperty + }, + + "mustPress" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.pushboolean(l, connectedNote.mustPress); + return 1; + }, + setter: SetNumProperty + }, + + "beat" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedNote.beat); + return 1; + }, + setter: SetNumProperty + }, + + "isSustain" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedNote.rawNoteData); + return 1; + }, + setter: SetNumProperty + }, + + "isParent" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.pushboolean(l, connectedNote.isParent); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "isParent is read-only."); + return 0; + } + }, + + "getParent" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.pushstring(l, "note_" + connectedNote.parent.luaID); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "getParent is read-only."); + return 0; + } + }, + + "getChildren" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.newtable(l); + + for (i in 0...connectedNote.children.length) + { + var note = connectedNote.children[i]; + Lua.pushstring(l, "note_" + note.luaID); + Lua.rawseti(l, -2, i); + } + + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "getChildren is read-only."); + return 0; + } + }, + + "getSpotInline" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedNote.spotInLine); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "spot in line is read-only."); + return 0; + } + }, + + "x" => { + defaultValue: connectedNote.x, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedNote.x); + return 1; + }, + setter: SetNumProperty + }, + + "tweenPos" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenPosC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenPos is read-only."); + return 0; + } + }, + + "tweenAlpha" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenAlphaC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenAlpha is read-only."); + return 0; + } + }, + + "tweenAngle" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenAngleC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenAngle is read-only."); + return 0; + } + }, + + "y" => { + defaultValue: connectedNote.y, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedNote.y); + return 1; + }, + setter: SetNumProperty + } + + ]; + } + + private static function findNote(time:Float, data:Int) + { + for (i in PlayState.instance.notes) + { + if (i.strumTime == time && i.noteData == data) + { + return i; + } + } + return null; + } + + private static function tweenPos(l:StatePointer):Int + { + // 1 = self + // 2 = x + // 3 = y + // 4 = time + var xp = LuaL.checknumber(state, 2); + var yp = LuaL.checknumber(state, 3); + var time = LuaL.checknumber(state, 4); + + Lua.getfield(state, 1, "strumTime"); + var time = Lua.tonumber(state, -1); + Lua.getfield(state, 1, "data"); + var data = Lua.tonumber(state, -1); + + var note = findNote(time, Math.floor(data)); + + if (note == null) + { + LuaL.error(state, "Failure to tween (couldn't find note " + time + ")"); + return 0; + } + + FlxTween.tween(note, {x: xp, y: yp}, time); + + return 0; + } + + private static function tweenAngle(l:StatePointer):Int + { + // 1 = self + // 2 = angle + // 3 = time + var nangle = LuaL.checknumber(state, 2); + var time = LuaL.checknumber(state, 3); + + Lua.getfield(state, 1, "strumTime"); + var time = Lua.tonumber(state, -1); + Lua.getfield(state, 1, "data"); + var data = Lua.tonumber(state, -1); + + var note = findNote(time, Math.floor(data)); + + if (note == null) + { + LuaL.error(state, "Failure to tween (couldn't find note " + time + ")"); + return 0; + } + + FlxTween.tween(note, {modAngle: nangle}, time); + + return 0; + } + + private static function tweenAlpha(l:StatePointer):Int + { + // 1 = self + // 2 = alpha + // 3 = time + var nalpha = LuaL.checknumber(state, 2); + var time = LuaL.checknumber(state, 3); + + Lua.getfield(state, 1, "strumTime"); + var time = Lua.tonumber(state, -1); + Lua.getfield(state, 1, "data"); + var data = Lua.tonumber(state, -1); + + var note = findNote(time, Math.floor(data)); + + if (note == null) + { + LuaL.error(state, "Failure to tween (couldn't find note " + time + ")"); + return 0; + } + FlxTween.tween(note, {alpha: nalpha}, time); + + return 0; + } + + private static var tweenPosC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenPos); + private static var tweenAngleC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAngle); + private static var tweenAlphaC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAlpha); + + private function SetNumProperty(l:State) + { + // 1 = self + // 2 = key + // 3 = value + // 4 = metatable + if (Lua.type(l, 3) != Lua.LUA_TNUMBER) + { + LuaL.error(l, "invalid argument #3 (number expected, got " + Lua.typename(l, Lua.type(l, 3)) + ")"); + return 0; + } + note.modifiedByLua = true; + Reflect.setProperty(note, Lua.tostring(l, 2), Lua.tonumber(l, 3)); + return 0; + } + + override function Register(l:State) + { + state = l; + super.Register(l); + } +} + +class LuaReceptor extends LuaClass +{ // again, stolen from andromeda but improved a lot for better thinking interoperability (I made that up) + private static var state:State; + + public var sprite:StaticArrow; + + public function new(connectedSprite:StaticArrow, name:String) + { + super(); + var defaultY = connectedSprite.y; + var defaultX = connectedSprite.x; + var defaultAngle = connectedSprite.angle; + + sprite = connectedSprite; + + className = name; + + properties = [ + "alpha" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedSprite.alpha); + return 1; + }, + setter: SetNumProperty + }, + + "id" => { + defaultValue: name, + getter: function(l:State, data:Any):Int + { + Lua.pushstring(l, name); + return 1; + }, + setter: SetNumProperty + }, + + "angle" => { + defaultValue: 0, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedSprite.angle); + return 1; + }, + setter: function(l:State):Int + { + // 1 = self + // 2 = key + // 3 = value + // 4 = metatable + if (Lua.type(l, 3) != Lua.LUA_TNUMBER) + { + LuaL.error(l, "invalid argument #3 (number expected, got " + Lua.typename(l, Lua.type(l, 3)) + ")"); + return 0; + } + + var angle = Lua.tonumber(l, 3); + connectedSprite.modAngle = angle; + + LuaClass.DefaultSetter(l); + return 0; + } + }, + + "x" => { + defaultValue: connectedSprite.x, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedSprite.x); + return 1; + }, + setter: SetNumProperty + }, + + "y" => { + defaultValue: connectedSprite.y, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedSprite.y); + return 1; + }, + setter: SetNumProperty + }, + + "defaultAngle" => { + defaultValue: defaultAngle, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, defaultAngle); + return 1; + }, + setter: SetNumProperty + }, + + "defaultX" => { + defaultValue: defaultX, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, defaultX); + return 1; + }, + setter: SetNumProperty + }, + + "tweenPos" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenPosC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenPos is read-only."); + return 0; + } + }, + + "tweenAlpha" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenAlphaC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenAlpha is read-only."); + return 0; + } + }, + + "tweenAngle" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenAngleC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenAngle is read-only."); + return 0; + } + }, + + "defaultY" => { + defaultValue: defaultY, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, defaultY); + return 1; + }, + setter: function(l:State):Int + { + // 1 = self + // 2 = key + // 3 = value + // 4 = metatable + return 0; + } + } + + ]; + } + + private static function findReceptor(index:Int) + { + for (i in 0...PlayState.strumLineNotes.length) + { + if (index == i) + { + return PlayState.strumLineNotes.members[i]; + } + } + return null; + } + + private static function tweenPos(l:StatePointer):Int + { + // 1 = self + // 2 = x + // 3 = y + // 4 = time + var xp = LuaL.checknumber(state, 2); + var yp = LuaL.checknumber(state, 3); + var time = LuaL.checknumber(state, 4); + + Lua.getfield(state, 1, "id"); + var index = Std.parseInt(Lua.tostring(state, -1).split('_')[1]); + + var receptor = findReceptor(index); + + if (receptor == null) + { + LuaL.error(state, "Failure to tween (couldn't find receptor " + index + ")"); + return 0; + } + + FlxTween.tween(receptor, {x: xp, y: yp}, time); + + return 0; + } + + private static function tweenAngle(l:StatePointer):Int + { + // 1 = self + // 2 = angle + // 3 = time + var nangle = LuaL.checknumber(state, 2); + var time = LuaL.checknumber(state, 3); + + Lua.getfield(state, 1, "id"); + var index = Std.parseInt(Lua.tostring(state, -1).split('_')[1]); + + var receptor = findReceptor(index); + + if (receptor == null) + { + LuaL.error(state, "Failure to tween (couldn't find receptor " + index + ")"); + return 0; + } + + FlxTween.tween(receptor, {modAngle: nangle}, time); + + return 0; + } + + private static function tweenAlpha(l:StatePointer):Int + { + // 1 = self + // 2 = alpha + // 3 = time + var nalpha = LuaL.checknumber(state, 2); + var time = LuaL.checknumber(state, 3); + + Lua.getfield(state, 1, "id"); + var index = Std.parseInt(Lua.tostring(state, -1).split('_')[1]); + + var receptor = findReceptor(index); + + if (receptor == null) + { + LuaL.error(state, "Failure to tween (couldn't find receptor " + index + ")"); + return 0; + } + + FlxTween.tween(receptor, {alpha: nalpha}, time); + + return 0; + } + + private static var tweenPosC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenPos); + private static var tweenAngleC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAngle); + private static var tweenAlphaC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAlpha); + + private function SetNumProperty(l:State) + { + // 1 = self + // 2 = key + // 3 = value + // 4 = metatable + if (Lua.type(l, 3) != Lua.LUA_TNUMBER) + { + LuaL.error(l, "invalid argument #3 (number expected, got " + Lua.typename(l, Lua.type(l, 3)) + ")"); + return 0; + } + + sprite.modifiedByLua = true; + + Reflect.setProperty(sprite, Lua.tostring(l, 2), Lua.tonumber(l, 3)); + return 0; + } + + override function Register(l:State) + { + state = l; + super.Register(l); + trace("Registered " + className); + } +} + +class LuaCamera extends LuaClass +{ // again, stolen from andromeda but improved a lot for better thinking interoperability (I made that up) + private static var state:State; + + public var cam:FlxCamera; + + public function new(connectedCamera:FlxCamera, name:String) + { + super(); + cam = connectedCamera; + + className = name; + + properties = [ + "alpha" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedCamera.alpha); + return 1; + }, + setter: SetNumProperty + }, + + "angle" => { + defaultValue: 0, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedCamera.angle); + return 1; + }, + setter: SetNumProperty + }, + + "x" => { + defaultValue: connectedCamera.x, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedCamera.x); + return 1; + }, + setter: SetNumProperty + }, + + "y" => { + defaultValue: connectedCamera.y, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedCamera.y); + return 1; + }, + setter: SetNumProperty + }, + + "id" => { + defaultValue: className, + getter: function(l:State, data:Any):Int + { + Lua.pushstring(l, className); + return 1; + }, + setter: SetNumProperty + }, + + "tweenZoom" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenZoomC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenZoom is read-only."); + return 0; + } + }, + + "tweenPos" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenPosC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenPos is read-only."); + return 0; + } + }, + + "tweenAlpha" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenAlphaC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenAlpha is read-only."); + return 0; + } + }, + + "tweenAngle" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenAngleC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenAngle is read-only."); + return 0; + } + }, + ]; + + LuaStorage.ListOfCameras.push(this); + } + + private function SetNumProperty(l:State) + { + // 1 = self + // 2 = key + // 3 = value + // 4 = metatable + if (Lua.type(l, 3) != Lua.LUA_TNUMBER) + { + LuaL.error(l, "invalid argument #3 (number expected, got " + Lua.typename(l, Lua.type(l, 3)) + ")"); + return 0; + } + Reflect.setProperty(cam, Lua.tostring(l, 2), Lua.tonumber(l, 3)); + return 0; + } + + private static function tweenZoom(l:StatePointer):Int + { + // 1 = self + // 2 = zoom + // 3 = time + var nzoom = LuaL.checknumber(state, 2); + var time = LuaL.checknumber(state, 3); + + Lua.getfield(state, 1, "id"); + var index = Lua.tostring(state, -1); + + var camera:FlxCamera = null; + + for (i in LuaStorage.ListOfCameras) + { + if (i.className == index) + { + camera = i.cam; + } + } + + if (camera == null) + { + LuaL.error(state, "Failure to tween (couldn't find camera " + index + ")"); + return 0; + } + + FlxTween.tween(camera, {zoom: nzoom}, time); + + return 0; + } + + private static var tweenZoomC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenZoom); + + private static function tweenPos(l:StatePointer):Int + { + // 1 = self + // 2 = x + // 3 = y + // 4 = time + var xp = LuaL.checknumber(state, 2); + var yp = LuaL.checknumber(state, 3); + var time = LuaL.checknumber(state, 4); + + Lua.getfield(state, 1, "id"); + var index = Lua.tostring(state, -1); + + var camera:FlxCamera = null; + + for (i in LuaStorage.ListOfCameras) + { + if (i.className == index) + camera = i.cam; + } + + if (camera == null) + { + LuaL.error(state, "Failure to tween (couldn't find camera " + index + ")"); + return 0; + } + + FlxTween.tween(camera, {x: xp, y: yp}, time); + + return 0; + } + + private static function tweenAngle(l:StatePointer):Int + { + // 1 = self + // 2 = angle + // 3 = time + var nangle = LuaL.checknumber(state, 2); + var time = LuaL.checknumber(state, 3); + + Lua.getfield(state, 1, "id"); + var index = Lua.tostring(state, -1); + + var camera:FlxCamera = null; + + for (i in LuaStorage.ListOfCameras) + { + if (i.className == index) + camera = i.cam; + } + + if (camera == null) + { + LuaL.error(state, "Failure to tween (couldn't find camera " + index + ")"); + return 0; + } + + FlxTween.tween(camera, {modAngle: nangle}, time); + + return 0; + } + + private static function tweenAlpha(l:StatePointer):Int + { + // 1 = self + // 2 = alpha + // 3 = time + var nalpha = LuaL.checknumber(state, 2); + var time = LuaL.checknumber(state, 3); + + Lua.getfield(state, 1, "id"); + var index = Lua.tostring(state, -1); + + var camera:FlxCamera = null; + + for (i in LuaStorage.ListOfCameras) + { + if (i.className == index) + camera = i.cam; + } + + if (camera == null) + { + LuaL.error(state, "Failure to tween (couldn't find camera " + index + ")"); + return 0; + } + + FlxTween.tween(camera, {alpha: nalpha}, time); + + return 0; + } + + private static var tweenPosC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenPos); + private static var tweenAngleC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAngle); + private static var tweenAlphaC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAlpha); + + override function Register(l:State) + { + state = l; + super.Register(l); + trace("Registered " + className); + } +} + +class LuaCharacter extends LuaClass +{ // again, stolen from andromeda but improved a lot for better thinking interoperability (I made that up) + private static var state:State; + + public var char:Character; + public var isPlayer:Bool = false; + + public static var ListOfCharacters:Array = []; + + public function new(connectedCharacter:Character, name:String) + { + super(); + className = name; + + char = connectedCharacter; + + isPlayer = char.isPlayer; + + properties = [ + "alpha" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedCharacter.alpha); + return 1; + }, + setter: SetNumProperty + }, + + "angle" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedCharacter.angle); + return 1; + }, + setter: function(l:State):Int + { + // 1 = self + // 2 = key + // 3 = value + // 4 = metatable + if (Lua.type(l, 3) != Lua.LUA_TNUMBER) + { + LuaL.error(l, "invalid argument #3 (number expected, got " + Lua.typename(l, Lua.type(l, 3)) + ")"); + return 0; + } + + var angle = Lua.tonumber(l, 3); + connectedCharacter.angle = angle; + + LuaClass.DefaultSetter(l); + return 0; + } + }, + + "x" => { + defaultValue: connectedCharacter.x, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedCharacter.x); + return 1; + }, + setter: SetNumProperty + }, + + "tweenPos" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenPosC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenPos is read-only."); + return 0; + } + }, + + "id" => { + defaultValue: name, + getter: function(l:State, data:Any):Int + { + Lua.pushstring(l, name); + return 1; + }, + setter: SetNumProperty + }, + + "tweenAlpha" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenAlphaC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenAlpha is read-only."); + return 0; + } + }, + + "tweenAngle" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenAngleC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenAngle is read-only."); + return 0; + } + }, + + "changeCharacter" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, changeCharacterC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "changeCharacter is read-only."); + return 0; + } + }, + + "playAnim" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, playAnimC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "playAnim is read-only."); + return 0; + } + }, + + "y" => { + defaultValue: connectedCharacter.y, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedCharacter.y); + return 1; + }, + setter: SetNumProperty + } + + ]; + + ListOfCharacters.push(this); + } + + private static function findNote(time:Float, data:Int) + { + for (i in PlayState.instance.notes) + { + if (i.strumTime == time && i.noteData == data) + { + return i; + } + } + return null; + } + + private static function tweenPos(l:StatePointer):Int + { + // 1 = self + // 2 = x + // 3 = y + // 4 = time + var xp = LuaL.checknumber(state, 2); + var yp = LuaL.checknumber(state, 3); + var time = LuaL.checknumber(state, 4); + + Lua.getfield(state, 1, "id"); + var index = Lua.tostring(state, -1); + + var char:Character = null; + + for (i in ListOfCharacters) + { + if (i.className == index) + char = i.char; + } + + if (char == null) + { + LuaL.error(state, "Failure to tween (couldn't find character " + index + ")"); + return 0; + } + + FlxTween.tween(char, {x: xp, y: yp}, time); + + return 0; + } + + private static function tweenAngle(l:StatePointer):Int + { + // 1 = self + // 2 = angle + // 3 = time + var nangle = LuaL.checknumber(state, 2); + var time = LuaL.checknumber(state, 3); + + Lua.getfield(state, 1, "id"); + var index = Lua.tostring(state, -1); + + var char:Character = null; + + for (i in ListOfCharacters) + { + if (i.className == index) + char = i.char; + } + + if (char == null) + { + LuaL.error(state, "Failure to tween (couldn't find character " + index + ")"); + return 0; + } + + FlxTween.tween(char, {angle: nangle}, time); + + return 0; + } + + private static function tweenAlpha(l:StatePointer):Int + { + // 1 = self + // 2 = alpha + // 3 = time + var nalpha = LuaL.checknumber(state, 2); + var time = LuaL.checknumber(state, 3); + + Lua.getfield(state, 1, "id"); + var index = Lua.tostring(state, -1); + + var char:Character = null; + + for (i in ListOfCharacters) + { + if (i.className == index) + char = i.char; + } + + if (char == null) + { + LuaL.error(state, "Failure to tween (couldn't find character " + index + ")"); + return 0; + } + + FlxTween.tween(char, {alpha: nalpha}, time); + + return 0; + } + + private static function changeCharacter(l:StatePointer):Int + { + // 1 = self + // 2 = newName + // 3 = x + // 4 = y + var newName = LuaL.checkstring(state, 2); + var x = LuaL.checknumber(state, 3); + var y = LuaL.checknumber(state, 4); + + Lua.getfield(state, 1, "id"); + var index = Lua.tostring(state, -1); + + var char:Character = null; + var property:LuaCharacter = null; + + for (i in ListOfCharacters) + { + if (i.className == index) + { + char = i.char; + property = i; + } + } + + trace("fuck " + char); + + if (char == null) + { + LuaL.error(state, "Failure to tween (couldn't find character " + index + ")"); + return 0; + } + + PlayState.instance.remove(char); + + PlayState.dad = new Character(x, y, newName, char.isPlayer); + + property.char = PlayState.dad; + + PlayState.instance.add(PlayState.dad); + + return 0; + } + + private static function playAnim(l:StatePointer):Int + { + // 1 = self + // 2 = animation + var anim = LuaL.checkstring(state, 2); + + Lua.getfield(state, 1, "id"); + var index = Lua.tostring(state, -1); + + var char:Character = null; + + for (i in ListOfCharacters) + { + if (i.className == index) + { + char = i.char; + } + } + + if (char == null) + { + LuaL.error(state, "Failure to tween (couldn't find character " + index + ")"); + return 0; + } + + char.playAnim(anim); + + return 0; + } + + private static var playAnimC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(playAnim); + private static var changeCharacterC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(changeCharacter); + private static var tweenPosC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenPos); + private static var tweenAngleC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAngle); + private static var tweenAlphaC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAlpha); + + private function SetNumProperty(l:State) + { + // 1 = self + // 2 = key + // 3 = value + // 4 = metatable + if (Lua.type(l, 3) != Lua.LUA_TNUMBER) + { + LuaL.error(l, "invalid argument #3 (number expected, got " + Lua.typename(l, Lua.type(l, 3)) + ")"); + return 0; + } + Reflect.setProperty(char, Lua.tostring(l, 2), Lua.tonumber(l, 3)); + return 0; + } + + override function Register(l:State) + { + state = l; + super.Register(l); + } } -class LuaNote extends LuaClass { // again, stolen from andromeda but improved a lot for better thinking interoperability (I made that up) - private static var state:State; - public var note:Note; - public function new(connectedNote:Note, index:Int){ - super(); - className= "note_" + index; - - note = connectedNote; - - properties=[ - "alpha"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedNote.alpha); - return 1; - }, - setter: SetNumProperty - }, - - "angle"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedNote.angle); - return 1; - }, - setter: function(l:State):Int{ - // 1 = self - // 2 = key - // 3 = value - // 4 = metatable - if(Lua.type(l,3)!=Lua.LUA_TNUMBER){ - LuaL.error(l,"invalid argument #3 (number expected, got " + Lua.typename(l,Lua.type(l,3)) + ")"); - return 0; - } - - var angle = Lua.tonumber(l,3); - connectedNote.modAngle = angle; - - LuaClass.DefaultSetter(l); - return 0; - } - }, - - "strumTime"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedNote.strumTime); - return 1; - }, - setter: function(l:State):Int{ - // 1 = self - // 2 = key - // 3 = value - // 4 = metatable - // mf you can't modify this shit - return 0; - } - }, - - "data"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedNote.noteData); - return 1; - }, - setter: SetNumProperty - }, - - "mustPress"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.pushboolean(l,connectedNote.mustPress); - return 1; - }, - setter: SetNumProperty - }, - - "beat"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedNote.beat); - return 1; - }, - setter: SetNumProperty - }, - - "isSustain"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedNote.rawNoteData); - return 1; - }, - setter: SetNumProperty - }, - - "isParent"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.pushboolean(l,connectedNote.isParent); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"isParent is read-only."); - return 0; - } - }, - - "getParent"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.pushstring(l,"note_" + connectedNote.parent.luaID); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"getParent is read-only."); - return 0; - } - }, - - "getChildren"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.newtable(l); - - for(i in 0...connectedNote.children.length) - { - var note = connectedNote.children[i]; - Lua.pushstring(l,"note_" + note.luaID); - Lua.rawseti(l, -2, i); - } - - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"getChildren is read-only."); - return 0; - } - }, - - "getSpotInline"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedNote.spotInLine); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"spot in line is read-only."); - return 0; - } - }, - - "x"=> { - defaultValue: connectedNote.x, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedNote.x); - return 1; - }, - setter: SetNumProperty - }, - - "tweenPos"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenPosC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenPos is read-only."); - return 0; - } - }, - - "tweenAlpha"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenAlphaC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenAlpha is read-only."); - return 0; - } - }, - - "tweenAngle"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenAngleC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenAngle is read-only."); - return 0; - } - }, - - - "y"=> { - defaultValue: connectedNote.y, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedNote.y); - return 1; - }, - setter: SetNumProperty - } - - ]; - } - - - private static function findNote(time:Float,data:Int) - { - - for(i in PlayState.instance.notes) - { - if (i.strumTime == time && i.noteData == data) - { - return i; - } - } - return null; - } - - private static function tweenPos(l:StatePointer):Int{ - // 1 = self - // 2 = x - // 3 = y - // 4 = time - var xp = LuaL.checknumber(state,2); - var yp = LuaL.checknumber(state,3); - var time = LuaL.checknumber(state,4); - - Lua.getfield(state,1,"strumTime"); - var time = Lua.tonumber(state,-1); - Lua.getfield(state,1,"data"); - var data = Lua.tonumber(state,-1); - - var note = findNote(time,Math.floor(data)); - - if (note == null) - { - LuaL.error(state,"Failure to tween (couldn't find note " + time + ")"); - return 0; - - } - - FlxTween.tween(note,{x: xp,y:yp},time); - - return 0; - } - - private static function tweenAngle(l:StatePointer):Int{ - // 1 = self - // 2 = angle - // 3 = time - var nangle = LuaL.checknumber(state,2); - var time = LuaL.checknumber(state,3); - - Lua.getfield(state,1,"strumTime"); - var time = Lua.tonumber(state,-1); - Lua.getfield(state,1,"data"); - var data = Lua.tonumber(state,-1); - - var note = findNote(time,Math.floor(data)); - - if (note == null) - { - LuaL.error(state,"Failure to tween (couldn't find note " + time + ")"); - return 0; - - } - - FlxTween.tween(note,{modAngle: nangle},time); - - return 0; - } - - private static function tweenAlpha(l:StatePointer):Int{ - // 1 = self - // 2 = alpha - // 3 = time - var nalpha = LuaL.checknumber(state,2); - var time = LuaL.checknumber(state,3); - - Lua.getfield(state,1,"strumTime"); - var time = Lua.tonumber(state,-1); - Lua.getfield(state,1,"data"); - var data = Lua.tonumber(state,-1); - - var note = findNote(time,Math.floor(data)); - - if (note == null) - { - LuaL.error(state,"Failure to tween (couldn't find note " + time + ")"); - return 0; - - } - FlxTween.tween(note,{alpha: nalpha},time); - - return 0; - } - - private static var tweenPosC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenPos); - private static var tweenAngleC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAngle); - private static var tweenAlphaC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAlpha); - - private function SetNumProperty(l:State){ - // 1 = self - // 2 = key - // 3 = value - // 4 = metatable - if(Lua.type(l,3)!=Lua.LUA_TNUMBER){ - LuaL.error(l,"invalid argument #3 (number expected, got " + Lua.typename(l,Lua.type(l,3)) + ")"); - return 0; - } - note.modifiedByLua = true; - Reflect.setProperty(note,Lua.tostring(l,2),Lua.tonumber(l,3)); - return 0; - } - - override function Register(l:State){ - state=l; - super.Register(l); - } - } - - class LuaReceptor extends LuaClass { // again, stolen from andromeda but improved a lot for better thinking interoperability (I made that up) - private static var state:State; - public var sprite:StaticArrow; - public function new(connectedSprite:StaticArrow, name:String){ - super(); - var defaultY = connectedSprite.y; - var defaultX = connectedSprite.x; - var defaultAngle = connectedSprite.angle; - - sprite = connectedSprite; - - className= name; - - properties=[ - "alpha"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedSprite.alpha); - return 1; - }, - setter: SetNumProperty - }, - - "id"=>{ - defaultValue: name , - getter: function(l:State,data:Any):Int{ - Lua.pushstring(l,name); - return 1; - }, - setter: SetNumProperty - }, - - "angle"=>{ - defaultValue: 0 , - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedSprite.angle); - return 1; - }, - setter: function(l:State):Int{ - // 1 = self - // 2 = key - // 3 = value - // 4 = metatable - if(Lua.type(l,3)!=Lua.LUA_TNUMBER){ - LuaL.error(l,"invalid argument #3 (number expected, got " + Lua.typename(l,Lua.type(l,3)) + ")"); - return 0; - } - - var angle = Lua.tonumber(l,3); - connectedSprite.modAngle = angle; - - LuaClass.DefaultSetter(l); - return 0; - } - }, - - "x"=> { - defaultValue: connectedSprite.x, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedSprite.x); - return 1; - }, - setter: SetNumProperty - }, - - - "y"=> { - defaultValue: connectedSprite.y, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedSprite.y); - return 1; - }, - setter: SetNumProperty - }, - - "defaultAngle"=>{ - defaultValue: defaultAngle , - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,defaultAngle); - return 1; - }, - setter: SetNumProperty - }, - - "defaultX"=> { - defaultValue: defaultX, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,defaultX); - return 1; - }, - setter: SetNumProperty - }, - - - - "tweenPos"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenPosC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenPos is read-only."); - return 0; - } - }, - - "tweenAlpha"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenAlphaC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenAlpha is read-only."); - return 0; - } - }, - - "tweenAngle"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenAngleC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenAngle is read-only."); - return 0; - } - }, - - - "defaultY"=> { - defaultValue: defaultY, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,defaultY); - return 1; - }, - setter: function(l:State):Int{ - // 1 = self - // 2 = key - // 3 = value - // 4 = metatable - return 0; - } - } - - ]; - } - - private static function findReceptor(index:Int) - { - for(i in 0...PlayState.strumLineNotes.length) - { - if (index == i) - { - return PlayState.strumLineNotes.members[i]; - } - } - return null; - } - - private static function tweenPos(l:StatePointer):Int{ - // 1 = self - // 2 = x - // 3 = y - // 4 = time - var xp = LuaL.checknumber(state,2); - var yp = LuaL.checknumber(state,3); - var time = LuaL.checknumber(state,4); - - Lua.getfield(state,1,"id"); - var index = Std.parseInt(Lua.tostring(state,-1).split('_')[1]); - - var receptor = findReceptor(index); - - if (receptor == null) - { - LuaL.error(state,"Failure to tween (couldn't find receptor " + index + ")"); - return 0; - } - - FlxTween.tween(receptor,{x: xp,y:yp},time); - - return 0; - } - - private static function tweenAngle(l:StatePointer):Int{ - // 1 = self - // 2 = angle - // 3 = time - var nangle = LuaL.checknumber(state,2); - var time = LuaL.checknumber(state,3); - - Lua.getfield(state,1,"id"); - var index = Std.parseInt(Lua.tostring(state,-1).split('_')[1]); - - var receptor = findReceptor(index); - - if (receptor == null) - { - LuaL.error(state,"Failure to tween (couldn't find receptor " + index + ")"); - return 0; - } - - FlxTween.tween(receptor,{modAngle: nangle},time); - - return 0; - } - - private static function tweenAlpha(l:StatePointer):Int{ - // 1 = self - // 2 = alpha - // 3 = time - var nalpha = LuaL.checknumber(state,2); - var time = LuaL.checknumber(state,3); - - Lua.getfield(state,1,"id"); - var index = Std.parseInt(Lua.tostring(state,-1).split('_')[1]); - - var receptor = findReceptor(index); - - if (receptor == null) - { - LuaL.error(state,"Failure to tween (couldn't find receptor " + index + ")"); - return 0; - } - - FlxTween.tween(receptor,{alpha: nalpha},time); - - return 0; - } - - private static var tweenPosC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenPos); - private static var tweenAngleC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAngle); - private static var tweenAlphaC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAlpha); - - private function SetNumProperty(l:State){ - // 1 = self - // 2 = key - // 3 = value - // 4 = metatable - if(Lua.type(l,3)!=Lua.LUA_TNUMBER){ - LuaL.error(l,"invalid argument #3 (number expected, got " + Lua.typename(l,Lua.type(l,3)) + ")"); - return 0; - } - - sprite.modifiedByLua = true; - - Reflect.setProperty(sprite,Lua.tostring(l,2),Lua.tonumber(l,3)); - return 0; - } - - override function Register(l:State){ - state=l; - super.Register(l); - trace("Registered " + className); - } - } - - class LuaCamera extends LuaClass { // again, stolen from andromeda but improved a lot for better thinking interoperability (I made that up) - private static var state:State; - public var cam:FlxCamera; - - public function new(connectedCamera:FlxCamera, name:String){ - super(); - cam = connectedCamera; - - className= name; - - properties=[ - "alpha"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedCamera.alpha); - return 1; - }, - setter: SetNumProperty - }, - - "angle"=>{ - defaultValue: 0 , - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedCamera.angle); - return 1; - }, - setter: SetNumProperty - }, - - "x"=> { - defaultValue: connectedCamera.x, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedCamera.x); - return 1; - }, - setter: SetNumProperty - }, - - - "y"=> { - defaultValue: connectedCamera.y, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedCamera.y); - return 1; - }, - setter: SetNumProperty - }, - - "id"=> { - defaultValue: className, - getter: function(l:State,data:Any):Int{ - Lua.pushstring(l,className); - return 1; - }, - setter: SetNumProperty - }, - - "tweenZoom"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenZoomC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenZoom is read-only."); - return 0; - } - }, - - "tweenPos"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenPosC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenPos is read-only."); - return 0; - } - }, - - "tweenAlpha"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenAlphaC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenAlpha is read-only."); - return 0; - } - }, - - "tweenAngle"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenAngleC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenAngle is read-only."); - return 0; - } - }, - ]; - - LuaStorage.ListOfCameras.push(this); - } - - private function SetNumProperty(l:State){ - // 1 = self - // 2 = key - // 3 = value - // 4 = metatable - if(Lua.type(l,3)!=Lua.LUA_TNUMBER){ - LuaL.error(l,"invalid argument #3 (number expected, got " + Lua.typename(l,Lua.type(l,3)) + ")"); - return 0; - } - Reflect.setProperty(cam,Lua.tostring(l,2),Lua.tonumber(l,3)); - return 0; - } - - private static function tweenZoom(l:StatePointer):Int{ - // 1 = self - // 2 = zoom - // 3 = time - var nzoom = LuaL.checknumber(state,2); - var time = LuaL.checknumber(state,3); - - Lua.getfield(state,1,"id"); - var index = Lua.tostring(state,-1); - - var camera:FlxCamera = null; - - for(i in LuaStorage.ListOfCameras) - { - if (i.className == index) - { - camera = i.cam; - } - } - - if (camera == null) - { - LuaL.error(state,"Failure to tween (couldn't find camera " + index + ")"); - return 0; - } - - FlxTween.tween(camera,{zoom: nzoom},time); - - return 0; - } - - private static var tweenZoomC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenZoom); - - private static function tweenPos(l:StatePointer):Int{ - // 1 = self - // 2 = x - // 3 = y - // 4 = time - var xp = LuaL.checknumber(state,2); - var yp = LuaL.checknumber(state,3); - var time = LuaL.checknumber(state,4); - - Lua.getfield(state,1,"id"); - var index = Lua.tostring(state,-1); - - var camera:FlxCamera = null; - - for(i in LuaStorage.ListOfCameras) - { - if (i.className == index) - camera = i.cam; - } - - if (camera == null) - { - LuaL.error(state,"Failure to tween (couldn't find camera " + index + ")"); - return 0; - } - - FlxTween.tween(camera,{x: xp,y:yp},time); - - return 0; - } - - private static function tweenAngle(l:StatePointer):Int{ - // 1 = self - // 2 = angle - // 3 = time - var nangle = LuaL.checknumber(state,2); - var time = LuaL.checknumber(state,3); - - Lua.getfield(state,1,"id"); - var index = Lua.tostring(state,-1); - - var camera:FlxCamera = null; - - for(i in LuaStorage.ListOfCameras) - { - if (i.className == index) - camera = i.cam; - } - - if (camera == null) - { - LuaL.error(state,"Failure to tween (couldn't find camera " + index + ")"); - return 0; - } - - FlxTween.tween(camera,{modAngle: nangle},time); - - return 0; - } - - private static function tweenAlpha(l:StatePointer):Int{ - // 1 = self - // 2 = alpha - // 3 = time - var nalpha = LuaL.checknumber(state,2); - var time = LuaL.checknumber(state,3); - - Lua.getfield(state,1,"id"); - var index = Lua.tostring(state,-1); - - var camera:FlxCamera = null; - - for(i in LuaStorage.ListOfCameras) - { - if (i.className == index) - camera = i.cam; - } - - if (camera == null) - { - LuaL.error(state,"Failure to tween (couldn't find camera " + index + ")"); - return 0; - } - - FlxTween.tween(camera,{alpha: nalpha},time); - - return 0; - } - - private static var tweenPosC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenPos); - private static var tweenAngleC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAngle); - private static var tweenAlphaC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAlpha); - - override function Register(l:State){ - state=l; - super.Register(l); - trace("Registered " + className); - } - - } - - class LuaCharacter extends LuaClass { // again, stolen from andromeda but improved a lot for better thinking interoperability (I made that up) - private static var state:State; - public var char:Character; - public var isPlayer:Bool = false; - - public static var ListOfCharacters:Array = []; - - public function new(connectedCharacter:Character, name:String){ - super(); - className= name; - - char = connectedCharacter; - - isPlayer = char.isPlayer; - - properties=[ - "alpha"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedCharacter.alpha); - return 1; - }, - setter: SetNumProperty - }, - - "angle"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedCharacter.angle); - return 1; - }, - setter: function(l:State):Int{ - // 1 = self - // 2 = key - // 3 = value - // 4 = metatable - if(Lua.type(l,3)!=Lua.LUA_TNUMBER){ - LuaL.error(l,"invalid argument #3 (number expected, got " + Lua.typename(l,Lua.type(l,3)) + ")"); - return 0; - } - - var angle = Lua.tonumber(l,3); - connectedCharacter.angle = angle; - - LuaClass.DefaultSetter(l); - return 0; - } - }, - - "x"=> { - defaultValue: connectedCharacter.x, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedCharacter.x); - return 1; - }, - setter: SetNumProperty - }, - - "tweenPos"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenPosC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenPos is read-only."); - return 0; - } - }, - - "id"=>{ - defaultValue: name , - getter: function(l:State,data:Any):Int{ - Lua.pushstring(l,name); - return 1; - }, - setter: SetNumProperty - }, - - "tweenAlpha"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenAlphaC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenAlpha is read-only."); - return 0; - } - }, - - "tweenAngle"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenAngleC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenAngle is read-only."); - return 0; - } - }, - - "changeCharacter"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,changeCharacterC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"changeCharacter is read-only."); - return 0; - } - }, - - "playAnim"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,playAnimC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"playAnim is read-only."); - return 0; - } - }, - - "y"=> { - defaultValue: connectedCharacter.y, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedCharacter.y); - return 1; - }, - setter: SetNumProperty - } - - ]; - - ListOfCharacters.push(this); - } - - - private static function findNote(time:Float,data:Int) - { - - for(i in PlayState.instance.notes) - { - if (i.strumTime == time && i.noteData == data) - { - return i; - } - } - return null; - } - - private static function tweenPos(l:StatePointer):Int{ - // 1 = self - // 2 = x - // 3 = y - // 4 = time - var xp = LuaL.checknumber(state,2); - var yp = LuaL.checknumber(state,3); - var time = LuaL.checknumber(state,4); - - Lua.getfield(state,1,"id"); - var index = Lua.tostring(state,-1); - - var char:Character = null; - - for(i in ListOfCharacters) - { - if (i.className == index) - char = i.char; - } - - if (char == null) - { - LuaL.error(state,"Failure to tween (couldn't find character " + index + ")"); - return 0; - } - - FlxTween.tween(char,{x: xp,y:yp},time); - - return 0; - } - - private static function tweenAngle(l:StatePointer):Int{ - // 1 = self - // 2 = angle - // 3 = time - var nangle = LuaL.checknumber(state,2); - var time = LuaL.checknumber(state,3); - - Lua.getfield(state,1,"id"); - var index = Lua.tostring(state,-1); - - var char:Character = null; - - for(i in ListOfCharacters) - { - if (i.className == index) - char = i.char; - } - - if (char == null) - { - LuaL.error(state,"Failure to tween (couldn't find character " + index + ")"); - return 0; - } - - FlxTween.tween(char,{angle: nangle},time); - - return 0; - } - - private static function tweenAlpha(l:StatePointer):Int{ - // 1 = self - // 2 = alpha - // 3 = time - var nalpha = LuaL.checknumber(state,2); - var time = LuaL.checknumber(state,3); - - Lua.getfield(state,1,"id"); - var index = Lua.tostring(state,-1); - - var char:Character = null; - - for(i in ListOfCharacters) - { - if (i.className == index) - char = i.char; - } - - if (char == null) - { - LuaL.error(state,"Failure to tween (couldn't find character " + index + ")"); - return 0; - } - - FlxTween.tween(char,{alpha: nalpha},time); - - return 0; - } - - private static function changeCharacter(l:StatePointer):Int{ - // 1 = self - // 2 = newName - // 3 = x - // 4 = y - var newName = LuaL.checkstring(state,2); - var x = LuaL.checknumber(state,3); - var y = LuaL.checknumber(state,4); - - Lua.getfield(state,1,"id"); - var index = Lua.tostring(state,-1); - - var char:Character = null; - var property:LuaCharacter = null; - - for(i in ListOfCharacters) - { - if (i.className == index) - { - char = i.char; - property = i; - } - } - - trace("fuck " + char); - - if (char == null) - { - LuaL.error(state,"Failure to tween (couldn't find character " + index + ")"); - return 0; - } - - - PlayState.instance.remove(char); - - PlayState.dad = new Character(x,y,newName,char.isPlayer); - - property.char = PlayState.dad; - - PlayState.instance.add(PlayState.dad); - - return 0; - } - - private static function playAnim(l:StatePointer):Int{ - // 1 = self - // 2 = animation - var anim = LuaL.checkstring(state,2); - - Lua.getfield(state,1,"id"); - var index = Lua.tostring(state,-1); - - var char:Character = null; - - for(i in ListOfCharacters) - { - if (i.className == index) - { - char = i.char; - } - } - - if (char == null) - { - LuaL.error(state,"Failure to tween (couldn't find character " + index + ")"); - return 0; - } - - char.playAnim(anim); - - return 0; - } - - private static var playAnimC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(playAnim); - private static var changeCharacterC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(changeCharacter); - private static var tweenPosC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenPos); - private static var tweenAngleC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAngle); - private static var tweenAlphaC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAlpha); - - private function SetNumProperty(l:State){ - // 1 = self - // 2 = key - // 3 = value - // 4 = metatable - if(Lua.type(l,3)!=Lua.LUA_TNUMBER){ - LuaL.error(l,"invalid argument #3 (number expected, got " + Lua.typename(l,Lua.type(l,3)) + ")"); - return 0; - } - Reflect.setProperty(char,Lua.tostring(l,2),Lua.tonumber(l,3)); - return 0; - } - - override function Register(l:State){ - state=l; - super.Register(l); - } - } - - class LuaSprite extends LuaClass { // again, stolen from andromeda but improved a lot for better thinking interoperability (I made that up) - private static var state:State; - public var sprite:FlxSprite; - - public static var ListOfSprites:Array = []; - - public function new(connectedSprite:FlxSprite, name:String){ - super(); - className= name; - - properties=[ - "alpha"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedSprite.alpha); - return 1; - }, - setter: SetNumProperty - }, - - "angle"=>{ - defaultValue: 1 , - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedSprite.angle); - return 1; - }, - setter: function(l:State):Int{ - // 1 = self - // 2 = key - // 3 = value - // 4 = metatable - if(Lua.type(l,3)!=Lua.LUA_TNUMBER){ - LuaL.error(l,"invalid argument #3 (number expected, got " + Lua.typename(l,Lua.type(l,3)) + ")"); - return 0; - } - - var angle = Lua.tonumber(l,3); - connectedSprite.angle = angle; - - LuaClass.DefaultSetter(l); - return 0; - } - }, - - "x"=> { - defaultValue: connectedSprite.x, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedSprite.x); - return 1; - }, - setter: SetNumProperty - }, - - "tweenPos"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenPosC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenPos is read-only."); - return 0; - } - }, - - "id"=>{ - defaultValue: name , - getter: function(l:State,data:Any):Int{ - Lua.pushstring(l,name); - return 1; - }, - setter: SetNumProperty - }, - - "tweenAlpha"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenAlphaC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenAlpha is read-only."); - return 0; - } - }, - - "tweenAngle"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenAngleC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenAngle is read-only."); - return 0; - } - }, - - "destroy"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,destroyC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"destroy is read-only."); - return 0; - } - }, - - "y"=> { - defaultValue: connectedSprite.y, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,connectedSprite.y); - return 1; - }, - setter: SetNumProperty - } - - ]; - - ListOfSprites.push(this); - } - - - private static function findNote(time:Float,data:Int) - { - - for(i in PlayState.instance.notes) - { - if (i.strumTime == time && i.noteData == data) - { - return i; - } - } - return null; - } - - private static function tweenPos(l:StatePointer):Int{ - // 1 = self - // 2 = x - // 3 = y - // 4 = time - var xp = LuaL.checknumber(state,2); - var yp = LuaL.checknumber(state,3); - var time = LuaL.checknumber(state,4); - - Lua.getfield(state,1,"id"); - var index = Lua.tostring(state,-1); - - var sprite:FlxSprite = null; - - for(i in ListOfSprites) - { - if (i.className == index) - sprite = i.sprite; - } - - if (sprite == null) - { - LuaL.error(state,"Failure to tween (couldn't find sprite " + index + ")"); - return 0; - } - - FlxTween.tween(sprite,{x: xp,y:yp},time); - - return 0; - } - - private static function tweenAngle(l:StatePointer):Int{ - // 1 = self - // 2 = angle - // 3 = time - var nangle = LuaL.checknumber(state,2); - var time = LuaL.checknumber(state,3); - - Lua.getfield(state,1,"id"); - var index = Lua.tostring(state,-1); - - var sprite:FlxSprite = null; - - for(i in ListOfSprites) - { - if (i.className == index) - sprite = i.sprite; - } - - if (sprite == null) - { - LuaL.error(state,"Failure to tween (couldn't find sprite " + index + ")"); - return 0; - } - - FlxTween.tween(sprite,{angle: nangle},time); - - return 0; - } - - private static function tweenAlpha(l:StatePointer):Int{ - // 1 = self - // 2 = alpha - // 3 = time - var nalpha = LuaL.checknumber(state,2); - var time = LuaL.checknumber(state,3); - - Lua.getfield(state,1,"id"); - var index = Lua.tostring(state,-1); - - var sprite:FlxSprite = null; - - for(i in ListOfSprites) - { - if (i.className == index) - sprite = i.sprite; - } - - if (sprite == null) - { - LuaL.error(state,"Failure to tween (couldn't find sprite " + index + ")"); - return 0; - } - - FlxTween.tween(sprite,{alpha: nalpha},time); - - return 0; - } - - - private static function destroy(l:StatePointer):Int{ - // 1 = self - - Lua.getfield(state,1,"id"); - var index = Lua.tostring(state,-1); - - var sprite:FlxSprite = null; - - for(i in ListOfSprites) - { - if (i.className == index) - sprite = i.sprite; - } - - if (sprite == null) - { - LuaL.error(state,"Failure to tween (couldn't find sprite " + index + ")"); - return 0; - } - - PlayState.instance.remove(sprite); - sprite.destroy(); - - return 0; - } - - private static var destroyC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(destroy); - private static var tweenPosC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenPos); - private static var tweenAngleC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAngle); - private static var tweenAlphaC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAlpha); - - private function SetNumProperty(l:State){ - // 1 = self - // 2 = key - // 3 = value - // 4 = metatable - if(Lua.type(l,3)!=Lua.LUA_TNUMBER){ - LuaL.error(l,"invalid argument #3 (number expected, got " + Lua.typename(l,Lua.type(l,3)) + ")"); - return 0; - } - Reflect.setProperty(sprite,Lua.tostring(l,2),Lua.tonumber(l,3)); - return 0; - } - - override function Register(l:State){ - state=l; - super.Register(l); - } - } - - class LuaWindow extends LuaClass { // again, stolen from andromeda but improved a lot for better thinking interoperability (I made that up) - private static var state:State; - - public function new(){ - super(); - className= "Window"; - - properties=[ - "x"=> { - defaultValue: Application.current.window.x, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,Application.current.window.x); - return 1; - }, - setter: SetNumProperty - }, - - "y"=> { - defaultValue: Application.current.window.y, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,Application.current.window.y); - return 1; - }, - setter: SetNumProperty - }, - - - "width"=> { - defaultValue: Application.current.window.width, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,Application.current.window.width); - return 1; - }, - setter: SetNumProperty - }, - - "height"=> { - defaultValue: Application.current.window.height, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,Application.current.window.height); - return 1; - }, - setter: SetNumProperty - }, - - "tweenPos"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,tweenPosC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"tweenPos is read-only."); - return 0; - }, - - }, - ]; - - } - private static function tweenPos(l:StatePointer):Int{ - // 1 = self - // 2 = x - // 3 = y - // 4 = time - var xp = LuaL.checknumber(state,2); - var yp = LuaL.checknumber(state,3); - var time = LuaL.checknumber(state,4); - - FlxTween.tween(Application.current.window,{x: xp,y:yp},time); - - return 0; - } - - - private static var tweenPosC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenPos); - - private function SetNumProperty(l:State){ - // 1 = self - // 2 = key - // 3 = value - // 4 = metatable - if(Lua.type(l,3)!=Lua.LUA_TNUMBER){ - LuaL.error(l,"invalid argument #3 (number expected, got " + Lua.typename(l,Lua.type(l,3)) + ")"); - return 0; - } - Reflect.setProperty(Application.current.window,Lua.tostring(l,2),Lua.tonumber(l,3)); - return 0; - } - - override function Register(l:State){ - state=l; - super.Register(l); - } - } - - class LuaGame extends LuaClass { // again, stolen from andromeda but improved a lot for better thinking interoperability (I made that up) - private static var state:State; - - public function new(){ - super(); - className= "Game"; - - properties=[ - - "health"=> { - defaultValue: PlayState.instance.health, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,PlayState.instance.health); - return 1; - }, - setter: function(l:State):Int{ - PlayState.instance.health = Lua.tonumber(l,3); - return 0; - }, - }, - - "accuracy"=> { - defaultValue: PlayState.instance.accuracy, - getter: function(l:State,data:Any):Int{ - Lua.pushnumber(l,PlayState.instance.accuracy); - return 1; - }, - setter: SetNumProperty - }, - "changeStage"=>{ - defaultValue:0, - getter:function(l:State,data:Any){ - Lua.pushcfunction(l,changeStageC); - return 1; - }, - setter:function(l:State){ - LuaL.error(l,"changeStage is read-only."); - return 0; - }, - } - ]; - - } - - private static function changeStage(l:StatePointer):Int{ - // 1 = self - // 2 = stage - var stageName = LuaL.checkstring(state,2); - - for (i in PlayState.Stage.toAdd) - { - PlayState.instance.remove(i); - } - - PlayState.Stage = new Stage(stageName); - - for (i in PlayState.Stage.toAdd) - { - PlayState.instance.add(i); - } - - return 0; - } - - - private static var changeStageC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(changeStage); - - private function SetNumProperty(l:State){ - // 1 = self - // 2 = key - // 3 = value - // 4 = metatable - if(Lua.type(l,3)!=Lua.LUA_TNUMBER){ - LuaL.error(l,"invalid argument #3 (number expected, got " + Lua.typename(l,Lua.type(l,3)) + ")"); - return 0; - } - Reflect.setProperty(Application.current.window,Lua.tostring(l,2),Lua.tonumber(l,3)); - return 0; - } - - override function Register(l:State){ - state=l; - super.Register(l); - } - } \ No newline at end of file +class LuaSprite extends LuaClass +{ // again, stolen from andromeda but improved a lot for better thinking interoperability (I made that up) + private static var state:State; + + public var sprite:FlxSprite; + + public static var ListOfSprites:Array = []; + + public function new(connectedSprite:FlxSprite, name:String) + { + super(); + className = name; + + properties = [ + "alpha" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedSprite.alpha); + return 1; + }, + setter: SetNumProperty + }, + + "angle" => { + defaultValue: 1, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedSprite.angle); + return 1; + }, + setter: function(l:State):Int + { + // 1 = self + // 2 = key + // 3 = value + // 4 = metatable + if (Lua.type(l, 3) != Lua.LUA_TNUMBER) + { + LuaL.error(l, "invalid argument #3 (number expected, got " + Lua.typename(l, Lua.type(l, 3)) + ")"); + return 0; + } + + var angle = Lua.tonumber(l, 3); + connectedSprite.angle = angle; + + LuaClass.DefaultSetter(l); + return 0; + } + }, + + "x" => { + defaultValue: connectedSprite.x, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedSprite.x); + return 1; + }, + setter: SetNumProperty + }, + + "tweenPos" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenPosC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenPos is read-only."); + return 0; + } + }, + + "id" => { + defaultValue: name, + getter: function(l:State, data:Any):Int + { + Lua.pushstring(l, name); + return 1; + }, + setter: SetNumProperty + }, + + "tweenAlpha" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenAlphaC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenAlpha is read-only."); + return 0; + } + }, + + "tweenAngle" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenAngleC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenAngle is read-only."); + return 0; + } + }, + + "destroy" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, destroyC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "destroy is read-only."); + return 0; + } + }, + + "y" => { + defaultValue: connectedSprite.y, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, connectedSprite.y); + return 1; + }, + setter: SetNumProperty + } + + ]; + + ListOfSprites.push(this); + } + + private static function findNote(time:Float, data:Int) + { + for (i in PlayState.instance.notes) + { + if (i.strumTime == time && i.noteData == data) + { + return i; + } + } + return null; + } + + private static function tweenPos(l:StatePointer):Int + { + // 1 = self + // 2 = x + // 3 = y + // 4 = time + var xp = LuaL.checknumber(state, 2); + var yp = LuaL.checknumber(state, 3); + var time = LuaL.checknumber(state, 4); + + Lua.getfield(state, 1, "id"); + var index = Lua.tostring(state, -1); + + var sprite:FlxSprite = null; + + for (i in ListOfSprites) + { + if (i.className == index) + sprite = i.sprite; + } + + if (sprite == null) + { + LuaL.error(state, "Failure to tween (couldn't find sprite " + index + ")"); + return 0; + } + + FlxTween.tween(sprite, {x: xp, y: yp}, time); + + return 0; + } + + private static function tweenAngle(l:StatePointer):Int + { + // 1 = self + // 2 = angle + // 3 = time + var nangle = LuaL.checknumber(state, 2); + var time = LuaL.checknumber(state, 3); + + Lua.getfield(state, 1, "id"); + var index = Lua.tostring(state, -1); + + var sprite:FlxSprite = null; + + for (i in ListOfSprites) + { + if (i.className == index) + sprite = i.sprite; + } + + if (sprite == null) + { + LuaL.error(state, "Failure to tween (couldn't find sprite " + index + ")"); + return 0; + } + + FlxTween.tween(sprite, {angle: nangle}, time); + + return 0; + } + + private static function tweenAlpha(l:StatePointer):Int + { + // 1 = self + // 2 = alpha + // 3 = time + var nalpha = LuaL.checknumber(state, 2); + var time = LuaL.checknumber(state, 3); + + Lua.getfield(state, 1, "id"); + var index = Lua.tostring(state, -1); + + var sprite:FlxSprite = null; + + for (i in ListOfSprites) + { + if (i.className == index) + sprite = i.sprite; + } + + if (sprite == null) + { + LuaL.error(state, "Failure to tween (couldn't find sprite " + index + ")"); + return 0; + } + + FlxTween.tween(sprite, {alpha: nalpha}, time); + + return 0; + } + + private static function destroy(l:StatePointer):Int + { + // 1 = self + + Lua.getfield(state, 1, "id"); + var index = Lua.tostring(state, -1); + + var sprite:FlxSprite = null; + + for (i in ListOfSprites) + { + if (i.className == index) + sprite = i.sprite; + } + + if (sprite == null) + { + LuaL.error(state, "Failure to tween (couldn't find sprite " + index + ")"); + return 0; + } + + PlayState.instance.remove(sprite); + sprite.destroy(); + + return 0; + } + + private static var destroyC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(destroy); + private static var tweenPosC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenPos); + private static var tweenAngleC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAngle); + private static var tweenAlphaC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenAlpha); + + private function SetNumProperty(l:State) + { + // 1 = self + // 2 = key + // 3 = value + // 4 = metatable + if (Lua.type(l, 3) != Lua.LUA_TNUMBER) + { + LuaL.error(l, "invalid argument #3 (number expected, got " + Lua.typename(l, Lua.type(l, 3)) + ")"); + return 0; + } + Reflect.setProperty(sprite, Lua.tostring(l, 2), Lua.tonumber(l, 3)); + return 0; + } + + override function Register(l:State) + { + state = l; + super.Register(l); + } +} + +class LuaWindow extends LuaClass +{ // again, stolen from andromeda but improved a lot for better thinking interoperability (I made that up) + private static var state:State; + + public function new() + { + super(); + className = "Window"; + + properties = [ + "x" => { + defaultValue: Application.current.window.x, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, Application.current.window.x); + return 1; + }, + setter: SetNumProperty + }, + + "y" => { + defaultValue: Application.current.window.y, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, Application.current.window.y); + return 1; + }, + setter: SetNumProperty + }, + + "width" => { + defaultValue: Application.current.window.width, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, Application.current.window.width); + return 1; + }, + setter: SetNumProperty + }, + + "height" => { + defaultValue: Application.current.window.height, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, Application.current.window.height); + return 1; + }, + setter: SetNumProperty + }, + + "tweenPos" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, tweenPosC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "tweenPos is read-only."); + return 0; + }, + }, + ]; + } + + private static function tweenPos(l:StatePointer):Int + { + // 1 = self + // 2 = x + // 3 = y + // 4 = time + var xp = LuaL.checknumber(state, 2); + var yp = LuaL.checknumber(state, 3); + var time = LuaL.checknumber(state, 4); + + FlxTween.tween(Application.current.window, {x: xp, y: yp}, time); + + return 0; + } + + private static var tweenPosC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(tweenPos); + + private function SetNumProperty(l:State) + { + // 1 = self + // 2 = key + // 3 = value + // 4 = metatable + if (Lua.type(l, 3) != Lua.LUA_TNUMBER) + { + LuaL.error(l, "invalid argument #3 (number expected, got " + Lua.typename(l, Lua.type(l, 3)) + ")"); + return 0; + } + Reflect.setProperty(Application.current.window, Lua.tostring(l, 2), Lua.tonumber(l, 3)); + return 0; + } + + override function Register(l:State) + { + state = l; + super.Register(l); + } +} + +class LuaGame extends LuaClass +{ // again, stolen from andromeda but improved a lot for better thinking interoperability (I made that up) + private static var state:State; + + public function new() + { + super(); + className = "Game"; + + properties = [ + + "health" => { + defaultValue: PlayState.instance.health, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, PlayState.instance.health); + return 1; + }, + setter: function(l:State):Int + { + PlayState.instance.health = Lua.tonumber(l, 3); + return 0; + }, + }, + + "accuracy" => { + defaultValue: PlayState.instance.accuracy, + getter: function(l:State, data:Any):Int + { + Lua.pushnumber(l, PlayState.instance.accuracy); + return 1; + }, + setter: SetNumProperty + }, + "changeStage" => { + defaultValue: 0, + getter: function(l:State, data:Any) + { + Lua.pushcfunction(l, changeStageC); + return 1; + }, + setter: function(l:State) + { + LuaL.error(l, "changeStage is read-only."); + return 0; + }, + } + ]; + } + + private static function changeStage(l:StatePointer):Int + { + // 1 = self + // 2 = stage + var stageName = LuaL.checkstring(state, 2); + + for (i in PlayState.Stage.toAdd) + { + PlayState.instance.remove(i); + } + + PlayState.Stage = new Stage(stageName); + + for (i in PlayState.Stage.toAdd) + { + PlayState.instance.add(i); + } + + return 0; + } + + private static var changeStageC:cpp.CallableInt> = cpp.Callable.fromStaticFunction(changeStage); + + private function SetNumProperty(l:State) + { + // 1 = self + // 2 = key + // 3 = value + // 4 = metatable + if (Lua.type(l, 3) != Lua.LUA_TNUMBER) + { + LuaL.error(l, "invalid argument #3 (number expected, got " + Lua.typename(l, Lua.type(l, 3)) + ")"); + return 0; + } + Reflect.setProperty(Application.current.window, Lua.tostring(l, 2), Lua.tonumber(l, 3)); + return 0; + } + + override function Register(l:State) + { + state = l; + super.Register(l); + } +} +#end diff --git a/source/PlayState.hx b/source/PlayState.hx index 405056ad98..2a1dead8fc 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1,9 +1,11 @@ package; +#if desktop import LuaClass.LuaCamera; import LuaClass.LuaCharacter; -import lime.media.openal.AL; import LuaClass.LuaNote; +#end +import lime.media.openal.AL; import Song.Event; import openfl.media.Sound; #if sys @@ -763,6 +765,7 @@ class PlayState extends MusicBeatState } #end + #if desktop if (executeModchart) { new LuaCamera(camGame, "camGame").Register(ModchartState.lua); @@ -773,6 +776,8 @@ class PlayState extends MusicBeatState new LuaCharacter(gf, "gf").Register(ModchartState.lua); new LuaCharacter(boyfriend, "boyfriend").Register(ModchartState.lua); } + #end + var index = 0; if (startTime != 0) @@ -1445,10 +1450,11 @@ class PlayState extends MusicBeatState if (useVideo) GlobalVideo.get().resume(); + + #if desktop if (executeModchart) luaModchart.executeState("songStart", [null]); - - #if desktop + // Updating Discord Rich Presence (with Time Left) DiscordClient.changePresence(detailsText + " " @@ -1963,9 +1969,12 @@ class PlayState extends MusicBeatState @:privateAccess { + #if desktop + // The __backend.handle attribute is only available on native. lime.media.openal.AL.sourcef(FlxG.sound.music._channel.__source.__backend.handle, lime.media.openal.AL.PITCH, songMultiplier); if (vocals.playing) lime.media.openal.AL.sourcef(vocals._channel.__source.__backend.handle, lime.media.openal.AL.PITCH, songMultiplier); + #end } #if desktop @@ -2019,18 +2028,22 @@ class PlayState extends MusicBeatState var dunceNote:Note = unspawnNotes[0]; notes.add(dunceNote); + #if desktop if (executeModchart) { new LuaNote(dunceNote, currentLuaIndex); dunceNote.luaID = currentLuaIndex; } + #end if (executeModchart) { + #if desktop if (!dunceNote.isSustainNote) dunceNote.cameras = [camNotes]; else dunceNote.cameras = [camSustains]; + #end } else { diff --git a/source/Waveform.hx b/source/Waveform.hx index 816dd0d0ed..e2bbcbbebf 100644 --- a/source/Waveform.hx +++ b/source/Waveform.hx @@ -48,9 +48,6 @@ class Waveform extends FlxSprite public function drawWaveform() { - var currentTime:Float = Sys.time(); - var finishedTime:Float; - var index:Int = 0; var drawIndex:Int = 0; @@ -59,7 +56,6 @@ class Waveform extends FlxSprite var min:Float = 0; var max:Float = 0; - Sys.println("Interating over " + totalSamples); for(index in 0...Math.round(totalSamples)) { @@ -94,9 +90,5 @@ class Waveform extends FlxSprite min = 0; max = 0; } - - finishedTime = Sys.time(); - - Sys.println("Took " + (finishedTime - currentTime) + " seconds."); } } diff --git a/source/WaveformTestState.hx b/source/WaveformTestState.hx index 69d48b8d01..67d5f5a8c4 100644 --- a/source/WaveformTestState.hx +++ b/source/WaveformTestState.hx @@ -10,7 +10,9 @@ import lime.media.AudioBuffer; import lime.media.vorbis.VorbisFile; import openfl.geom.Rectangle; import openfl.media.Sound; +#if cpp import sys.thread.Thread; +#end class WaveformTestState extends FlxState { @@ -23,7 +25,9 @@ class WaveformTestState extends FlxState // fuckin stupid ass bitch ass fucking waveform if (PlayState.isSM) { + #if desktop waveform = new Waveform(0, 0, PlayState.pathToSm + "/" + PlayState.sm.header.MUSIC, 720); + #end } else { From ec17ef75d50cd4535c97f3989e14b1bc7d23492a Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Fri, 10 Sep 2021 02:03:43 -0400 Subject: [PATCH 13/17] Rework defines. FEATURE_ indicates whether a library or class is supported on the target system. --- Project.xml | 18 +++++- source/Caching.hx | 12 ++-- source/ChartingState.hx | 18 +++--- source/Discord.hx | 4 +- source/FreeplayState.hx | 18 +++--- source/GameplayCustomizeState.hx | 5 +- source/LoadReplayState.hx | 14 ++--- source/LuaClass.hx | 4 +- source/Main.hx | 6 +- source/MainMenuState.hx | 4 +- source/ModchartState.hx | 6 +- source/MusicBeatState.hx | 2 +- source/Note.hx | 2 +- source/Paths.hx | 10 +-- source/PauseSubState.hx | 10 +-- source/PlayState.hx | 105 +++++++++++++++---------------- source/Replay.hx | 8 +-- source/ResultsScreen.hx | 4 +- source/StoryMenuState.hx | 4 +- source/TitleState.hx | 10 +-- source/WaveformTestState.hx | 5 +- source/WebmHandler.hx | 4 +- source/smTools/SMFile.hx | 2 +- source/smTools/SMHeader.hx | 2 +- source/smTools/SMMeasure.hx | 2 +- source/smTools/SMNote.hx | 2 +- 26 files changed, 146 insertions(+), 135 deletions(-) diff --git a/Project.xml b/Project.xml index 2ff478dd6d..fe4df8fdf0 100644 --- a/Project.xml +++ b/Project.xml @@ -185,5 +185,21 @@ - + + + + + + + + + + + + + + + + + diff --git a/source/Caching.hx b/source/Caching.hx index 9b62ff0997..d6084c4206 100644 --- a/source/Caching.hx +++ b/source/Caching.hx @@ -1,8 +1,8 @@ -#if sys +#if FEATURE_FILESYSTEM package; import lime.app.Application; -#if desktop +#if FEATURE_DISCORD import Discord.DiscordClient; #end import openfl.display.BitmapData; @@ -11,7 +11,7 @@ import flixel.ui.FlxBar; import haxe.Exception; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; -#if cpp +#if FEATURE_FILESYSTEM import sys.FileSystem; import sys.io.File; #end @@ -80,7 +80,7 @@ class Caching extends MusicBeatState FlxGraphic.defaultPersist = FlxG.save.data.cacheImages; - #if cpp + #if FEATURE_FILESYSTEM if (FlxG.save.data.cacheImages) { trace("caching images..."); @@ -113,7 +113,7 @@ class Caching extends MusicBeatState trace('starting caching..'); - #if cpp + #if FEATURE_MULTITHREADING // update thread sys.thread.Thread.create(() -> @@ -150,7 +150,7 @@ class Caching extends MusicBeatState function cache() { - #if !linux + #if FEATURE_FILESYSTEM trace("LOADING: " + toBeDone + " OBJECTS."); for (i in images) diff --git a/source/ChartingState.hx b/source/ChartingState.hx index 74f373be80..aa2b3102d6 100644 --- a/source/ChartingState.hx +++ b/source/ChartingState.hx @@ -2,7 +2,7 @@ package; import openfl.system.System; import lime.app.Application; -#if sys +#if FEATURE_FILESYSTEM import sys.io.File; import sys.FileSystem; #end @@ -45,7 +45,7 @@ import openfl.events.IOErrorEvent; import openfl.media.Sound; import openfl.net.FileReference; import openfl.utils.ByteArray; -#if desktop +#if FEATURE_DISCORD import Discord.DiscordClient; #end @@ -141,7 +141,7 @@ class ChartingState extends MusicBeatState override function create() { - #if desktop + #if FEATURE_DISCORD DiscordClient.changePresence("Chart Editor", null, null, true); #end @@ -173,7 +173,7 @@ class ChartingState extends MusicBeatState if (PlayState.SONG != null) { if (PlayState.isSM) { - #if desktop + #if FEATURE_STEPMANIA _song = Song.conversionChecks(Song.loadFromJsonRAW(File.getContent(PlayState.pathToSm + "/converted.json"))); #end } else { @@ -1037,7 +1037,7 @@ class ChartingState extends MusicBeatState var stepperSpeedLabel = new FlxText(74, 80, 'Scroll Speed'); var stepperVocalVol:FlxUINumericStepper = new FlxUINumericStepper(10, 95, 0.1, 1, 0.1, 10, 1); - #if sys + #if FEATURE_STEPMANIA if (!PlayState.isSM) stepperVocalVol.value = vocals.volume; else @@ -1467,7 +1467,7 @@ class ChartingState extends MusicBeatState } if (reloadFromFile) { - #if sys + #if FEATURE_STEPMANIA if (PlayState.isSM) { trace("Loading " + PlayState.pathToSm + "/" + PlayState.sm.header.MUSIC); @@ -1483,7 +1483,7 @@ class ChartingState extends MusicBeatState #end if (PlayState.isSM) { - #if desktop + #if FEATURE_STEPMANIA _song = Song.conversionChecks(Song.loadFromJsonRAW(File.getContent(PlayState.pathToSm + "/converted.json"))); #end } @@ -1506,7 +1506,7 @@ class ChartingState extends MusicBeatState } } // WONT WORK FOR TUTORIAL OR TEST SONG!!! REDO LATER - #if sys + #if FEATURE_STEPMANIA if (PlayState.isSM) vocals = null; else @@ -2833,7 +2833,7 @@ class ChartingState extends MusicBeatState function updateHeads():Void { var mustHit = check_mustHitSection.checked; - #if sys + #if FEATURE_FILESYSTEM var head = (mustHit ? _song.player1 : _song.player2); var i = sectionRenderes.members[curSection]; diff --git a/source/Discord.hx b/source/Discord.hx index 5dc9c640f9..658e3521df 100644 --- a/source/Discord.hx +++ b/source/Discord.hx @@ -1,4 +1,5 @@ package; +#if FEATURE_DISCORD import Sys.sleep; import discord_rpc.DiscordRpc; @@ -84,4 +85,5 @@ class DiscordClient //trace('Discord RPC Updated. Arguments: $details, $state, $smallImageKey, $hasStartTimestamp, $endTimestamp'); } -} \ No newline at end of file +} +#end \ No newline at end of file diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx index ef7096c954..926c4046b4 100644 --- a/source/FreeplayState.hx +++ b/source/FreeplayState.hx @@ -3,8 +3,10 @@ import lime.app.Application; import openfl.utils.Future; import openfl.media.Sound; import flixel.system.FlxSound; -#if sys +#if FEATURE_STEPMANIA import smTools.SMFile; +#end +#if FEATURE_FILESYSTEM import sys.FileSystem; import sys.io.File; #end @@ -21,7 +23,7 @@ import flixel.util.FlxColor; import lime.utils.Assets; -#if desktop +#if FEATURE_DISCORD import Discord.DiscordClient; #end @@ -93,7 +95,7 @@ class FreeplayState extends MusicBeatState var diffsThatExist = []; - #if sys + #if FEATURE_FILESYSTEM if (FileSystem.exists('assets/data/${format}/${format}-hard.json')) diffsThatExist.push("Hard"); if (FileSystem.exists('assets/data/${format}/${format}-easy.json')) @@ -129,7 +131,7 @@ class FreeplayState extends MusicBeatState trace("tryin to load sm files"); - #if sys + #if FEATURE_STEPMANIA for(i in FileSystem.readDirectory("assets/sm/")) { trace(i); @@ -178,7 +180,7 @@ class FreeplayState extends MusicBeatState } */ - #if desktop + #if FEATURE_DISCORD // Updating Discord Rich Presence DiscordClient.changePresence("In the Freeplay Menu", null); #end @@ -448,7 +450,7 @@ class FreeplayState extends MusicBeatState PlayState.storyDifficulty = curDifficulty; PlayState.storyWeek = songs[curSelected].week; trace('CUR WEEK' + PlayState.storyWeek); - #if sys + #if FEATURE_STEPMANIA if (songs[curSelected].songCharacter == "sm") { PlayState.isSM = true; @@ -606,7 +608,7 @@ class SongMetadata { public var songName:String = ""; public var week:Int = 0; - #if sys + #if FEATURE_STEPMANIA public var sm:SMFile; public var path:String; #end @@ -614,7 +616,7 @@ class SongMetadata public var diffs = []; - #if sys + #if FEATURE_STEPMANIA public function new(song:String, week:Int, songCharacter:String, ?sm:SMFile = null, ?path:String = "") { this.songName = song; diff --git a/source/GameplayCustomizeState.hx b/source/GameplayCustomizeState.hx index 16dd43fb76..4fcbbb537a 100644 --- a/source/GameplayCustomizeState.hx +++ b/source/GameplayCustomizeState.hx @@ -6,9 +6,8 @@ import flixel.math.FlxMath; import flixel.FlxCamera; import flixel.math.FlxPoint; import flixel.FlxObject; -#if desktop +#if FEATURE_DISCORD import Discord.DiscordClient; -import sys.thread.Thread; #end import flixel.group.FlxGroup.FlxTypedGroup; @@ -41,7 +40,7 @@ class GameplayCustomizeState extends MusicBeatState private var camHUD:FlxCamera; public override function create() { - #if desktop + #if FEATURE_DISCORD // Updating Discord Rich Presence DiscordClient.changePresence("Customizing Gameplay Modules", null); #end diff --git a/source/LoadReplayState.hx b/source/LoadReplayState.hx index 2cf4e9e624..9014e480df 100644 --- a/source/LoadReplayState.hx +++ b/source/LoadReplayState.hx @@ -3,9 +3,8 @@ package; import haxe.Exception; import lime.app.Application; -#if sys +#if FEATURE_STEPMANIA import smTools.SMFile; -import sys.FileSystem; #end import Controls.KeyboardScheme; import Controls.Control; @@ -19,7 +18,8 @@ import flixel.math.FlxMath; import flixel.text.FlxText; import flixel.util.FlxColor; import lime.utils.Assets; -#if sys +#if FEATURE_FILESYSTEM +import sys.FileSystem; import sys.io.File; #end @@ -39,7 +39,7 @@ class LoadReplayState extends MusicBeatState override function create() { var menuBG:FlxSprite = new FlxSprite().loadGraphic(Paths.image('menuDesat')); - #if sys + #if FEATURE_FILESYSTEM controlsStrings = sys.FileSystem.readDirectory(Sys.getCwd() + "/assets/replays/"); #end trace(controlsStrings); @@ -179,7 +179,7 @@ class LoadReplayState extends MusicBeatState var poop = ""; - #if sys + #if FEATURE_STEPMANIA if (PlayState.rep.replay.sm) if (!FileSystem.exists(StringTools.replace(PlayState.rep.replay.chartPath,"converted.json",""))) { @@ -189,12 +189,12 @@ class LoadReplayState extends MusicBeatState #end PlayState.isSM = PlayState.rep.replay.sm; - #if sys + #if FEATURE_STEPMANIA if (PlayState.isSM) PlayState.pathToSm = StringTools.replace(PlayState.rep.replay.chartPath,"converted.json",""); #end - #if sys + #if FEATURE_STEPMANIA if (PlayState.isSM) { poop = File.getContent(PlayState.rep.replay.chartPath); diff --git a/source/LuaClass.hx b/source/LuaClass.hx index bce1861fb5..0fb9579ef1 100644 --- a/source/LuaClass.hx +++ b/source/LuaClass.hx @@ -1,4 +1,4 @@ -#if desktop +#if FEATURE_LUAMODCHART import flixel.FlxG; import llua.Convert; import llua.Lua; @@ -8,7 +8,7 @@ import flixel.util.FlxAxes; import flixel.FlxSprite; import lime.app.Application; import openfl.Lib; -#if sys +#if FEATURE_FILESYSTEM import sys.io.File; import sys.FileSystem; #end diff --git a/source/Main.hx b/source/Main.hx index d3b690e4dc..c2a9a202f5 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -1,7 +1,7 @@ package; import lime.app.Application; -#if desktop +#if FEATURE_DISCORD import Discord.DiscordClient; #end import openfl.display.BlendMode; @@ -82,14 +82,14 @@ class Main extends Sprite framerate = 60; #end - #if cpp + #if FEATURE_FILESYSTEM initialState = Caching; game = new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen); #else game = new FlxGame(gameWidth, gameHeight, initialState, zoom, framerate, framerate, skipSplash, startFullscreen); #end addChild(game); - #if desktop + #if FEATURE_DISCORD DiscordClient.initialize(); Application.current.onExit.add (function (exitCode) { diff --git a/source/MainMenuState.hx b/source/MainMenuState.hx index 8d098e71ee..d53e1d25e6 100644 --- a/source/MainMenuState.hx +++ b/source/MainMenuState.hx @@ -15,7 +15,7 @@ import flixel.util.FlxColor; import flixel.util.FlxTimer; import lime.app.Application; -#if desktop +#if FEATURE_DISCORD import Discord.DiscordClient; #end @@ -50,7 +50,7 @@ class MainMenuState extends MusicBeatState { trace(0 / 2); clean(); - #if desktop + #if FEATURE_DISCORD // Updating Discord Rich Presence DiscordClient.changePresence("In the Menus", null); #end diff --git a/source/ModchartState.hx b/source/ModchartState.hx index cef30ec75a..12aaf7301d 100644 --- a/source/ModchartState.hx +++ b/source/ModchartState.hx @@ -1,6 +1,7 @@ // this file is for modchart things, this is to declutter playstate.hx // Lua +#if FEATURE_LUAMODCHART import LuaClass.LuaGame; import LuaClass.LuaWindow; import LuaClass.LuaSprite; @@ -9,7 +10,6 @@ import LuaClass.LuaReceptor; import openfl.display3D.textures.VideoTexture; import flixel.graphics.FlxGraphic; import flixel.graphics.frames.FlxAtlasFrames; -#if cpp import flixel.tweens.FlxEase; import openfl.filters.ShaderFilter; import flixel.tweens.FlxTween; @@ -259,7 +259,7 @@ class ModchartState function makeAnimatedLuaSprite(spritePath:String,names:Array,prefixes:Array,startAnim:String, id:String) { - #if sys + #if FEATURE_FILESYSTEM // pre lowercasing the song name (makeAnimatedLuaSprite) var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase(); switch (songLowercase) { @@ -294,7 +294,7 @@ class ModchartState function makeLuaSprite(spritePath:String,toBeCalled:String, drawBehind:Bool) { - #if sys + #if FEATURE_FILESYSTEM // pre lowercasing the song name (makeLuaSprite) var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase(); switch (songLowercase) { diff --git a/source/MusicBeatState.hx b/source/MusicBeatState.hx index 5c67e48c08..91abadba55 100644 --- a/source/MusicBeatState.hx +++ b/source/MusicBeatState.hx @@ -1,7 +1,7 @@ package; import flixel.FlxBasic; -#if desktop +#if FEATURE_DISCORD import Discord.DiscordClient; #end import flixel.util.FlxColor; diff --git a/source/Note.hx b/source/Note.hx index 09d118a998..51b644ba82 100644 --- a/source/Note.hx +++ b/source/Note.hx @@ -96,7 +96,7 @@ class Note extends FlxSprite else { this.strumTime = strumTime; - #if sys + #if FEATURE_STEPMANIA if (PlayState.isSM) { rStrumTime = strumTime; diff --git a/source/Paths.hx b/source/Paths.hx index 9bc8fd35a9..17333fcae9 100644 --- a/source/Paths.hx +++ b/source/Paths.hx @@ -131,12 +131,12 @@ class Paths inline static public function getSparrowAtlas(key:String, ?library:String, ?isCharacter:Bool = false) { var usecahce = FlxG.save.data.cacheImages; - #if !cpp + #if !FEATURE_FILESYSTEM usecahce = false; #end if (isCharacter) if (usecahce) - #if cpp + #if FEATURE_FILESYSTEM return FlxAtlasFrames.fromSparrow(imageCached(key), file('images/characters/$key.xml', library)); #else return null; @@ -146,7 +146,7 @@ class Paths return FlxAtlasFrames.fromSparrow(image(key, library), file('images/$key.xml', library)); } - #if cpp + #if FEATURE_FILESYSTEM inline static public function imageCached(key:String):FlxGraphic { var data = Caching.bitmapData.get(key); @@ -158,12 +158,12 @@ class Paths inline static public function getPackerAtlas(key:String, ?library:String, ?isCharacter:Bool = false) { var usecahce = FlxG.save.data.cacheImages; - #if !cpp + #if !FEATURE_FILESYSTEM usecahce = false; #end if (isCharacter) if (usecahce) - #if cpp + #if FEATURE_FILESYSTEM return FlxAtlasFrames.fromSpriteSheetPacker(imageCached(key), file('images/characters/$key.txt', library)); #else return null; diff --git a/source/PauseSubState.hx b/source/PauseSubState.hx index 563af69b85..b79feae3a6 100644 --- a/source/PauseSubState.hx +++ b/source/PauseSubState.hx @@ -2,7 +2,7 @@ package; import flixel.input.gamepad.FlxGamepad; import openfl.Lib; -#if desktop +#if FEATURE_LUAMODCHART import llua.Lua; #end import Controls.Control; @@ -82,7 +82,7 @@ class PauseSubState extends MusicBeatSubstate perSongOffset.scrollFactor.set(); perSongOffset.setFormat("VCR OSD Mono", 16, FlxColor.WHITE, LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); - #if cpp + #if FEATURE_FILESYSTEM add(perSongOffset); #end @@ -134,7 +134,7 @@ class PauseSubState extends MusicBeatSubstate } var songPath = 'assets/data/' + songLowercase + '/'; - #if sys + #if FEATURE_STEPMANIA if (PlayState.isSM && !PlayState.isStoryMode) songPath = PlayState.pathToSm; #end @@ -149,7 +149,7 @@ class PauseSubState extends MusicBeatSubstate changeSelection(1); } - #if cpp + #if FEATURE_FILESYSTEM else if (controls.LEFT_P || leftPcontroller) { oldOffset = PlayState.songOffset; @@ -242,7 +242,7 @@ class PauseSubState extends MusicBeatSubstate } PlayState.loadRep = false; PlayState.stageTesting = false; - #if desktop + #if FEATURE_LUAMODCHART if (PlayState.luaModchart != null) { PlayState.luaModchart.die(); diff --git a/source/PlayState.hx b/source/PlayState.hx index 2a1dead8fc..fefcefd741 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -1,6 +1,6 @@ package; -#if desktop +#if FEATURE_LUAMODCHART import LuaClass.LuaCamera; import LuaClass.LuaCharacter; import LuaClass.LuaNote; @@ -8,10 +8,14 @@ import LuaClass.LuaNote; import lime.media.openal.AL; import Song.Event; import openfl.media.Sound; -#if sys -import sys.io.File; +#if FEATURE_STEPMANIA import smTools.SMFile; #end +#if FEATURE_FILESYSTEM +import sys.io.File; +import Sys; +import sys.FileSystem; +#end import openfl.ui.KeyLocation; import openfl.events.Event; import haxe.EnumTools; @@ -19,7 +23,7 @@ import openfl.ui.Keyboard; import openfl.events.KeyboardEvent; import Replay.Ana; import Replay.Analysis; -#if cpp +#if FEATURE_WEBM import webm.WebmPlayer; #end import flixel.input.keyboard.FlxKey; @@ -74,13 +78,9 @@ import lime.utils.Assets; import openfl.display.BlendMode; import openfl.display.StageQuality; import openfl.filters.ShaderFilter; -#if desktop +#if FEATURE_DISCORD import Discord.DiscordClient; #end -#if cpp -import Sys; -import sys.FileSystem; -#end using StringTools; @@ -117,7 +117,7 @@ class PlayState extends MusicBeatState var songLength:Float = 0; var kadeEngineWatermark:FlxText; - #if cpp + #if FEATURE_DISCORD // Discord RPC variables var storyDifficultyText:String = ""; var iconRPC:String = ""; @@ -128,7 +128,7 @@ class PlayState extends MusicBeatState private var vocals:FlxSound; public static var isSM:Bool = false; - #if sys + #if FEATURE_STEPMANIA public static var sm:SMFile; public static var pathToSm:String; #end @@ -341,7 +341,7 @@ class PlayState extends MusicBeatState removedVideo = false; - #if cpp + #if FEATURE_LUAMODCHART executeModchart = FileSystem.exists(Paths.lua(songLowercase + "/modchart")); if (isSM) executeModchart = FileSystem.exists(pathToSm + "/modchart.lua"); @@ -357,7 +357,7 @@ class PlayState extends MusicBeatState if (executeModchart) songMultiplier = 1; - #if desktop + #if FEATURE_DISCORD // Making difficulty text for Discord Rich Presence. storyDifficultyText = CoolUtil.difficultyFromInt(storyDifficulty); @@ -746,7 +746,7 @@ class PlayState extends MusicBeatState generateSong(SONG.song); - #if cpp + #if FEATURE_LUAMODCHART // pre lowercasing the song name (startCountdown) var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase(); switch (songLowercase) @@ -765,7 +765,7 @@ class PlayState extends MusicBeatState } #end - #if desktop + #if FEATURE_LUAMODCHART if (executeModchart) { new LuaCamera(camGame, "camGame").Register(ModchartState.lua); @@ -1119,7 +1119,7 @@ class PlayState extends MusicBeatState var perfectMode:Bool = false; var luaWiggles:Array = []; - #if cpp + #if FEATURE_LUAMODCHART public static var luaModchart:ModchartState = null; #end @@ -1450,11 +1450,12 @@ class PlayState extends MusicBeatState if (useVideo) GlobalVideo.get().resume(); - - #if desktop + #if FEATURE_LUAMODCHART if (executeModchart) luaModchart.executeState("songStart", [null]); + #end + #if FEATURE_DISCORD // Updating Discord Rich Presence (with Time Left) DiscordClient.changePresence(detailsText + " " @@ -1538,7 +1539,7 @@ class PlayState extends MusicBeatState curSong = songData.song; - #if sys + #if FEATURE_STEPMANIA if (SONG.needsVoices && !isSM) vocals = new FlxSound().loadEmbedded(Paths.voices(PlayState.SONG.song)); else @@ -1556,7 +1557,7 @@ class PlayState extends MusicBeatState if (!paused) { - #if sys + #if FEATURE_STEPMANIA if (!isStoryMode && isSM) { trace("Loading " + pathToSm + "/" + sm.header.MUSIC); @@ -1629,7 +1630,7 @@ class PlayState extends MusicBeatState var playerCounter:Int = 0; // Per song offset check - #if cpp + #if FEATURE_FILESYSTEM // pre lowercasing the song name (generateSong) var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase(); switch (songLowercase) @@ -1644,7 +1645,7 @@ class PlayState extends MusicBeatState var songPath = 'assets/data/' + songLowercase + '/'; - #if sys + #if FEATURE_STEPMANIA if (isSM && !isStoryMode) songPath = pathToSm; #end @@ -1895,7 +1896,7 @@ class PlayState extends MusicBeatState vocals.pause(); } - #if desktop + #if FEATURE_DISCORD DiscordClient.changePresence("PAUSED on " + SONG.song + " (" @@ -1929,7 +1930,7 @@ class PlayState extends MusicBeatState startTimer.active = true; paused = false; - #if desktop + #if FEATURE_DISCORD if (startTimer.finished) { DiscordClient.changePresence(detailsText @@ -1977,7 +1978,7 @@ class PlayState extends MusicBeatState #end } - #if desktop + #if FEATURE_DISCORD DiscordClient.changePresence(detailsText + " " + SONG.song @@ -2028,7 +2029,7 @@ class PlayState extends MusicBeatState var dunceNote:Note = unspawnNotes[0]; notes.add(dunceNote); - #if desktop + #if FEATURE_LUAMODCHART if (executeModchart) { new LuaNote(dunceNote, currentLuaIndex); @@ -2038,7 +2039,7 @@ class PlayState extends MusicBeatState if (executeModchart) { - #if desktop + #if FEATURE_LUAMODCHART if (!dunceNote.isSustainNote) dunceNote.cameras = [camNotes]; else @@ -2171,7 +2172,7 @@ class PlayState extends MusicBeatState } } - #if cpp + #if FEATURE_LUAMODCHART if (executeModchart && luaModchart != null && songStarted) { luaModchart.setVar('songPos', Conductor.songPosition); @@ -2289,10 +2290,8 @@ class PlayState extends MusicBeatState { GlobalVideo.get().stop(); remove(videoSprite); - #if sys FlxG.stage.window.onFocusOut.remove(focusOut); FlxG.stage.window.onFocusIn.remove(focusIn); - #end removedVideo = true; } cannotDie = true; @@ -2302,7 +2301,7 @@ class PlayState extends MusicBeatState PlayState.stageTesting = false; FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN, handleInput); FlxG.stage.removeEventListener(KeyboardEvent.KEY_UP, releaseInput); - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) { luaModchart.die(); @@ -2319,10 +2318,8 @@ class PlayState extends MusicBeatState { GlobalVideo.get().stop(); remove(videoSprite); - #if sys FlxG.stage.window.onFocusOut.remove(focusOut); FlxG.stage.window.onFocusIn.remove(focusIn); - #end removedVideo = true; } cannotDie = true; @@ -2332,7 +2329,7 @@ class PlayState extends MusicBeatState PlayState.stageTesting = false; FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN, handleInput); FlxG.stage.removeEventListener(KeyboardEvent.KEY_UP, releaseInput); - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) { luaModchart.die(); @@ -2387,7 +2384,7 @@ class PlayState extends MusicBeatState PlayState.stageTesting = false; FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN, handleInput); FlxG.stage.removeEventListener(KeyboardEvent.KEY_UP, releaseInput); - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) { luaModchart.die(); @@ -2431,7 +2428,7 @@ class PlayState extends MusicBeatState clean(); FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN, handleInput); FlxG.stage.removeEventListener(KeyboardEvent.KEY_UP, releaseInput); - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) { luaModchart.die(); @@ -2447,7 +2444,7 @@ class PlayState extends MusicBeatState PlayState.stageTesting = false; FlxG.stage.removeEventListener(KeyboardEvent.KEY_DOWN, handleInput); FlxG.stage.removeEventListener(KeyboardEvent.KEY_UP, releaseInput); - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) { luaModchart.die(); @@ -2662,7 +2659,7 @@ class PlayState extends MusicBeatState } } - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) luaModchart.setVar("mustHit", currentSection.mustHitSection); #end @@ -2671,7 +2668,7 @@ class PlayState extends MusicBeatState { var offsetX = 0; var offsetY = 0; - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) { offsetX = luaModchart.getVar("followXOffset", "float"); @@ -2679,7 +2676,7 @@ class PlayState extends MusicBeatState } #end camFollow.setPosition(dad.getMidpoint().x + 150 + offsetX, dad.getMidpoint().y - 100 + offsetY); - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) luaModchart.executeState('playerTwoTurn', []); #end @@ -2699,7 +2696,7 @@ class PlayState extends MusicBeatState { var offsetX = 0; var offsetY = 0; - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) { offsetX = luaModchart.getVar("followXOffset", "float"); @@ -2708,7 +2705,7 @@ class PlayState extends MusicBeatState #end camFollow.setPosition(boyfriend.getMidpoint().x - 100 + offsetX, boyfriend.getMidpoint().y - 100 + offsetY); - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) luaModchart.executeState('playerOneTurn', []); #end @@ -2805,7 +2802,7 @@ class PlayState extends MusicBeatState openSubState(new GameOverSubstate(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y)); } - #if desktop + #if FEATURE_DISCORD // Game Over doesn't get his own variable because it's only used here DiscordClient.changePresence("GAME OVER -- " + SONG.song @@ -2848,7 +2845,7 @@ class PlayState extends MusicBeatState openSubState(new GameOverSubstate(boyfriend.getScreenPosition().x, boyfriend.getScreenPosition().y)); } - #if desktop + #if FEATURE_DISCORD // Game Over doesn't get his own variable because it's only used here DiscordClient.changePresence("GAME OVER -- " + SONG.song @@ -3011,7 +3008,7 @@ class PlayState extends MusicBeatState }); } - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) luaModchart.executeState('playerTwoSing', [Math.abs(daNote.noteData), Conductor.songPosition]); #end @@ -3045,7 +3042,7 @@ class PlayState extends MusicBeatState }); } - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) luaModchart.executeState('playerTwoSing', [Math.abs(daNote.noteData), Conductor.songPosition]); #end @@ -3322,7 +3319,7 @@ class PlayState extends MusicBeatState if (FlxG.save.data.fpsCap > 290) (cast(Lib.current.getChildAt(0), Main)).setFPSCap(290); - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) { luaModchart.die(); @@ -3421,7 +3418,7 @@ class PlayState extends MusicBeatState clean(); } - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) { luaModchart.die(); @@ -3859,7 +3856,7 @@ class PlayState extends MusicBeatState var pressArray:Array = [controls.LEFT_P, controls.DOWN_P, controls.UP_P, controls.RIGHT_P]; var releaseArray:Array = [controls.LEFT_R, controls.DOWN_R, controls.UP_R, controls.RIGHT_R]; var keynameArray:Array = ['left', 'down', 'up', 'right']; - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) { for (i in 0...pressArray.length) @@ -4149,7 +4146,7 @@ class PlayState extends MusicBeatState public function backgroundVideo(source:String) // for background videos { - #if cpp + #if FEATURE_WEBM useVideo = true; FlxG.stage.window.onFocusOut.add(focusOut); @@ -4269,7 +4266,7 @@ class PlayState extends MusicBeatState // Hole switch statement replaced with a single line :) boyfriend.playAnim('sing' + dataSuffix[direction] + 'miss', true); - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) luaModchart.executeState('playerOneMiss', [direction, Conductor.songPosition]); #end @@ -4421,7 +4418,7 @@ class PlayState extends MusicBeatState boyfriend.playAnim('sing' + dataSuffix[note.noteData] + altAnim, true); - #if cpp + #if FEATURE_LUAMODCHART if (luaModchart != null) luaModchart.executeState('playerOneSing', [note.noteData, Conductor.songPosition]); #end @@ -4484,7 +4481,7 @@ class PlayState extends MusicBeatState resyncVocals(); } - #if cpp + #if FEATURE_LUAMODCHART if (executeModchart && luaModchart != null) { luaModchart.setVar('curStep', curStep); @@ -4502,7 +4499,7 @@ class PlayState extends MusicBeatState notes.sort(FlxSort.byY, (PlayStateChangeables.useDownscroll ? FlxSort.ASCENDING : FlxSort.DESCENDING)); } - #if cpp + #if FEATURE_LUAMODCHART if (executeModchart && luaModchart != null) { luaModchart.executeState('beatHit', [curBeat]); diff --git a/source/Replay.hx b/source/Replay.hx index 5d88f329a5..d9819e4d83 100644 --- a/source/Replay.hx +++ b/source/Replay.hx @@ -1,4 +1,4 @@ -#if sys +#if FEATURE_FILESYSTEM import sys.io.File; #end import Controls.Control; @@ -90,7 +90,7 @@ class Replay public function SaveReplay(notearray:Array, judge:Array, ana:Analysis) { - #if sys + #if FEATURE_STEPMANIA var chartPath = PlayState.isSM ? PlayState.pathToSm + "/converted.json" : ""; #else var chartPath = ""; @@ -115,7 +115,7 @@ class Replay var time = Date.now().getTime(); - #if sys + #if FEATURE_FILESYSTEM File.saveContent("assets/replays/replay-" + PlayState.SONG.song + "-time" + time + ".kadeReplay", data); path = "replay-" + PlayState.SONG.song + "-time" + time + ".kadeReplay"; // for score screen shit @@ -128,7 +128,7 @@ class Replay public function LoadFromJSON() { - #if sys + #if FEATURE_FILESYSTEM trace('loading ' + Sys.getCwd() + 'assets/replays/' + path + ' replay...'); try { diff --git a/source/ResultsScreen.hx b/source/ResultsScreen.hx index c10ef87df3..116056ffea 100644 --- a/source/ResultsScreen.hx +++ b/source/ResultsScreen.hx @@ -1,7 +1,9 @@ package; import haxe.Exception; -#if sys +#if FEATURE_STEPMANIA import smTools.SMFile; +#end +#if FEATURE_FILESYSTEM import sys.FileSystem; import sys.io.File; #end diff --git a/source/StoryMenuState.hx b/source/StoryMenuState.hx index 1ee5999de5..0f4c7225e4 100644 --- a/source/StoryMenuState.hx +++ b/source/StoryMenuState.hx @@ -14,7 +14,7 @@ import flixel.util.FlxColor; import flixel.util.FlxTimer; import lime.net.curl.CURLCode; -#if desktop +#if FEATURE_DISCORD import Discord.DiscordClient; #end @@ -90,7 +90,7 @@ class StoryMenuState extends MusicBeatState { weekUnlocked = unlockWeeks(); - #if desktop + #if FEATURE_DISCORD // Updating Discord Rich Presence DiscordClient.changePresence("In the Story Mode Menu", null); #end diff --git a/source/TitleState.hx b/source/TitleState.hx index de9512f876..f8a9d2ec2f 100644 --- a/source/TitleState.hx +++ b/source/TitleState.hx @@ -1,6 +1,6 @@ package; -#if sys +#if FEATURE_STEPMANIA import smTools.SMFile; #end import flixel.FlxG; @@ -26,14 +26,10 @@ import flixel.util.FlxTimer; import lime.app.Application; import openfl.Assets; -#if desktop +#if FEATURE_DISCORD import Discord.DiscordClient; #end -#if cpp -import sys.thread.Thread; -#end - using StringTools; class TitleState extends MusicBeatState @@ -56,7 +52,7 @@ class TitleState extends MusicBeatState polymod.Polymod.init({modRoot: "mods", dirs: ['introMod']}); #end - #if sys + #if FEATURE_FILESYSTEM if (!sys.FileSystem.exists(Sys.getCwd() + "/assets/replays")) sys.FileSystem.createDirectory(Sys.getCwd() + "/assets/replays"); #end diff --git a/source/WaveformTestState.hx b/source/WaveformTestState.hx index 67d5f5a8c4..e3d100b3f4 100644 --- a/source/WaveformTestState.hx +++ b/source/WaveformTestState.hx @@ -10,9 +10,6 @@ import lime.media.AudioBuffer; import lime.media.vorbis.VorbisFile; import openfl.geom.Rectangle; import openfl.media.Sound; -#if cpp -import sys.thread.Thread; -#end class WaveformTestState extends FlxState { @@ -25,7 +22,7 @@ class WaveformTestState extends FlxState // fuckin stupid ass bitch ass fucking waveform if (PlayState.isSM) { - #if desktop + #if FEATURE_FILESYSTEM waveform = new Waveform(0, 0, PlayState.pathToSm + "/" + PlayState.sm.header.MUSIC, 720); #end } diff --git a/source/WebmHandler.hx b/source/WebmHandler.hx index 77b9391b3b..d23fad7b41 100644 --- a/source/WebmHandler.hx +++ b/source/WebmHandler.hx @@ -2,13 +2,13 @@ package; import flixel.FlxG; import openfl.display.Sprite; -#if desktop +#if FEATURE_WEBM import webm.*; #end class WebmHandler { - #if desktop + #if FEATURE_WEBM public var webm:WebmPlayer; public var vidPath:String = ""; public var io:WebmIo; diff --git a/source/smTools/SMFile.hx b/source/smTools/SMFile.hx index c653c7d3d9..96f176b6c7 100644 --- a/source/smTools/SMFile.hx +++ b/source/smTools/SMFile.hx @@ -1,4 +1,4 @@ -#if sys +#if FEATURE_STEPMANIA package smTools; import sys.io.File; diff --git a/source/smTools/SMHeader.hx b/source/smTools/SMHeader.hx index ed39e99475..e58c6ff27a 100644 --- a/source/smTools/SMHeader.hx +++ b/source/smTools/SMHeader.hx @@ -1,4 +1,4 @@ -#if sys +#if FEATURE_STEPMANIA package smTools; class SMHeader diff --git a/source/smTools/SMMeasure.hx b/source/smTools/SMMeasure.hx index 4519cbd876..3a0a2a115d 100644 --- a/source/smTools/SMMeasure.hx +++ b/source/smTools/SMMeasure.hx @@ -1,4 +1,4 @@ -#if sys +#if FEATURE_STEPMANIA package smTools; class SMMeasure diff --git a/source/smTools/SMNote.hx b/source/smTools/SMNote.hx index 0a97f637f5..687a34fe5e 100644 --- a/source/smTools/SMNote.hx +++ b/source/smTools/SMNote.hx @@ -1,4 +1,4 @@ -#if sys +#if FEATURE_STEPMANIA package smTools; class SMNote From 4ae705c790f7e981c386c45f343afd182f2cf4d3 Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Fri, 10 Sep 2021 02:03:54 -0400 Subject: [PATCH 14/17] Fix Superlinter task. --- .github/workflows/superlinter.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/superlinter.yml b/.github/workflows/superlinter.yml index a10058fc04..f2d23bdef1 100644 --- a/.github/workflows/superlinter.yml +++ b/.github/workflows/superlinter.yml @@ -1,6 +1,11 @@ +name: Superlinter + +# Controls when the workflow will run +on: push + jobs: build: - runs-on: [ubuntu-latest, macos-latest] + runs-on: ubuntu-latest steps: - uses: krdlab/setup-haxe@v1 with: From f452b56745e50e77a9addf09de51e2b263aa757b Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Fri, 10 Sep 2021 02:04:06 -0400 Subject: [PATCH 15/17] Correct artifacts for HTML5 target. --- .github/workflows/html5.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/html5.yml b/.github/workflows/html5.yml index e711678bcd..3edd1fecdc 100644 --- a/.github/workflows/html5.yml +++ b/.github/workflows/html5.yml @@ -50,5 +50,5 @@ jobs: - uses: actions/upload-artifact@v2 with: - name: Windows Build - path: export/release/windows/bin + name: HTML5 Build + path: export/release/html5/bin From 372254dd153735b0d2ccef5ef356c05861e00000 Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Fri, 10 Sep 2021 02:05:57 -0400 Subject: [PATCH 16/17] Corrected Linux VSCode launch config. --- .vscode/launch.json | 14 ++++++++++++++ .vscode/tasks.json | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/.vscode/launch.json b/.vscode/launch.json index 23080b9c64..e9fbe66de4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -29,5 +29,19 @@ "type": "node-terminal", "command": "npx live-server \"${workspaceFolder}/export/release/html5/bin/\"" }, + { + "name": "Linux (Debug)", + "type": "hxcpp", + "preLaunchTask": "Build Linux (Debug)", + "request": "launch", + "program": "${workspaceFolder}/export/debug/linux/bin/Kade Engine" + }, + { + "name": "Linux (Release)", + "type": "hxcpp", + "preLaunchTask": "Build Linux (Release)", + "request": "launch", + "program": "${workspaceFolder}/export/debug/linux/bin/Kade Engine" + }, ], } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 75ca12c717..012d4d784b 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -40,6 +40,26 @@ "kind": "build", "isDefault": true } + }, + { + "label": "Build Linux (Debug)", + "type": "lime", + "targetConfiguration": "Build Linux (Debug)", + "command": "build", + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "Build Linux (Release)", + "type": "lime", + "targetConfiguration": "Build Linux (Release)", + "command": "build", + "group": { + "kind": "build", + "isDefault": true + } } ] } From 0ef8d2a61c9e403c7004a70f4dc8550c52726c4c Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Fri, 10 Sep 2021 02:34:43 -0400 Subject: [PATCH 17/17] SuperLinter doesn't support Haxe. --- .github/workflows/superlinter.yml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .github/workflows/superlinter.yml diff --git a/.github/workflows/superlinter.yml b/.github/workflows/superlinter.yml deleted file mode 100644 index f2d23bdef1..0000000000 --- a/.github/workflows/superlinter.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Superlinter - -# Controls when the workflow will run -on: push - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: krdlab/setup-haxe@v1 - with: - haxe-version: 4.0.5 - - run: | - haxe -version - haxelib install hxnodejs