Author SHA1 Message Date
⍚~NexandFuro 0d9360f0ff Bring dev/scripted-game-modes 2026-01-21 18:17:48 +01:00
⍚~Nex 1cfe6ca468 forgor 2026-01-21 17:16:31 +01:00
⍚~Nex 3bbeafcc3e restarting again
i hate git
2026-01-21 17:09:15 +01:00
HEIHUAaandGitHub 9d9640071c NoteGroup optimize (#881)
* NoteGroup optimize

* CoolUtil.bound faster
2026-01-21 07:26:55 +07:00
HEIHUAaandGitHub 8fc1493759 optimize updateInput (#878)
* optimize updateInput

* resize optimize

* __notePerStrum optimize

* Update StrumLine.hx
2026-01-20 13:16:41 +07:00
HEIHUAaandGitHub 69d82f560d repair ScriptableShader.shader = null (#877) 2026-01-20 13:16:30 +07:00
HEIHUAaandGitHub ccc509ac9f Remove unnecessary quantization on note draw 2026-01-18 18:26:37 +07:00
KolzeandGitHub ce8e91b361 change the anim ghost from first frame to last (#870) 2026-01-11 16:50:08 +01:00
FuroandGitHub 5ac7408af6 Fuckass compiler 2026-01-06 07:02:17 +01:00
FuroandGitHub 421ed4ca09 saveIfDefault for custom events 2026-01-05 18:44:27 +01:00
⍚~Nex bfe152dd8f title menu press enter sprite dumb fix
how did we forget this lmao
2026-01-05 05:09:53 +01:00
KolzeandGitHub d318ccaca8 the fucking sfx delay that i hate (#864) 2026-01-02 04:50:25 +07:00
HEIHUAaandGitHub a87dff7240 More accurate compilation error reports (#861) 2025-12-31 11:39:06 +01:00
⍚~Nex 8873d63067 kms
LOWKEY AAAUGHH
2025-12-23 03:52:46 +01:00
⍚~Nex 2913d7eea7 FUCK 2025-12-23 03:46:03 +01:00
⍚~Nex a89f3509e3 opa 2025-12-23 03:21:48 +01:00
cde7d46572 Improve documentation generation scripts and guide (#814)
* Improve documentation generation scripts

There is now a UNIX documentation generation script in the form of a
shell script. The Windows shell script has also been improved, and some
of the output of that script has been improved to match the UNIX one.

Because the scripts still use Lime to generate the documentation, the
shell script checks the kernel name using uname, and change the
documentation generation command ever so slightly. The reason for this
is that Lime only supports building to one platform at a time. This
makes manual intervention necessary, so the UNIX script checks for the
kernel ahead of time.

* Allow Linux-compatible kernels to work with UNIX doc generation script

Considering the variety of kernels available alongside ELF compatibility,
the UNIX documentation generation script has been modified to only check
for the Darwin kernel and assume every other kernel as Linux-compatible.

* Small consistency change in UNIX doc script when echoing pre-check message

* moving and small change

* cooler readme + docs generation guide

---------

Co-authored-by: ⍚~Nex <87421482+NexIsDumb@users.noreply.github.com>
2025-12-23 03:13:21 +01:00
⍚~Nex d504aa3c35 bubba 2025-12-23 02:26:34 +01:00
⍚~Nex 8b449e590f debug builds in actions
yes i know they use different caches, but codename crew is a public organization so it doesnt have size limits, besides there were cons and pros in compiling both in the same jobs, so it doesnt matter much

resolves #797
2025-12-23 01:52:12 +01:00
sillyborjaandGitHub e6f1fed96e add preventSustainClip (#856) 2025-12-19 08:16:59 +07:00
Ralty e585de7db5 Fix Sustain Miss As One Note 2025-12-18 17:20:12 +07:00
Ralty 219e95117b OH MY GOD WAKE UP 2025-12-18 16:36:37 +07:00
Ralty 06e8ba8c18 Oh my god 2025-12-18 16:32:50 +07:00
Ralty 34639d729d Fix ScriptedCutscene Confusing Event Names 2025-12-18 16:32:01 +07:00
HEIHUAaandGitHub abf77f72f2 Fix UTF-8 Characters in CLI Logs 2025-12-16 17:00:12 +07:00
4a99e7eda7 Input Improvements & Fixes (#837)
* Input

* Health

* optimize

* Update StrumLine.hx

* Update StrumLine.hx

* Delete directly?

* Update StrumLine.hx

* optimize

* Update StrumLine.hx

* Options.sustainsAsOneNote

* languages

* Update Options.xml

* Update PlayState.hx

* Flags

* Automatically set SUSTAINS_AS_ONE_NOTE

---------

Co-authored-by: Ralty <78720179+Raltyro@users.noreply.github.com>
2025-12-15 22:18:47 +07:00
LeonGamerPS4andGitHub 8bab844e0c Fix Sustain Clipping 2025-12-13 09:09:15 +07:00
RafiandGitHub fb90e2dd96 Use 'arch -x86_64' to force-compile on macOS 14 temporary 2025-12-13 09:04:00 +07:00
HEIHUAaandGitHub 7dcbbc3c64 Update PsychParser.hx (#841) 2025-11-30 12:47:58 +07:00
richandGitHub 9bd9490c49 dont desable persistent sounds (#840) 2025-11-30 06:07:21 +07:00
Ralty 1b403b2ab2 oh, theres ThreadUtil 2025-11-29 11:24:39 +07:00
Ralty 162f1add75 Fix possible crashes on Threading 2025-11-27 19:14:00 +07:00
Ralty 6951ac82cd Fix actions cache? 2025-11-26 21:06:14 +07:00
Ralty 56f53c73a9 streamedVocals is now default to true. 2025-11-26 20:53:10 +07:00
Ralty 87b825b046 apparently moving a window just breaks onUpdate 2025-11-26 20:52:56 +07:00
Ralty cd631c6eda i am a dumbass 2025-11-26 20:13:50 +07:00
Ralty eccaa77f0e So, you do not want to flush the buffers 2025-11-26 20:04:41 +07:00
Ralty a24de64707 Fix Zoom Factor & zoomMultiplier not affecting it 2025-11-26 20:04:12 +07:00
Ralty 7d186d2203 Stable Streaming Audio 2025-11-26 18:43:43 +07:00
Ralty 86b3fb3ad9 audio_stream_async branch 2025-11-23 13:13:02 +07:00
Ralty 82fb0bcf88 Stable audio_stream_async 2025-11-23 13:11:44 +07:00
Ralty e6bcb144d9 Fix really small sounds not playing 2025-11-22 20:57:10 +07:00
Ralty 44d134eed0 Fix again 2025-11-22 13:09:21 +07:00
Ralty 846f2deedb some fixes 2025-11-22 12:57:24 +07:00
Ralty deef60b231 Add a way to force set a highscore saves 2025-11-22 12:22:15 +07:00
Ralty 1d2a391a90 experimental audio_stream_async (disabled default) 2025-11-22 12:22:01 +07:00
HEIHUAaandGitHub e9bd5a52ac Improve Accurate VocalsResync (#833)
* Improve Accurate VocalsResync

* Update PlayState.hx
2025-11-22 06:55:15 +07:00
JurtaandGitHub 74343852cf Quick fix on hits commit pull request (#835)
* Quick fix allowing hits to be counted even if showRating is false
2025-11-22 06:44:44 +07:00
Ralty fa094580cd Fix Sustain Cliprect not updating on press hit 2025-11-21 19:20:13 +07:00
Ralty 8cadcd78f6 Hopefully fixes the time parameter being 0? 2025-11-21 19:19:52 +07:00
JurtaandGitHub d0bffe825a Save total of each rating to unused hits parameter in SongScore (#831)
* Save received ratings to unused hits parameter in SongScore

* Adding function to set up keys for the hits map, as to prevent potential null issues
2025-11-21 18:41:38 +07:00
JurtaandGitHub be27447de9 Prevent empty difficulty strings from accidentally existing (#832)
* Prevent empty difficulty strings from being inputted

* Also taking into account variants + making separator only show up when both difficulty and variant options are available
2025-11-21 18:41:04 +07:00
HEIHUAaandGitHub a8808be29e Fix FramerateCounter and VRAM Counter (#820)
* Update FramerateCounter.hx

* Update FramerateCounter.hx

* Update FramerateCounter.hx

* Update FramerateCounter.hx

* Update FramerateCounter.hx

* Update FramerateCounter.hx

* Update FramerateCounter.hx

* Update FramerateCounter.hx

* Update FramerateCounter.hx

* Optimize memory label update in MemoryCounter

* Optimize frame update logic in AssetTreeInfo and MemoryCounter

* Fixed VRAM display showing -2147483648B

* Update SystemInfo.hx

* VRAM: 6MB?
2025-11-20 06:46:04 +07:00
BittoandGitHub 53aa9cc2e7 KeybindsOptions: Default categories accessible outside of the state, translation support for custom options (#780)
* Update KeybindsOptions.hx

* the fps keybind that was added a bit ago
2025-11-19 17:07:59 +01:00
richandGitHub b7dfce0f70 Support for newer hxvlc compiling (#818) 2025-11-19 11:34:37 +07:00
CareandGitHub b1de3b1896 Update PauseSubState.hx (#827). No description provided. 2025-11-19 07:00:29 +07:00
JurtaandGitHub cdb751e6e1 Fix events file not being removed when all global events are deleted (#826). Friday Night Funkin' 2025-11-19 07:00:12 +07:00
JurtaandGitHub 5eddbc59d3 Fix NOR error when deleting an animation that's ghosted (#828) 2025-11-19 06:59:34 +07:00
Ralty 15496de225 Fix Voices Muted Option in Charter 2025-11-18 12:33:11 +07:00
Ralty 7fc047615f Fix Legacy Rating/Timing Handler 2025-11-18 11:25:07 +07:00
JurtaandGitHub 535e702bc2 Expand animation swapping function to support all variants (#822)
* Expanding animation swapping function to support all variants

* More straight-forward variable names, switching to string interpolation
2025-11-18 07:51:30 +07:00
Ralty 31a01bea97 legacyJudge should use MOD_API_VERSION instead 2025-11-18 07:48:37 +07:00
syrupandGitHub 5b2a86aace Input System Rewrite (#810)
* the freaking rewrite bro!

* backwards compatibility

* listened to some feedback

* legacyJudge now determines on the API number

* listened to feedback (again)
2025-11-17 15:49:53 +07:00
SrtHero278 43d599acfd never thought i'd have to acknowledge blit rendering 2025-11-16 19:21:30 -08:00
RaltyandGitHub 38c9836dc3 Remove "inline" to fix Compiling issue
it's pushed in github mobile im not on my pc rn
2025-11-17 04:51:00 +07:00
FuroandGitHub a73a51eef3 use CURRENT_API_VERSION in generated config file 2025-11-16 20:27:50 +01:00
MooshieandGitHub 36640c1a43 Add variation to Week.hx so it works in storymode (#783) 2025-11-16 17:46:27 +07:00
richandGitHub 3720bc149c add onCloseSubState for MusicBeatSubState (#817) 2025-11-16 17:15:05 +07:00
Ralty 8f09809e69 Re-apply this code cuz im a dumbass 2025-11-16 16:23:17 +07:00
Ralty 5d8a9c71a2 Update Audio Backend from Vs Camellia v2.75.1 (info at desc)
Before anyone asks why vs cam, the code is public, plus i helped most of the audio backend rewrite in the mod too. :P

- Static sounds can now also seamlessly loop with AL_SOFT_loop_points extension
- Panning stereo sounds is now possible with AL_EXT_STEREO_ANGLES extension (although this was already implemented before)
- Improved streaming sounds, should fix most of the lagspike issues
- Streaming sounds should no longer regenrate if it's in the nearest timestamp (not for reversing though)
! You still can't access FlxSound.latency because of the new procedures that's not available in lime

If there's any crashes with this pls report an issue asap.
2025-11-16 15:22:58 +07:00
bbe3464085 Option stufff for camer abop event idk (#811)
* Update PlayState.hx

* Fix camera zoom logic in PlayState.hx

---------

Co-authored-by: Ralty <78720179+Raltyro@users.noreply.github.com>
2025-11-09 07:07:58 +07:00
Ralty 3a88e78cec Implement FlxSound.pan for stereo sounds 2025-11-02 15:46:42 +07:00
Ralty 4d73ec3477 Add FlxSound.scrollFactor, getPosition 2025-11-02 10:51:23 +07:00
Ralty 4d8e99f630 Fix NumOption showing $v 2025-11-02 10:51:16 +07:00
Ralty 323c51e42c Make the Quality Option not confusing 2025-10-26 15:46:18 +07:00
axelandGitHub c13a0a2afd Change FunkinModchart version to a more stable one. (#800)
There was some critical bugs, such as:
- Hold notes were invisible just until a hold from player 2 (boyfriend) appears.
- Renderer skipping Independent strum/note/strumline cameras.
2025-10-25 23:04:14 +02:00
FuroandGitHub eecfb619b7 FlxKey.NUMBER_3 doesn’t exist but FlxKey.THREE does 2025-10-25 11:01:32 +02:00
⍚~Nex c14207236f fix keybinds options shitty text overlap 2025-10-25 01:12:45 +02:00
⍚~Nex 8938665acb fps counter keybind + fix when disabling global.hx 2025-10-25 00:34:57 +02:00
⍚~Nex 8369e8fcab translation prefixes for custom options.xml 2025-10-24 23:01:32 +02:00
Furo a465a97c32 Adds Duration Arrows for some built-in events 2025-10-22 11:58:54 +02:00
119 changed files with 2574 additions and 1583 deletions
+4 -1
View File
@@ -37,4 +37,7 @@ f8b20774e3f035eeddb9211a28a391b20db74456
# Revert a revert (scripted cutscene path)
d73f86d26ec2dbf031c01f588ba4be11842db09c
fe0ab0aa454f4ae12ced9502db8a01e7bca3e04c
fe0ab0aa454f4ae12ced9502db8a01e7bca3e04c
# Forgot the # in the commit message
484bbcb22aa8f28b62912abb6d8c89fb58e63889
+2 -3
View File
@@ -5,10 +5,9 @@
pages/** linguist-vendored
# Include HScript files as Haxe
*.hscript linguist-language=Haxe
*.hsc linguist-language=Haxe
*.hxs linguist-language=Haxe
*.hxp linguist-language=Haxe
*.hsc linguist-language=Haxe
*.hscript linguist-language=Haxe
# Include Shader files as GLSL
*.frag linguist-language=GLSL
+77 -9
View File
@@ -1,22 +1,23 @@
name: Linux Builds
name: Linux Build
on:
push:
workflow_dispatch:
jobs:
build:
name: Linux Build
permissions: write-all
runs-on: ubuntu-24.04
steps:
- name: Pulling the source
uses: actions/checkout@v2
- name: Pulling the new commit
uses: actions/checkout@v4
- name: Setting up Haxe
uses: krdlab/setup-haxe@v2
with:
haxe-version: 4.3.7
- name: Restore existing build cache for faster compilation
uses: actions/cache@v3
uses: actions/cache@v4.2.3
with:
# not caching the bin folder to prevent asset duplication and stuff like that
key: cache-build-linux
@@ -24,8 +25,8 @@ jobs:
.haxelib/
export/release/linux/haxe/
export/release/linux/obj/
restore-keys: |
cache-build-linux
- run: |
echo "HXCPP_COMPILE_CACHE=~/.hxcpp" >> $GITHUB_ENV
- name: Installing LibVLC
run: |
sudo apt-get install libvlc-dev libvlccore-dev
@@ -67,7 +68,7 @@ jobs:
}
}
- name: Uploading new cache
uses: actions/cache@v3
uses: actions/cache@v4.2.3
with:
# caching again since for some reason it doesnt work with the first post cache shit
key: cache-build-linux
@@ -75,5 +76,72 @@ jobs:
.haxelib/
export/release/linux/haxe/
export/release/linux/obj/
restore-keys: |
cache-build-linux
# didnt compile debug in the same job or github would have said that job wasn't completed until debug was done too (debug uploads are not essential)
debug_build:
name: Linux Debug Build
permissions: write-all
runs-on: ubuntu-24.04
needs: build # since its low priority, it'll run after, so actions will concentrate first on normal builds
steps:
- name: Pulling the new commit
uses: actions/checkout@v4
- name: Setting up Haxe
uses: krdlab/setup-haxe@v2
with:
haxe-version: 4.3.7
- name: Restore existing build cache for faster compilation
uses: actions/cache@v4.2.3
with:
# not caching the bin folder to prevent asset duplication and stuff like that
key: cache-build-linux-debug
path: |
.haxelib/
export/debug/linux/haxe/
export/debug/linux/obj/
- run: |
echo "HXCPP_COMPILE_CACHE=~/.hxcpp" >> $GITHUB_ENV
- name: Installing LibVLC
run: |
sudo apt-get install libvlc-dev libvlccore-dev
- name: Installing/Updating libraries
run: |
haxe -cp commandline -D analyzer-optimize --run Main setup -s
- name: Building the game
run: |
haxelib run lime build linux -debug
# - name: Tar files
# run: tar -zcvf CodenameEngine.tar.gz -C export/debug/linux/bin .
- name: Uploading artifact (entire build)
uses: actions/upload-artifact@v4
with:
name: Codename Engine Debug
path: export/debug/linux/bin/
- name: Clearing already existing cache
uses: actions/github-script@v6
with:
script: |
const caches = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
})
for (const cache of caches.data.actions_caches) {
if (cache.key == "cache-build-linux-debug") {
console.log('Clearing ' + cache.key + '...')
await github.rest.actions.deleteActionsCacheById({
owner: context.repo.owner,
repo: context.repo.repo,
cache_id: cache.id,
})
console.log("Cache cleared.")
}
}
- name: Uploading new cache
uses: actions/cache@v4.2.3
with:
# caching again since for some reason it doesnt work with the first post cache shit
key: cache-build-linux-debug
path: |
.haxelib/
export/debug/linux/haxe/
export/debug/linux/obj/
+75 -10
View File
@@ -1,22 +1,23 @@
name: Mac OS Builds
name: Mac OS Build
on:
push:
workflow_dispatch:
jobs:
build:
name: Mac OS Build
permissions: write-all
runs-on: macos-13
runs-on: macos-14
steps:
- name: Pulling the new commit
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setting up Haxe
uses: krdlab/setup-haxe@v2
with:
haxe-version: 4.3.7
- name: Restore existing build cache for faster compilation
uses: actions/cache@v3
uses: actions/cache@v4.2.3
with:
# not caching the bin folder to prevent asset duplication and stuff like that
key: cache-build-mac
@@ -24,14 +25,14 @@ jobs:
.haxelib/
export/release/macos/haxe/
export/release/macos/obj/
restore-keys: |
cache-build-mac
- run: |
echo "HXCPP_COMPILE_CACHE=~/.hxcpp" >> $GITHUB_ENV
- name: Installing/Updating libraries
run: |
haxe -cp commandline -D analyzer-optimize --run Main setup -s
- name: Building the game
run: |
haxelib run lime build mac
arch -x86_64 haxelib run lime build mac
- name: Tar files
run: tar -zcvf CodenameEngine.tar.gz -C export/release/macos/bin .
- name: Uploading artifact (executable)
@@ -64,7 +65,7 @@ jobs:
}
}
- name: Uploading new cache
uses: actions/cache@v3
uses: actions/cache@v4.2.3
with:
# caching again since for some reason it doesnt work with the first post cache shit
key: cache-build-mac
@@ -72,5 +73,69 @@ jobs:
.haxelib/
export/release/macos/haxe/
export/release/macos/obj/
restore-keys: |
cache-build-mac
# didnt compile debug in the same job or github would have said that job wasn't completed until debug was done too (debug uploads are not essential)
debug_build:
name: Mac OS Debug Build
permissions: write-all
runs-on: macos-14
needs: build # since its low priority, it'll run after, so actions will concentrate first on normal builds
steps:
- name: Pulling the new commit
uses: actions/checkout@v4
- name: Setting up Haxe
uses: krdlab/setup-haxe@v2
with:
haxe-version: 4.3.7
- name: Restore existing build cache for faster compilation
uses: actions/cache@v4.2.3
with:
# not caching the bin folder to prevent asset duplication and stuff like that
key: cache-build-mac-debug
path: |
.haxelib/
export/debug/macos/haxe/
export/debug/macos/obj/
- run: |
echo "HXCPP_COMPILE_CACHE=~/.hxcpp" >> $GITHUB_ENV
- name: Installing/Updating libraries
run: |
haxe -cp commandline -D analyzer-optimize --run Main setup -s
- name: Building the game
run: |
arch -x86_64 haxelib run lime build mac -debug
- name: Tar files
run: tar -zcvf CodenameEngine.tar.gz -C export/debug/macos/bin .
- name: Uploading artifact (entire build)
uses: actions/upload-artifact@v4
with:
name: Codename Engine Debug
path: CodenameEngine.tar.gz
- name: Clearing already existing cache
uses: actions/github-script@v6
with:
script: |
const caches = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
})
for (const cache of caches.data.actions_caches) {
if (cache.key == "cache-build-mac-debug") {
console.log('Clearing ' + cache.key + '...')
await github.rest.actions.deleteActionsCacheById({
owner: context.repo.owner,
repo: context.repo.repo,
cache_id: cache.id,
})
console.log("Cache cleared.")
}
}
- name: Uploading new cache
uses: actions/cache@v4.2.3
with:
# caching again since for some reason it doesnt work with the first post cache shit
key: cache-build-mac-debug
path: |
.haxelib/
export/debug/macos/haxe/
export/debug/macos/obj/
+1 -1
View File
@@ -184,7 +184,7 @@ jobs:
name: Release ${{ github.event.inputs.tag_name }}
draft: true
prerelease: ${{ github.event.inputs.prerelease }}
body: ${{ steps.build_body.outputs.body }}
body: ${{ steps.build_body.outputs.body }}
generate_release_notes: true
files: |
renamed/Codename Engine-Windows.zip
+71 -8
View File
@@ -1,8 +1,9 @@
name: Windows Builds
name: Windows Build
on:
push:
workflow_dispatch:
jobs:
build:
name: Windows Build
@@ -10,13 +11,13 @@ jobs:
runs-on: windows-latest
steps:
- name: Pulling the new commit
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setting up Haxe
uses: krdlab/setup-haxe@v2
with:
haxe-version: 4.3.7
- name: Restore existing build cache for faster compilation
uses: actions/cache@v3
uses: actions/cache@v4.2.3
with:
# not caching the bin folder to prevent asset duplication and stuff like that
key: cache-build-windows
@@ -24,8 +25,8 @@ jobs:
.haxelib/
export/release/windows/haxe/
export/release/windows/obj/
restore-keys: |
cache-build-windows
- run: |
echo "HXCPP_COMPILE_CACHE=~/.hxcpp" >> $GITHUB_ENV
- name: Installing/Updating libraries
run: |
haxe -cp commandline -D analyzer-optimize --run Main setup -s --no-vscheck
@@ -62,7 +63,7 @@ jobs:
}
}
- name: Uploading new cache
uses: actions/cache@v3
uses: actions/cache@v4.2.3
with:
# caching again since for some reason it doesnt work with the first post cache shit
key: cache-build-windows
@@ -70,5 +71,67 @@ jobs:
.haxelib/
export/release/windows/haxe/
export/release/windows/obj/
restore-keys: |
cache-build-windows
# didnt compile debug in the same job or github would have said that job wasn't completed until debug was done too (debug uploads are not essential)
debug_build:
name: Windows Debug Build
permissions: write-all
runs-on: windows-latest
needs: build # since its low priority, it'll run after, so actions will concentrate first on normal builds
steps:
- name: Pulling the new commit
uses: actions/checkout@v4
- name: Setting up Haxe
uses: krdlab/setup-haxe@v2
with:
haxe-version: 4.3.7
- name: Restore existing build cache for faster compilation
uses: actions/cache@v4.2.3
with:
# not caching the bin folder to prevent asset duplication and stuff like that
key: cache-build-windows-debug
path: |
.haxelib/
export/debug/windows/haxe/
export/debug/windows/obj/
- run: |
echo "HXCPP_COMPILE_CACHE=~/.hxcpp" >> $GITHUB_ENV
- name: Installing/Updating libraries
run: |
haxe -cp commandline -D analyzer-optimize --run Main setup -s --no-vscheck
- name: Building the game
run: |
haxelib run lime build windows -debug
- name: Uploading artifact (entire build)
uses: actions/upload-artifact@v4
with:
name: Codename Engine Debug
path: export/debug/windows/bin
- name: Clearing already existing cache
uses: actions/github-script@v6
with:
script: |
const caches = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
})
for (const cache of caches.data.actions_caches) {
if (cache.key == "cache-build-windows-debug") {
console.log('Clearing ' + cache.key + '...')
await github.rest.actions.deleteActionsCacheById({
owner: context.repo.owner,
repo: context.repo.repo,
cache_id: cache.id,
})
console.log("Cache cleared.")
}
}
- name: Uploading new cache
uses: actions/cache@v4.2.3
with:
# caching again since for some reason it doesnt work with the first post cache shit
key: cache-build-windows-debug
path: |
.haxelib/
export/debug/windows/haxe/
export/debug/windows/obj/
+1 -4
View File
@@ -1,15 +1,12 @@
{
"editor.detectIndentation": false,
"editor.insertSpaces": false,
"editor.tabSize": 4,
"files.associations": {
"*.hx": "haxe",
"*.hscript": "haxe",
"*.hsc": "haxe",
"*.hxs": "haxe",
"*.hxp": "haxe"
"*.hxs": "haxe"
},
"lime.projectFile": "project.hxp",
"lime.targetConfigurations": [
{
"label": "Windows (Test Build)",
+2 -2
View File
@@ -71,11 +71,11 @@ _**QOL = Quality of Life**_
- Characters are located in `data/weeks/characters`.
- Weeks are located in `data/weeks/weeks/`
- If you need to rearrange the weeks in-game, you can use the `data/weeks/weeks.txt` file.
- Editors for Charts and Characters (Stage coming soon)
- Editors for Charts and Characters
- Undos/Redos supported
- Warning on closing unsaved work
- Clean UI (for ocd freaks)
- Mature Chart editor (Character editor rework soon)
- Mature Chart editor
- Features not found in other editors!
- Every single state & substate can be modified via HScript (`data/states/StateName.hx`)
- **Instances launched via `lime test windows` will automatically use assets from source.**
+1 -1
View File
@@ -68,7 +68,7 @@ The engine uses [HaxeFlixel](https://haxeflixel.com/) and it mainly features:
</details>
<details>
<summary><h2>How to setup and build</h2></summary>
<summary><h2>How to setup and build the engine and its documentation</h2></summary>
Check out our guide [HERE](building/README.md)
</details>
-10
View File
@@ -1,10 +0,0 @@
## DEV (PRIVATE) REPO INSTRUCTIONS TO SYNC UP WITH IT INSTEAD OF SYNCING WITH THE PUBLIC ONE
- Open a Command Prompt window in the public codename repo folder
- Type those commands:
- `git remote add dev https://www.github.com/YoshiCrafter29/CodenameEngine-Dev`
- `git branch --set-upstream-to dev/main`
- GitHub desktop should be synchronized with the dev repo now. If you're unsure,
- Repo name should still say "CodenameEngine"
- Current branch should still say "main"
- "Fetch" button should say "Fetch dev"
- You shouldn't have any commit to push.
-8
View File
@@ -1,8 +0,0 @@
@ECHO OFF
cd ..
echo Building Game...
lime build windows --haxeflag="-xml docs/doc.xml" -D doc-gen -D DOCUMENTATION --no-output
echo art
echo Generated the api xml file at docs/doc.xml
echo Please put this in codename-website/api-generator/api/doc.xml
+3
View File
@@ -1,3 +1,6 @@
# THIS FILE ISN'T NECESSARY,
# BUT YOU CAN USE IT TO SORT AND WHITELIST FREEPLAY SONGS
test
tutorial
+8
View File
@@ -0,0 +1,8 @@
# THIS FILE ISN'T NECESSARY,
# BUT YOU CAN USE IT TO SORT AND WHITELIST GAME MODES
solo
opponent
coop
coop-switched
botplay
@@ -1,5 +1,5 @@
# THIS FILE ISN'T NECESSARY,
# BUT YOU CAN USE IT TO SORT WEEKS
# BUT YOU CAN USE IT TO SORT AND WHITELIST WEEKS
tutorial
week1
+4
View File
@@ -0,0 +1,4 @@
{
"displayName": "Botplay Mode",
"modeID": "codename.botplay"
}
+2
View File
@@ -0,0 +1,2 @@
<!DOCTYPE codename-engine-game-mode>
<mode name="Botplay Mode" id="codename.botplay"/>
+5
View File
@@ -0,0 +1,5 @@
{
"displayName": "Co-Op Mode (Switched)",
"modeID": "codename.coop-opponent",
"scripts": ["opponent", "coop"]
}
+11
View File
@@ -0,0 +1,11 @@
<!DOCTYPE codename-engine-game-mode>
<mode name="Co-Op Mode (Switched)" id="codename.coop-opponent">
<script>coop</script>
<script>opponent</script>
<!--
just a small example of what you could do with fields!!
<field name="switchStrums" type="bool" val="true"/>
<field name="strumSize" type="float" val="0.6"/>
-->
</mode>
+4
View File
@@ -0,0 +1,4 @@
{
"displayName": "Co-Op Mode",
"modeID": "codename.coop"
}
+2
View File
@@ -0,0 +1,2 @@
<!DOCTYPE codename-engine-game-mode>
<mode name="Co-Op Mode" id="codename.coop"/>
+5
View File
@@ -0,0 +1,5 @@
solo
opponent
coop
coop-switched
botplay
+4
View File
@@ -0,0 +1,4 @@
{
"displayName": "Opponent Mode",
"modeID": "codename.opponent"
}
+2
View File
@@ -0,0 +1,2 @@
<!DOCTYPE codename-engine-game-mode>
<mode name="Opponent Mode" id="codename.opponent"/>
+4
View File
@@ -0,0 +1,4 @@
{
"displayName": "Solo Mode",
"modeID": "codename.solo"
}
+2
View File
@@ -0,0 +1,2 @@
<!DOCTYPE codename-engine-game-mode>
<mode name="Solo Mode" id="codename.solo"/>
+1
View File
@@ -48,6 +48,7 @@
<str id="category.engine">Engine</str>
<group name="engine" prefix="engine.">
<str id="switchMod">Switch Mod</str>
<str id="fpsCounter">FPS Counter</str>
</group>
<str id="category.volume">Volume</str>
+2 -1
View File
@@ -46,8 +46,9 @@
<group name="engine" prefix="engine.">
<str id="switchMod">Cambiar Mod</str>
<str id="fpsCounter">Contador de FPS</str>
</group>
<str id="category.volume">Volumen</str>
<str id="volume.up">Arriba</str>
<str id="volume.down">Abajo</str>
+1
View File
@@ -46,6 +46,7 @@
<group name="engine" prefix="engine.">
<str id="switchMod">Cambia Mod</str>
<str id="fpsCounter">Contatore FPS</str>
</group>
<str id="volume.up">Su</str>
+2 -1
View File
@@ -44,8 +44,9 @@
<str id="category.engine">Silnik</str>
<group name="engine" prefix="engine.">
<str id="switchMod">Zmień Moda</str>
<str id="fpsCounter">Licznik FPS</str>
</group>
<str id="category.volume">Głośność</str>
<str id="volume.up">Głóśniej</str>
<str id="volume.down">Ciszej</str>
+1
View File
@@ -48,6 +48,7 @@
<str id="category.engine">Codename Engine</str>
<group name="engine" prefix="engine.">
<str id="switchMod">Trocar Mod</str>
<str id="fpsCounter">Contador de FPS</str>
</group>
<str id="category.volume">Volume</str>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+22 -3
View File
@@ -1,6 +1,6 @@
Here's the full guide on how to setup and compile Codename Engine!<br>
> **Open the instructions for your platform**
# Compiling Codename Engine
Do you want to turn your source code into a playable build to play? Then you want to **compile the source code**, follow this guide.
> **Open the instructions for your platform.**
<details>
<summary>Windows</summary>
@@ -38,3 +38,22 @@ Here's the full guide on how to setup and compile Codename Engine!<br>
> You can also run `./cne-windows.bat -help` or `./cne-unix.sh -help` (depending on your platform) to check out more useful commands!<br>
> For example `./cne-windows test` or `./cne-unix.sh test` builds the game and uses the source assets folder instead of the export one for easier development (although you can still use `lime test` normally).
> - If you're running the terminal from the project's main folder, use instead `./building/cne-windows.bat -COMMAND HERE` or `./building/cne-unix.sh -COMMAND HERE` depending on your platform.
# Generating Codename Engine's API documentation
**Mainly recommended if you intend to fork the engine and make your own custom version to publish.**<br>Do you want to generate an API documentation so people can understand and mod your playable build? This documentation can be uploaded to your website.<br>If you just want to compile the engine normally for your hardcoded mod or for yourself you can skip this step.
> **Select your platform to continue.**
<details>
<summary>Windows</summary>
1. Run `generate-docs-windows.bat` using cmd or double-clicking it and wait for the `doc.xml` to be generated inside the `docs` folder.
</details>
<details>
<summary>MacOS/Linux</summary>
1. Run `generate-docs-unix.sh` using the terminal or double-clicking it and wait for the `doc.xml` to be generated inside the `docs` folder.
</details>
2. You can use this `doc.xml` file to generate a full HTML documentation (that you can open in your browser for example) using Haxe's [dox](https://github.com/HaxeFoundation/dox) generator; check [Codename Engine's webiste](https://github.com/CodenameCrew/codename-website/tree/main/api-generator) for example.
> [!CAUTION]
> The doc.xml might contain some sensible paths of your computer: make sure to filter the file before publishing it for everyone if you want to keep those paths private!<br>To filter and delete those paths, you may use Codename Engine's website's [doc filter Python script](https://github.com/CodenameCrew/codename-website/blob/main/api-generator/api/filter.py) by simply running it in the same folder of your `doc.xml` file. This script will also delete everything irrelevant to the engine that was generated in your documentation, such as libraries' (like OpenFL or Flixel) APIs.
+9 -6
View File
@@ -1,14 +1,17 @@
[general]
[General]
sample-type=float32
stereo-mode=speakers
stereo-encoding=panpot
hrtf=false
cf_level=0
resampler=fast_bsinc24
front-stablizer=false
output-limiter=false
front-stabilizer=false
volume-adjust=0
period_size=441
sources=512
sends=64
dither=false
[decoder]
hq-mode=false
distance-comp=false
hq-mode=true
distance-comp=true
nfc=false
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env sh
cd "$(dirname "$0")/.."
echo "Generating documentation..."
if [ $(uname) == "Darwin" ]; then
echo "Platform is macOS"
haxelib run lime build mac --haxeflag="-xml docs/doc.xml" -D doc-gen -D DOCUMENTATION --no-output
else
echo "Platform is not macOS; assuming platform to be Linux compatible"
haxelib run lime build linux --haxeflag="-xml docs/doc.xml" -D doc-gen -D DOCUMENTATION --no-output
fi
echo "The XML file for the API documentation has been generated at docs/doc.xml."
echo "For updating the API documentation hosted at the website, please replace codename-website/api-generator/api/doc.xml with the file listed above."
+8
View File
@@ -0,0 +1,8 @@
@ECHO OFF
cd /d "%~dp0.."
echo Generating documentation...
echo Platform is based on Windows
haxelib run lime build windows --haxeflag="-xml docs/doc.xml" -D doc-gen -D DOCUMENTATION --no-output
echo The XML file for the API documentation has been generated at docs/doc.xml.
echo For updating the API documentation hosted at the website, please replace codename-website/api-generator/api/doc.xml with the file listed above.
+3 -2
View File
@@ -5,7 +5,7 @@
<!-- OpenFL & Lime (Required for Flixel) -->
<git name="openfl" url="https://github.com/CodenameCrew/cne-openfl" />
<lib name="lime" version="8.2.0" />
<lib name="lime" version="8.1.2" />
<!-- <git name="lime" url="https://github.com/CodenameCrew/cne-lime" /> disabled for now until fixed -->
<!-- Flixel -->
@@ -16,8 +16,9 @@
<git name="hscript-improved" url="https://github.com/CodenameCrew/hscript-improved" ref="codename-dev" />
<git name="flxanimate" url="https://github.com/CodenameCrew/cne-flxanimate" />
<git name="hxdiscord_rpc" url="https://github.com/CodenameCrew/cne-hxdiscord_rpc" skipDeps="true" />
<git name="funkin-modchart" url="https://github.com/TheoDevelops/FunkinModchart" ref="f30676579d8de7ccac7d12e13b664e8b2c42c6bf" skipDeps="true" />
<lib name="funkin-modchart" version="1.2.4" skipDeps="true" />
<lib name="hxvlc" version="1.9.3" skipDeps="true" />
<git name="bin-serializer" url="https://github.com/CodenameCrew/bin-serializer" />
<!-- Documentation and other features -->
<git name="away3d" url="https://github.com/CodenameCrew/away3d" />
-494
View File
@@ -1,494 +0,0 @@
// funkin source classes cannot be imported here
import haxe.io.Path;
import hxp.*;
import lime.tools.*;
import sys.FileSystem;
import sys.io.Process;
using StringTools;
class Project extends HXProject
{
static final TITLE:String = "Friday Night Funkin' - Codename Engine";
static final EXECUTABLE:String = "CodenameEngine";
static final VERSION:String = "1.0.1";
static final COMPANY:String = "Yoshman29";
static final PACKAGE:String = "com.codenamecrew.codenameengine";
static final MAIN_CLASS:String = "funkin.backend.system.MainApplication";
static final PRELOADER:String = "flixel.system.FlxPreloader";
static final SOURCE_FOLDERS:Array<String> = ["source"];
// Compile Flags
static final EMBED_ASSETS:CompileFlag = CompileFlag.get("EMBED_ASSETS");
static final PRELOAD_ALL:CompileFlag = CompileFlag.get("PRELOAD_ALL");
static final STRIPPED_COMPILE:CompileFlag = CompileFlag.get("STRIPPED_COMPILE");
static final UPDATE_CHECKING:CompileFlag = CompileFlag.get("UPDATE_CHECKING");
static final DISCORD_RPC:CompileFlag = CompileFlag.get("DISCORD_RPC");
static final MODCHARTING_FEATURES:CompileFlag = CompileFlag.get("MODCHARTING_FEATURES");
static final GITHUB_API:CompileFlag = CompileFlag.get("GITHUB_API");
static final COMPILE_ALL_CLASSES:CompileFlag = CompileFlag.get("COMPILE_ALL_CLASSES");
static final CUSTOM_CLASSES:CompileFlag = CompileFlag.get("CUSTOM_CLASSES");
static final ALLOW_MULTITHREADING:CompileFlag = CompileFlag.get("ALLOW_MULTITHREADING");
static final MOD_SUPPORT:CompileFlag = CompileFlag.get("MOD_SUPPORT");
static final TRANSLATIONS_SUPPORT:CompileFlag = CompileFlag.get("TRANSLATIONS_SUPPORT");
static final GLOBAL_SCRIPT:CompileFlag = CompileFlag.get("GLOBAL_SCRIPT");
static final SOFTCODED_STATES:CompileFlag = CompileFlag.get("SOFTCODED_STATES");
static final NDLLS_SUPPORTED:CompileFlag = CompileFlag.get("NDLLS_SUPPORTED");
static final USE_ADAPTED_ASSETS:CompileFlag = CompileFlag.get("USE_ADAPTED_ASSETS");
static final THREE_D_SUPPORT:CompileFlag = CompileFlag.get("THREE_D_SUPPORT");
static final NAPE_ENABLED:CompileFlag = CompileFlag.get("NAPE_ENABLED");
static final VIDEO_CUTSCENES:CompileFlag = CompileFlag.get("VIDEO_CUTSCENES");
static final SHOW_BUILD_ON_FPS:CompileFlag = CompileFlag.get("SHOW_BUILD_ON_FPS");
static final DARK_MODE_WINDOW:CompileFlag = CompileFlag.get("DARK_MODE_WINDOW");
public function new():Void
{
super();
CompileFlag.project = this;
haxe.Log.trace = (v:Dynamic, ?info:haxe.PosInfos) ->
{
if (!isDisplay())
Sys.println(v);
};
doWelcomeHeader();
trace("Configuring project...");
trace("");
configureApp();
configureCompileFlags();
configureAssets();
configureLibs();
configureIcons();
trace("");
trace("Configured project");
trace("Starting build...");
trace("");
}
function getHaxeVersion():String {
var process = new Process("haxe", ["-version"]);
var version:String = "";
try {
version = process.stdout.readAll().toString().trim();
} catch (e) {}
process.close();
return version;
}
function doWelcomeHeader() {
var haxeVersion = getHaxeVersion().trim();
var sleepChangeVersion = false;
var width = 60; // total banner width
inline function centerText(text:String, width:Int):String {
var innerWidth = width - 2;
var padding = Std.int(Math.max(0, Std.int((innerWidth - text.length) / 2)));
var left = StringTools.lpad("", " ", padding);
var right = StringTools.lpad("", " ", innerWidth - text.length - padding);
return "=" + left + text + right + "=";
}
inline function infoLine(label:String, value:String):String {
var innerWidth = width - 2;
if (label.length == 0) {
// no label: center the value
var padding = Std.int(Math.max(0, (innerWidth - value.length) / 2));
var left = StringTools.lpad("", " ", padding);
var right = StringTools.lpad("", " ", innerWidth - value.length - padding);
return "=" + left + value + right + "=";
} else {
var colonPos = Std.int(innerWidth / 2);
var labelPart = StringTools.lpad(label, " ", Std.int(Math.max(0, colonPos - 2)));
var valuePart = value;
var remainingSpace = Std.int(Math.max(0, innerWidth - (labelPart.length + 3 + valuePart.length)));
var rightPad = StringTools.lpad("", " ", remainingSpace);
return "=" + labelPart + " : " + valuePart + rightPad + "=";
}
}
var unicode = #if (target.unicode) true #else false #end;
trace('');
trace(StringTools.lpad("", "=", width));
trace(centerText(TITLE, width));
trace(StringTools.lpad("", "=", width));
trace(infoLine("Engine Version", 'v${VERSION}'));
trace(infoLine("Haxe Version", 'v${haxeVersion}'));
trace(StringTools.lpad("", "=", width));
try {
var lastBuiltWith:Null<String> = null;
var compiling = isDebug() ? "debug" : "release";
var target = isWeb() ? "html5" : (isIOS() ? "ios" : (isAndroid() ? "android" : (isWindows() ? "windows" : (isMac() ? "macos" : (isLinux() ? "linux" : "")))));
if (target == "") throw "Unknown target";
var exportPath = Sys.getCwd() + "/export/" + compiling + "/" + target + "/obj/Options.txt";
var options = sys.io.File.getContent(exportPath);
for (option in options.split("\n")) {
if (option.startsWith("haxe=")) {
lastBuiltWith = option.substr(5).trim();
break;
}
}
if (lastBuiltWith != null && lastBuiltWith.length > 0 && lastBuiltWith != haxeVersion) {
trace(infoLine("", unicode ? "⚠️ Haxe version mismatch!" : "[WARNING] Haxe version mismatch!"));
trace(infoLine("Last Built With", lastBuiltWith));
trace(infoLine("Current Version", haxeVersion));
trace(StringTools.lpad("", "=", width));
trace(infoLine("", "!!! Make sure to DELETE your EXPORT folders !!!"));
trace(StringTools.lpad("", "=", width));
sleepChangeVersion = true;
}
} catch (e) {}
var targetPlatform = isWeb() ? "Web (HTML5)" : (isIOS() ? "iOS" : (isAndroid() ? "Android" : (isWindows() ? "Windows" : (isMac() ? "Mac" : (isLinux() ? "Linux" : "Unknown")))));
if (isHashLink())
targetPlatform = "Hashlink (" + targetPlatform + ")";
trace(infoLine("Target Platform", targetPlatform));
trace(infoLine("Build Type", isDebug() ? "Debug" : "Release"));
trace(infoLine("Build Date", Date.now().toString()));
trace(StringTools.lpad("", "=", width));
trace('');
if (sleepChangeVersion)
Sys.sleep(5);
}
function configureApp():Void
{
trace("Configuring game...");
meta.title = TITLE;
meta.version = VERSION;
meta.company = COMPANY;
meta.packageName = PACKAGE;
app.main = MAIN_CLASS;
app.file = EXECUTABLE;
app.preloader = PRELOADER;
var buildDir = 'export/${isDebug() ? 'debug' : 'release'}/';
trace('Output directory: $buildDir');
app.path = buildDir;
sources = SOURCE_FOLDERS;
templatePaths.push(Path.combine(Haxelib.getPath(new Haxelib(#if lime "lime" #else "hxp" #end)), #if lime "templates" #else "" #end));
window.hardware = true;
window.vsync = false;
window.allowHighDPI = true;
if (isWeb())
window.resizable = true;
if (isDesktop())
{
window.orientation = Orientation.LANDSCAPE;
window.fullscreen = false;
window.resizable = true;
window.vsync = false;
} else if (isMobile())
{
window.orientation = Orientation.LANDSCAPE;
window.fullscreen = true;
window.resizable = false;
window.borderless = true;
window.width = 0;
window.height = 0;
}
}
function configureCompileFlags()
{
trace("Configuring compile flags...");
setDefine("disable-version-check");
setHaxedef("disable-version-check");
setHaxedef("no-deprecation-warnings");
// DO NOT REMOVE!! ALLOWS ME TO DO REGIONS LIKE IN C# AND KEEP CODE ORGANIZED. REMOVING IT WOULD BREAK THE ENGINE
setHaxedef("REGION");
setHaxedef("SAVE_PATH", EXECUTABLE);
setHaxedef("SAVE_NAME", "save-default");
setHaxedef("SAVE_OPTIONS_PATH", EXECUTABLE);
setHaxedef("SAVE_OPTIONS_NAME", "options");
PRELOAD_ALL.integrate(!isWeb());
EMBED_ASSETS.integrate(false);
UPDATE_CHECKING.integrate(!isWeb() && !isHashLink());
DISCORD_RPC.integrate(isCPP() && isDesktop());
STRIPPED_COMPILE.integrate(false); //should be isRelease() if you want to use it
MODCHARTING_FEATURES.integrate(STRIPPED_COMPILE.isDisabled());
GITHUB_API.integrate(!isWeb() && !isHashLink());
COMPILE_ALL_CLASSES.integrate(STRIPPED_COMPILE.isDisabled());
CUSTOM_CLASSES.integrate(STRIPPED_COMPILE.isDisabled());
ALLOW_MULTITHREADING.integrate(!isWeb());
MOD_SUPPORT.integrate(!isWeb());
TRANSLATIONS_SUPPORT.integrate(true);
GLOBAL_SCRIPT.integrate(true);
SOFTCODED_STATES.integrate(true);
NDLLS_SUPPORTED.integrate(!isWeb() && !isHashLink());
USE_ADAPTED_ASSETS.integrate(!isWeb());
THREE_D_SUPPORT.integrate(STRIPPED_COMPILE.isDisabled());
NAPE_ENABLED.integrate(STRIPPED_COMPILE.isDisabled());
VIDEO_CUTSCENES.integrate(isCPP() && (isDesktop() || isMobile()));
SHOW_BUILD_ON_FPS.integrate(true);
DARK_MODE_WINDOW.integrate(true);
setDefine("FLX_NO_GENERIC"); // Disable a optimization, to allow reflection to use more functions
if (DISCORD_RPC.isEnabled())
setHaxedef("DISCORD_DISABLE_IO_THREAD");
if (MODCHARTING_FEATURES.isEnabled())
{
setHaxedef("FM_ENGINE", "CODENAME");
setHaxedef("FM_ENGINE_VERSION", "1.0");
addMacroFlag("modchart.backend.macros.Macro.includeFiles()");
}
if (COMPILE_ALL_CLASSES.isEnabled())
{
addHaxeFlag("-dce no");
addMacroFlag("funkin.backend.system.macros.Macros.addAdditionalClasses()");
}
addMacroFlag("funkin.backend.system.macros.Macros.initMacros()");
if (isDebug())
setHaxedef("HXCPP_DEBUG_LINK");
environment.set("HAXEPATH", "./");
setHaxedef("HXCPP_CHECK_POINTER");
setHaxedef("HXCPP_STACK_LINE");
setHaxedef("HXCPP_CATCH_SEGV");
setHaxedef("hscriptPos");
setHaxedef("EXPERIMENTAL_FLXGRAPHIC_DESTROY_FIX");
setHaxedef("FLX_NO_FOCUS_LOST_SCREEN");
if (isRelease())
{
setHaxedef("FLX_NO_DEBUG");
setHaxedef("analyzer-optimize");
}
setHaxedef("openfl_dpi_aware");
}
function configureAssets()
{
trace("Configuring assets...");
var shouldPreload = PRELOAD_ALL.isEnabled();
var shouldEmbed = EMBED_ASSETS.isEnabled();
includeAssetLibrary("default", shouldEmbed, shouldPreload);
addAssetPath("assets", shouldEmbed);
addAsset("art/readme.txt", "do NOT readme.txt", false);
if (isDesktop())
addAsset("building/alsoft.txt", 'plugins/alsoft.${isWindows() ? "ini" : "conf"}', false);
}
function configureLibs()
{
trace("Configuring libraries...");
includeHaxelib("flixel");
includeHaxelib("flixel-addons");
includeHaxelib("format");
includeHaxelib("flxanimate");
includeHaxelib("hscript-improved");
includeHaxelib("markdown");
if (VIDEO_CUTSCENES.isEnabled())
includeHaxelib("hxvlc");
if (THREE_D_SUPPORT.isEnabled())
includeHaxelib("away3d");
if (NAPE_ENABLED.isEnabled())
includeHaxelib("nape-haxe4");
if (DISCORD_RPC.isEnabled())
includeHaxelib("hxdiscord_rpc");
if (MODCHARTING_FEATURES.isEnabled())
includeHaxelib("funkin-modchart");
if (isDebug())
includeHaxelib("hxcpp-debug-server");
}
function configureIcons()
{
trace("Configuring app icons...");
// TODO: ADD MOBILE ICONS
for (size in [16, 32, 64])
addIcon('art/icon${size}.png', size);
addIcon("art/icons/iconOG.png");
}
function includeHaxelib(name:String, version:String = ""):Void
{
haxelibs.push(new Haxelib(name, version));
}
function addAsset(path:String, ?rename:String, embed:Bool = false):Void
{
var asset = new Asset(path, rename, null, embed, true);
asset.library = "default";
assets.push(asset);
}
public function addAssetPath(path:String, ?rename:String, embed:Bool = false):Void
{
if (path == "") return;
var targetPath = Path.addTrailingSlash(rename ?? path);
if (!FileSystem.exists(path))
trace('[ERROR] Path "${path}" was not found');
else if (!FileSystem.isDirectory(path))
trace('[ERROR] Path "${path}" needs to be a directory.');
for (file in FileSystem.readDirectory(path))
{
if (FileSystem.isDirectory('${path}/${file}'))
addAssetPath('${path}/${file}', '${targetPath}${file}', embed);
else
addAsset('${path}/${file}', '${targetPath}${file}', embed);
}
}
function includeAssetLibrary(name:String, embed:Bool = false, preload:Bool = false):Void
{
this.libraries.push(new Library('', name, null, embed, preload, false, ""));
}
inline function addIcon(icon:String, ?size:Int):Void
icons.push(new Icon(icon, size));
inline function addHaxeFlag(value:String):Void
haxeflags.push(value);
inline function addMacroFlag(value:String):Void
addHaxeFlag('--macro ${value}');
inline function isDebug():Bool
return debug;
inline function isRelease():Bool
return !isDebug();
inline function isDisplay():Bool
return command == "display";
inline function isWeb():Bool
return platformType == PlatformType.WEB;
inline function isMobile():Bool
return platformType == PlatformType.MOBILE;
inline function isDesktop():Bool
return platformType == PlatformType.DESKTOP;
inline function isWindows():Bool
return target == Platform.WINDOWS;
inline function isMac():Bool
return target == Platform.MAC;
inline function isLinux():Bool
return target == Platform.LINUX;
inline function isAndroid():Bool
return target == Platform.ANDROID;
inline function isIOS():Bool
return target == Platform.IOS;
inline function isHashLink():Bool
return targetFlags.exists("hl");
inline function isCPP():Bool
return defines.exists("cpp");
public inline function getHaxedef(name:String):Null<Dynamic>
return haxedefs.get(name);
public inline function setHaxedef(name:String, ?value:String):Void
haxedefs.set(name, value ?? "");
public inline function unsetHaxedef(name:String):Void
haxedefs.remove(name);
public inline function getDefine(name:String):Null<Dynamic>
return defines.get(name);
public inline function setDefine(name:String, ?value:String):Void
defines.set(name, value ?? "");
public inline function unsetDefine(name:String):Void
defines.remove(name);
}
class CompileFlag {
public static final INVERSION:String = "NO_";
public static var project:Project;
public static function get(name:String):CompileFlag {
return new CompileFlag(name);
}
var name:String;
public function new(name:String) {
this.name = name;
}
public function enable(stopPropagation:Bool = false):Void
{
project.setHaxedef(name);
project.setDefine(name);
if (!stopPropagation)
getInverse().disable(true);
}
public function disable(stopPropagation:Bool = false):Void
{
project.unsetHaxedef(name);
project.unsetDefine(name);
if (!stopPropagation)
getInverse().enable(true);
}
public function integrate(defaultEnabled:Bool = false):Void {
var inverse = getInverse();
if (isEnabled()) inverse.disable(true); // Makes sure the inverse is disabled if it wasn't already
else if (inverse.isEnabled()) disable(true); // If the inverse is enabled, disable this
else (defaultEnabled ? enable : disable)(true); // Set to the default state otherwise
}
public function isEnabled():Bool {
return project.haxedefs.exists(name) || project.defines.exists(name);
}
public function isDisabled():Bool {
return getInverse().isEnabled() || !isEnabled();
}
function getInverse():CompileFlag {
var inversionName = name;
if (!inversionName.startsWith(INVERSION))
inversionName = INVERSION + inversionName;
return new CompileFlag(inversionName);
}
}
+12 -9
View File
@@ -3,19 +3,16 @@
<!-- _________________________ Application Settings _________________________ -->
<app
title="Friday Night Funkin' - Codename Engine" main="funkin.backend.system.Main"
file="CodenameEngine" packageName="com.yoshman29.codenameengine"
package="com.yoshman29.codenameengine"
version="1.0.1" company="Yoshman29" />
file="CodenameEngine" packageName="com.codenamecrew.codenameengine"
package="com.codenamecrew.codenameengine"
version="1.0.1" company="CodenameCrew" />
<!--
CHANGE THE SAVE PATH & NAME FOR YOUR MOD HERE!
CHANGE THE SAVE PATH & NAME FOR YOUR HARDCODED MOD HERE!
-->
<haxedef name="SAVE_PATH" value="CodenameEngine"/>
<haxedef name="SAVE_PATH" value="CodenameCrew/CodenameEngine"/>
<haxedef name="SAVE_NAME" value="save-default"/>
<haxedef name="SAVE_OPTIONS_PATH" value="CodenameEngine"/>
<haxedef name="SAVE_OPTIONS_NAME" value="options"/>
<!--Switch Export with Unique ApplicationID and Icon-->
<set name="APP_ID" value="0x0100f6c013bbc000" />
@@ -50,7 +47,7 @@
<!-- _________________________________ Engine Settings _______________________________ -->
<!-- Comment this out to disable updates !-->
<define name="UPDATE_CHECKING" unless="web || hl || neko"/>
<define name="UPDATE_CHECKING" unless="web || hl || neko || debug"/>
<!-- Comment this out to disable Discord RPC !-->
<section if="cpp">
@@ -131,6 +128,7 @@
<haxelib name="away3d" if="THREE_D_SUPPORT" />
<haxelib name="format" />
<haxelib name="flxanimate" />
<haxelib name="bin-serializer" />
<haxelib name="nape-haxe4" if="NAPE_ENABLED"/>
<haxelib name="hscript-improved" />
@@ -172,6 +170,8 @@
<!-- ______________________________ Haxedefines _____________________________ -->
<haxeflag name="--macro" value="funkin.backend.system.macros.BuildInfo.printBuildInfo()" />
<haxedef name="FLX_NO_FOCUS_LOST_SCREEN" />
<!--Disable the Flixel core debugger. Automatically gets set whenever you compile in release mode!-->
@@ -187,6 +187,9 @@
<haxedef name="USE_ADAPTED_ASSETS" if="USE_ADAPTED_ASSETS" />
<haxedef name="openfl_dpi_aware" if="openfl_dpi_aware" />
<!-- Disable it for more concise compilation errors. -->
<haxedef name="message.reporting" value="pretty" />
<!-- _________________________________ Custom _______________________________ -->
<!--Place custom nodes like icons here (higher priority to override the HaxeFlixel icon)-->
+70 -39
View File
@@ -21,6 +21,7 @@ import flixel.math.FlxMath;
import flixel.math.FlxPoint;
import flixel.system.FlxAssets.FlxSoundAsset;
import flixel.tweens.FlxTween;
import flixel.util.FlxDestroyUtil;
import flixel.util.FlxSignal;
import flixel.util.FlxStringUtil;
import flixel.FlxBasic;
@@ -136,11 +137,18 @@ class FlxSound extends FlxBasic {
public var radius:Float;
/**
* Whether the proximity alters the pan or not
* Whether the proximity alters the pan or not.
* @since raltyMod
*/
public var proximityPan:Bool;
/**
* Controls how much this object is affected by camera scrolling. `0` = no movement (e.g. a static sound),
* This is only useful if used with proximity (Initialized once proximity is used).
* @since raltyMod
*/
public var scrollFactor(default, null):FlxPoint;
/**
* Stores for how much channels are in the loaded sound.
* @since raltyMod
@@ -302,6 +310,8 @@ class FlxSound extends FlxBasic {
_lastTime = null;
if (destroySound) {
scrollFactor = FlxDestroyUtil.put(scrollFactor);
if (group != null) group.remove(this);
if (_channel != null) {
@@ -348,15 +358,24 @@ class FlxSound extends FlxBasic {
_amplitudeUpdate = true;
// Distance-based volume control (TODO for Ralty: REDO THIS)
// Distance-based volume control
if (target != null) {
var targetPosition = target.getPosition();
var radialMultiplier = targetPosition.distanceTo(FlxPoint.weak(x, y)) / radius;
targetPosition.put();
radialMultiplier = 1 - FlxMath.bound(radialMultiplier, 0, 1);
var targetPosition = target.getPosition(), position = getPosition();
var camera = camera;
if (camera != null) {
targetPosition.subtract(camera.scroll.x * target.scrollFactor.x, camera.scroll.y * target.scrollFactor.y);
if (scrollFactor != null) position.subtract(camera.scroll.x * scrollFactor.x, camera.scroll.y * scrollFactor.y);
else position.subtract(camera.scroll.x, camera.scroll.y);
}
_volumeAdjust = radialMultiplier;
if (proximityPan) _panAdjust = (x - target.x) / radius;
var radialMultiplier = targetPosition.distanceTo(position) / radius;
// Make it so it affects the 3d position of the source and not just the panning?
_volumeAdjust = 1 - FlxMath.bound(radialMultiplier, 0, 1);
if (proximityPan) _panAdjust = (position.x - targetPosition.x) / radius;
targetPosition.put();
position.put();
}
else
_volumeAdjust = 1.0;
@@ -536,12 +555,15 @@ class FlxSound extends FlxBasic {
* @param Pan Whether panning should be used in addition to the volume changes.
* @return This FlxSound instance (nice for chaining stuff together, if you're into that).
*/
public function proximity(x = 0.0, y = 0.0, ?targetObject:FlxObject, ?radius:Float, pan = true):FlxSound {
public function proximity(x = 0.0, y = 0.0, ?targetObject:FlxObject, ?radius:Float, pan = true, ?scrollFactor:FlxPoint):FlxSound {
setPosition(x, y);
if (targetObject != null) this.target = targetObject;
if (radius != null) this.radius = radius;
proximityPan = pan;
if (this.scrollFactor == null) this.scrollFactor = FlxPoint.get(1, 1);
if (scrollFactor != null) this.scrollFactor.copyFrom(scrollFactor);
return this;
}
@@ -549,14 +571,28 @@ class FlxSound extends FlxBasic {
* Helper function to set the coordinates of this object.
* Sound positioning is used in conjunction with proximity/panning.
*
* @param x The new x position
* @param y The new y position
* @param x The new x position
* @param y The new y position
*/
public inline function setPosition(x = 0.0, y = 0.0):Void {
public function setPosition(x = 0.0, y = 0.0):Void {
this.x = x;
this.y = y;
}
/**
* Returns the world position of this object.
*
* @param result Optional arg for the returning point.
* @return The world position of this object.
* @since raltyMod
*/
public function getPosition(?result:FlxPoint):FlxPoint {
if (result == null)
result = FlxPoint.get();
return result.set(x, y);
}
/**
* Call this function to play the sound - also works on paused sounds.
*
@@ -682,7 +718,7 @@ class FlxSound extends FlxBasic {
_paused = false;
_time = startTime;
_lastTime = FlxG.game.getTicks();
if (_channel == null || !_channel.__isValid || _source == null #if lime_cffi || _source.__backend.disposed || _source.__backend.handle == null #end)
if (_channel == null || !_channel.__isValid || _source == null #if lime_cffi || _source.__backend.disposed #end)
makeChannel();
if (_channel != null) {
@@ -733,7 +769,8 @@ class FlxSound extends FlxBasic {
_lastTime = FlxG.game.getTicks();
_time = loopTime;
}
else _channel.loops = 999;
else if (_source != null)
_source.loops = 999;
}
/**
@@ -763,7 +800,7 @@ class FlxSound extends FlxBasic {
}
inline function get_playing():Bool @:privateAccess
return _channel != null && _channel.__isValid && _source.playing;
return _source != null && _source.playing;
inline function get_volume():Float
return _volume;
@@ -796,12 +833,12 @@ class FlxSound extends FlxBasic {
inline function get_buffer():AudioBuffer
@:privateAccess return _sound != null ? _sound.__buffer : null;
function update_amplitude():Void @:privateAccess {
if (_channel == null || !_channel.__updatePeaks(get_time()) || !_amplitudeUpdate) return;
_amplitudeUpdate = false;
_amplitudeLeft = _channel.__leftPeak;
_amplitudeRight = _channel.__rightPeak;
inline function update_amplitude():Void @:privateAccess {
if (_channel != null && _channel.__updatePeaks(get_time()) && _amplitudeUpdate) {
_amplitudeUpdate = false;
_amplitudeLeft = _channel.__leftPeak;
_amplitudeRight = _channel.__rightPeak;
}
}
inline function get_amplitudeLeft():Float {
@@ -829,30 +866,27 @@ class FlxSound extends FlxBasic {
inline function get_pitch():Float
return _pitch;
function set_pitch(v:Float):Float {
inline function set_pitch(v:Float):Float {
_realPitch = (_pitch = v) * _timeScaleAdjust;
if (_channel != null) _channel.pitch = _realPitch;
if (_source != null) _source.pitch = _realPitch;
return _pitch;
}
#end
function set_looped(v:Bool):Bool {
if (playing) {
if (v) _channel.loops = 999;
else _channel.loops = 0;
}
if (playing) _source.loops = v ? 999 : 0;
return looped = v;
}
function set_loopTime(v:Float):Float {
if (playing) _channel.loopTime = v;
if (playing) _source.loopTime = v;
return loopTime = v;
}
function set_endTime(v:Null<Float>):Null<Float> {
if (playing) {
if (v != null && v > 0 && v < _length) _channel.endTime = v;
else _channel.endTime = null;
if (v != null && v > 0 && v < _length) _source.length = v;
else _source.length = null;
}
return endTime = v;
}
@@ -864,7 +898,7 @@ class FlxSound extends FlxBasic {
return _time;
}
function get_time():Float {
if (_channel == null || @:privateAccess !_channel.__isValid || /*AudioManager.context == null*/funkin.backend.system.Main.audioDisconnected) return _time;
if (_source == null || /*AudioManager.context == null*/funkin.backend.system.Main.audioDisconnected) return _time;
final sourceTime = _source.currentTime - _source.offset - _offset;
if (!_source.playing || _realPitch <= 0) {
@@ -903,24 +937,21 @@ class FlxSound extends FlxBasic {
return _time = time;
}
inline function get_offset():Float return _offset;
inline function set_offset(offset:Float):Float {
function get_offset():Float return _offset;
function set_offset(offset:Float):Float {
if (_offset == (_offset = offset)) return offset;
//time = time + _offset;
return offset;
}
inline function get_length():Float return _length - _offset;
function get_length():Float return _length - _offset;
/*function get_latency():Float {
if (_channel != null) return _source.latency;
return 0;
}*/
//function get_latency():Float return _source != null ? _source.latency : 0;
override function toString():String {
return FlxStringUtil.getDebugString([
LabelValuePair.weak("playing", playing),
LabelValuePair.weak("time", _time),
LabelValuePair.weak("time", time),
LabelValuePair.weak("length", length),
LabelValuePair.weak("volume", volume),
LabelValuePair.weak("pitch", pitch)
+45 -20
View File
@@ -70,6 +70,8 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
@:noCompletion public var atlasPlayingAnim:String;
@:noCompletion public var atlasPath:String;
var _rect2:FlxRect;
public function new(?X:Float = 0, ?Y:Float = 0, ?SimpleGraphic:FlxGraphicAsset)
{
super(X, Y);
@@ -112,6 +114,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
spr.transformMatrix = casted.transformMatrix;
spr.matrixExposed = casted.matrixExposed;
spr.animOffsets = casted.animOffsets.copy();
spr.zoomFactor = casted.zoomFactor;
}
}
return spr;
@@ -131,6 +134,11 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
}
}
override function initVars() {
super.initVars();
_rect2 = FlxRect.get();
}
public function loadSprite(path:String, Unique:Bool = false, Key:String = null)
{
var noExt = Path.withoutExtension(path);
@@ -226,6 +234,8 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
animOffsets = null;
}
super.destroy();
_rect2 = FlxDestroyUtil.put(_rect2);
}
#end
@@ -233,27 +243,40 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
private inline function __shouldDoZoomFactor()
return zoomFactorEnabled && zoomFactor != 1;
private inline function __prepareZoomFactor(?rect:FlxRect, camera:FlxCamera):FlxRect {
if (Flags.USE_LEGACY_ZOOM_FACTOR)
return (rect ?? FlxRect.get()).set(
camera.width * 0.5,
camera.height * 0.5,
(camera.scaleX > 0 ? Math.max : Math.min)(0, FlxMath.lerp(1 / camera.scaleX, 1, zoomFactor)),
(camera.scaleY > 0 ? Math.max : Math.min)(0, FlxMath.lerp(1 / camera.scaleY, 1, zoomFactor))
);
else
return (rect ?? FlxRect.get()).set(
camera.width * 0.5 + camera.scroll.x * scrollFactor.x,
camera.height * 0.5 + camera.scroll.y * scrollFactor.y,
(camera.scaleX > 0 ? Math.max : Math.min)(0, FlxMath.lerp(1 / camera.scaleX, 1, zoomFactor)),
(camera.scaleY > 0 ? Math.max : Math.min)(0, FlxMath.lerp(1 / camera.scaleY, 1, zoomFactor))
);
}
public override function getScreenBounds(?newRect:FlxRect, ?camera:FlxCamera):FlxRect
{
if (camera == null)
camera = FlxG.camera;
var r = super.getScreenBounds(newRect, camera);
newRect = super.getScreenBounds(newRect, camera);
if(__shouldDoZoomFactor()) {
r.x -= camera.width / 2;
r.y -= camera.height / 2;
var ratio = (camera.zoom > 0 ? Math.max : Math.min)(0, FlxMath.lerp(1 / camera.zoom, 1, zoomFactor));
r.x *= ratio;
r.y *= ratio;
r.width *= ratio;
r.height *= ratio;
r.x += camera.width / 2;
r.y += camera.height / 2;
__prepareZoomFactor(_rect2, camera);
newRect.set(
(newRect.x - _rect2.x) * _rect2.width + _rect2.x,
(newRect.y - _rect2.y) * _rect2.height + _rect2.y,
newRect.width * _rect2.width,
newRect.height * _rect2.height,
);
}
return r;
return newRect;
}
override public function isOnScreen(?camera:FlxCamera):Bool
@@ -273,14 +296,16 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
// ZOOM FACTOR RENDERING
public override function doAdditionalMatrixStuff(matrix:FlxMatrix, camera:FlxCamera)
{
super.doAdditionalMatrixStuff(matrix, camera);
// no need to...
//super.doAdditionalMatrixStuff(matrix, camera);
if(__shouldDoZoomFactor()) {
matrix.translate(-camera.width / 2, -camera.height / 2);
var requestedZoom = (camera.zoom >= 0 ? Math.max : Math.min)(FlxMath.lerp(1, camera.zoom, zoomFactor), 0);
var diff = requestedZoom / camera.zoom;
matrix.scale(diff, diff);
matrix.translate(camera.width / 2, camera.height / 2);
__prepareZoomFactor(_rect, camera);
matrix.setTo(
matrix.a * _rect.width, matrix.b * _rect.height,
matrix.c * _rect.width, matrix.d * _rect.height,
(matrix.tx - _rect.x) * _rect.width + _rect.x,
(matrix.ty - _rect.y) * _rect.height + _rect.y,
);
}
}
@@ -236,6 +236,12 @@ class MusicBeatSubstate extends FlxSubState implements IBeatCancellableReceiver
super.openSubState(e.substate is FlxSubState ? cast e.substate : subState);
}
public override function closeSubState() {
var e = event("onCloseSubState", EventManager.get(StateEvent).recycle(subState));
if (!e.cancelled)
super.closeSubState();
}
public override function onResize(w:Int, h:Int) {
super.onResize(w, h);
event("onResize", EventManager.get(ResizeEvent).recycle(w, h, null, null));
+36
View File
@@ -97,6 +97,41 @@ class Chart {
data.setFieldDefault("vocalsSuffix", "");
data.setFieldDefault("needsVoices", true);
data.setFieldDefault("difficulties", []);
var songNameLower = songName.toLowerCase();
var metaPath = Paths.file('songs/${songNameLower}/meta.json');
var metaDiffPath = Paths.file('songs/${songNameLower}/meta-${difficulty.toLowerCase()}.json');
var blacklist:Array<String> = [];
var data:ChartMetaData = null;
var fromMods:Bool = fromMods;
for (path in [metaDiffPath, metaPath]) {
if (Assets.exists(path)) {
fromMods = Paths.assetsTree.existsSpecific(path, "TEXT", MODS);
try {
var temp = CoolUtil.parseJson(path);
// Backwards compatibility (they both can be null so != true) - Nex
var coopExlc = false;
if (Reflect.hasField(temp, "coopAllowed") && Reflect.field(temp, "coopAllowed") != true) {
blacklist = blacklist.concat(["codename.coop", "codename.coop-opponent"]);
Reflect.deleteField(temp, "coopAllowed");
coopExlc = true;
}
if (Reflect.hasField(temp, "opponentModeAllowed") && Reflect.field(temp, "opponentModeAllowed") != true) {
if (!coopExlc) blacklist.push("codename.coop-opponent");
blacklist.push("codename.opponent");
Reflect.deleteField(temp, "opponentModeAllowed");
}
data = temp;
} catch(e) {
Logs.trace('Failed to load song metadata for ${songName} ($path): ${Std.string(e)}', ERROR);
}
if (data != null) break;
}
}
data.setFieldDefault("excludedGameModes", blacklist);
data.setFieldDefault("variants", []);
data.setFieldDefault("metas", []);
@@ -300,6 +335,7 @@ class Chart {
var eventsPath = '$songPath/events$variantSuffix.json', events = filterEventsForSaving(chart.events, false, true);
if (events.length != 0) CoolUtil.safeSaveFile(eventsPath, Json.stringify({events: events}, null, prettyPrint));
else if (FileSystem.exists(eventsPath)) FileSystem.deleteFile(eventsPath); // If there's no events to save, then get rid of the file (if it exists already).
}
#end
+1 -2
View File
@@ -32,8 +32,7 @@ typedef ChartMetaData = {
public var ?icon:String;
public var ?color:FlxColor;
public var ?coopAllowed:Bool;
public var ?opponentModeAllowed:Bool;
public var ?excludedGameModes:Array<String>;
public var ?metas:Map<String, ChartMetaData>;
public var ?instSuffix:String;
+3 -1
View File
@@ -179,7 +179,8 @@ class EventsData {
finalParams.push({
name: paramData.name,
type: hscriptInterp.expr(hscriptParser.parseString(paramData.type)),
defValue: paramData.defaultValue
defValue: paramData.defaultValue,
saveIfDefault: paramData.saveIfDefault
});
} catch (e) {trace('Error parsing event param ${paramData.name} - ${eventName}: $e'); finalParams.push(null);}
}
@@ -196,6 +197,7 @@ typedef EventInfoFile = {
var name:String;
var type:String;
var defaultValue:Dynamic;
var ?saveIfDefault:Bool;
}>;
}
+1 -1
View File
@@ -60,7 +60,7 @@ class PsychParser {
note.time, // TIME
note.id, // DATA
note.sLen, // SUSTAIN LENGTH
chart.noteTypes.getDefault([""])[note.type] // NOTE TYPE
chart.noteTypes.getDefault([""])[note.type - 1] // NOTE TYPE
];
if ((swagSection.mustHitSection && strumLine.type == OPPONENT) ||
@@ -55,9 +55,6 @@ class GlobalScript {
reloading = false;
MusicBeatState.ALLOW_DEV_RELOAD = _lastAllow_Reload;
}
if (PlayerSettings.solo.controls.DEV_CONSOLE)
NativeAPI.allocConsole();
});
FlxG.signals.preDraw.add(function() {
call("preDraw");
@@ -1,14 +1,8 @@
package funkin.backend.scripting;
#if ALLOW_MULTITHREADING
import sys.thread.Thread;
#end
import hscript.IHScriptCustomBehaviour;
class MultiThreadedScript implements IFlxDestroyable implements IHScriptCustomBehaviour {
var thread:#if ALLOW_MULTITHREADING Thread #else Dynamic #end;
/**
* Script being ran.
*/
@@ -46,13 +40,6 @@ class MultiThreadedScript implements IFlxDestroyable implements IHScriptCustomBe
script.load();
#if ALLOW_MULTITHREADING
thread = Thread.createWithEventLoop(function() {
// Prevent the thread from being auto deleted
Thread.current().events.promise();
});
#end
__variables = Type.getInstanceFields(Type.getClass(this));
}
@@ -69,7 +56,7 @@ class MultiThreadedScript implements IFlxDestroyable implements IHScriptCustomBe
public function call(func:String, args:Array<Dynamic>) {
#if ALLOW_MULTITHREADING
thread.events.run(function() {
funkin.backend.utils.ThreadUtil.execAsync(() -> {
callEnded = false;
returnValue = script.call(func, args);
callEnded = true;
@@ -85,13 +72,5 @@ class MultiThreadedScript implements IFlxDestroyable implements IHScriptCustomBe
script.call("destroy");
script.destroy();
}
#if ALLOW_MULTITHREADING
if (thread != null) {
thread.events.runPromised(function() {
// close the thing
});
}
#end
}
}
+2 -1
View File
@@ -102,6 +102,7 @@ class Script extends FlxBasic implements IFlxDestroyable {
#if sys "ZipUtil" => funkin.backend.utils.ZipUtil, #end
"MarkdownUtil" => funkin.backend.utils.MarkdownUtil,
"EngineUtil" => funkin.backend.utils.EngineUtil,
"ThreadUtil" => funkin.backend.utils.ThreadUtil,
"MemoryUtil" => funkin.backend.utils.MemoryUtil,
"BitmapUtil" => funkin.backend.utils.BitmapUtil,
@@ -401,4 +402,4 @@ class Script extends FlxBasic implements IFlxDestroyable {
* Called when the script is loaded.
*/
public function onLoad() {}
}
}
@@ -1,5 +1,7 @@
package funkin.backend.scripting.events.menu.freeplay;
import funkin.menus.FreeplayState.FreeplayGameMode;
final class FreeplaySongSelectEvent extends CancellableEvent {
/**
* Song name that is about to be played
@@ -14,11 +16,26 @@ final class FreeplaySongSelectEvent extends CancellableEvent {
*/
public var variant:String;
/**
* Whenever opponent mode is enabled or not.
* Used game mode's data.
*/
public var opponentMode:Bool;
/**
* Whenever coop mode is enabled.
*/
public var coopMode:Bool;
public var gameMode:FreeplayGameMode;
// Backwards compat
@:noCompletion public var opponentMode(get, set):Bool;
@:noCompletion private function get_opponentMode() return gameMode.modeID == "codename.opponent" || gameMode.modeID == "codename.coop-opponent";
@:noCompletion private function set_opponentMode(val:Bool) {
gameMode = coopMode ?
(val ? new FreeplayGameMode("Co-Op Mode (Switched)", "codename.coop-opponent", ["coop-switched", "opponent", "coop"]) : new FreeplayGameMode("Opponent Mode", "codename.opponent", ["opponent"])) :
(val ? new FreeplayGameMode("Opponent Mode", "codename.opponent", ["opponent"]) : null);
return val;
}
@:noCompletion public var coopMode(get, set):Bool;
@:noCompletion private function get_coopMode() return gameMode.modeID == "codename.coop" || gameMode.modeID == "codename.coop-opponent";
@:noCompletion private function set_coopMode(val:Bool) {
gameMode = opponentMode ?
(val ? new FreeplayGameMode("Co-Op Mode (Switched)", "codename.coop-opponent", ["coop-switched", "opponent", "coop"]) : new FreeplayGameMode("Co-Op Mode", "codename.coop", ["coop"])) :
(val ? new FreeplayGameMode("Co-Op Mode", "codename.coop", ["coop"]) : null);
return val;
}
}
@@ -11,6 +11,7 @@ final class NoteHitEvent extends CancellableEvent {
@:dox(hide) public var unmuteVocals:Bool = true;
@:dox(hide) public var enableCamZooming:Bool = true;
@:dox(hide) public var autoHitLastSustain:Bool = true;
@:dox(hide) public var clipSustain:Bool = true;
/**
* Whenever a miss should be added.
@@ -145,6 +146,13 @@ final class NoteHitEvent extends CancellableEvent {
deleteNote = true;
}
/**
* Prevents the sustain from being cut. Only works if the note is a sustain.
*/
public function preventSustainClip() {
clipSustain = false;
}
/**
* Prevents the vocals volume from being set to 1 after pressing the note.
*/
@@ -30,6 +30,8 @@ class ScriptableShader extends FlxBasic implements IHScriptCustomBehaviour {
if((shader is CustomShader)) scriptName = cast(shader, CustomShader).fileName;
else throw "Missing name for shader script, please provide a scriptName, or use CustomShader";
this.shader = shader;
script = Script.create(Paths.script('shaders/$scriptName'));
script.setParent(shader);
script.set("shader", shader);
+6
View File
@@ -25,6 +25,7 @@ enum Control
CHANGE_MODE;
//CHEAT;
SWITCHMOD;
FPS_COUNTER;
// Debugs
DEV_ACCESS;
@@ -161,6 +162,11 @@ class Controls extends FlxActionSet
@:pressed("switchmod") public var SWITCHMOD_HOLD(get, set): Bool;
@:justReleased("switchmod") public var SWITCHMOD_R(get, set): Bool;
@:gamepad([])
@:justPressed("fps-counter") public var FPS_COUNTER(get, set): Bool;
@:pressed("fps-counter") public var FPS_COUNTER_HOLD(get, set): Bool;
@:justReleased("fps-counter") public var FPS_COUNTER_R(get, set): Bool;
@:devModeOnly
@:gamepad([])
@:justPressed("dev-access") public var DEV_ACCESS(get, set): Bool;
+41 -18
View File
@@ -13,16 +13,20 @@ import lime.utils.AssetType;
/**
* A class that reads the `flags.ini` file, allowing to read settable Flags (customs too).
*/
@:build(funkin.backend.system.macros.FlagMacro.build())
@:build(funkin.backend.system.macros.FlagMacro.build("onReset"))
class Flags {
public static var overridenFlags:Map<String, Bool> = [];
// -- Codename's Addon Config --
@:bypass public static var addonFlags:Map<String, Dynamic> = [];
public static var CURRENT_API_VERSION:Int = 2;
// -- Codename's Mod Config --
public static var MOD_NAME:String = "";
public static var MOD_DESCRIPTION:String = "";
public static var MOD_AUTHOR:String = "";
public static var MOD_API_VERSION:Int = 1;
@:lazy public static var MOD_API_VERSION:Null<Int> = null;
public static var MOD_DOWNLOAD_LINK:String = "";
public static var MOD_DEPENDENCIES:Array<String> = [];
@@ -41,12 +45,11 @@ class Flags {
@:lazy public static var SAVE_PATH:String = haxe.macro.Compiler.getDefine("SAVE_PATH");
@:lazy public static var SAVE_NAME:String = haxe.macro.Compiler.getDefine("SAVE_NAME");
public static var CURRENT_API_VERSION:Int = 1;
public static var COMMIT_NUMBER:Int = GitCommitMacro.commitNumber;
public static var COMMIT_HASH:String = GitCommitMacro.commitHash;
public static var COMMIT_MESSAGE:String = 'Commit $COMMIT_NUMBER ($COMMIT_HASH)';
@:bypass public static var WINDOW_TITLE_USE_MOD_NAME:Bool = false;
@:lazy public static var WINDOW_TITLE_USE_MOD_NAME:Null<Bool> = null;
@:lazy public static var TITLE:String = Application.current.meta.get('name');
@:lazy public static var VERSION:String = Application.current.meta.get('version');
@@ -125,12 +128,16 @@ class Flags {
@:also(funkin.game.PlayState.opponentMode)
public static var DEFAULT_OPPONENT_MODE:Bool = false;
public static var USE_LEGACY_TIMING:Null<Bool> = null;
public static var DEFAULT_NOTE_MS_LIMIT:Float = 1500;
public static var DEFAULT_NOTE_SCALE:Float = 0.7;
#if MODCHARTING_FEATURES
public static var DEFAULT_MODCHART_HOLD_SUBDIVISIONS:Int = 4;
#end
public static var SUSTAINS_AS_ONE_NOTE:Null<Bool> = null;
@:also(funkin.game.Character.FALLBACK_DEAD_CHARACTER)
public static var DEFAULT_GAMEOVER_CHARACTER:String = "bf-dead";
@@ -148,7 +155,9 @@ class Flags {
public static var DEFAULT_HUD_ZOOM_MULT:Float = 0.03;
public static var DEFAULT_CAM_ZOOM_LERP:Float = 0.05;
public static var DEFAULT_HUD_ZOOM_LERP:Float = 0.05;
public static var USE_LEGACY_ZOOM_FACTOR:Null<Bool> = null;
// Font configuration
public static var DEFAULT_FONT:String = "vcr.ttf";
public static var DEFAULT_FONT_SIZE:Int = 16;
@@ -277,8 +286,6 @@ class Flags {
@:bypass public static var customFlags:Map<String, String> = [];
public static function loadFromData(flags:Map<String, String>, data:String) {
WINDOW_TITLE_USE_MOD_NAME = false;
if (!(data.length > 0)) return;
var res = IniUtil.parseString(data);
@@ -295,26 +302,41 @@ class Flags {
else trace('Invalid section $name');
}
}
if (!flags.exists("WINDOW_TITLE_USE_MOD_NAME")) WINDOW_TITLE_USE_MOD_NAME = !flags.exists('TITLE') && flags.exists('MOD_NAME');
else WINDOW_TITLE_USE_MOD_NAME = parseBool(flags.get("WINDOW_TITLE_USE_MOD_NAME"));
flags.remove("WINDOW_TITLE_USE_MOD_NAME");
}
public static function loadFromDatas(datas:Array<String>) {
private static function loadPost() {
if (MOD_API_VERSION == null) MOD_API_VERSION = CURRENT_API_VERSION;
if (WINDOW_TITLE_USE_MOD_NAME == null) WINDOW_TITLE_USE_MOD_NAME = !overridenFlags.exists('TITLE') && overridenFlags.exists('MOD_NAME');
if (USE_LEGACY_TIMING == null) USE_LEGACY_TIMING = MOD_API_VERSION < 2;
if (USE_LEGACY_ZOOM_FACTOR == null) USE_LEGACY_ZOOM_FACTOR = MOD_API_VERSION < 2;
if (SUSTAINS_AS_ONE_NOTE == null) SUSTAINS_AS_ONE_NOTE = MOD_API_VERSION >= 2;
}
private static function onReset() {
var currentModFolder = ModsFolder.currentModFolder;
if (currentModFolder != null) SAVE_NAME = currentModFolder;
}
public static function loadFromDatas(datas:Array<String>):Map<String, String> {
var flags:Map<String, String> = [];
for(data in datas) {
if(data != null)
for (data in datas) {
if (data != null)
loadFromData(flags, data);
}
loadPost();
return flags;
}
public static function parseFlags(flags:Map<String, String>) {
for(name=>value in flags)
if(!parse(name, value))
customFlags.set(name, value);
var parsed:Bool;
for (name => value in flags) switch (name) {
case "MOD_API_VERSION":
var version = Std.parseInt(value) ?? CURRENT_API_VERSION;
if (version > MOD_API_VERSION || MOD_API_VERSION == null) MOD_API_VERSION = version;
default:
if (!(parsed = parse(name, value))) customFlags.set(name, value);
if (!overridenFlags.exists(name)) overridenFlags.set(name, parsed);
}
Options.modchartingHoldSubdivisions = DEFAULT_MODCHART_HOLD_SUBDIVISIONS;
}
@@ -365,5 +387,6 @@ class Flags {
parseFlags(flags);
}
}
loadPost();
}
}
+19 -27
View File
@@ -1,7 +1,5 @@
package funkin.backend.system;
import sys.io.File;
import sys.FileSystem;
import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond;
import flixel.addons.transition.FlxTransitionableState;
import flixel.addons.transition.TransitionData;
@@ -9,21 +7,22 @@ import flixel.graphics.FlxGraphic;
import flixel.math.FlxPoint;
import flixel.math.FlxRect;
import flixel.system.ui.FlxSoundTray;
import funkin.backend.assets.AssetSource;
import funkin.backend.assets.AssetsLibraryList;
import funkin.backend.assets.ModsFolder;
import funkin.backend.assets.AssetSource;
import funkin.backend.system.framerate.Framerate;
import funkin.backend.system.framerate.SystemInfo;
import funkin.backend.system.modules.*;
import funkin.backend.utils.ThreadUtil;
import funkin.editors.SaveWarning;
import funkin.options.PlayerSettings;
import openfl.Assets;
import openfl.Lib;
import openfl.display.Sprite;
import openfl.text.TextFormat;
import openfl.utils.AssetLibrary;
#if ALLOW_MULTITHREADING
import sys.thread.Thread;
#end
import sys.FileSystem;
import sys.io.File;
#if android
import android.content.Context;
import android.os.Build;
@@ -40,7 +39,7 @@ class Main extends Sprite
public static var scaleMode:FunkinRatioScaleMode;
#if !mobile
public static var framerateSprite:funkin.backend.system.framerate.Framerate;
public static var framerateSprite:Framerate;
#end
var gameWidth:Int = 1280; // Width of the game in pixels (might be less / more in actual pixels).
@@ -58,10 +57,6 @@ class Main extends Sprite
// You can pretty much ignore everything from here on - your code should go in your states.
#if ALLOW_MULTITHREADING
public static var gameThreads:Array<Thread> = [];
#end
public static function preInit() {
funkin.backend.utils.NativeAPI.registerAsDPICompatible();
funkin.backend.system.CommandLineHandler.parseCommandLine(Sys.args());
@@ -79,7 +74,7 @@ class Main extends Sprite
addChild(game = new FunkinGame(gameWidth, gameHeight, MainState, Options.framerate, Options.framerate, skipSplash, startFullscreen));
#if (!mobile && !web)
addChild(framerateSprite = new funkin.backend.system.framerate.Framerate());
addChild(framerateSprite = new Framerate());
SystemInfo.init();
#end
}
@@ -97,16 +92,8 @@ class Main extends Sprite
#end;
public static var startedFromSource:Bool = #if TEST_BUILD true #else false #end;
private static var __threadCycle:Int = 0;
public static function execAsync(func:Void->Void) {
#if ALLOW_MULTITHREADING
var thread = gameThreads[(__threadCycle++) % gameThreads.length];
thread.events.run(func);
#else
func();
#end
}
// DEPRECATED
@:dox(hide) public static function execAsync(func:Void->Void) ThreadUtil.execAsync(func);
private static function getTimer():Int {
return time = Lib.getTimer();
@@ -118,10 +105,6 @@ class Main extends Sprite
MemoryUtil.init();
@:privateAccess
FlxG.game.getTimer = getTimer;
#if ALLOW_MULTITHREADING
for(i in 0...4)
gameThreads.push(Thread.createWithEventLoop(function() {Thread.current().events.promise();}));
#end
FunkinCache.init();
Paths.assetsTree = new AssetsLibraryList();
@@ -156,6 +139,7 @@ class Main extends Sprite
FlxG.signals.focusGained.add(onFocus);
FlxG.signals.preStateSwitch.add(onStateSwitch);
FlxG.signals.postStateSwitch.add(onStateSwitchPost);
FlxG.signals.postUpdate.add(onUpdate);
FlxG.mouse.useSystemCursor = true;
#if DARK_MODE_WINDOW
@@ -210,6 +194,14 @@ class Main extends Sprite
scaleMode.resetSize();
}
public static function onUpdate() {
if (PlayerSettings.solo.controls.DEV_CONSOLE)
NativeAPI.allocConsole();
if (PlayerSettings.solo.controls.FPS_COUNTER)
Framerate.debugMode = (Framerate.debugMode + 1) % 3;
}
private static function onStateSwitchPost() {
// manual asset clearing since base openfl one does'nt clear lime one
// does'nt clear bitmaps since flixel fork does it auto
@@ -1,14 +0,0 @@
package funkin.backend.system;
import lime.app.Application;
import funkin.backend.system.Main;
class MainApplication extends Application {
public function new() {
super();
#if openfl
openfl.Lib.current.stage.addChild(new Main());
#end
}
}
@@ -8,12 +8,20 @@ import funkin.backend.assets.IModsAssetLibrary;
import funkin.backend.assets.ScriptedAssetLibrary;
class AssetTreeInfo extends FramerateCategory {
private var lastUpdateTime:Float = 1;
public function new() {
super("Asset Libraries Tree Info");
}
public override function __enterFrame(t:Int) {
if (alpha <= 0.05) return;
if ((lastUpdateTime += FlxG.rawElapsed) < 1)
return;
lastUpdateTime = 0;
var text = 'Not initialized yet\n';
if (Paths.assetsTree != null){
text = "";
@@ -53,13 +53,6 @@ class Framerate extends Sprite {
x = 10;
y = 2;
FlxG.stage.addEventListener(KeyboardEvent.KEY_UP, function(e:KeyboardEvent) {
switch(e.keyCode) {
case #if web Keyboard.NUMBER_3 #else Keyboard.F3 #end: // 3 on web or F3 on windows, linux and other things that runs code
debugMode = (debugMode + 1) % 3;
}
});
if (__bitmap == null)
__bitmap = new BitmapData(1, 1, 0xFF000000);
@@ -9,6 +9,13 @@ class FramerateCounter extends Sprite {
public var fpsLabel:TextField;
public var lastFPS:Float = 0;
private var frameCount:Int = 0;
private var accumulatedTime:Float = openfl.Lib.getTimer();
private final updateInterval:Float = 1 / 15;
private var lastUpdateTime:Float = 0;
public function new() {
super();
@@ -27,15 +34,40 @@ class FramerateCounter extends Sprite {
}
}
public function reload() {}
public function reload() {
lastUpdateTime = 0;
}
public override function __enterFrame(t:Int) {
if (alpha <= 0.05) return;
super.__enterFrame(t);
lastFPS = CoolUtil.fpsLerp(lastFPS, FlxG.rawElapsed == 0 ? 0 : (1 / FlxG.rawElapsed), 0.25);
fpsNum.text = Std.string(Math.floor(lastFPS));
frameCount++;
if ((lastUpdateTime += FlxG.rawElapsed) < updateInterval)
{
updateLabelPosition();
return;
}
final timer = openfl.Lib.getTimer();
final time = timer - accumulatedTime;
accumulatedTime = timer;
lastFPS = FlxMath.lerp(lastFPS, time <= 0 ? 0 : (1000 / time * frameCount), 1.0 - Math.pow(0.75, time * 0.06));
fpsNum.text = Std.string(Math.round(lastFPS));
lastUpdateTime = frameCount = 0;
updateLabelPosition();
}
private inline function updateLabelPosition():Void
{
fpsLabel.x = fpsNum.x + fpsNum.width;
fpsLabel.y = (fpsNum.y + fpsNum.height) - fpsLabel.height;
}
}
}
@@ -36,11 +36,21 @@ class MemoryCounter extends Sprite {
if (alpha <= 0.05) return;
super.__enterFrame(t);
memory = MemoryUtil.currentMemUsage();
final mem = MemoryUtil.currentMemUsage();
if (mem == memory) {
updateLabelPosition();
return;
}
memory = mem;
if (memoryPeak < memory) memoryPeak = memory;
memoryText.text = CoolUtil.getSizeString(memory);
memoryPeakText.text = ' / ${CoolUtil.getSizeString(memoryPeak)}';
memoryPeakText.x = memoryText.x + memoryText.width;
updateLabelPosition();
}
private inline function updateLabelPosition():Void
memoryPeakText.x = memoryText.x + memoryText.width;
}
@@ -115,8 +115,7 @@ class SystemInfo extends FramerateCategory {
if (vRAMBytes == 1000 || vRAMBytes == 1 || vRAMBytes <= 0)
Logs.trace('Unable to grab GPU VRAM', ERROR, RED);
else {
var vRAMBytesFloat:#if cpp Float64 #else Float #end = vRAMBytes*1024;
vRAM = CoolUtil.getSizeString64(vRAMBytesFloat);
vRAM = getSizeString(vRAMBytes / 1024);
}
}
} else
@@ -155,6 +154,17 @@ class SystemInfo extends FramerateCategory {
if (totalMem != "Unknown" && memType != "Unknown") __formattedSysText += '\nTotal MEM: $totalMem $memType';
}
static function getSizeString(size:Float):String {
if (size < 1024)
return Std.int(size) + " MB";
else if (size < 1024 * 1024)
return Std.int(size / 1024) + " GB";
else {
var tb = size / (1024 * 1024);
return Std.int(tb) + "." + CoolUtil.addZeros(Std.string(Std.int((tb % 1) * 100)), 2) + " TB";
}
}
public function new() {
super("System Info");
}
@@ -0,0 +1,68 @@
package funkin.backend.system.macros;
using StringTools;
#if macro
class BuildInfo {
public static function printBuildInfo() {
if(haxe.macro.Context.defined("display") || haxe.macro.Context.defined("display-details")) return;
var haxeVersion = haxe.macro.Context.definedValue("haxe").trim();
var sleepChangeVersion = false;
Sys.println('[ BUILD INFO ]');
Sys.println('Haxe Version: ${haxeVersion}');
try {
var lastBuiltWith:Null<String> = null;
var compiling = #if final "release" #elseif debug "debug" #else "release" #end;
var target = #if hl "hl"
#elseif html5 "html5"
#elseif ios "ios"
#elseif android "android"
#elseif windows "windows"
#elseif (mac || macos) "macos"
#elseif linux "linux"
#else ""
#end;
if(target == "") throw "Unknown target";
var exportPath = Sys.getCwd() + "/export/" + compiling + "/" + target + "/";
exportPath += "obj/Options.txt";
var options = sys.io.File.getContent(exportPath);
for(option in options.split("\n")) {
if(option.startsWith("haxe=")) {
lastBuiltWith = option.substr(5).trim();
break;
}
}
if(lastBuiltWith != null && lastBuiltWith.length > 0 && lastBuiltWith != haxeVersion) {
Sys.println('Last Built With Haxe: ${lastBuiltWith} [!!!! MAKE SURE IF YOU SWITCHED VERSIONS YOU DELETE EXPORT FOLDERS !!!!]');
sleepChangeVersion = true;
}
} catch(e) {}
var targetPlatform = #if html5 "Web (HTML5)"
#elseif ios "iOS"
#elseif android "Android"
#elseif windows "Windows"
#elseif (mac || macos) "Mac"
#elseif linux "Linux"
#else "Unknown"
#end;
if(haxe.macro.Context.defined("hl")) {
targetPlatform = "Hashlink (" + targetPlatform + ")";
}
Sys.println('Target Platform: ' + targetPlatform);
Sys.println('Build Date: ${Date.now().toString()}');
Sys.println('');
if(sleepChangeVersion) {
Sys.println('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
Sys.println('!!!! MAKE SURE IF YOU SWITCHED VERSIONS YOU DELETE EXPORT FOLDERS !!!!');
Sys.println('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
Sys.println('');
Sys.sleep(5);
}
}
}
#end
@@ -19,7 +19,7 @@ class FlagMacro {
return false;
}
public static function build():Array<Field> {
public static function build(resetCallback:String):Array<Field> {
var fields = Context.getBuildFields();
var clRef = Context.getLocalClass();
@@ -248,7 +248,10 @@ class FlagMacro {
access: [APublic, AStatic],
kind: FFun({
args: [],
expr: macro $b{resetExprs},
expr: macro {
$b{resetExprs};
$i{resetCallback}();
},
ret: macro: Void
}),
pos: Context.currentPos(),
@@ -58,6 +58,11 @@ class Macros {
final macroPath = 'funkin.backend.system.macros.Macros';
Compiler.addMetadata('@:build($macroPath.buildLimeAssetLibrary())', 'lime.utils.AssetLibrary');
//Adds Compat for #if hscript blocks when you have hscript improved
if (Context.defined("hscript_improved") && !Context.defined("hscript")) {
Compiler.define('hscript');
}
}
public static function buildLimeAssetLibrary():Array<Field> {
@@ -2,22 +2,30 @@ package funkin.backend.system.updating;
import funkin.backend.system.github.GitHub;
import funkin.backend.system.github.GitHubRelease;
#if ALLOW_MULTITHREADING
import funkin.backend.utils.ThreadUtil;
#end
import lime.app.Application;
import sys.thread.Mutex;
import sys.thread.Thread;
import sys.FileSystem;
import haxe.io.Path;
#if (target.threaded)
import sys.thread.Thread;
import sys.thread.Mutex;
#end
using funkin.backend.system.github.GitHub;
class UpdateUtil {
public static var lastUpdateCheck:Null<UpdateCheckCallback>;
#if (target.threaded)
private static var __waitCallbacks:Array<UpdateCheckCallback->Void>;
private static var __mutex:Mutex;
#end
public static function init() {
// deletes old bak file if it exists
@@ -26,26 +34,34 @@ class UpdateUtil {
if (FileSystem.exists(bakPath)) FileSystem.deleteFile(bakPath);
#end
#if (target.threaded)
__waitCallbacks = [];
__mutex = new Mutex();
Thread.create(checkForUpdates.bind(true, false));
#if ALLOW_MULTITHREADING ThreadUtil.execAsync #else Thread.create #end(checkForUpdates.bind(true, false));
#end
}
public static function waitForUpdates(force = false, callback:UpdateCheckCallback->Void, lazy = false) {
#if (target.threaded)
if (__mutex.tryAcquire()) {
__mutex.release();
if (__shouldCheck(lazy) || force) {
__waitCallbacks.push(callback);
Thread.create(checkForUpdates.bind(force, false));
#if ALLOW_MULTITHREADING ThreadUtil.execAsync #else Thread.create #end(checkForUpdates.bind(force, false));
}
else
callback(lastUpdateCheck);
}
else
__waitCallbacks.push(callback);
#else
callback(checkForUpdates(true, false));
#end
}
public static function checkForUpdates(force = false, lazy = false):UpdateCheckCallback {
#if (target.threaded)
var wasAcquired = !__mutex.tryAcquire();
if (wasAcquired) __mutex.acquire();
@@ -60,8 +76,19 @@ class UpdateUtil {
FlxG.signals.preUpdate.addOnce(__callWaitCallbacks);
return lastUpdateCheck;
#else
if (!__shouldCheck(lazy)) return lastUpdateCheck;
return lastUpdateCheck = __checkForUpdates();
#end
}
#if (target.threaded)
static function __callWaitCallbacks() {
for (callback in __waitCallbacks) callback(lastUpdateCheck);
__waitCallbacks.resize(0);
}
#end
static function __checkForUpdates():UpdateCheckCallback {
var curTag = 'v' + (Flags.VERSION == null ? Application.current.meta.get('version') : Flags.VERSION), error = false;
var newUpdates = __doReleaseFiltering(GitHub.getReleases(Flags.REPO_OWNER, Flags.REPO_NAME, (e) -> {
@@ -82,11 +109,6 @@ class UpdateUtil {
static function __shouldCheck(lazy:Bool):Bool
return lastUpdateCheck == null || !lazy && (!lastUpdateCheck.newUpdate || Date.now().getTime() - lastUpdateCheck.date.getTime() > 1800000);
static function __callWaitCallbacks() {
for (callback in __waitCallbacks) callback(lastUpdateCheck);
__waitCallbacks.resize(0);
}
static function __doReleaseFiltering(releases:Array<GitHubRelease>, currentVersionTag:String) {
releases = releases.filterReleases(Options.betaUpdates, false);
if (releases.length <= 0)
+20 -20
View File
@@ -20,8 +20,7 @@ typedef AudioAnalyzerCallback = Int->Int->Void;
* An utility that analyze FlxSounds,
* can be used to make waveform or real-time audio visualizer.
*
* FlxSound.amplitude does work in CNE so if any case if your only checking for peak of current
* time, use that instead.
* FlxSound.amplitude works so if any case if your only checking for peak of current time, use that instead.
*/
final class AudioAnalyzer {
/**
@@ -96,9 +95,9 @@ final class AudioAnalyzer {
static var __twiddleImags:Array<Array<Float>> = [];
static var __freqReals:Array<Array<Float>> = [];
static var __freqImags:Array<Array<Float>> = [];
static var __freqCalculating:Int = 0;
#if (target.threaded)
static var __mutex:Mutex = new Mutex();
static var __freqCalculating:Int = 0;
#end
/**
@@ -296,7 +295,7 @@ final class AudioAnalyzer {
__check();
}
function __check() if (sound.buffer != buffer) {
function __check() if (sound != null && sound.buffer != buffer) {
byteSize = 1 << ((buffer = sound.buffer).bitsPerSample - 1);
#if (lime_cffi && lime_vorbis)
@@ -324,7 +323,7 @@ final class AudioAnalyzer {
* @param maxFreq The maximum frequency to cap (Optional, default 22000.0, Above 23000.0 is not recommended).
* @return Output of levels/bars that ranges from 0 to 1.
*/
public function getLevels(startPos:Float, ?volume:Float, barCount:Int, ?levels:Array<Float>, ?ratio:Float, ?minDb:Float, ?maxDb:Float, ?minFreq:Float, ?maxFreq:Float):Array<Float>
public function getLevels(?startPos:Float, ?volume:Float, barCount:Int, ?levels:Array<Float>, ?ratio:Float, ?minDb:Float, ?maxDb:Float, ?minFreq:Float, ?maxFreq:Float):Array<Float>
return inline getLevelsFromFrequencies(__frequencies = getFrequencies(startPos, volume, __frequencies), buffer.sampleRate, barCount, levels, ratio, minDb, maxDb, minFreq, maxFreq);
/**
@@ -334,8 +333,8 @@ final class AudioAnalyzer {
* @param frequencies The output for getting the frequencies, to avoid memory leaks (Optional).
* @return Output of frequencies.
*/
public function getFrequencies(startPos:Float, ?volume:Float, ?frequencies:Array<Float>):Array<Float>
return inline getFrequenciesFromSamples(__freqSamples = getSamples(startPos, fftN, true, -1, volume, __freqSamples), fftN, useWindowingFFT, frequencies);
public function getFrequencies(?startPos:Float, ?volume:Float, ?frequencies:Array<Float>):Array<Float>
return inline getFrequenciesFromSamples(__freqSamples = getSamples(startPos != null ? startPos : sound.time, fftN, true, -1, volume, __freqSamples), fftN, useWindowingFFT, frequencies);
/**
* Analyzes an attached FlxSound from startPos to endPos in milliseconds to get the amplitudes.
@@ -467,36 +466,37 @@ final class AudioAnalyzer {
@:privateAccess return sound._source != null && sound._source.__backend != null && sound._source.__backend.playing;
inline function __readStream(startPos:Float, endPos:Float, callback:AudioAnalyzerCallback):Float @:privateAccess {
var backend = sound._source.__backend;
var i = backend.bufferSizes.length - backend.queuedBuffers;
var time = backend.bufferTimes[i] * 1000;
final backend = sound._source.__backend;
// TODO: Wrap it with try until i figured it out an effective way to do this...
// So... sometimes it just uses the decoder even if it looks good?? please help
var n = Math.floor((endPos - startPos) * __toBits);
if (startPos >= time && startPos < backend.bufferTimes[backend.bufferSizes.length - 1] * 1000) {
var pos = Math.floor((startPos - time) * __toBits), buf = backend.bufferDatas[i].buffer, size = backend.bufferSizes[i], c = 0;
var i = backend.bufferLengths.length - backend.requestBuffers - 1, time:Float;
while (++i < backend.bufferLengths.length) if (startPos >= (time = backend.bufferTimes[i] * 1000)) {
var pos = Math.floor((startPos - time) * __toBits), buf = backend.bufferDatas[i].buffer, size = backend.bufferLengths[i], c = 0;
while (pos >= size) {
if (++i >= backend.bufferSizes.length) {
n = 0;
break;
}
if (++i >= backend.bufferLengths.length) break;
pos -= size;
buf = backend.bufferDatas[i].buffer;
size = backend.bufferSizes[i];
size = backend.bufferLengths[i];
}
pos -= pos % __sampleSize;
if (i >= backend.bufferLengths.length) break;
if ((pos -= pos % __sampleSize) < 0) pos = 0;
n -= pos % __sampleSize;
while (n > 0) {
callback(getByte(buf, pos, __wordSize), c);
if (++c > buffer.channels) c = 0;
if ((pos += __wordSize) >= size) {
if (++i >= backend.bufferSizes.length) break;
if (++i >= backend.bufferLengths.length) break;
pos = 0;
buf = backend.bufferDatas[i].buffer;
size = backend.bufferSizes[i];
size = backend.bufferLengths[i];
}
n -= __wordSize;
}
break;
}
return endPos - (n / __toBits);
+1 -1
View File
@@ -1495,4 +1495,4 @@ enum abstract CoolSfx(Int) from Int {
var CHECKED = 3;
var UNCHECKED = 4;
var WARNING = 5;
}
}
+1 -1
View File
@@ -541,4 +541,4 @@ typedef DEvents =
var ?joinGame:String->Void;
var ?spectateGame:String->Void;
var ?joinRequest:DUser->Void;
}
}
@@ -38,7 +38,7 @@ class FunkinParentDisabler extends FlxBasic {
for(c in __cameras) c.paused = true;
// sounds
__sounds = [for(s in FlxG.sound.list) if (s.playing) s];
__sounds = [for(s in FlxG.sound.list) if (s.playing && !s.persist) s];
for(s in __sounds) s.pause();
}
}
@@ -71,4 +71,4 @@ class FunkinParentDisabler extends FlxBasic {
for(s in __sounds) s.play();
}
}
}
}
+84 -19
View File
@@ -1,32 +1,97 @@
package funkin.backend.utils;
#if ALLOW_MULTITHREADING
#if (target.threaded)
import sys.thread.Deque;
import sys.thread.Thread;
import sys.thread.Mutex;
#else
private typedef Thread = Dynamic;
#end
#if !macro
import funkin.backend.system.Logs;
#end
final class ThreadUtil {
inline static function error(text:String) {
#if macro
trace(text);
#else
FlxG.signals.preUpdate.addOnce(Logs.error.bind(text));
#end
}
/**
* Creates a new Thread with an error handler.
* @param func Function to execute
* @param autoRestart Whenever the thread should auto restart itself after crashing.
*/
public static function createSafe(func:Void->Void, autoRestart:Bool = false) {
if (autoRestart) {
return sys.thread.Thread.create(function() {
while(true) {
try {
func();
} catch(e) {
trace(e.details());
}
}
});
} else {
return sys.thread.Thread.create(function() {
try {
public static function createSafe(func:Void->Void, autoRestart:Bool = false):Thread {
#if (target.threaded)
try {
return if (autoRestart) Thread.create(() -> {
var restart = true;
while (restart) try {
func();
} catch(e) {
trace(e.details());
restart = false;
}
catch (e) error(e.details());
})
else Thread.create(() -> {
try {func();}
catch (e) error(e.details());
});
}
catch (e) error("Failed to safely create a thread: " + e.details());
#end
return null;
}
}
#end
#if ALLOW_MULTITHREADING
public static var maxThreads:Int = 4;
static var __threads:Array<Thread> = [];
static var __pendingExecs:Deque<Void->Void> = new Deque();
static var __threadMutex:Mutex = new Mutex();
static var __threadUsed:Int = 0;
static function __threadExecAsync() {
var callback:Void->Void;
while ((callback = __pendingExecs.pop(true)) != null) {
__threadMutex.acquire();
__threadUsed++;
__threadMutex.release();
callback();
__threadMutex.acquire();
__threadUsed--;
__threadMutex.release();
}
__threadMutex.acquire();
__threads.remove(Thread.current());
__threadMutex.release();
}
#end
public static function execAsync(func:Void->Void) {
if (func == null) return;
#if (ALLOW_MULTITHREADING && !macro)
__pendingExecs.add(func);
if (__threadUsed >= __threads.length) {
if (__threads.length == maxThreads) return;
__threadMutex.acquire();
try {
var thread = Thread.create(__threadExecAsync);
__threads.push(thread);
}
catch (e) Logs.warn(e.details());
__threadMutex.release();
}
#else
func();
#end
}
}
@@ -204,6 +204,9 @@ final class Windows {
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
SetConsoleOutputCP(65001);
SetConsoleCP(65001);
')
public static function allocConsole() {
}
+2 -1
View File
@@ -41,7 +41,8 @@ class Week {
weekObj.songs.push({
name: name,
hide: song.getAtt('hide').getDefault('false') == "true",
displayName: song.getAtt('displayName')
displayName: song.getAtt('displayName'),
variation: song.getAtt('variation')
});
} catch(e) {
Logs.trace('Song at index ${k} in week $weekName cannot contain any other XML nodes in its name.', WARNING);
+2 -2
View File
@@ -9,7 +9,7 @@ class ModConfigWarning extends UIState {
var library:ModsFolderLibrary = null;
var goToState:Class<FlxState>;
public static inline var defaultModConfigText =
public static var defaultModConfigText =
'[Common] # This section applies the \'MOD_\' prefix to the flags so you don\'t have to.
NAME="YOUR MOD NAME HERE"
DESCRIPTION="YOUR MOD DESCRIPTION HERE"
@@ -17,7 +17,7 @@ AUTHOR="YOU/YOUR TEAM HERE"
VERSION="YOUR MOD\'S VERSION HERE"
# DO NOT EDIT!! this is used to check for version compatibility!
API_VERSION=1
API_VERSION=${Flags.CURRENT_API_VERSION}
DOWNLOAD_LINK="YOUR MOD PAGE LINK HERE"
@@ -104,6 +104,7 @@ class CharacterAnimsWindow extends UIButtonList<CharacterAnimButton> {
if (character.getAnimName() == button.anim)
@:privateAccess CharacterEditor.instance._animation_down(null);
character.ghosts.remove(button.anim);
character.removeAnimation(button.anim);
if (character.animOffsets.exists(button.anim)) character.animOffsets.remove(button.anim);
if (character.animDatas.exists(button.anim)) character.animDatas.remove(button.anim);
@@ -37,7 +37,7 @@ class CharacterGhost extends Character {
alpha = 0.4; color = 0xFFAEAEAE;
var flxanim:FlxAnimation = animation._animations.get(anim);
var frameIndex:Int = flxanim.frames.getDefault([0])[0];
var frameIndex:Int = flxanim.frames.getDefault([0])[flxanim.frames.length - 1];
frame = frames.frames[frameIndex];
setAnimOffset(anim);
+4 -3
View File
@@ -80,6 +80,7 @@ class Charter extends UIState {
public var metronome:FlxSound;
public var vocals:FlxSound;
public var voicesMuted:Bool = false;
public var quant:Int = 16;
public var quants:Array<Int> = [4, 8, 12, 16, 20, 24, 32, 48, 64, 192]; // different quants
@@ -1812,9 +1813,9 @@ class Charter extends UIState {
t.icon = 1 - Std.int(Math.ceil(FlxG.sound.music.volume));
}
function _song_mutevoices(t) {
vocals.volume = vocals.volume > 0 ? 0 : 1;
for (strumLine in strumLines.members) strumLine.vocals.volume = strumLine.vocals.volume > 0 ? 0 : 1;
t.icon = 1 - Std.int(Math.ceil(vocals.volume));
vocals.volume = (voicesMuted = !voicesMuted) ? 0 : 1;
for (strumLine in strumLines.members) strumLine.updateVoicesVolume();
t.icon = voicesMuted ? 1 : 0;
}
function _playback_back(_) {
if (FlxG.sound.music.playing) return;
+42 -5
View File
@@ -82,7 +82,7 @@ class CharterEvent extends UISliceSprite implements ICharterSelectable {
}
/**
* Pack data is a list of 4 strings separated by `________PACKSEP________`
* Pack data is a list of 5 strings separated by `________PACKSEP________`
* [0] Event Name
* [1] Event Script
* [2] Event JSON Info
@@ -276,10 +276,47 @@ class CharterEvent extends UISliceSprite implements ICharterSelectable {
}
case "Camera Movement":
// camera movement, use health icon
if(event.params != null) {
var icon = getIconFromStrumline(event.params[0]);
if(icon != null) return icon;
var shouldDoArrow:Bool = false;
var icon:Null<FlxSprite> = null;
if (event.params != null) {
shouldDoArrow = event.params[1] && event.params[3] != "CLASSIC"; // is Tweened and isnt Lerped
icon = getIconFromStrumline(event.params[0]); // camera movement, use health icon
}
if (icon == null) icon = generateDefaultIcon(event.name);
if(event.params != null && shouldDoArrow && !inMenu) {
var group = new EventIconGroup();
group.add(icon);
group.members[0].x -= 8;
group.members[0].y -= 8;
generateEventIconDurationArrow(group, event.params[2]);
return group;
} else
return icon;
case "Camera Position":
var shouldDoArrow:Bool = false;
if (event.params != null)
shouldDoArrow = event.params[2] && event.params[4] != "CLASSIC"; // is Tweened and isnt Lerped
if(event.params != null && shouldDoArrow && !inMenu) {
var group = new EventIconGroup();
group.add(generateDefaultIcon(event.name));
generateEventIconDurationArrow(group, event.params[3]);
return group;
}
case "Camera Zoom":
var shouldDoArrow:Bool = false;
if (event.params != null)
shouldDoArrow = event.params[0];
if(event.params != null && shouldDoArrow && !inMenu) {
var group = new EventIconGroup();
group.add(generateDefaultIcon(event.name));
generateEventIconDurationArrow(group, event.params[3]);
return group;
}
}
return generateDefaultIcon(event.name);
@@ -17,7 +17,7 @@ class CharterEventGroup extends FlxTypedGroup<CharterEvent> {
if (autoSort && members.length != __lastSort)
sortEvents();
eventsRowText.y = FlxMath.lerp(eventsRowText.y, -40 + (members[0] != null ? Math.min(members[0].y, 0) : 0), 1/20);
eventsRowText.y = FlxMath.lerp(eventsRowText.y, -40 + (members[0] != null ? Math.min(members[0].y, 0) : 0), 1/10);
}
public override function remove(v:CharterEvent, force:Bool = true):CharterEvent {
@@ -1,5 +1,6 @@
package funkin.editors.charter;
import funkin.game.HealthIcon;
import flixel.math.FlxPoint;
import funkin.backend.chart.ChartData.ChartMetaData;
import funkin.editors.extra.PropertyButton;
@@ -21,8 +22,7 @@ class CharterMetaDataScreen extends UISubstateWindow {
public var displayNameTextBox:UITextBox;
public var iconTextBox:UITextBox;
public var iconSprite:HealthIcon;
public var opponentModeCheckbox:UICheckbox;
public var coopAllowedCheckbox:UICheckbox;
public var excludedGameModesList:UIAutoCompleteButtonList;
public var needsVoicesCheckbox:UICheckbox;
public var colorWheel:UIColorwheel;
public var difficultiesTextBox:UITextBox;
@@ -78,25 +78,29 @@ class CharterMetaDataScreen extends UISubstateWindow {
add(displayNameTextBox);
addLabelOn(displayNameTextBox, translate("displayName"));
add(iconSprite = new HealthIcon(metadata.icon));
iconSprite.scale.set(0.5, 0.5);
iconSprite.updateHitbox();
iconTextBox = new UITextBox(displayNameTextBox.x + 320 + 26, displayNameTextBox.y, metadata.icon, 150);
iconTextBox.onChange = (newIcon:String) -> {updateIcon(newIcon);}
iconTextBox.onChange = (newIcon:String) -> iconSprite.setIcon(newIcon);
add(iconTextBox);
addLabelOn(iconTextBox, translate("icon"));
updateIcon(metadata.icon);
opponentModeCheckbox = new UICheckbox(displayNameTextBox.x, iconTextBox.y + 10 + 32 + 26, translate("opponentMode"), metadata.opponentModeAllowed);
add(opponentModeCheckbox);
addLabelOn(opponentModeCheckbox, translate("modesAllowed"));
coopAllowedCheckbox = new UICheckbox(opponentModeCheckbox.x + 150 + 26, opponentModeCheckbox.y, translate("coopAllowed"), metadata.coopAllowed);
add(coopAllowedCheckbox);
add(excludedGameModesList = new UIAutoCompleteButtonList(displayNameTextBox.x, iconTextBox.y + 62, Std.int(displayNameTextBox.bWidth), 100, "", [for (mode in funkin.menus.FreeplayState.FreeplayGameMode.get()) mode.modeID]));
excludedGameModesList.frames = Paths.getFrames('editors/ui/inputbox');
excludedGameModesList.cameraSpacing = 0;
addLabelOn(excludedGameModesList, "Excluded Game Modes (IDs)");
for (mode in metadata.excludedGameModes)
excludedGameModesList.add(new UIAutoCompleteButtonList.UIAutoCompleteButton(0, 0, excludedGameModesList, excludedGameModesList.suggestItems, mode));
colorWheel = new UIColorwheel(iconTextBox.x, coopAllowedCheckbox.y, metadata.color);
add(colorWheel);
addLabelOn(colorWheel, translate("color"));
difficultiesTextBox = new UITextBox(opponentModeCheckbox.x, opponentModeCheckbox.y + 6 + 32 + 26, metadata.difficulties.join(", "));
difficultiesTextBox = new UITextBox(excludedGameModesList.x, excludedGameModesList.y + excludedGameModesList.bHeight + 32, metadata.difficulties.join(", "));
add(difficultiesTextBox);
addLabelOn(difficultiesTextBox, translate("difficulties"));
@@ -111,9 +115,6 @@ class CharterMetaDataScreen extends UISubstateWindow {
add(customPropertiesButtonList);
addLabelOn(customPropertiesButtonList, translate("customValues"));
for (checkbox in [opponentModeCheckbox, coopAllowedCheckbox])
{checkbox.y += 6; checkbox.x += 4;}
saveButton = new UIButton(windowSpr.x + windowSpr.bWidth - 20, windowSpr.y + windowSpr.bHeight - 20, TU.translate("editor.saveClose"), function() {
saveMeta();
close();
@@ -161,8 +162,7 @@ class CharterMetaDataScreen extends UISubstateWindow {
meta.displayName = displayNameTextBox.label.text;
meta.icon = iconTextBox.label.text;
meta.color = colorWheel.curColor;
meta.opponentModeAllowed = opponentModeCheckbox.checked;
meta.coopAllowed = coopAllowedCheckbox.checked;
meta.excludedGameModes = [for (button in excludedGameModesList.buttons.members) button.textBox.label.text.trim()],
meta.difficulties = [for (diff in difficultiesTextBox.label.text.split(",")) diff.trim()];
meta.customValues = customVals;
@@ -40,7 +40,7 @@ class CharterSelectionScreen extends EditorTreeMenuScreen {
var screen = new EditorTreeMenuScreen((first || !isVariant) ? (s.name + (isVariant ? ' (${s.variant})' : '')) : s.variant, getID('selectDifficulty'));
for (d in s.difficulties) if (d != '') screen.add(makeChartOption(d, isVariant ? s.variant : null, s.name));
screen.add(new Separator());
if (s.difficulties.length > 0 && s.variants.length > 0) screen.add(new Separator()); // Create a separator only when there are both difficulty and variant options available.
for (v in s.variants) if (s.metas.get(v) != null) screen.add(makeVariationOption(s.metas.get(v)));
#if sys
@@ -48,13 +48,13 @@ class CharterSelectionScreen extends EditorTreeMenuScreen {
parent.openSubState(new ChartCreationScreen(saveChart));
}));
if (!first) screen.curSelected = 1;
if (!first) screen.curSelected = (s.difficulties.length + s.variants.length) > 0 ? 1 : 0;
else {
cast(screen.members[0], NewOption).itemHeight = 120;
screen.insert(1, new NewOption(getID('newVariation'), getID('newVariationDesc'), () -> {
parent.openSubState(new VariationCreationScreen(s, saveSong));
}));
screen.curSelected = 2;
screen.curSelected = (s.difficulties.length + s.variants.length) > 0 ? 2 : 1;
}
#end
@@ -22,6 +22,7 @@ class CharterStrumline extends UISprite {
public var curMenu:UIContextMenu = null;
public var vocals:FlxSound;
public var voicesMuted:Bool = false;
public var keyCount:Int = 4;
public var startingID(get, null):Int;
@@ -147,6 +148,10 @@ class CharterStrumline extends UISprite {
}
vocals.group = FlxG.sound.defaultMusicGroup;
}
public function updateVoicesVolume() {
vocals.volume = (voicesMuted || (Charter.instance?.voicesMuted ?? false)) ? 0 : 1;
}
}
class CharterStrumlineOptions extends UITopMenuButton {
@@ -176,9 +181,10 @@ class CharterStrumlineOptions extends UITopMenuButton {
{
label: TU.translate("charter.strumLine.muteVocals"),
onSelect: function(_) {
strLine.vocals.volume = strLine.vocals.volume > 0 ? 0 : 1;
strLine.voicesMuted = !strLine.voicesMuted;
strLine.updateVoicesVolume();
},
icon: strLine.vocals.volume > 0 ? 0 : 1
icon: strLine.voicesMuted ? 1 : 0
},
null,
{
@@ -287,4 +287,4 @@ class CharacterButton extends UIButton {
super.update(elapsed);
}
}
}
@@ -1,5 +1,6 @@
package funkin.editors.charter;
import funkin.game.HealthIcon;
import flixel.group.FlxGroup;
import flixel.text.FlxText.FlxTextFormat;
import flixel.text.FlxText.FlxTextFormatMarkerPair;
@@ -37,8 +38,7 @@ class SongCreationScreen extends UISubstateWindow {
public var displayNameTextBox:UITextBox;
public var iconTextBox:UITextBox;
public var iconSprite:HealthIcon;
public var opponentModeCheckbox:UICheckbox;
public var coopAllowedCheckbox:UICheckbox;
public var excludedGameModesList:UIAutoCompleteButtonList;
public var colorWheel:UIColorwheel;
public var difficultiesTextBox:UITextBox;
@@ -166,24 +166,19 @@ class SongCreationScreen extends UISubstateWindow {
updateIcon("face");
opponentModeCheckbox = new UICheckbox(displayNameTextBox.x, iconTextBox.y + 10 + 32 + 26, translateMeta("opponentMode"), true);
menuDataGroup.add(opponentModeCheckbox);
addLabelOn(opponentModeCheckbox, translateMeta("modesAllowed"));
menuDataGroup.add(excludedGameModesList = new UIAutoCompleteButtonList(displayNameTextBox.x, iconTextBox.y + 62, Std.int(displayNameTextBox.bWidth), 100, "", [for (mode in funkin.menus.FreeplayState.FreeplayGameMode.get()) mode.modeID]));
excludedGameModesList.frames = Paths.getFrames('editors/ui/inputbox');
excludedGameModesList.cameraSpacing = 0;
addLabelOn(excludedGameModesList, "Excluded Game Modes (IDs)");
coopAllowedCheckbox = new UICheckbox(opponentModeCheckbox.x + 150 + 26, opponentModeCheckbox.y, translateMeta("coopAllowed"), true);
menuDataGroup.add(coopAllowedCheckbox);
colorWheel = new UIColorwheel(iconTextBox.x, coopAllowedCheckbox.y, 0xFFFFFF);
colorWheel = new UIColorwheel(iconTextBox.x, excludedGameModesList.y, 0xFFFFFF);
menuDataGroup.add(colorWheel);
addLabelOn(colorWheel, translateMeta("color"));
difficultiesTextBox = new UITextBox(opponentModeCheckbox.x, opponentModeCheckbox.y + 6 + 32 + 26, "");
difficultiesTextBox = new UITextBox(excludedGameModesList.x, excludedGameModesList.y + excludedGameModesList.bHeight + 32, "");
menuDataGroup.add(difficultiesTextBox);
addLabelOn(difficultiesTextBox, translateMeta("difficulties"));
for (checkbox in [opponentModeCheckbox, coopAllowedCheckbox])
{checkbox.y += 6; checkbox.x += 4;}
var menuTitle:UIText;
selectFormatGroup.add(menuTitle = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, translate("importSource"), 28));
@@ -433,9 +428,8 @@ class SongCreationScreen extends UISubstateWindow {
displayName: displayNameTextBox.label.text,
icon: iconTextBox.label.text,
color: colorWheel.curColor,
opponentModeAllowed: opponentModeCheckbox.checked,
coopAllowed: coopAllowedCheckbox.checked,
difficulties: [for (diff in difficultiesTextBox.label.text.split(",")) diff.trim()]
excludedGameModes: [for (button in excludedGameModesList.buttons.members) button.textBox.label.text.trim()],
difficulties: [for (diff in difficultiesTextBox.label.text.split(",")) if (diff.length > 0) diff.trim()]
});
if (onSave != null) onSave({
@@ -0,0 +1,50 @@
package funkin.editors.ui;
typedef UIAutoCompleteButtonList = UITypedAutoCompleteButtonList<UIAutoCompleteButton>;
class UITypedAutoCompleteButtonList<T:UIAutoCompleteButton> extends UIButtonList<T> {
public var suggestItems(default, set):Array<String> = [];
private function set_suggestItems(value:Array<String>) {
buttons.forEachAlive((button) -> button.textBox.suggestItems = value);
return suggestItems = value;
}
public function new(x:Float, y:Float, width:Int, height:Int, windowName:String, ?suggestItems:Array<String>, ?buttonSize:FlxPoint, ?buttonOffset:FlxPoint, buttonSpacing:Float = 0) {
super(x, y, width, height, windowName, buttonSize == null ? FlxPoint.get(width, width * 0.15) : buttonSize, buttonOffset, buttonSpacing);
if (suggestItems != null && suggestItems.length > 0) this.suggestItems = suggestItems;
addButton.callback = () -> add(cast new UIAutoCompleteButton(0, 0, cast this, this.suggestItems));
}
}
class UIAutoCompleteButton extends UIButton {
public var textBox:UIAutoCompleteTextBox;
public var deleteButton:UIButton;
public var deleteIcon:FlxSprite;
public function new (x:Float, y:Float, parent:UIAutoCompleteButtonList, ?suggestItems:Array<String>, text:String = "", ?w:Int, ?h:Int, multiline:Bool = false) {
super(x, y, "", null, w == null ? Std.int(parent.buttonSize.x) : w, h == null ? Std.int(parent.buttonSize.y) : h);
members.push(textBox = new UIAutoCompleteTextBox(16, bHeight/2 - (32/2), text, Std.int(bWidth - 32 - 36), 32, multiline));
if (suggestItems != null && suggestItems.length > 0) textBox.suggestItems = suggestItems;
textBox.antialiasing = false;
members.push(deleteButton = new UIButton(textBox.x + textBox.bWidth + 10, textBox.y, "", () -> { parent.remove(this); destroy(); }, 32));
deleteButton.color = 0xFFFF0000;
deleteButton.autoAlpha = false;
members.push(deleteIcon = new FlxSprite(deleteButton.x + (15/2), deleteButton.y + 8).loadGraphic(Paths.image('editors/delete-button')));
deleteIcon.antialiasing = false;
}
override function update(elapsed) {
deleteButton.y = y + bHeight / 2 - deleteButton.bHeight / 2;
textBox.y = y + bHeight/2 - 16;
deleteIcon.x = deleteButton.x + (15/2); deleteIcon.y = deleteButton.y + 8;
textBox.selectable = deleteButton.selectable = selectable;
deleteButton.shouldPress = shouldPress;
super.update(elapsed);
}
}
+13 -5
View File
@@ -108,11 +108,19 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
}
public function swapLeftRightAnimations() {
CoolUtil.switchAnimFrames(animation.getByName('singRIGHT'), animation.getByName('singLEFT'));
CoolUtil.switchAnimFrames(animation.getByName('singRIGHTmiss'), animation.getByName('singLEFTmiss'));
// Find all "alternate" poses
var variants = ['']; // Pre-fill with empty string
var pose = 'singRIGHT'; // Any "sing" animation string could work, really
for (a in xml.nodes.anim) {
if (a.att.name != pose && StringTools.startsWith(a.att.name, pose)) {
variants.push(a.att.name.substring(pose.length));
}
}
switchOffset('singLEFT', 'singRIGHT');
switchOffset('singLEFTmiss', 'singRIGHTmiss');
for (i in variants) {
CoolUtil.switchAnimFrames(animation.getByName('singRIGHT$i'), animation.getByName('singLEFT$i'));
switchOffset('singLEFT$i', 'singRIGHT$i');
}
__swappedLeftRightAnims = true;
}
@@ -580,4 +588,4 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
list.push(CoolUtil.getFilename(path));
return list;
}
}
}
+15 -2
View File
@@ -60,6 +60,15 @@ class Note extends FlxSprite
*/
public var sustainParent:Null<Note>;
/**
* Number of active sustain pieces attached to this note
*
* Increases by 1 every time a hold piece is initialized.
*
* Decreases by 1 every time a hold piece gets destroyed.
*/
public var tailCount:Int = 0;
/**
* Name of the splash.
*/
@@ -74,6 +83,7 @@ class Note extends FlxSprite
public var sustainLength:Float = 0;
public var isSustainNote:Bool = false;
public var noSustainClip:Bool = false;
public var flipSustain:Bool = true;
public var noteTypeID:Int = 0;
@@ -104,6 +114,8 @@ class Note extends FlxSprite
public var animSuffix:String = null;
// Deprecated?
@:dox(hide) public var tripTimer:Float = 0; // ranges from 0 to 1
private static function customTypePathExists(path:String) {
if (__customNoteTypeExists.exists(path))
@@ -211,6 +223,7 @@ class Note extends FlxSprite
public var lastScrollSpeed:Null<Float> = null;
public var gapFix:SingleOrFloat = 0;
public var useAntialiasingFix(get, set):Bool;
inline function set_useAntialiasingFix(v:Bool) {
if(v != useAntialiasingFix) {
gapFix = v ? 1 : 0;
@@ -297,8 +310,8 @@ class Note extends FlxSprite
updateSustainClip();
}
public function updateSustainClip() if (wasGoodHit) {
var t = FlxMath.bound((Conductor.songPosition - strumTime) / height * 0.45 * lastScrollSpeed, 0, 1);
public function updateSustainClip() if (wasGoodHit && !noSustainClip) {
var t = CoolUtil.bound((Conductor.songPosition - strumTime) / height * 0.45 * lastScrollSpeed, 0, 1);
var rect = clipRect == null ? FlxRect.get() : clipRect;
clipRect = rect.set(0, frameHeight * t, frameWidth, frameHeight * (1 - t));
}
+9 -14
View File
@@ -53,14 +53,11 @@ class NoteGroup extends FlxTypedGroup<Note> {
public override function update(elapsed:Float) {
i = length-1;
__loopSprite = null;
__time = __getSongPos();
__time = __getSongPos() + limit;
while(i >= 0) {
__loopSprite = members[i--];
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.active) {
continue;
}
if (__loopSprite.strumTime - __time > limit)
break;
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.active) continue;
if (__loopSprite.strumTime > __time) break;
__loopSprite.update(elapsed);
}
}
@@ -74,12 +71,11 @@ class NoteGroup extends FlxTypedGroup<Note> {
i = length-1;
__loopSprite = null;
__time = __getSongPos();
__time = __getSongPos() + limit;
while(i >= 0) {
__loopSprite = members[i--];
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.visible)
continue;
if (__loopSprite.strumTime - __time > limit) break;
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.visible) continue;
if (__loopSprite.strumTime > __time) break;
__loopSprite.draw();
}
__currentlyLooping = oldCur;
@@ -97,16 +93,15 @@ class NoteGroup extends FlxTypedGroup<Note> {
public override function forEach(noteFunc:Note->Void, recursive:Bool = false) {
i = length-1;
__loopSprite = null;
__time = __getSongPos();
__time = __getSongPos() + limit;
var oldCur = __currentlyLooping;
__currentlyLooping = true;
while(i >= 0) {
__loopSprite = members[i--];
if (__loopSprite == null || !__loopSprite.exists)
continue;
if (__loopSprite.strumTime - __time > limit) break;
if (__loopSprite == null || !__loopSprite.exists) continue;
if (__loopSprite.strumTime > __time) break;
noteFunc(__loopSprite);
}
__currentlyLooping = oldCur;
+96 -52
View File
@@ -29,6 +29,8 @@ import funkin.editors.charter.Charter;
import funkin.editors.charter.CharterSelection;
import funkin.game.SplashHandler;
import funkin.game.cutscenes.*;
import funkin.game.scoring.*;
import funkin.game.scoring.RatingManager.Rating;
import funkin.menus.*;
import funkin.backend.week.WeekData;
import funkin.savedata.FunkinSave;
@@ -330,6 +332,10 @@ class PlayState extends MusicBeatState
* The total accuracy amount.
*/
public var totalAccuracyAmount:Float = 0;
/**
* Tracks how much of each rating was received.
*/
public var hits:Map<String, Int> = [];
/**
* FunkinText that shows your score.
@@ -362,6 +368,11 @@ class PlayState extends MusicBeatState
public static var campaignAccuracyTotal:Float = 0;
public static var campaignAccuracyCount:Float = 0;
/**
* Number of each rating received for the current week.
*/
public static var campaignHits:Map<String, Int> = [];
/**
* Camera zoom at which the game lerps to.
*/
@@ -529,6 +540,10 @@ class PlayState extends MusicBeatState
* Group containing all of the combo sprites.
*/
public var comboGroup:RotatingSpriteGroup;
/**
* Manager that helps judge note hits to return ratings.
*/
public var ratingManager:RatingManager = new RatingManager();
/**
* Whenever the Rating sprites should be shown or not.
*
@@ -551,10 +566,11 @@ class PlayState extends MusicBeatState
public var noteTypesArray:Array<String> = [null];
/**
* Hit window, in milliseconds. Defaults to 250ms unless changed in options.
* Base game hit window is 175ms.
* Hit window, in milliseconds. A Legacy CNE Hit window configuration,
* Don't use this, it's for mods that still uses the old judgement timing, instead use ratingManager.
*/
public var hitWindow:Float = Options.hitWindow; // is calculated in create(), is safeFrames in milliseconds.
public var hitWindow:Float = Options.hitWindow;
@:noCompletion @:dox(hide) private var _legacyRating:Rating = {name: "", window: 0, accuracy: 0, score: 0};
@:noCompletion @:dox(hide) private var _startCountdownCalled:Bool = false;
@:noCompletion @:dox(hide) private var _endSongCalled:Bool = false;
@@ -673,6 +689,8 @@ class PlayState extends MusicBeatState
detailsText = isStoryMode ? ("Story Mode: " + storyWeek.name) : "Freeplay";
for (rating in [for (i in ratingManager.ratingData) i.name]) hits.set(rating, 0); // Ensure all keys exist as to prevent null errors.
// Checks if cutscene files exists
var cutscenePath = Paths.script('songs/${SONG.meta.name}/cutscene');
var endCutscenePath = Paths.script('songs/${SONG.meta.name}/cutscene-end');
@@ -1237,12 +1255,13 @@ class PlayState extends MusicBeatState
}
@:dox(hide)
function resyncVocals():Void
inline function resyncVocals():Void
{
var time = Conductor.songPosition + Conductor.songOffset;
for (strumLine in strumLines.members) strumLine.vocals.play(true, time);
vocals.play(true, time);
final time = Conductor.songPosition + Conductor.songOffset;
if (!inst.playing) inst.play(true, time);
vocals.play(true, time);
for (strumLine in strumLines.members) strumLine.vocals.play(true, time);
gameAndCharsCall("onVocalsResync");
}
@@ -1401,13 +1420,12 @@ class PlayState extends MusicBeatState
else if (FlxG.sound.music != null && (__vocalSyncTimer -= elapsed) < 0) {
__vocalSyncTimer = 1;
var instTime = FlxG.sound.music.getActualTime();
var isOffsync:Bool = vocals.loaded && Math.abs(instTime - vocals.getActualTime()) > 100;
if (!isOffsync) {
for (strumLine in strumLines.members) {
if ((isOffsync = strumLine.vocals.loaded && Math.abs(instTime - strumLine.vocals.getActualTime()) > 100)) break;
}
}
final instTime = FlxG.sound.music.getActualTime();
var isOffsync:Bool = vocals.loaded && Math.abs(instTime - vocals.getActualTime()) > 12;
if (!isOffsync)
for (strumLine in strumLines.members)
if ((isOffsync = strumLine.vocals.loaded && Math.abs(instTime - strumLine.vocals.getActualTime()) > 12))
break;
if (isOffsync) resyncVocals();
}
@@ -1587,11 +1605,13 @@ class PlayState extends MusicBeatState
var camera:FlxCamera = event.params[1] == "camHUD" ? camHUD : camGame;
camera.zoom += event.params[0];
case "Camera Bop":
if (useCamZoomMult) {
camZoomingMult += event.params[0];
} else {
FlxG.camera.zoom += event.params[0] * camZoomingStrength;
camHUD.zoom += event.params[0] * camZoomingStrength;
if (Options.camZoomOnBeat) {
if (useCamZoomMult) {
camZoomingMult += event.params[0];
} else {
FlxG.camera.zoom += event.params[0] * camZoomingStrength;
camHUD.zoom += event.params[0] * camZoomingStrength;
}
}
case "Camera Zoom":
var cam = event.params[2] == "camHUD" ? camHUD : camGame;
@@ -1722,7 +1742,7 @@ class PlayState extends MusicBeatState
score: songScore,
misses: misses,
accuracy: accuracy,
hits: [],
hits: hits,
date: Date.now().toString()
}, getSongChanges());
#end
@@ -1749,6 +1769,7 @@ class PlayState extends MusicBeatState
campaignMisses += misses;
campaignAccuracyTotal += accuracy;
campaignAccuracyCount++;
for (k => v in hits) campaignHits[k] += v;
storyPlaylist.shift();
storyVariations.shift();
@@ -1762,7 +1783,7 @@ class PlayState extends MusicBeatState
score: campaignScore,
misses: campaignMisses,
accuracy: campaignAccuracy,
hits: [],
hits: campaignHits,
date: Date.now().toString()
});
#end
@@ -1812,11 +1833,25 @@ class PlayState extends MusicBeatState
*/
public function noteMiss(strumLine:StrumLine, note:Note, ?direction:Int, ?player:Int):Void
{
var playerID:Null<Int> = note == null ? player : strumLines.members.indexOf(strumLine);
var directionID:Null<Int> = note == null ? direction : note.strumID;
var hasNote:Bool = note != null;
var playerID:Null<Int> = hasNote ? strumLines.members.indexOf(strumLine) : player;
var directionID:Null<Int> = hasNote ? note.strumID : direction;
if (playerID == null || directionID == null || playerID == -1) return;
var event:NoteMissEvent = gameAndCharsEvent("onPlayerMiss", EventManager.get(NoteMissEvent).recycle(note, -10, 1, muteVocalsOnMiss, note != null ? -0.0475 : -0.04, Paths.sound(FlxG.random.getObject(Flags.DEFAULT_MISS_SOUNDS)), FlxG.random.float(0.1, 0.2), note == null, combo > 5, "sad", true, true, "miss", strumLines.members[playerID].characters, playerID, note != null ? note.noteType : null, directionID, 0));
if (hasNote) {
if (Flags.SUSTAINS_AS_ONE_NOTE && note.isSustainNote) {
strumLine.deleteNote(note);
if (note.sustainParent.wasGoodHit) {
note.sustainParent.wasGoodHit = false;
note.sustainParent.tooLate = true;
note = note.sustainParent;
}
else
return;
}
}
var event:NoteMissEvent = gameAndCharsEvent("onPlayerMiss", EventManager.get(NoteMissEvent).recycle(note, -10, 1, muteVocalsOnMiss, hasNote ? ((note.isSustainNote && Flags.SUSTAINS_AS_ONE_NOTE) ? -0.1425 : -0.0475) : -0.04, Paths.sound(FlxG.random.getObject(Flags.DEFAULT_MISS_SOUNDS)), FlxG.random.float(0.1, 0.2), !hasNote, combo > 5, "sad", true, true, "miss", strumLines.members[playerID].characters, playerID, hasNote ? note.noteType : null, directionID, 0));
strumLine.onMiss.dispatch(event);
if (event.cancelled) {
gameAndCharsEvent("onPostPlayerMiss", event);
@@ -1855,7 +1890,7 @@ class PlayState extends MusicBeatState
}
}
if (event.deleteNote && strumLine != null && note != null)
if (event.deleteNote && strumLine != null && hasNote)
strumLine.deleteNote(note);
gameAndCharsEvent("onPostPlayerMiss", event);
@@ -1876,43 +1911,49 @@ class PlayState extends MusicBeatState
note.wasGoodHit = true;
/**
* CALCULATES RATING
*/
var noteDiff = Math.abs(Conductor.songPosition - note.strumTime);
var daRating:String = "sick";
var score:Int = 300;
var accuracy:Float = 1;
if (noteDiff > hitWindow * 0.9)
{
daRating = 'shit';
score = 50;
accuracy = 0.25;
}
else if (noteDiff > hitWindow * 0.75)
{
daRating = 'bad';
score = 100;
accuracy = 0.45;
}
else if (noteDiff > hitWindow * 0.2)
{
daRating = 'good';
score = 200;
accuracy = 0.75;
var noteDiff = Math.abs(Conductor.songPosition - note.strumTime), rating:Rating;
if (!Flags.USE_LEGACY_TIMING) rating = ratingManager.judgeNote(noteDiff);
else {
(rating = _legacyRating).splash = false;
if (noteDiff > hitWindow * 0.9) {
rating.window = hitWindow;
rating.name = "shit";
rating.score = 50;
rating.accuracy = 0.25;
}
else if (noteDiff > hitWindow * 0.75) {
rating.window = hitWindow * 0.9;
rating.name = "bad";
rating.score = 100;
rating.accuracy = 0.45;
}
else if (noteDiff > hitWindow * 0.2) {
rating.window = hitWindow * 0.75;
rating.name = "good";
rating.score = 200;
rating.accuracy = 0.75;
}
else {
rating.window = hitWindow * 0.2;
rating.name = "sick";
rating.score = 300;
rating.accuracy = 1;
rating.splash = true;
}
}
var event:NoteHitEvent;
if (strumLine != null && !strumLine.cpu)
event = EventManager.get(NoteHitEvent).recycle(false, !note.isSustainNote, !note.isSustainNote, null, defaultDisplayRating, defaultDisplayCombo, note, strumLine.characters, true, note.noteType, note.animSuffix.getDefault(note.strumID < strumLine.members.length ? strumLine.members[note.strumID].animSuffix : strumLine.animSuffix), "game/score/", "", note.strumID, score, note.isSustainNote ? null : accuracy, 0.023, daRating, Options.splashesEnabled && !note.isSustainNote && daRating == "sick", 0.5, true, 0.7, true, true, iconP1);
event = EventManager.get(NoteHitEvent).recycle(false, !note.isSustainNote, !note.isSustainNote, null, defaultDisplayRating, defaultDisplayCombo, note, strumLine.characters, true, note.noteType, note.animSuffix.getDefault(note.strumID < strumLine.members.length ? strumLine.members[note.strumID].animSuffix : strumLine.animSuffix), "game/score/", "", note.strumID, rating.score, note.isSustainNote ? null : rating.accuracy, 0.023, rating.name, Options.splashesEnabled && !note.isSustainNote && rating.splash, 0.5, true, 0.7, true, true, iconP1);
else
event = EventManager.get(NoteHitEvent).recycle(false, false, false, null, defaultDisplayRating, defaultDisplayCombo, note, strumLine.characters, false, note.noteType, note.animSuffix.getDefault(note.strumID < strumLine.members.length ? strumLine.members[note.strumID].animSuffix : strumLine.animSuffix), "game/score/", "", note.strumID, 0, null, 0, daRating, false, 0.5, true, 0.7, true, true, iconP2);
event = EventManager.get(NoteHitEvent).recycle(false, false, false, null, defaultDisplayRating, defaultDisplayCombo, note, strumLine.characters, false, note.noteType, note.animSuffix.getDefault(note.strumID < strumLine.members.length ? strumLine.members[note.strumID].animSuffix : strumLine.animSuffix), "game/score/", "", note.strumID, 0, null, 0, rating.name, false, 0.5, true, 0.7, true, true, iconP2);
event.deleteNote = !note.isSustainNote; // work around, to allow sustain notes to be deleted
event = scripts.event(strumLine != null && !strumLine.cpu ? "onPlayerHit" : "onDadHit", event);
strumLine.onHit.dispatch(event);
gameAndCharsEvent("onNoteHit", event);
note.noSustainClip = !event.clipSustain;
if (!event.cancelled) {
if (!note.isSustainNote) {
if (event.countScore) songScore += event.score;
@@ -1930,6 +1971,7 @@ class PlayState extends MusicBeatState
displayRating(event.rating, event);
ratingNum += 1;
}
if (event.player) hits[rating.name] += 1;
}
if (strumLine != null) strumLine.addHealth(event.healthGain);
@@ -1958,6 +2000,7 @@ class PlayState extends MusicBeatState
}
if (event.deleteNote) strumLine.deleteNote(note);
else note.updateSustainClip();
gameAndCharsEvent("onPostNoteHit", event);
}
@@ -2165,6 +2208,7 @@ class PlayState extends MusicBeatState
campaignMisses = 0;
campaignAccuracyTotal = 0;
campaignAccuracyCount = 0;
campaignHits = [];
chartingMode = coopMode = opponentMode = false;
__loadSong(storyPlaylist[0], difficulty, storyVariations[0]);
}
+8 -8
View File
@@ -121,7 +121,7 @@ class Strum extends FlxSprite {
public override function update(elapsed:Float) {
super.update(elapsed);
if (cpu) {
if (lastHit + (Conductor.crochet / 2) < Conductor.songPosition && getAnim() == "confirm") {
if (lastHit + (Conductor.crochet * 0.5) < Conductor.songPosition && getAnim() == "confirm") {
playAnim("static");
}
}
@@ -133,7 +133,7 @@ class Strum extends FlxSprite {
}
@:noCompletion public static inline final PIX180:Float = 565.4866776461628; // 180 * Math.PI
@:noCompletion public static final N_WIDTHDIV2:Float = Note.swagWidth / 2;
@:noCompletion public static final N_WIDTHDIV2:Float = Note.swagWidth / 2; // DEPRECATED
/**
* Updates the position of a note.
@@ -162,16 +162,16 @@ class Strum extends FlxSprite {
if (shouldX || shouldY) {
if (daNote.strumRelativePos) {
if (shouldX) daNote.x = (this.width - daNote.width) / 2;
if (shouldX) daNote.x = (this.width - daNote.width) * 0.5;
if (shouldY) {
daNote.y = (daNote.strumTime - Conductor.songPosition) * (0.45 * CoolUtil.quantize(getScrollSpeed(daNote), 100));
if (daNote.isSustainNote) daNote.y += N_WIDTHDIV2;
daNote.y = (daNote.strumTime - Conductor.songPosition) * (0.45 * getScrollSpeed(daNote));
if (daNote.isSustainNote) daNote.y += height * 0.5;
}
} else {
var offset = FlxPoint.get(0, (Conductor.songPosition - daNote.strumTime) * (0.45 * CoolUtil.quantize(getScrollSpeed(daNote), 100)));
var offset = FlxPoint.get(0, (Conductor.songPosition - daNote.strumTime) * (0.45 * getScrollSpeed(daNote)));
var realOffset = FlxPoint.get(0, 0);
if (daNote.isSustainNote) offset.y -= N_WIDTHDIV2;
if (daNote.isSustainNote) offset.y -= height * 0.5;
if (Std.int(daNote.__noteAngle % 360) != 0) {
var noteAngleCos = FlxMath.fastCos(daNote.__noteAngle / PIX180);
@@ -257,4 +257,4 @@ class Strum extends FlxSprite {
public inline function getAnim() {
return animation.name;
}
}
}
+51 -38
View File
@@ -161,6 +161,9 @@ class StrumLine extends FlxTypedGroup<Strum> {
curLen = Math.min(len, Conductor.stepCrochet);
notes.members[total-(il++)-1] = prev = new Note(this, note, true, curLen, note.sLen - len, prev);
len -= curLen;
if (prev != null && prev.sustainParent != null)
prev.sustainParent.tailCount++;
}
}
}
@@ -213,7 +216,7 @@ class StrumLine extends FlxTypedGroup<Strum> {
if (__updateNote_event.cancelled) return;
if (__updateNote_event.__updateHitWindow) {
var hitWindow = PlayState.instance.hitWindow;
var hitWindow = Flags.USE_LEGACY_TIMING ? PlayState.instance.hitWindow : PlayState.instance.ratingManager.lastHitWindow;
daNote.canBeHit = (daNote.strumTime > __updateNote_songPos - (hitWindow * daNote.latePressWindow)
&& daNote.strumTime < __updateNote_songPos + (hitWindow * daNote.earlyPressWindow));
@@ -221,9 +224,10 @@ class StrumLine extends FlxTypedGroup<Strum> {
daNote.tooLate = true;
}
if (cpu && __updateNote_event.__autoCPUHit && !daNote.avoid && !daNote.wasGoodHit && daNote.strumTime < __updateNote_songPos) PlayState.instance.goodNoteHit(this, daNote);
if (cpu && __updateNote_event.__autoCPUHit && !daNote.avoid && !daNote.wasGoodHit && daNote.strumTime < __updateNote_songPos)
PlayState.instance.goodNoteHit(this, daNote);
if (daNote.wasGoodHit && daNote.isSustainNote && daNote.strumTime + daNote.sustainLength < __updateNote_songPos) {
if (daNote.wasGoodHit && daNote.isSustainNote && daNote.strumTime + daNote.sustainLength < __updateNote_songPos && !daNote.noSustainClip) {
deleteNote(daNote);
return;
}
@@ -236,29 +240,38 @@ class StrumLine extends FlxTypedGroup<Strum> {
if (__updateNote_event.strum == null) return;
if (__updateNote_event.__reposNote) __updateNote_event.strum.updateNotePosition(daNote);
if (daNote.isSustainNote)
if (daNote.isSustainNote) {
daNote.updateSustain(__updateNote_event.strum);
}
}
var __funcsToExec:Array<Note->Void> = [];
var __pressed:Array<Bool> = [];
var __justPressed:Array<Bool> = [];
var __justReleased:Array<Bool> = [];
var __notePerStrum:Array<Note> = [];
function __inputProcessPressed(note:Note) {
if (__pressed[note.strumID] && note.isSustainNote && note.strumTime < __updateNote_songPos && !note.wasGoodHit) {
if (__pressed[note.strumID] && note.isSustainNote && note.strumTime < __updateNote_songPos && !note.wasGoodHit && note.sustainParent.wasGoodHit) {
PlayState.instance.goodNoteHit(this, note);
note.updateSustainClip();
}
}
function __inputProcessJustPressed(note:Note) {
if (__justPressed[note.strumID] && !note.isSustainNote && !note.wasGoodHit && note.canBeHit) {
if (__notePerStrum[note.strumID] == null) __notePerStrum[note.strumID] = note;
else if (Math.abs(__notePerStrum[note.strumID].strumTime - note.strumTime) <= 2) deleteNote(note);
else if (note.strumTime < __notePerStrum[note.strumID].strumTime) __notePerStrum[note.strumID] = note;
var cur = __notePerStrum[note.strumID];
var songPos = __updateNote_songPos;
var noteDist = Math.abs(note.strumTime - songPos);
var curDist = cur != null ? Math.abs(cur.strumTime - songPos) : 999999;
var notePenalty = note.avoid ? 1 : 0;
var curPenalty = (cur != null && cur.avoid) ? 1 : 0;
if (cur == null
|| notePenalty < curPenalty
|| (notePenalty == curPenalty && noteDist < curDist))
__notePerStrum[note.strumID] = note;
}
}
@@ -271,15 +284,16 @@ class StrumLine extends FlxTypedGroup<Strum> {
if (cpu) return;
__funcsToExec.clear();
__pressed.clear();
__justPressed.clear();
__justReleased.clear();
if (__pressed.length != members.length) {
__pressed.resize(members.length);
__justPressed.resize(members.length);
__justReleased.resize(members.length);
}
for(s in members) {
__pressed.push(s.__getPressed(this));
__justPressed.push(s.__getJustPressed(this));
__justReleased.push(s.__getJustReleased(this));
for (i in 0...members.length) {
__pressed[i] = members[i].__getPressed(this);
__justPressed[i] = members[i].__getJustPressed(this);
__justReleased[i] = members[i].__getJustReleased(this);
}
var event = EventManager.get(InputSystemEvent).recycle(__pressed, __justPressed, __justReleased, this, id);
@@ -290,34 +304,31 @@ class StrumLine extends FlxTypedGroup<Strum> {
__justPressed = CoolUtil.getDefault(event.justPressed, []);
__justReleased = CoolUtil.getDefault(event.justReleased, []);
__notePerStrum = cast new haxe.ds.Vector(members.length);//[for(_ in 0...members.length) null];
__notePerStrum = cast new haxe.ds.Vector(members.length); // [for(_ in 0...members.length) null];
if (__pressed.contains(true)) {
for(c in characters)
if (__justPressed.contains(true)) {
notes.forEachAlive(__inputProcessJustPressed);
if (!ghostTapping) for (k => pr in __justPressed) if (pr && __notePerStrum[k] == null)
PlayState.instance.noteMiss(this, null, k, ID); // FUCK YOU
for (e in __notePerStrum)
if (e != null)
PlayState.instance.goodNoteHit(this, e);
}
for (c in characters)
if (c.lastAnimContext != DANCE)
c.__lockAnimThisFrame = true;
__funcsToExec.push(__inputProcessPressed);
notes.forEachAlive(__inputProcessPressed);
}
if (__justPressed.contains(true))
__funcsToExec.push(__inputProcessJustPressed);
if (__funcsToExec.length > 0) {
notes.forEachAlive(function(note:Note) {
for(e in __funcsToExec) if (e != null) e(note);
});
}
if (!ghostTapping) for(k=>pr in __justPressed) if (pr && __notePerStrum[k] == null) {
// FUCK YOU
PlayState.instance.noteMiss(this, null, k, ID);
}
for(e in __notePerStrum) if (e != null) PlayState.instance.goodNoteHit(this, e);
forEach(function(str:Strum) {
str.updatePlayerInput(str.__getPressed(this), str.__getJustPressed(this), str.__getJustReleased(this));
str.updatePlayerInput(__pressed[str.ID], __justPressed[str.ID], __justReleased[str.ID]);
});
PlayState.instance.gameAndCharsCall("onPostInputUpdate");
}
@@ -411,6 +422,8 @@ class StrumLine extends FlxTypedGroup<Strum> {
var event:SimpleNoteEvent = EventManager.get(SimpleNoteEvent).recycle(note);
onNoteDelete.dispatch(event);
if (!event.cancelled) {
if (note.isSustainNote && note.sustainParent != null && note.sustainParent.tailCount > 0)
note.sustainParent.tailCount--;
note.kill();
notes.remove(note, true);
note.destroy();
@@ -95,18 +95,20 @@ class ScriptedCutscene extends Cutscene {
script.call("stepHit", [curStep]);
}
public override function openSubState(sub:FlxSubState)
public override function openSubState(subState:FlxSubState)
{
var event = EventManager.get(StateEvent).recycle(sub);
script.call("onSubstateClose", [event]);
if(!event.cancelled) super.openSubState(event.substate is FlxSubState ? cast event.substate : sub);
var event = EventManager.get(StateEvent).recycle(subState);
script.call(Flags.MOD_API_VERSION <= 1 ? "onSubstateClose" /*Remove this entirely*/ : "onOpenSubState", [event]);
if (!event.cancelled)
super.openSubState(event.substate is FlxSubState ? cast event.substate : subState);
}
public override function closeSubState()
{
var event = EventManager.get(StateEvent).recycle(subState);
script.call("onSubstateOpen", [event]);
if(!event.cancelled) super.closeSubState();
script.call(Flags.MOD_API_VERSION <= 1 ? "onSubstateOpen" /*Remove this entirely*/ : "onCloseSubState", [event]);
if (!event.cancelled)
super.closeSubState();
}
public override function destroy() {
@@ -60,7 +60,9 @@ class VideoCutscene extends Cutscene {
add(video = new FlxVideoSprite());
video.antialiasing = true;
#if (hxvlc < version("2.0.0"))
video.autoPause = false; // Imma handle it better inside this class, mainly because of the pause menu - Nex
#end
video.bitmap.onEndReached.add(close);
video.bitmap.onFormatSetup.add(function() if (video.bitmap != null && video.bitmap.bitmapData != null) {
final width = video.bitmap.bitmapData.width;
@@ -205,6 +207,7 @@ class VideoCutscene extends Cutscene {
}
}
#if (hxvlc < version("2.0.0"))
@:dox(hide) override public function onFocus() {
if(FlxG.autoPause && !paused) video.resume();
super.onFocus();
@@ -214,6 +217,7 @@ class VideoCutscene extends Cutscene {
if(FlxG.autoPause && !paused) video.pause();
super.onFocusLost();
}
#end
public override function pauseCutscene() {
video.pause();
@@ -0,0 +1,76 @@
package funkin.game.scoring;
import haxe.ds.StringMap;
class HitWindowData
{
public static function getWindows(preset:WindowPreset):StringMap<Float>
{
var map = new StringMap<Float>();
switch (preset) {
// Old Codename, really forgiving inputs (hard to get bad ratings)
case CNE_CLASSIC:
map.set("sick", 50.0);
map.set("good", 187.5);
map.set("bad", 225.0);
map.set("shit", 250.0);
// Week 7
case FNF_CLASSIC:
map.set("sick", 33.334);
map.set("good", 125.0025);
map.set("bad", 150.003);
map.set("shit", 166.67);
// V-Slice
case FNF_VSLICE:
map.set("sick", 45.0);
map.set("good", 90.0);
map.set("bad", 135.4);
map.set("shit", 180.0);
// Default, taken from Etterna
case _:
map.set("sick", 37.8);
map.set("good", 75.6);
map.set("bad", 113.4);
map.set("shit", 180.0);
}
return map;
}
public static var JUDGE_SCALES:Array<Float> = [1.5, 1.33, 1.16, 1.0, 0.84, 0.66, 0.5, 0.33, 0.2];
public static function scaleWindows(windows:StringMap<Float>, scale:Float):StringMap<Float>
{
var scaled = new StringMap<Float>();
for (k in windows.keys())
scaled.set(k, windows.get(k) * scale);
return scaled;
}
public static function offsetWindows(windows:StringMap<Float>, offset:Float):StringMap<Float>
{
var adjusted = new StringMap<Float>();
for (k in windows.keys())
adjusted.set(k, windows.get(k) + offset);
return adjusted;
}
}
enum abstract WindowPreset(Int) from Int to Int
{
var DEFAULT = 0;
var CNE_CLASSIC = 1;
var FNF_CLASSIC = 2;
var FNF_VSLICE = 3;
public function toString():String
{
return switch (cast this : WindowPreset)
{
case CNE_CLASSIC: "Codename (Classic)";
case FNF_CLASSIC: "Funkin' (Week 7)";
case FNF_VSLICE: "Funkin' (V-Slice)";
case _: "Default";
}
}
}
+138
View File
@@ -0,0 +1,138 @@
package funkin.game.scoring;
import funkin.game.scoring.*;
import funkin.game.scoring.HitWindowData.WindowPreset;
import haxe.ds.StringMap;
/**
* Judges note hits and returns a rating.
*/
class RatingManager
{
public var hitWindows:StringMap<Float>;
public var ratingData:Array<Rating> = [];
public var lastHitWindow:Float = -1;
public function new(?preset:WindowPreset):Void
{
var usedPreset = preset != null ? preset : WindowPreset.DEFAULT;
hitWindows = HitWindowData.getWindows(usedPreset);
initDefaultData(hitWindows);
}
/**
* Returns a rating based on a wimdow of time.
* @param time The timing window to judge.
*/
public function judgeNote(time:Float):Rating
{
for (i => rating in ratingData)
{
if (rating.hittable && rating.window > -1 && time <= rating.window)
{
return rating;
}
}
return ratingData.last();
}
/**
* Initializes the default rating data containing the four judgements.
*
* "Sick", "Good", "Bad", "Shit"
*/
public function initDefaultData(windows:StringMap<Float>)
{
inline function getWindow(name:String):Float
{
return windows.exists(name) ? windows.get(name) : -1;
}
addRating({name: "sick", window: getWindow("sick"), accuracy: 1, score: 300, splash: true});
addRating({name: "good", window: getWindow("good"), accuracy: 0.75, score: 200});
addRating({name: "bad", window: getWindow("bad"), accuracy: 0.45, score: 100});
addRating({name: "shit", window: getWindow("shit"), accuracy: 0.25, score: 50});
}
public function addRating(data:Dynamic)
{
if (data == null || data.name == null) return;
var name = data.name.toLowerCase();
var window = data.window != null
? data.window
: (hitWindows.exists(name) ? hitWindows.get(name) : -1);
if (window > lastHitWindow) lastHitWindow = window;
var newRating:Rating = {
name: name,
window: window,
accuracy: data.accuracy != null ? data.accuracy : 1,
score: data.score != null ? data.score : 0,
splash: data.splash == true,
hittable: data.hittable != null ? data.hittable : true
};
var existingIndex = -1;
for (i in 0...ratingData.length)
if (ratingData[i].name == name)
existingIndex = i;
if (existingIndex >= 0)
ratingData[existingIndex] = newRating;
else
ratingData.push(newRating);
ratingData.sort((a, b) -> Reflect.compare(a.window, b.window));
}
public function removeRating(name:String):Void
{
if (name == null) return;
name = name.toLowerCase();
ratingData = ratingData.filter(r -> r.name != name);
}
public function getHitWindow(name:String):Float
{
return hitWindows.exists(name) ? hitWindows.get(name) : -1;
}
}
@:structInit
final class Rating
{
/**
* Name of rating.
*
* Also used for the image file name of the rating.
*/
public var name:String = "unknown";
/**
* Amount of accuracy given when earning this rating.
*/
public var accuracy:Float = 0.0;
/**
* MS Timing Window to hit the rating.
*/
public var window:Float = -1;
/**
* Amount of score given when earning this rating.
*/
public var score:Int = 0;
/**
* If this rating was hit, a note splash will appear.
*/
@:optional public var splash:Bool = false;
/**
* Whether the rating is hittable or not.
*/
@:optional public var hittable:Bool = true;
}

Some files were not shown because too many files have changed in this diff Show More