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
114 changed files with 2500 additions and 1067 deletions
+4 -1
View File
@@ -37,4 +37,7 @@ f8b20774e3f035eeddb9211a28a391b20db74456
# Revert a revert (scripted cutscene path) # Revert a revert (scripted cutscene path)
d73f86d26ec2dbf031c01f588ba4be11842db09c d73f86d26ec2dbf031c01f588ba4be11842db09c
fe0ab0aa454f4ae12ced9502db8a01e7bca3e04c fe0ab0aa454f4ae12ced9502db8a01e7bca3e04c
# Forgot the # in the commit message
484bbcb22aa8f28b62912abb6d8c89fb58e63889
+77 -9
View File
@@ -1,22 +1,23 @@
name: Linux Builds
name: Linux Build
on: on:
push: push:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
build: build:
name: Linux Build name: Linux Build
permissions: write-all permissions: write-all
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
steps: steps:
- name: Pulling the source - name: Pulling the new commit
uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Setting up Haxe - name: Setting up Haxe
uses: krdlab/setup-haxe@v2 uses: krdlab/setup-haxe@v2
with: with:
haxe-version: 4.3.7 haxe-version: 4.3.7
- name: Restore existing build cache for faster compilation - name: Restore existing build cache for faster compilation
uses: actions/cache@v3 uses: actions/cache@v4.2.3
with: with:
# not caching the bin folder to prevent asset duplication and stuff like that # not caching the bin folder to prevent asset duplication and stuff like that
key: cache-build-linux key: cache-build-linux
@@ -24,8 +25,8 @@ jobs:
.haxelib/ .haxelib/
export/release/linux/haxe/ export/release/linux/haxe/
export/release/linux/obj/ export/release/linux/obj/
restore-keys: | - run: |
cache-build-linux echo "HXCPP_COMPILE_CACHE=~/.hxcpp" >> $GITHUB_ENV
- name: Installing LibVLC - name: Installing LibVLC
run: | run: |
sudo apt-get install libvlc-dev libvlccore-dev sudo apt-get install libvlc-dev libvlccore-dev
@@ -67,7 +68,7 @@ jobs:
} }
} }
- name: Uploading new cache - name: Uploading new cache
uses: actions/cache@v3 uses: actions/cache@v4.2.3
with: with:
# caching again since for some reason it doesnt work with the first post cache shit # caching again since for some reason it doesnt work with the first post cache shit
key: cache-build-linux key: cache-build-linux
@@ -75,5 +76,72 @@ jobs:
.haxelib/ .haxelib/
export/release/linux/haxe/ export/release/linux/haxe/
export/release/linux/obj/ 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: on:
push: push:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
build: build:
name: Mac OS Build name: Mac OS Build
permissions: write-all permissions: write-all
runs-on: macos-13 runs-on: macos-14
steps: steps:
- name: Pulling the new commit - name: Pulling the new commit
uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Setting up Haxe - name: Setting up Haxe
uses: krdlab/setup-haxe@v2 uses: krdlab/setup-haxe@v2
with: with:
haxe-version: 4.3.7 haxe-version: 4.3.7
- name: Restore existing build cache for faster compilation - name: Restore existing build cache for faster compilation
uses: actions/cache@v3 uses: actions/cache@v4.2.3
with: with:
# not caching the bin folder to prevent asset duplication and stuff like that # not caching the bin folder to prevent asset duplication and stuff like that
key: cache-build-mac key: cache-build-mac
@@ -24,14 +25,14 @@ jobs:
.haxelib/ .haxelib/
export/release/macos/haxe/ export/release/macos/haxe/
export/release/macos/obj/ export/release/macos/obj/
restore-keys: | - run: |
cache-build-mac echo "HXCPP_COMPILE_CACHE=~/.hxcpp" >> $GITHUB_ENV
- name: Installing/Updating libraries - name: Installing/Updating libraries
run: | run: |
haxe -cp commandline -D analyzer-optimize --run Main setup -s haxe -cp commandline -D analyzer-optimize --run Main setup -s
- name: Building the game - name: Building the game
run: | run: |
haxelib run lime build mac arch -x86_64 haxelib run lime build mac
- name: Tar files - name: Tar files
run: tar -zcvf CodenameEngine.tar.gz -C export/release/macos/bin . run: tar -zcvf CodenameEngine.tar.gz -C export/release/macos/bin .
- name: Uploading artifact (executable) - name: Uploading artifact (executable)
@@ -64,7 +65,7 @@ jobs:
} }
} }
- name: Uploading new cache - name: Uploading new cache
uses: actions/cache@v3 uses: actions/cache@v4.2.3
with: with:
# caching again since for some reason it doesnt work with the first post cache shit # caching again since for some reason it doesnt work with the first post cache shit
key: cache-build-mac key: cache-build-mac
@@ -72,5 +73,69 @@ jobs:
.haxelib/ .haxelib/
export/release/macos/haxe/ export/release/macos/haxe/
export/release/macos/obj/ 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 }} name: Release ${{ github.event.inputs.tag_name }}
draft: true draft: true
prerelease: ${{ github.event.inputs.prerelease }} prerelease: ${{ github.event.inputs.prerelease }}
body: ${{ steps.build_body.outputs.body }} body: ${{ steps.build_body.outputs.body }}
generate_release_notes: true generate_release_notes: true
files: | files: |
renamed/Codename Engine-Windows.zip renamed/Codename Engine-Windows.zip
+71 -8
View File
@@ -1,8 +1,9 @@
name: Windows Builds
name: Windows Build
on: on:
push: push:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
build: build:
name: Windows Build name: Windows Build
@@ -10,13 +11,13 @@ jobs:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- name: Pulling the new commit - name: Pulling the new commit
uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Setting up Haxe - name: Setting up Haxe
uses: krdlab/setup-haxe@v2 uses: krdlab/setup-haxe@v2
with: with:
haxe-version: 4.3.7 haxe-version: 4.3.7
- name: Restore existing build cache for faster compilation - name: Restore existing build cache for faster compilation
uses: actions/cache@v3 uses: actions/cache@v4.2.3
with: with:
# not caching the bin folder to prevent asset duplication and stuff like that # not caching the bin folder to prevent asset duplication and stuff like that
key: cache-build-windows key: cache-build-windows
@@ -24,8 +25,8 @@ jobs:
.haxelib/ .haxelib/
export/release/windows/haxe/ export/release/windows/haxe/
export/release/windows/obj/ export/release/windows/obj/
restore-keys: | - run: |
cache-build-windows echo "HXCPP_COMPILE_CACHE=~/.hxcpp" >> $GITHUB_ENV
- name: Installing/Updating libraries - name: Installing/Updating libraries
run: | run: |
haxe -cp commandline -D analyzer-optimize --run Main setup -s --no-vscheck haxe -cp commandline -D analyzer-optimize --run Main setup -s --no-vscheck
@@ -62,7 +63,7 @@ jobs:
} }
} }
- name: Uploading new cache - name: Uploading new cache
uses: actions/cache@v3 uses: actions/cache@v4.2.3
with: with:
# caching again since for some reason it doesnt work with the first post cache shit # caching again since for some reason it doesnt work with the first post cache shit
key: cache-build-windows key: cache-build-windows
@@ -70,5 +71,67 @@ jobs:
.haxelib/ .haxelib/
export/release/windows/haxe/ export/release/windows/haxe/
export/release/windows/obj/ 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/
+2 -2
View File
@@ -71,11 +71,11 @@ _**QOL = Quality of Life**_
- Characters are located in `data/weeks/characters`. - Characters are located in `data/weeks/characters`.
- Weeks are located in `data/weeks/weeks/` - 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. - 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 - Undos/Redos supported
- Warning on closing unsaved work - Warning on closing unsaved work
- Clean UI (for ocd freaks) - Clean UI (for ocd freaks)
- Mature Chart editor (Character editor rework soon) - Mature Chart editor
- Features not found in other editors! - Features not found in other editors!
- Every single state & substate can be modified via HScript (`data/states/StateName.hx`) - 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.** - **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>
<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) Check out our guide [HERE](building/README.md)
</details> </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 test
tutorial 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, # THIS FILE ISN'T NECESSARY,
# BUT YOU CAN USE IT TO SORT WEEKS # BUT YOU CAN USE IT TO SORT AND WHITELIST WEEKS
tutorial tutorial
week1 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> <str id="category.engine">Engine</str>
<group name="engine" prefix="engine."> <group name="engine" prefix="engine.">
<str id="switchMod">Switch Mod</str> <str id="switchMod">Switch Mod</str>
<str id="fpsCounter">FPS Counter</str>
</group> </group>
<str id="category.volume">Volume</str> <str id="category.volume">Volume</str>
+2 -1
View File
@@ -46,8 +46,9 @@
<group name="engine" prefix="engine."> <group name="engine" prefix="engine.">
<str id="switchMod">Cambiar Mod</str> <str id="switchMod">Cambiar Mod</str>
<str id="fpsCounter">Contador de FPS</str>
</group> </group>
<str id="category.volume">Volumen</str> <str id="category.volume">Volumen</str>
<str id="volume.up">Arriba</str> <str id="volume.up">Arriba</str>
<str id="volume.down">Abajo</str> <str id="volume.down">Abajo</str>
+1
View File
@@ -46,6 +46,7 @@
<group name="engine" prefix="engine."> <group name="engine" prefix="engine.">
<str id="switchMod">Cambia Mod</str> <str id="switchMod">Cambia Mod</str>
<str id="fpsCounter">Contatore FPS</str>
</group> </group>
<str id="volume.up">Su</str> <str id="volume.up">Su</str>
+2 -1
View File
@@ -44,8 +44,9 @@
<str id="category.engine">Silnik</str> <str id="category.engine">Silnik</str>
<group name="engine" prefix="engine."> <group name="engine" prefix="engine.">
<str id="switchMod">Zmień Moda</str> <str id="switchMod">Zmień Moda</str>
<str id="fpsCounter">Licznik FPS</str>
</group> </group>
<str id="category.volume">Głośność</str> <str id="category.volume">Głośność</str>
<str id="volume.up">Głóśniej</str> <str id="volume.up">Głóśniej</str>
<str id="volume.down">Ciszej</str> <str id="volume.down">Ciszej</str>
+1
View File
@@ -48,6 +48,7 @@
<str id="category.engine">Codename Engine</str> <str id="category.engine">Codename Engine</str>
<group name="engine" prefix="engine."> <group name="engine" prefix="engine.">
<str id="switchMod">Trocar Mod</str> <str id="switchMod">Trocar Mod</str>
<str id="fpsCounter">Contador de FPS</str>
</group> </group>
<str id="category.volume">Volume</str> <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> # 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** > **Open the instructions for your platform.**
<details> <details>
<summary>Windows</summary> <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> > 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). > 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. > - 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 sample-type=float32
stereo-mode=speakers stereo-mode=speakers
stereo-encoding=panpot
hrtf=false hrtf=false
cf_level=0 cf_level=0
resampler=fast_bsinc24
front-stablizer=false
output-limiter=false output-limiter=false
front-stabilizer=false
volume-adjust=0 volume-adjust=0
period_size=441
sources=512
sends=64
dither=false
[decoder] [decoder]
hq-mode=false hq-mode=true
distance-comp=false distance-comp=true
nfc=false 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.
+2 -1
View File
@@ -16,8 +16,9 @@
<git name="hscript-improved" url="https://github.com/CodenameCrew/hscript-improved" ref="codename-dev" /> <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="flxanimate" url="https://github.com/CodenameCrew/cne-flxanimate" />
<git name="hxdiscord_rpc" url="https://github.com/CodenameCrew/cne-hxdiscord_rpc" skipDeps="true" /> <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" /> <lib name="hxvlc" version="1.9.3" skipDeps="true" />
<git name="bin-serializer" url="https://github.com/CodenameCrew/bin-serializer" />
<!-- Documentation and other features --> <!-- Documentation and other features -->
<git name="away3d" url="https://github.com/CodenameCrew/away3d" /> <git name="away3d" url="https://github.com/CodenameCrew/away3d" />
+10 -9
View File
@@ -3,19 +3,16 @@
<!-- _________________________ Application Settings _________________________ --> <!-- _________________________ Application Settings _________________________ -->
<app <app
title="Friday Night Funkin' - Codename Engine" main="funkin.backend.system.Main" title="Friday Night Funkin' - Codename Engine" main="funkin.backend.system.Main"
file="CodenameEngine" packageName="com.yoshman29.codenameengine" file="CodenameEngine" packageName="com.codenamecrew.codenameengine"
package="com.yoshman29.codenameengine" package="com.codenamecrew.codenameengine"
version="1.0.1" company="Yoshman29" /> 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_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--> <!--Switch Export with Unique ApplicationID and Icon-->
<set name="APP_ID" value="0x0100f6c013bbc000" /> <set name="APP_ID" value="0x0100f6c013bbc000" />
@@ -50,7 +47,7 @@
<!-- _________________________________ Engine Settings _______________________________ --> <!-- _________________________________ Engine Settings _______________________________ -->
<!-- Comment this out to disable updates !--> <!-- 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 !--> <!-- Comment this out to disable Discord RPC !-->
<section if="cpp"> <section if="cpp">
@@ -131,6 +128,7 @@
<haxelib name="away3d" if="THREE_D_SUPPORT" /> <haxelib name="away3d" if="THREE_D_SUPPORT" />
<haxelib name="format" /> <haxelib name="format" />
<haxelib name="flxanimate" /> <haxelib name="flxanimate" />
<haxelib name="bin-serializer" />
<haxelib name="nape-haxe4" if="NAPE_ENABLED"/> <haxelib name="nape-haxe4" if="NAPE_ENABLED"/>
<haxelib name="hscript-improved" /> <haxelib name="hscript-improved" />
@@ -189,6 +187,9 @@
<haxedef name="USE_ADAPTED_ASSETS" if="USE_ADAPTED_ASSETS" /> <haxedef name="USE_ADAPTED_ASSETS" if="USE_ADAPTED_ASSETS" />
<haxedef name="openfl_dpi_aware" if="openfl_dpi_aware" /> <haxedef name="openfl_dpi_aware" if="openfl_dpi_aware" />
<!-- Disable it for more concise compilation errors. -->
<haxedef name="message.reporting" value="pretty" />
<!-- _________________________________ Custom _______________________________ --> <!-- _________________________________ Custom _______________________________ -->
<!--Place custom nodes like icons here (higher priority to override the HaxeFlixel icon)--> <!--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.math.FlxPoint;
import flixel.system.FlxAssets.FlxSoundAsset; import flixel.system.FlxAssets.FlxSoundAsset;
import flixel.tweens.FlxTween; import flixel.tweens.FlxTween;
import flixel.util.FlxDestroyUtil;
import flixel.util.FlxSignal; import flixel.util.FlxSignal;
import flixel.util.FlxStringUtil; import flixel.util.FlxStringUtil;
import flixel.FlxBasic; import flixel.FlxBasic;
@@ -136,11 +137,18 @@ class FlxSound extends FlxBasic {
public var radius:Float; public var radius:Float;
/** /**
* Whether the proximity alters the pan or not * Whether the proximity alters the pan or not.
* @since raltyMod * @since raltyMod
*/ */
public var proximityPan:Bool; 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. * Stores for how much channels are in the loaded sound.
* @since raltyMod * @since raltyMod
@@ -302,6 +310,8 @@ class FlxSound extends FlxBasic {
_lastTime = null; _lastTime = null;
if (destroySound) { if (destroySound) {
scrollFactor = FlxDestroyUtil.put(scrollFactor);
if (group != null) group.remove(this); if (group != null) group.remove(this);
if (_channel != null) { if (_channel != null) {
@@ -348,15 +358,24 @@ class FlxSound extends FlxBasic {
_amplitudeUpdate = true; _amplitudeUpdate = true;
// Distance-based volume control (TODO for Ralty: REDO THIS) // Distance-based volume control
if (target != null) { if (target != null) {
var targetPosition = target.getPosition(); var targetPosition = target.getPosition(), position = getPosition();
var radialMultiplier = targetPosition.distanceTo(FlxPoint.weak(x, y)) / radius; var camera = camera;
targetPosition.put(); if (camera != null) {
radialMultiplier = 1 - FlxMath.bound(radialMultiplier, 0, 1); 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; var radialMultiplier = targetPosition.distanceTo(position) / radius;
if (proximityPan) _panAdjust = (x - target.x) / 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 else
_volumeAdjust = 1.0; _volumeAdjust = 1.0;
@@ -536,12 +555,15 @@ class FlxSound extends FlxBasic {
* @param Pan Whether panning should be used in addition to the volume changes. * @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). * @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); setPosition(x, y);
if (targetObject != null) this.target = targetObject; if (targetObject != null) this.target = targetObject;
if (radius != null) this.radius = radius; if (radius != null) this.radius = radius;
proximityPan = pan; proximityPan = pan;
if (this.scrollFactor == null) this.scrollFactor = FlxPoint.get(1, 1);
if (scrollFactor != null) this.scrollFactor.copyFrom(scrollFactor);
return this; return this;
} }
@@ -549,14 +571,28 @@ class FlxSound extends FlxBasic {
* Helper function to set the coordinates of this object. * Helper function to set the coordinates of this object.
* Sound positioning is used in conjunction with proximity/panning. * Sound positioning is used in conjunction with proximity/panning.
* *
* @param x The new x position * @param x The new x position
* @param y The new y 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.x = x;
this.y = y; 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. * Call this function to play the sound - also works on paused sounds.
* *
@@ -682,7 +718,7 @@ class FlxSound extends FlxBasic {
_paused = false; _paused = false;
_time = startTime; _time = startTime;
_lastTime = FlxG.game.getTicks(); _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(); makeChannel();
if (_channel != null) { if (_channel != null) {
@@ -733,7 +769,8 @@ class FlxSound extends FlxBasic {
_lastTime = FlxG.game.getTicks(); _lastTime = FlxG.game.getTicks();
_time = loopTime; _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 inline function get_playing():Bool @:privateAccess
return _channel != null && _channel.__isValid && _source.playing; return _source != null && _source.playing;
inline function get_volume():Float inline function get_volume():Float
return _volume; return _volume;
@@ -796,12 +833,12 @@ class FlxSound extends FlxBasic {
inline function get_buffer():AudioBuffer inline function get_buffer():AudioBuffer
@:privateAccess return _sound != null ? _sound.__buffer : null; @:privateAccess return _sound != null ? _sound.__buffer : null;
function update_amplitude():Void @:privateAccess { inline function update_amplitude():Void @:privateAccess {
if (_channel == null || !_channel.__updatePeaks(get_time()) || !_amplitudeUpdate) return; if (_channel != null && _channel.__updatePeaks(get_time()) && _amplitudeUpdate) {
_amplitudeUpdate = false;
_amplitudeUpdate = false; _amplitudeLeft = _channel.__leftPeak;
_amplitudeLeft = _channel.__leftPeak; _amplitudeRight = _channel.__rightPeak;
_amplitudeRight = _channel.__rightPeak; }
} }
inline function get_amplitudeLeft():Float { inline function get_amplitudeLeft():Float {
@@ -829,30 +866,27 @@ class FlxSound extends FlxBasic {
inline function get_pitch():Float inline function get_pitch():Float
return _pitch; return _pitch;
function set_pitch(v:Float):Float { inline function set_pitch(v:Float):Float {
_realPitch = (_pitch = v) * _timeScaleAdjust; _realPitch = (_pitch = v) * _timeScaleAdjust;
if (_channel != null) _channel.pitch = _realPitch; if (_source != null) _source.pitch = _realPitch;
return _pitch; return _pitch;
} }
#end #end
function set_looped(v:Bool):Bool { function set_looped(v:Bool):Bool {
if (playing) { if (playing) _source.loops = v ? 999 : 0;
if (v) _channel.loops = 999;
else _channel.loops = 0;
}
return looped = v; return looped = v;
} }
function set_loopTime(v:Float):Float { function set_loopTime(v:Float):Float {
if (playing) _channel.loopTime = v; if (playing) _source.loopTime = v;
return loopTime = v; return loopTime = v;
} }
function set_endTime(v:Null<Float>):Null<Float> { function set_endTime(v:Null<Float>):Null<Float> {
if (playing) { if (playing) {
if (v != null && v > 0 && v < _length) _channel.endTime = v; if (v != null && v > 0 && v < _length) _source.length = v;
else _channel.endTime = null; else _source.length = null;
} }
return endTime = v; return endTime = v;
} }
@@ -864,7 +898,7 @@ class FlxSound extends FlxBasic {
return _time; return _time;
} }
function get_time():Float { 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; final sourceTime = _source.currentTime - _source.offset - _offset;
if (!_source.playing || _realPitch <= 0) { if (!_source.playing || _realPitch <= 0) {
@@ -903,24 +937,21 @@ class FlxSound extends FlxBasic {
return _time = time; return _time = time;
} }
inline function get_offset():Float return _offset; function get_offset():Float return _offset;
inline function set_offset(offset:Float):Float { function set_offset(offset:Float):Float {
if (_offset == (_offset = offset)) return offset; if (_offset == (_offset = offset)) return offset;
//time = time + _offset; //time = time + _offset;
return offset; return offset;
} }
inline function get_length():Float return _length - _offset; function get_length():Float return _length - _offset;
/*function get_latency():Float { //function get_latency():Float return _source != null ? _source.latency : 0;
if (_channel != null) return _source.latency;
return 0;
}*/
override function toString():String { override function toString():String {
return FlxStringUtil.getDebugString([ return FlxStringUtil.getDebugString([
LabelValuePair.weak("playing", playing), LabelValuePair.weak("playing", playing),
LabelValuePair.weak("time", _time), LabelValuePair.weak("time", time),
LabelValuePair.weak("length", length), LabelValuePair.weak("length", length),
LabelValuePair.weak("volume", volume), LabelValuePair.weak("volume", volume),
LabelValuePair.weak("pitch", pitch) 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 atlasPlayingAnim:String;
@:noCompletion public var atlasPath:String; @:noCompletion public var atlasPath:String;
var _rect2:FlxRect;
public function new(?X:Float = 0, ?Y:Float = 0, ?SimpleGraphic:FlxGraphicAsset) public function new(?X:Float = 0, ?Y:Float = 0, ?SimpleGraphic:FlxGraphicAsset)
{ {
super(X, Y); super(X, Y);
@@ -112,6 +114,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
spr.transformMatrix = casted.transformMatrix; spr.transformMatrix = casted.transformMatrix;
spr.matrixExposed = casted.matrixExposed; spr.matrixExposed = casted.matrixExposed;
spr.animOffsets = casted.animOffsets.copy(); spr.animOffsets = casted.animOffsets.copy();
spr.zoomFactor = casted.zoomFactor;
} }
} }
return spr; 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) public function loadSprite(path:String, Unique:Bool = false, Key:String = null)
{ {
var noExt = Path.withoutExtension(path); var noExt = Path.withoutExtension(path);
@@ -226,6 +234,8 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
animOffsets = null; animOffsets = null;
} }
super.destroy(); super.destroy();
_rect2 = FlxDestroyUtil.put(_rect2);
} }
#end #end
@@ -233,27 +243,40 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
private inline function __shouldDoZoomFactor() private inline function __shouldDoZoomFactor()
return zoomFactorEnabled && zoomFactor != 1; 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 public override function getScreenBounds(?newRect:FlxRect, ?camera:FlxCamera):FlxRect
{ {
if (camera == null) if (camera == null)
camera = FlxG.camera; camera = FlxG.camera;
var r = super.getScreenBounds(newRect, camera); newRect = super.getScreenBounds(newRect, camera);
if(__shouldDoZoomFactor()) { if(__shouldDoZoomFactor()) {
r.x -= camera.width / 2; __prepareZoomFactor(_rect2, camera);
r.y -= camera.height / 2; newRect.set(
(newRect.x - _rect2.x) * _rect2.width + _rect2.x,
var ratio = (camera.zoom > 0 ? Math.max : Math.min)(0, FlxMath.lerp(1 / camera.zoom, 1, zoomFactor)); (newRect.y - _rect2.y) * _rect2.height + _rect2.y,
r.x *= ratio; newRect.width * _rect2.width,
r.y *= ratio; newRect.height * _rect2.height,
r.width *= ratio; );
r.height *= ratio;
r.x += camera.width / 2;
r.y += camera.height / 2;
} }
return r; return newRect;
} }
override public function isOnScreen(?camera:FlxCamera):Bool override public function isOnScreen(?camera:FlxCamera):Bool
@@ -273,14 +296,16 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I
// ZOOM FACTOR RENDERING // ZOOM FACTOR RENDERING
public override function doAdditionalMatrixStuff(matrix:FlxMatrix, camera:FlxCamera) public override function doAdditionalMatrixStuff(matrix:FlxMatrix, camera:FlxCamera)
{ {
super.doAdditionalMatrixStuff(matrix, camera); // no need to...
//super.doAdditionalMatrixStuff(matrix, camera);
if(__shouldDoZoomFactor()) { if(__shouldDoZoomFactor()) {
matrix.translate(-camera.width / 2, -camera.height / 2); __prepareZoomFactor(_rect, camera);
matrix.setTo(
var requestedZoom = (camera.zoom >= 0 ? Math.max : Math.min)(FlxMath.lerp(1, camera.zoom, zoomFactor), 0); matrix.a * _rect.width, matrix.b * _rect.height,
var diff = requestedZoom / camera.zoom; matrix.c * _rect.width, matrix.d * _rect.height,
matrix.scale(diff, diff); (matrix.tx - _rect.x) * _rect.width + _rect.x,
matrix.translate(camera.width / 2, camera.height / 2); (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); 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) { public override function onResize(w:Int, h:Int) {
super.onResize(w, h); super.onResize(w, h);
event("onResize", EventManager.get(ResizeEvent).recycle(w, h, null, null)); event("onResize", EventManager.get(ResizeEvent).recycle(w, h, null, null));
+36
View File
@@ -97,6 +97,41 @@ class Chart {
data.setFieldDefault("vocalsSuffix", ""); data.setFieldDefault("vocalsSuffix", "");
data.setFieldDefault("needsVoices", true); data.setFieldDefault("needsVoices", true);
data.setFieldDefault("difficulties", []); 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("variants", []);
data.setFieldDefault("metas", []); data.setFieldDefault("metas", []);
@@ -300,6 +335,7 @@ class Chart {
var eventsPath = '$songPath/events$variantSuffix.json', events = filterEventsForSaving(chart.events, false, true); 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)); 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 #end
+1 -2
View File
@@ -32,8 +32,7 @@ typedef ChartMetaData = {
public var ?icon:String; public var ?icon:String;
public var ?color:FlxColor; public var ?color:FlxColor;
public var ?coopAllowed:Bool; public var ?excludedGameModes:Array<String>;
public var ?opponentModeAllowed:Bool;
public var ?metas:Map<String, ChartMetaData>; public var ?metas:Map<String, ChartMetaData>;
public var ?instSuffix:String; public var ?instSuffix:String;
+3 -1
View File
@@ -179,7 +179,8 @@ class EventsData {
finalParams.push({ finalParams.push({
name: paramData.name, name: paramData.name,
type: hscriptInterp.expr(hscriptParser.parseString(paramData.type)), 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);} } catch (e) {trace('Error parsing event param ${paramData.name} - ${eventName}: $e'); finalParams.push(null);}
} }
@@ -196,6 +197,7 @@ typedef EventInfoFile = {
var name:String; var name:String;
var type:String; var type:String;
var defaultValue:Dynamic; var defaultValue:Dynamic;
var ?saveIfDefault:Bool;
}>; }>;
} }
+1 -1
View File
@@ -60,7 +60,7 @@ class PsychParser {
note.time, // TIME note.time, // TIME
note.id, // DATA note.id, // DATA
note.sLen, // SUSTAIN LENGTH 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) || if ((swagSection.mustHitSection && strumLine.type == OPPONENT) ||
@@ -55,9 +55,6 @@ class GlobalScript {
reloading = false; reloading = false;
MusicBeatState.ALLOW_DEV_RELOAD = _lastAllow_Reload; MusicBeatState.ALLOW_DEV_RELOAD = _lastAllow_Reload;
} }
if (PlayerSettings.solo.controls.DEV_CONSOLE)
NativeAPI.allocConsole();
}); });
FlxG.signals.preDraw.add(function() { FlxG.signals.preDraw.add(function() {
call("preDraw"); call("preDraw");
@@ -1,14 +1,8 @@
package funkin.backend.scripting; package funkin.backend.scripting;
#if ALLOW_MULTITHREADING
import sys.thread.Thread;
#end
import hscript.IHScriptCustomBehaviour; import hscript.IHScriptCustomBehaviour;
class MultiThreadedScript implements IFlxDestroyable implements IHScriptCustomBehaviour { class MultiThreadedScript implements IFlxDestroyable implements IHScriptCustomBehaviour {
var thread:#if ALLOW_MULTITHREADING Thread #else Dynamic #end;
/** /**
* Script being ran. * Script being ran.
*/ */
@@ -46,13 +40,6 @@ class MultiThreadedScript implements IFlxDestroyable implements IHScriptCustomBe
script.load(); 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)); __variables = Type.getInstanceFields(Type.getClass(this));
} }
@@ -69,7 +56,7 @@ class MultiThreadedScript implements IFlxDestroyable implements IHScriptCustomBe
public function call(func:String, args:Array<Dynamic>) { public function call(func:String, args:Array<Dynamic>) {
#if ALLOW_MULTITHREADING #if ALLOW_MULTITHREADING
thread.events.run(function() { funkin.backend.utils.ThreadUtil.execAsync(() -> {
callEnded = false; callEnded = false;
returnValue = script.call(func, args); returnValue = script.call(func, args);
callEnded = true; callEnded = true;
@@ -85,13 +72,5 @@ class MultiThreadedScript implements IFlxDestroyable implements IHScriptCustomBe
script.call("destroy"); script.call("destroy");
script.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 #if sys "ZipUtil" => funkin.backend.utils.ZipUtil, #end
"MarkdownUtil" => funkin.backend.utils.MarkdownUtil, "MarkdownUtil" => funkin.backend.utils.MarkdownUtil,
"EngineUtil" => funkin.backend.utils.EngineUtil, "EngineUtil" => funkin.backend.utils.EngineUtil,
"ThreadUtil" => funkin.backend.utils.ThreadUtil,
"MemoryUtil" => funkin.backend.utils.MemoryUtil, "MemoryUtil" => funkin.backend.utils.MemoryUtil,
"BitmapUtil" => funkin.backend.utils.BitmapUtil, "BitmapUtil" => funkin.backend.utils.BitmapUtil,
@@ -401,4 +402,4 @@ class Script extends FlxBasic implements IFlxDestroyable {
* Called when the script is loaded. * Called when the script is loaded.
*/ */
public function onLoad() {} public function onLoad() {}
} }
@@ -1,5 +1,7 @@
package funkin.backend.scripting.events.menu.freeplay; package funkin.backend.scripting.events.menu.freeplay;
import funkin.menus.FreeplayState.FreeplayGameMode;
final class FreeplaySongSelectEvent extends CancellableEvent { final class FreeplaySongSelectEvent extends CancellableEvent {
/** /**
* Song name that is about to be played * Song name that is about to be played
@@ -14,11 +16,26 @@ final class FreeplaySongSelectEvent extends CancellableEvent {
*/ */
public var variant:String; public var variant:String;
/** /**
* Whenever opponent mode is enabled or not. * Used game mode's data.
*/ */
public var opponentMode:Bool; public var gameMode:FreeplayGameMode;
/**
* Whenever coop mode is enabled.
*/ // Backwards compat
public var coopMode:Bool; @: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 unmuteVocals:Bool = true;
@:dox(hide) public var enableCamZooming:Bool = true; @:dox(hide) public var enableCamZooming:Bool = true;
@:dox(hide) public var autoHitLastSustain:Bool = true; @:dox(hide) public var autoHitLastSustain:Bool = true;
@:dox(hide) public var clipSustain:Bool = true;
/** /**
* Whenever a miss should be added. * Whenever a miss should be added.
@@ -145,6 +146,13 @@ final class NoteHitEvent extends CancellableEvent {
deleteNote = true; 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. * 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; if((shader is CustomShader)) scriptName = cast(shader, CustomShader).fileName;
else throw "Missing name for shader script, please provide a scriptName, or use CustomShader"; 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 = Script.create(Paths.script('shaders/$scriptName'));
script.setParent(shader); script.setParent(shader);
script.set("shader", shader); script.set("shader", shader);
+6
View File
@@ -25,6 +25,7 @@ enum Control
CHANGE_MODE; CHANGE_MODE;
//CHEAT; //CHEAT;
SWITCHMOD; SWITCHMOD;
FPS_COUNTER;
// Debugs // Debugs
DEV_ACCESS; DEV_ACCESS;
@@ -161,6 +162,11 @@ class Controls extends FlxActionSet
@:pressed("switchmod") public var SWITCHMOD_HOLD(get, set): Bool; @:pressed("switchmod") public var SWITCHMOD_HOLD(get, set): Bool;
@:justReleased("switchmod") public var SWITCHMOD_R(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 @:devModeOnly
@:gamepad([]) @:gamepad([])
@:justPressed("dev-access") public var DEV_ACCESS(get, set): Bool; @: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). * 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 { class Flags {
public static var overridenFlags:Map<String, Bool> = [];
// -- Codename's Addon Config -- // -- Codename's Addon Config --
@:bypass public static var addonFlags:Map<String, Dynamic> = []; @:bypass public static var addonFlags:Map<String, Dynamic> = [];
public static var CURRENT_API_VERSION:Int = 2;
// -- Codename's Mod Config -- // -- Codename's Mod Config --
public static var MOD_NAME:String = ""; public static var MOD_NAME:String = "";
public static var MOD_DESCRIPTION:String = ""; public static var MOD_DESCRIPTION:String = "";
public static var MOD_AUTHOR: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_DOWNLOAD_LINK:String = "";
public static var MOD_DEPENDENCIES:Array<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_PATH:String = haxe.macro.Compiler.getDefine("SAVE_PATH");
@:lazy public static var SAVE_NAME:String = haxe.macro.Compiler.getDefine("SAVE_NAME"); @: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_NUMBER:Int = GitCommitMacro.commitNumber;
public static var COMMIT_HASH:String = GitCommitMacro.commitHash; public static var COMMIT_HASH:String = GitCommitMacro.commitHash;
public static var COMMIT_MESSAGE:String = 'Commit $COMMIT_NUMBER ($COMMIT_HASH)'; 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 TITLE:String = Application.current.meta.get('name');
@:lazy public static var VERSION:String = Application.current.meta.get('version'); @:lazy public static var VERSION:String = Application.current.meta.get('version');
@@ -125,12 +128,16 @@ class Flags {
@:also(funkin.game.PlayState.opponentMode) @:also(funkin.game.PlayState.opponentMode)
public static var DEFAULT_OPPONENT_MODE:Bool = false; 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_MS_LIMIT:Float = 1500;
public static var DEFAULT_NOTE_SCALE:Float = 0.7; public static var DEFAULT_NOTE_SCALE:Float = 0.7;
#if MODCHARTING_FEATURES #if MODCHARTING_FEATURES
public static var DEFAULT_MODCHART_HOLD_SUBDIVISIONS:Int = 4; public static var DEFAULT_MODCHART_HOLD_SUBDIVISIONS:Int = 4;
#end #end
public static var SUSTAINS_AS_ONE_NOTE:Null<Bool> = null;
@:also(funkin.game.Character.FALLBACK_DEAD_CHARACTER) @:also(funkin.game.Character.FALLBACK_DEAD_CHARACTER)
public static var DEFAULT_GAMEOVER_CHARACTER:String = "bf-dead"; 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_HUD_ZOOM_MULT:Float = 0.03;
public static var DEFAULT_CAM_ZOOM_LERP:Float = 0.05; public static var DEFAULT_CAM_ZOOM_LERP:Float = 0.05;
public static var DEFAULT_HUD_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 // Font configuration
public static var DEFAULT_FONT:String = "vcr.ttf"; public static var DEFAULT_FONT:String = "vcr.ttf";
public static var DEFAULT_FONT_SIZE:Int = 16; public static var DEFAULT_FONT_SIZE:Int = 16;
@@ -277,8 +286,6 @@ class Flags {
@:bypass public static var customFlags:Map<String, String> = []; @:bypass public static var customFlags:Map<String, String> = [];
public static function loadFromData(flags:Map<String, String>, data:String) { public static function loadFromData(flags:Map<String, String>, data:String) {
WINDOW_TITLE_USE_MOD_NAME = false;
if (!(data.length > 0)) return; if (!(data.length > 0)) return;
var res = IniUtil.parseString(data); var res = IniUtil.parseString(data);
@@ -295,26 +302,41 @@ class Flags {
else trace('Invalid section $name'); 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> = []; var flags:Map<String, String> = [];
for(data in datas) { for (data in datas) {
if(data != null) if (data != null)
loadFromData(flags, data); loadFromData(flags, data);
} }
loadPost();
return flags; return flags;
} }
public static function parseFlags(flags:Map<String, String>) { public static function parseFlags(flags:Map<String, String>) {
for(name=>value in flags) var parsed:Bool;
if(!parse(name, value)) for (name => value in flags) switch (name) {
customFlags.set(name, value); 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; Options.modchartingHoldSubdivisions = DEFAULT_MODCHART_HOLD_SUBDIVISIONS;
} }
@@ -365,5 +387,6 @@ class Flags {
parseFlags(flags); parseFlags(flags);
} }
} }
loadPost();
} }
} }
+19 -27
View File
@@ -1,7 +1,5 @@
package funkin.backend.system; package funkin.backend.system;
import sys.io.File;
import sys.FileSystem;
import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond; import flixel.addons.transition.FlxTransitionSprite.GraphicTransTileDiamond;
import flixel.addons.transition.FlxTransitionableState; import flixel.addons.transition.FlxTransitionableState;
import flixel.addons.transition.TransitionData; import flixel.addons.transition.TransitionData;
@@ -9,21 +7,22 @@ import flixel.graphics.FlxGraphic;
import flixel.math.FlxPoint; import flixel.math.FlxPoint;
import flixel.math.FlxRect; import flixel.math.FlxRect;
import flixel.system.ui.FlxSoundTray; import flixel.system.ui.FlxSoundTray;
import funkin.backend.assets.AssetSource;
import funkin.backend.assets.AssetsLibraryList; import funkin.backend.assets.AssetsLibraryList;
import funkin.backend.assets.ModsFolder; 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.framerate.SystemInfo;
import funkin.backend.system.modules.*; import funkin.backend.system.modules.*;
import funkin.backend.utils.ThreadUtil;
import funkin.editors.SaveWarning; import funkin.editors.SaveWarning;
import funkin.options.PlayerSettings;
import openfl.Assets; import openfl.Assets;
import openfl.Lib; import openfl.Lib;
import openfl.display.Sprite; import openfl.display.Sprite;
import openfl.text.TextFormat; import openfl.text.TextFormat;
import openfl.utils.AssetLibrary; import openfl.utils.AssetLibrary;
import sys.FileSystem;
#if ALLOW_MULTITHREADING import sys.io.File;
import sys.thread.Thread;
#end
#if android #if android
import android.content.Context; import android.content.Context;
import android.os.Build; import android.os.Build;
@@ -40,7 +39,7 @@ class Main extends Sprite
public static var scaleMode:FunkinRatioScaleMode; public static var scaleMode:FunkinRatioScaleMode;
#if !mobile #if !mobile
public static var framerateSprite:funkin.backend.system.framerate.Framerate; public static var framerateSprite:Framerate;
#end #end
var gameWidth:Int = 1280; // Width of the game in pixels (might be less / more in actual pixels). 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. // 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() { public static function preInit() {
funkin.backend.utils.NativeAPI.registerAsDPICompatible(); funkin.backend.utils.NativeAPI.registerAsDPICompatible();
funkin.backend.system.CommandLineHandler.parseCommandLine(Sys.args()); 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)); addChild(game = new FunkinGame(gameWidth, gameHeight, MainState, Options.framerate, Options.framerate, skipSplash, startFullscreen));
#if (!mobile && !web) #if (!mobile && !web)
addChild(framerateSprite = new funkin.backend.system.framerate.Framerate()); addChild(framerateSprite = new Framerate());
SystemInfo.init(); SystemInfo.init();
#end #end
} }
@@ -97,16 +92,8 @@ class Main extends Sprite
#end; #end;
public static var startedFromSource:Bool = #if TEST_BUILD true #else false #end; public static var startedFromSource:Bool = #if TEST_BUILD true #else false #end;
// DEPRECATED
private static var __threadCycle:Int = 0; @:dox(hide) public static function execAsync(func:Void->Void) ThreadUtil.execAsync(func);
public static function execAsync(func:Void->Void) {
#if ALLOW_MULTITHREADING
var thread = gameThreads[(__threadCycle++) % gameThreads.length];
thread.events.run(func);
#else
func();
#end
}
private static function getTimer():Int { private static function getTimer():Int {
return time = Lib.getTimer(); return time = Lib.getTimer();
@@ -118,10 +105,6 @@ class Main extends Sprite
MemoryUtil.init(); MemoryUtil.init();
@:privateAccess @:privateAccess
FlxG.game.getTimer = getTimer; FlxG.game.getTimer = getTimer;
#if ALLOW_MULTITHREADING
for(i in 0...4)
gameThreads.push(Thread.createWithEventLoop(function() {Thread.current().events.promise();}));
#end
FunkinCache.init(); FunkinCache.init();
Paths.assetsTree = new AssetsLibraryList(); Paths.assetsTree = new AssetsLibraryList();
@@ -156,6 +139,7 @@ class Main extends Sprite
FlxG.signals.focusGained.add(onFocus); FlxG.signals.focusGained.add(onFocus);
FlxG.signals.preStateSwitch.add(onStateSwitch); FlxG.signals.preStateSwitch.add(onStateSwitch);
FlxG.signals.postStateSwitch.add(onStateSwitchPost); FlxG.signals.postStateSwitch.add(onStateSwitchPost);
FlxG.signals.postUpdate.add(onUpdate);
FlxG.mouse.useSystemCursor = true; FlxG.mouse.useSystemCursor = true;
#if DARK_MODE_WINDOW #if DARK_MODE_WINDOW
@@ -210,6 +194,14 @@ class Main extends Sprite
scaleMode.resetSize(); 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() { private static function onStateSwitchPost() {
// manual asset clearing since base openfl one does'nt clear lime one // manual asset clearing since base openfl one does'nt clear lime one
// does'nt clear bitmaps since flixel fork does it auto // does'nt clear bitmaps since flixel fork does it auto
@@ -8,12 +8,20 @@ import funkin.backend.assets.IModsAssetLibrary;
import funkin.backend.assets.ScriptedAssetLibrary; import funkin.backend.assets.ScriptedAssetLibrary;
class AssetTreeInfo extends FramerateCategory { class AssetTreeInfo extends FramerateCategory {
private var lastUpdateTime:Float = 1;
public function new() { public function new() {
super("Asset Libraries Tree Info"); super("Asset Libraries Tree Info");
} }
public override function __enterFrame(t:Int) { public override function __enterFrame(t:Int) {
if (alpha <= 0.05) return; if (alpha <= 0.05) return;
if ((lastUpdateTime += FlxG.rawElapsed) < 1)
return;
lastUpdateTime = 0;
var text = 'Not initialized yet\n'; var text = 'Not initialized yet\n';
if (Paths.assetsTree != null){ if (Paths.assetsTree != null){
text = ""; text = "";
@@ -53,13 +53,6 @@ class Framerate extends Sprite {
x = 10; x = 10;
y = 2; 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) if (__bitmap == null)
__bitmap = new BitmapData(1, 1, 0xFF000000); __bitmap = new BitmapData(1, 1, 0xFF000000);
@@ -9,6 +9,13 @@ class FramerateCounter extends Sprite {
public var fpsLabel:TextField; public var fpsLabel:TextField;
public var lastFPS:Float = 0; 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() { public function new() {
super(); super();
@@ -27,15 +34,40 @@ class FramerateCounter extends Sprite {
} }
} }
public function reload() {} public function reload() {
lastUpdateTime = 0;
}
public override function __enterFrame(t:Int) { public override function __enterFrame(t:Int) {
if (alpha <= 0.05) return; if (alpha <= 0.05) return;
super.__enterFrame(t); super.__enterFrame(t);
lastFPS = CoolUtil.fpsLerp(lastFPS, FlxG.rawElapsed == 0 ? 0 : (1 / FlxG.rawElapsed), 0.25); frameCount++;
fpsNum.text = Std.string(Math.floor(lastFPS));
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.x = fpsNum.x + fpsNum.width;
fpsLabel.y = (fpsNum.y + fpsNum.height) - fpsLabel.height; fpsLabel.y = (fpsNum.y + fpsNum.height) - fpsLabel.height;
} }
} }
@@ -36,11 +36,21 @@ class MemoryCounter extends Sprite {
if (alpha <= 0.05) return; if (alpha <= 0.05) return;
super.__enterFrame(t); super.__enterFrame(t);
memory = MemoryUtil.currentMemUsage(); final mem = MemoryUtil.currentMemUsage();
if (mem == memory) {
updateLabelPosition();
return;
}
memory = mem;
if (memoryPeak < memory) memoryPeak = memory; if (memoryPeak < memory) memoryPeak = memory;
memoryText.text = CoolUtil.getSizeString(memory); memoryText.text = CoolUtil.getSizeString(memory);
memoryPeakText.text = ' / ${CoolUtil.getSizeString(memoryPeak)}'; 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) if (vRAMBytes == 1000 || vRAMBytes == 1 || vRAMBytes <= 0)
Logs.trace('Unable to grab GPU VRAM', ERROR, RED); Logs.trace('Unable to grab GPU VRAM', ERROR, RED);
else { else {
var vRAMBytesFloat:#if cpp Float64 #else Float #end = vRAMBytes*1024; vRAM = getSizeString(vRAMBytes / 1024);
vRAM = CoolUtil.getSizeString64(vRAMBytesFloat);
} }
} }
} else } else
@@ -155,6 +154,17 @@ class SystemInfo extends FramerateCategory {
if (totalMem != "Unknown" && memType != "Unknown") __formattedSysText += '\nTotal MEM: $totalMem $memType'; 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() { public function new() {
super("System Info"); super("System Info");
} }
@@ -19,7 +19,7 @@ class FlagMacro {
return false; return false;
} }
public static function build():Array<Field> { public static function build(resetCallback:String):Array<Field> {
var fields = Context.getBuildFields(); var fields = Context.getBuildFields();
var clRef = Context.getLocalClass(); var clRef = Context.getLocalClass();
@@ -248,7 +248,10 @@ class FlagMacro {
access: [APublic, AStatic], access: [APublic, AStatic],
kind: FFun({ kind: FFun({
args: [], args: [],
expr: macro $b{resetExprs}, expr: macro {
$b{resetExprs};
$i{resetCallback}();
},
ret: macro: Void ret: macro: Void
}), }),
pos: Context.currentPos(), pos: Context.currentPos(),
@@ -58,6 +58,11 @@ class Macros {
final macroPath = 'funkin.backend.system.macros.Macros'; final macroPath = 'funkin.backend.system.macros.Macros';
Compiler.addMetadata('@:build($macroPath.buildLimeAssetLibrary())', 'lime.utils.AssetLibrary'); 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> { 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.GitHub;
import funkin.backend.system.github.GitHubRelease; import funkin.backend.system.github.GitHubRelease;
#if ALLOW_MULTITHREADING
import funkin.backend.utils.ThreadUtil;
#end
import lime.app.Application; import lime.app.Application;
import sys.thread.Mutex;
import sys.thread.Thread;
import sys.FileSystem; import sys.FileSystem;
import haxe.io.Path; import haxe.io.Path;
#if (target.threaded)
import sys.thread.Thread;
import sys.thread.Mutex;
#end
using funkin.backend.system.github.GitHub; using funkin.backend.system.github.GitHub;
class UpdateUtil { class UpdateUtil {
public static var lastUpdateCheck:Null<UpdateCheckCallback>; public static var lastUpdateCheck:Null<UpdateCheckCallback>;
#if (target.threaded)
private static var __waitCallbacks:Array<UpdateCheckCallback->Void>; private static var __waitCallbacks:Array<UpdateCheckCallback->Void>;
private static var __mutex:Mutex; private static var __mutex:Mutex;
#end
public static function init() { public static function init() {
// deletes old bak file if it exists // deletes old bak file if it exists
@@ -26,26 +34,34 @@ class UpdateUtil {
if (FileSystem.exists(bakPath)) FileSystem.deleteFile(bakPath); if (FileSystem.exists(bakPath)) FileSystem.deleteFile(bakPath);
#end #end
#if (target.threaded)
__waitCallbacks = []; __waitCallbacks = [];
__mutex = new Mutex(); __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) { public static function waitForUpdates(force = false, callback:UpdateCheckCallback->Void, lazy = false) {
#if (target.threaded)
if (__mutex.tryAcquire()) { if (__mutex.tryAcquire()) {
__mutex.release(); __mutex.release();
if (__shouldCheck(lazy) || force) { if (__shouldCheck(lazy) || force) {
__waitCallbacks.push(callback); __waitCallbacks.push(callback);
Thread.create(checkForUpdates.bind(force, false)); #if ALLOW_MULTITHREADING ThreadUtil.execAsync #else Thread.create #end(checkForUpdates.bind(force, false));
} }
else else
callback(lastUpdateCheck); callback(lastUpdateCheck);
} }
else else
__waitCallbacks.push(callback); __waitCallbacks.push(callback);
#else
callback(checkForUpdates(true, false));
#end
} }
public static function checkForUpdates(force = false, lazy = false):UpdateCheckCallback { public static function checkForUpdates(force = false, lazy = false):UpdateCheckCallback {
#if (target.threaded)
var wasAcquired = !__mutex.tryAcquire(); var wasAcquired = !__mutex.tryAcquire();
if (wasAcquired) __mutex.acquire(); if (wasAcquired) __mutex.acquire();
@@ -60,8 +76,19 @@ class UpdateUtil {
FlxG.signals.preUpdate.addOnce(__callWaitCallbacks); FlxG.signals.preUpdate.addOnce(__callWaitCallbacks);
return lastUpdateCheck; 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 { static function __checkForUpdates():UpdateCheckCallback {
var curTag = 'v' + (Flags.VERSION == null ? Application.current.meta.get('version') : Flags.VERSION), error = false; 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) -> { var newUpdates = __doReleaseFiltering(GitHub.getReleases(Flags.REPO_OWNER, Flags.REPO_NAME, (e) -> {
@@ -82,11 +109,6 @@ class UpdateUtil {
static function __shouldCheck(lazy:Bool):Bool static function __shouldCheck(lazy:Bool):Bool
return lastUpdateCheck == null || !lazy && (!lastUpdateCheck.newUpdate || Date.now().getTime() - lastUpdateCheck.date.getTime() > 1800000); 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) { static function __doReleaseFiltering(releases:Array<GitHubRelease>, currentVersionTag:String) {
releases = releases.filterReleases(Options.betaUpdates, false); releases = releases.filterReleases(Options.betaUpdates, false);
if (releases.length <= 0) if (releases.length <= 0)
+20 -20
View File
@@ -20,8 +20,7 @@ typedef AudioAnalyzerCallback = Int->Int->Void;
* An utility that analyze FlxSounds, * An utility that analyze FlxSounds,
* can be used to make waveform or real-time audio visualizer. * 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 * FlxSound.amplitude works so if any case if your only checking for peak of current time, use that instead.
* time, use that instead.
*/ */
final class AudioAnalyzer { final class AudioAnalyzer {
/** /**
@@ -96,9 +95,9 @@ final class AudioAnalyzer {
static var __twiddleImags:Array<Array<Float>> = []; static var __twiddleImags:Array<Array<Float>> = [];
static var __freqReals:Array<Array<Float>> = []; static var __freqReals:Array<Array<Float>> = [];
static var __freqImags:Array<Array<Float>> = []; static var __freqImags:Array<Array<Float>> = [];
static var __freqCalculating:Int = 0;
#if (target.threaded) #if (target.threaded)
static var __mutex:Mutex = new Mutex(); static var __mutex:Mutex = new Mutex();
static var __freqCalculating:Int = 0;
#end #end
/** /**
@@ -296,7 +295,7 @@ final class AudioAnalyzer {
__check(); __check();
} }
function __check() if (sound.buffer != buffer) { function __check() if (sound != null && sound.buffer != buffer) {
byteSize = 1 << ((buffer = sound.buffer).bitsPerSample - 1); byteSize = 1 << ((buffer = sound.buffer).bitsPerSample - 1);
#if (lime_cffi && lime_vorbis) #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). * @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. * @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); 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). * @param frequencies The output for getting the frequencies, to avoid memory leaks (Optional).
* @return Output of frequencies. * @return Output of frequencies.
*/ */
public function getFrequencies(startPos:Float, ?volume:Float, ?frequencies:Array<Float>):Array<Float> 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); 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. * 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; @:privateAccess return sound._source != null && sound._source.__backend != null && sound._source.__backend.playing;
inline function __readStream(startPos:Float, endPos:Float, callback:AudioAnalyzerCallback):Float @:privateAccess { inline function __readStream(startPos:Float, endPos:Float, callback:AudioAnalyzerCallback):Float @:privateAccess {
var backend = sound._source.__backend; final backend = sound._source.__backend;
var i = backend.bufferSizes.length - backend.queuedBuffers;
var time = backend.bufferTimes[i] * 1000;
// 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); var n = Math.floor((endPos - startPos) * __toBits);
if (startPos >= time && startPos < backend.bufferTimes[backend.bufferSizes.length - 1] * 1000) { var i = backend.bufferLengths.length - backend.requestBuffers - 1, time:Float;
var pos = Math.floor((startPos - time) * __toBits), buf = backend.bufferDatas[i].buffer, size = backend.bufferSizes[i], c = 0; 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) { while (pos >= size) {
if (++i >= backend.bufferSizes.length) { if (++i >= backend.bufferLengths.length) break;
n = 0;
break;
}
pos -= size; pos -= size;
buf = backend.bufferDatas[i].buffer; 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; n -= pos % __sampleSize;
while (n > 0) { while (n > 0) {
callback(getByte(buf, pos, __wordSize), c); callback(getByte(buf, pos, __wordSize), c);
if (++c > buffer.channels) c = 0; if (++c > buffer.channels) c = 0;
if ((pos += __wordSize) >= size) { if ((pos += __wordSize) >= size) {
if (++i >= backend.bufferSizes.length) break; if (++i >= backend.bufferLengths.length) break;
pos = 0; pos = 0;
buf = backend.bufferDatas[i].buffer; buf = backend.bufferDatas[i].buffer;
size = backend.bufferSizes[i]; size = backend.bufferLengths[i];
} }
n -= __wordSize; n -= __wordSize;
} }
break;
} }
return endPos - (n / __toBits); return endPos - (n / __toBits);
+1 -1
View File
@@ -1495,4 +1495,4 @@ enum abstract CoolSfx(Int) from Int {
var CHECKED = 3; var CHECKED = 3;
var UNCHECKED = 4; var UNCHECKED = 4;
var WARNING = 5; var WARNING = 5;
} }
+1 -1
View File
@@ -541,4 +541,4 @@ typedef DEvents =
var ?joinGame:String->Void; var ?joinGame:String->Void;
var ?spectateGame:String->Void; var ?spectateGame:String->Void;
var ?joinRequest:DUser->Void; var ?joinRequest:DUser->Void;
} }
@@ -38,7 +38,7 @@ class FunkinParentDisabler extends FlxBasic {
for(c in __cameras) c.paused = true; for(c in __cameras) c.paused = true;
// sounds // 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(); for(s in __sounds) s.pause();
} }
} }
@@ -71,4 +71,4 @@ class FunkinParentDisabler extends FlxBasic {
for(s in __sounds) s.play(); for(s in __sounds) s.play();
} }
} }
} }
+84 -19
View File
@@ -1,32 +1,97 @@
package funkin.backend.utils; 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 { 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. * Creates a new Thread with an error handler.
* @param func Function to execute * @param func Function to execute
* @param autoRestart Whenever the thread should auto restart itself after crashing. * @param autoRestart Whenever the thread should auto restart itself after crashing.
*/ */
public static function createSafe(func:Void->Void, autoRestart:Bool = false) { public static function createSafe(func:Void->Void, autoRestart:Bool = false):Thread {
if (autoRestart) { #if (target.threaded)
return sys.thread.Thread.create(function() { try {
while(true) { return if (autoRestart) Thread.create(() -> {
try { var restart = true;
func(); while (restart) try {
} catch(e) {
trace(e.details());
}
}
});
} else {
return sys.thread.Thread.create(function() {
try {
func(); func();
} catch(e) { restart = false;
trace(e.details());
} }
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("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr); freopen("CONOUT$", "w", stderr);
SetConsoleOutputCP(65001);
SetConsoleCP(65001);
') ')
public static function allocConsole() { public static function allocConsole() {
} }
+2 -1
View File
@@ -41,7 +41,8 @@ class Week {
weekObj.songs.push({ weekObj.songs.push({
name: name, name: name,
hide: song.getAtt('hide').getDefault('false') == "true", hide: song.getAtt('hide').getDefault('false') == "true",
displayName: song.getAtt('displayName') displayName: song.getAtt('displayName'),
variation: song.getAtt('variation')
}); });
} catch(e) { } catch(e) {
Logs.trace('Song at index ${k} in week $weekName cannot contain any other XML nodes in its name.', WARNING); 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 library:ModsFolderLibrary = null;
var goToState:Class<FlxState>; 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. '[Common] # This section applies the \'MOD_\' prefix to the flags so you don\'t have to.
NAME="YOUR MOD NAME HERE" NAME="YOUR MOD NAME HERE"
DESCRIPTION="YOUR MOD DESCRIPTION HERE" DESCRIPTION="YOUR MOD DESCRIPTION HERE"
@@ -17,7 +17,7 @@ AUTHOR="YOU/YOUR TEAM HERE"
VERSION="YOUR MOD\'S VERSION HERE" VERSION="YOUR MOD\'S VERSION HERE"
# DO NOT EDIT!! this is used to check for version compatibility! # 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" DOWNLOAD_LINK="YOUR MOD PAGE LINK HERE"
@@ -104,6 +104,7 @@ class CharacterAnimsWindow extends UIButtonList<CharacterAnimButton> {
if (character.getAnimName() == button.anim) if (character.getAnimName() == button.anim)
@:privateAccess CharacterEditor.instance._animation_down(null); @:privateAccess CharacterEditor.instance._animation_down(null);
character.ghosts.remove(button.anim);
character.removeAnimation(button.anim); character.removeAnimation(button.anim);
if (character.animOffsets.exists(button.anim)) character.animOffsets.remove(button.anim); if (character.animOffsets.exists(button.anim)) character.animOffsets.remove(button.anim);
if (character.animDatas.exists(button.anim)) character.animDatas.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; alpha = 0.4; color = 0xFFAEAEAE;
var flxanim:FlxAnimation = animation._animations.get(anim); 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]; frame = frames.frames[frameIndex];
setAnimOffset(anim); setAnimOffset(anim);
+4 -3
View File
@@ -80,6 +80,7 @@ class Charter extends UIState {
public var metronome:FlxSound; public var metronome:FlxSound;
public var vocals:FlxSound; public var vocals:FlxSound;
public var voicesMuted:Bool = false;
public var quant:Int = 16; public var quant:Int = 16;
public var quants:Array<Int> = [4, 8, 12, 16, 20, 24, 32, 48, 64, 192]; // different quants 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)); t.icon = 1 - Std.int(Math.ceil(FlxG.sound.music.volume));
} }
function _song_mutevoices(t) { function _song_mutevoices(t) {
vocals.volume = vocals.volume > 0 ? 0 : 1; vocals.volume = (voicesMuted = !voicesMuted) ? 0 : 1;
for (strumLine in strumLines.members) strumLine.vocals.volume = strumLine.vocals.volume > 0 ? 0 : 1; for (strumLine in strumLines.members) strumLine.updateVoicesVolume();
t.icon = 1 - Std.int(Math.ceil(vocals.volume)); t.icon = voicesMuted ? 1 : 0;
} }
function _playback_back(_) { function _playback_back(_) {
if (FlxG.sound.music.playing) return; 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 * [0] Event Name
* [1] Event Script * [1] Event Script
* [2] Event JSON Info * [2] Event JSON Info
@@ -276,10 +276,47 @@ class CharterEvent extends UISliceSprite implements ICharterSelectable {
} }
case "Camera Movement": case "Camera Movement":
// camera movement, use health icon var shouldDoArrow:Bool = false;
if(event.params != null) { var icon:Null<FlxSprite> = null;
var icon = getIconFromStrumline(event.params[0]); if (event.params != null) {
if(icon != null) return icon; 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); return generateDefaultIcon(event.name);
@@ -17,7 +17,7 @@ class CharterEventGroup extends FlxTypedGroup<CharterEvent> {
if (autoSort && members.length != __lastSort) if (autoSort && members.length != __lastSort)
sortEvents(); 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 { public override function remove(v:CharterEvent, force:Bool = true):CharterEvent {
@@ -1,5 +1,6 @@
package funkin.editors.charter; package funkin.editors.charter;
import funkin.game.HealthIcon;
import flixel.math.FlxPoint; import flixel.math.FlxPoint;
import funkin.backend.chart.ChartData.ChartMetaData; import funkin.backend.chart.ChartData.ChartMetaData;
import funkin.editors.extra.PropertyButton; import funkin.editors.extra.PropertyButton;
@@ -21,8 +22,7 @@ class CharterMetaDataScreen extends UISubstateWindow {
public var displayNameTextBox:UITextBox; public var displayNameTextBox:UITextBox;
public var iconTextBox:UITextBox; public var iconTextBox:UITextBox;
public var iconSprite:HealthIcon; public var iconSprite:HealthIcon;
public var opponentModeCheckbox:UICheckbox; public var excludedGameModesList:UIAutoCompleteButtonList;
public var coopAllowedCheckbox:UICheckbox;
public var needsVoicesCheckbox:UICheckbox; public var needsVoicesCheckbox:UICheckbox;
public var colorWheel:UIColorwheel; public var colorWheel:UIColorwheel;
public var difficultiesTextBox:UITextBox; public var difficultiesTextBox:UITextBox;
@@ -78,25 +78,29 @@ class CharterMetaDataScreen extends UISubstateWindow {
add(displayNameTextBox); add(displayNameTextBox);
addLabelOn(displayNameTextBox, translate("displayName")); 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 = 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); add(iconTextBox);
addLabelOn(iconTextBox, translate("icon")); addLabelOn(iconTextBox, translate("icon"));
updateIcon(metadata.icon); updateIcon(metadata.icon);
opponentModeCheckbox = new UICheckbox(displayNameTextBox.x, iconTextBox.y + 10 + 32 + 26, translate("opponentMode"), metadata.opponentModeAllowed); add(excludedGameModesList = new UIAutoCompleteButtonList(displayNameTextBox.x, iconTextBox.y + 62, Std.int(displayNameTextBox.bWidth), 100, "", [for (mode in funkin.menus.FreeplayState.FreeplayGameMode.get()) mode.modeID]));
add(opponentModeCheckbox); excludedGameModesList.frames = Paths.getFrames('editors/ui/inputbox');
addLabelOn(opponentModeCheckbox, translate("modesAllowed")); excludedGameModesList.cameraSpacing = 0;
addLabelOn(excludedGameModesList, "Excluded Game Modes (IDs)");
coopAllowedCheckbox = new UICheckbox(opponentModeCheckbox.x + 150 + 26, opponentModeCheckbox.y, translate("coopAllowed"), metadata.coopAllowed); for (mode in metadata.excludedGameModes)
add(coopAllowedCheckbox); excludedGameModesList.add(new UIAutoCompleteButtonList.UIAutoCompleteButton(0, 0, excludedGameModesList, excludedGameModesList.suggestItems, mode));
colorWheel = new UIColorwheel(iconTextBox.x, coopAllowedCheckbox.y, metadata.color); colorWheel = new UIColorwheel(iconTextBox.x, coopAllowedCheckbox.y, metadata.color);
add(colorWheel); add(colorWheel);
addLabelOn(colorWheel, translate("color")); 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); add(difficultiesTextBox);
addLabelOn(difficultiesTextBox, translate("difficulties")); addLabelOn(difficultiesTextBox, translate("difficulties"));
@@ -111,9 +115,6 @@ class CharterMetaDataScreen extends UISubstateWindow {
add(customPropertiesButtonList); add(customPropertiesButtonList);
addLabelOn(customPropertiesButtonList, translate("customValues")); 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() { saveButton = new UIButton(windowSpr.x + windowSpr.bWidth - 20, windowSpr.y + windowSpr.bHeight - 20, TU.translate("editor.saveClose"), function() {
saveMeta(); saveMeta();
close(); close();
@@ -161,8 +162,7 @@ class CharterMetaDataScreen extends UISubstateWindow {
meta.displayName = displayNameTextBox.label.text; meta.displayName = displayNameTextBox.label.text;
meta.icon = iconTextBox.label.text; meta.icon = iconTextBox.label.text;
meta.color = colorWheel.curColor; meta.color = colorWheel.curColor;
meta.opponentModeAllowed = opponentModeCheckbox.checked; meta.excludedGameModes = [for (button in excludedGameModesList.buttons.members) button.textBox.label.text.trim()],
meta.coopAllowed = coopAllowedCheckbox.checked;
meta.difficulties = [for (diff in difficultiesTextBox.label.text.split(",")) diff.trim()]; meta.difficulties = [for (diff in difficultiesTextBox.label.text.split(",")) diff.trim()];
meta.customValues = customVals; 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')); 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)); 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))); for (v in s.variants) if (s.metas.get(v) != null) screen.add(makeVariationOption(s.metas.get(v)));
#if sys #if sys
@@ -48,13 +48,13 @@ class CharterSelectionScreen extends EditorTreeMenuScreen {
parent.openSubState(new ChartCreationScreen(saveChart)); parent.openSubState(new ChartCreationScreen(saveChart));
})); }));
if (!first) screen.curSelected = 1; if (!first) screen.curSelected = (s.difficulties.length + s.variants.length) > 0 ? 1 : 0;
else { else {
cast(screen.members[0], NewOption).itemHeight = 120; cast(screen.members[0], NewOption).itemHeight = 120;
screen.insert(1, new NewOption(getID('newVariation'), getID('newVariationDesc'), () -> { screen.insert(1, new NewOption(getID('newVariation'), getID('newVariationDesc'), () -> {
parent.openSubState(new VariationCreationScreen(s, saveSong)); parent.openSubState(new VariationCreationScreen(s, saveSong));
})); }));
screen.curSelected = 2; screen.curSelected = (s.difficulties.length + s.variants.length) > 0 ? 2 : 1;
} }
#end #end
@@ -22,6 +22,7 @@ class CharterStrumline extends UISprite {
public var curMenu:UIContextMenu = null; public var curMenu:UIContextMenu = null;
public var vocals:FlxSound; public var vocals:FlxSound;
public var voicesMuted:Bool = false;
public var keyCount:Int = 4; public var keyCount:Int = 4;
public var startingID(get, null):Int; public var startingID(get, null):Int;
@@ -147,6 +148,10 @@ class CharterStrumline extends UISprite {
} }
vocals.group = FlxG.sound.defaultMusicGroup; vocals.group = FlxG.sound.defaultMusicGroup;
} }
public function updateVoicesVolume() {
vocals.volume = (voicesMuted || (Charter.instance?.voicesMuted ?? false)) ? 0 : 1;
}
} }
class CharterStrumlineOptions extends UITopMenuButton { class CharterStrumlineOptions extends UITopMenuButton {
@@ -176,9 +181,10 @@ class CharterStrumlineOptions extends UITopMenuButton {
{ {
label: TU.translate("charter.strumLine.muteVocals"), label: TU.translate("charter.strumLine.muteVocals"),
onSelect: function(_) { 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, null,
{ {
@@ -287,4 +287,4 @@ class CharacterButton extends UIButton {
super.update(elapsed); super.update(elapsed);
} }
} }
@@ -1,5 +1,6 @@
package funkin.editors.charter; package funkin.editors.charter;
import funkin.game.HealthIcon;
import flixel.group.FlxGroup; import flixel.group.FlxGroup;
import flixel.text.FlxText.FlxTextFormat; import flixel.text.FlxText.FlxTextFormat;
import flixel.text.FlxText.FlxTextFormatMarkerPair; import flixel.text.FlxText.FlxTextFormatMarkerPair;
@@ -37,8 +38,7 @@ class SongCreationScreen extends UISubstateWindow {
public var displayNameTextBox:UITextBox; public var displayNameTextBox:UITextBox;
public var iconTextBox:UITextBox; public var iconTextBox:UITextBox;
public var iconSprite:HealthIcon; public var iconSprite:HealthIcon;
public var opponentModeCheckbox:UICheckbox; public var excludedGameModesList:UIAutoCompleteButtonList;
public var coopAllowedCheckbox:UICheckbox;
public var colorWheel:UIColorwheel; public var colorWheel:UIColorwheel;
public var difficultiesTextBox:UITextBox; public var difficultiesTextBox:UITextBox;
@@ -166,24 +166,19 @@ class SongCreationScreen extends UISubstateWindow {
updateIcon("face"); updateIcon("face");
opponentModeCheckbox = new UICheckbox(displayNameTextBox.x, iconTextBox.y + 10 + 32 + 26, translateMeta("opponentMode"), true); 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]));
menuDataGroup.add(opponentModeCheckbox); excludedGameModesList.frames = Paths.getFrames('editors/ui/inputbox');
addLabelOn(opponentModeCheckbox, translateMeta("modesAllowed")); excludedGameModesList.cameraSpacing = 0;
addLabelOn(excludedGameModesList, "Excluded Game Modes (IDs)");
coopAllowedCheckbox = new UICheckbox(opponentModeCheckbox.x + 150 + 26, opponentModeCheckbox.y, translateMeta("coopAllowed"), true); colorWheel = new UIColorwheel(iconTextBox.x, excludedGameModesList.y, 0xFFFFFF);
menuDataGroup.add(coopAllowedCheckbox);
colorWheel = new UIColorwheel(iconTextBox.x, coopAllowedCheckbox.y, 0xFFFFFF);
menuDataGroup.add(colorWheel); menuDataGroup.add(colorWheel);
addLabelOn(colorWheel, translateMeta("color")); 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); menuDataGroup.add(difficultiesTextBox);
addLabelOn(difficultiesTextBox, translateMeta("difficulties")); addLabelOn(difficultiesTextBox, translateMeta("difficulties"));
for (checkbox in [opponentModeCheckbox, coopAllowedCheckbox])
{checkbox.y += 6; checkbox.x += 4;}
var menuTitle:UIText; var menuTitle:UIText;
selectFormatGroup.add(menuTitle = new UIText(windowSpr.x + 20, windowSpr.y + 30 + 16, 0, translate("importSource"), 28)); 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, displayName: displayNameTextBox.label.text,
icon: iconTextBox.label.text, icon: iconTextBox.label.text,
color: colorWheel.curColor, color: colorWheel.curColor,
opponentModeAllowed: opponentModeCheckbox.checked, excludedGameModes: [for (button in excludedGameModesList.buttons.members) button.textBox.label.text.trim()],
coopAllowed: coopAllowedCheckbox.checked, difficulties: [for (diff in difficultiesTextBox.label.text.split(",")) if (diff.length > 0) diff.trim()]
difficulties: [for (diff in difficultiesTextBox.label.text.split(",")) diff.trim()]
}); });
if (onSave != null) onSave({ 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() { public function swapLeftRightAnimations() {
CoolUtil.switchAnimFrames(animation.getByName('singRIGHT'), animation.getByName('singLEFT')); // Find all "alternate" poses
CoolUtil.switchAnimFrames(animation.getByName('singRIGHTmiss'), animation.getByName('singLEFTmiss')); 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'); for (i in variants) {
switchOffset('singLEFTmiss', 'singRIGHTmiss'); CoolUtil.switchAnimFrames(animation.getByName('singRIGHT$i'), animation.getByName('singLEFT$i'));
switchOffset('singLEFT$i', 'singRIGHT$i');
}
__swappedLeftRightAnims = true; __swappedLeftRightAnims = true;
} }
@@ -580,4 +588,4 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
list.push(CoolUtil.getFilename(path)); list.push(CoolUtil.getFilename(path));
return list; return list;
} }
} }
+15 -2
View File
@@ -60,6 +60,15 @@ class Note extends FlxSprite
*/ */
public var sustainParent:Null<Note>; 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. * Name of the splash.
*/ */
@@ -74,6 +83,7 @@ class Note extends FlxSprite
public var sustainLength:Float = 0; public var sustainLength:Float = 0;
public var isSustainNote:Bool = false; public var isSustainNote:Bool = false;
public var noSustainClip:Bool = false;
public var flipSustain:Bool = true; public var flipSustain:Bool = true;
public var noteTypeID:Int = 0; public var noteTypeID:Int = 0;
@@ -104,6 +114,8 @@ class Note extends FlxSprite
public var animSuffix:String = null; public var animSuffix:String = null;
// Deprecated?
@:dox(hide) public var tripTimer:Float = 0; // ranges from 0 to 1
private static function customTypePathExists(path:String) { private static function customTypePathExists(path:String) {
if (__customNoteTypeExists.exists(path)) if (__customNoteTypeExists.exists(path))
@@ -211,6 +223,7 @@ class Note extends FlxSprite
public var lastScrollSpeed:Null<Float> = null; public var lastScrollSpeed:Null<Float> = null;
public var gapFix:SingleOrFloat = 0; public var gapFix:SingleOrFloat = 0;
public var useAntialiasingFix(get, set):Bool; public var useAntialiasingFix(get, set):Bool;
inline function set_useAntialiasingFix(v:Bool) { inline function set_useAntialiasingFix(v:Bool) {
if(v != useAntialiasingFix) { if(v != useAntialiasingFix) {
gapFix = v ? 1 : 0; gapFix = v ? 1 : 0;
@@ -297,8 +310,8 @@ class Note extends FlxSprite
updateSustainClip(); updateSustainClip();
} }
public function updateSustainClip() if (wasGoodHit) { public function updateSustainClip() if (wasGoodHit && !noSustainClip) {
var t = FlxMath.bound((Conductor.songPosition - strumTime) / height * 0.45 * lastScrollSpeed, 0, 1); var t = CoolUtil.bound((Conductor.songPosition - strumTime) / height * 0.45 * lastScrollSpeed, 0, 1);
var rect = clipRect == null ? FlxRect.get() : clipRect; var rect = clipRect == null ? FlxRect.get() : clipRect;
clipRect = rect.set(0, frameHeight * t, frameWidth, frameHeight * (1 - t)); 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) { public override function update(elapsed:Float) {
i = length-1; i = length-1;
__loopSprite = null; __loopSprite = null;
__time = __getSongPos(); __time = __getSongPos() + limit;
while(i >= 0) { while(i >= 0) {
__loopSprite = members[i--]; __loopSprite = members[i--];
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.active) { if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.active) continue;
continue; if (__loopSprite.strumTime > __time) break;
}
if (__loopSprite.strumTime - __time > limit)
break;
__loopSprite.update(elapsed); __loopSprite.update(elapsed);
} }
} }
@@ -74,12 +71,11 @@ class NoteGroup extends FlxTypedGroup<Note> {
i = length-1; i = length-1;
__loopSprite = null; __loopSprite = null;
__time = __getSongPos(); __time = __getSongPos() + limit;
while(i >= 0) { while(i >= 0) {
__loopSprite = members[i--]; __loopSprite = members[i--];
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.visible) if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.visible) continue;
continue; if (__loopSprite.strumTime > __time) break;
if (__loopSprite.strumTime - __time > limit) break;
__loopSprite.draw(); __loopSprite.draw();
} }
__currentlyLooping = oldCur; __currentlyLooping = oldCur;
@@ -97,16 +93,15 @@ class NoteGroup extends FlxTypedGroup<Note> {
public override function forEach(noteFunc:Note->Void, recursive:Bool = false) { public override function forEach(noteFunc:Note->Void, recursive:Bool = false) {
i = length-1; i = length-1;
__loopSprite = null; __loopSprite = null;
__time = __getSongPos(); __time = __getSongPos() + limit;
var oldCur = __currentlyLooping; var oldCur = __currentlyLooping;
__currentlyLooping = true; __currentlyLooping = true;
while(i >= 0) { while(i >= 0) {
__loopSprite = members[i--]; __loopSprite = members[i--];
if (__loopSprite == null || !__loopSprite.exists) if (__loopSprite == null || !__loopSprite.exists) continue;
continue; if (__loopSprite.strumTime > __time) break;
if (__loopSprite.strumTime - __time > limit) break;
noteFunc(__loopSprite); noteFunc(__loopSprite);
} }
__currentlyLooping = oldCur; __currentlyLooping = oldCur;
+96 -52
View File
@@ -29,6 +29,8 @@ import funkin.editors.charter.Charter;
import funkin.editors.charter.CharterSelection; import funkin.editors.charter.CharterSelection;
import funkin.game.SplashHandler; import funkin.game.SplashHandler;
import funkin.game.cutscenes.*; import funkin.game.cutscenes.*;
import funkin.game.scoring.*;
import funkin.game.scoring.RatingManager.Rating;
import funkin.menus.*; import funkin.menus.*;
import funkin.backend.week.WeekData; import funkin.backend.week.WeekData;
import funkin.savedata.FunkinSave; import funkin.savedata.FunkinSave;
@@ -330,6 +332,10 @@ class PlayState extends MusicBeatState
* The total accuracy amount. * The total accuracy amount.
*/ */
public var totalAccuracyAmount:Float = 0; public var totalAccuracyAmount:Float = 0;
/**
* Tracks how much of each rating was received.
*/
public var hits:Map<String, Int> = [];
/** /**
* FunkinText that shows your score. * FunkinText that shows your score.
@@ -362,6 +368,11 @@ class PlayState extends MusicBeatState
public static var campaignAccuracyTotal:Float = 0; public static var campaignAccuracyTotal:Float = 0;
public static var campaignAccuracyCount: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. * Camera zoom at which the game lerps to.
*/ */
@@ -529,6 +540,10 @@ class PlayState extends MusicBeatState
* Group containing all of the combo sprites. * Group containing all of the combo sprites.
*/ */
public var comboGroup:RotatingSpriteGroup; 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. * Whenever the Rating sprites should be shown or not.
* *
@@ -551,10 +566,11 @@ class PlayState extends MusicBeatState
public var noteTypesArray:Array<String> = [null]; public var noteTypesArray:Array<String> = [null];
/** /**
* Hit window, in milliseconds. Defaults to 250ms unless changed in options. * Hit window, in milliseconds. A Legacy CNE Hit window configuration,
* Base game hit window is 175ms. * 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 _startCountdownCalled:Bool = false;
@:noCompletion @:dox(hide) private var _endSongCalled: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"; 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 // Checks if cutscene files exists
var cutscenePath = Paths.script('songs/${SONG.meta.name}/cutscene'); var cutscenePath = Paths.script('songs/${SONG.meta.name}/cutscene');
var endCutscenePath = Paths.script('songs/${SONG.meta.name}/cutscene-end'); var endCutscenePath = Paths.script('songs/${SONG.meta.name}/cutscene-end');
@@ -1237,12 +1255,13 @@ class PlayState extends MusicBeatState
} }
@:dox(hide) @:dox(hide)
function resyncVocals():Void inline function resyncVocals():Void
{ {
var time = Conductor.songPosition + Conductor.songOffset; final time = Conductor.songPosition + Conductor.songOffset;
for (strumLine in strumLines.members) strumLine.vocals.play(true, time);
vocals.play(true, time);
if (!inst.playing) inst.play(true, time); if (!inst.playing) inst.play(true, time);
vocals.play(true, time);
for (strumLine in strumLines.members) strumLine.vocals.play(true, time);
gameAndCharsCall("onVocalsResync"); gameAndCharsCall("onVocalsResync");
} }
@@ -1401,13 +1420,12 @@ class PlayState extends MusicBeatState
else if (FlxG.sound.music != null && (__vocalSyncTimer -= elapsed) < 0) { else if (FlxG.sound.music != null && (__vocalSyncTimer -= elapsed) < 0) {
__vocalSyncTimer = 1; __vocalSyncTimer = 1;
var instTime = FlxG.sound.music.getActualTime(); final instTime = FlxG.sound.music.getActualTime();
var isOffsync:Bool = vocals.loaded && Math.abs(instTime - vocals.getActualTime()) > 100; var isOffsync:Bool = vocals.loaded && Math.abs(instTime - vocals.getActualTime()) > 12;
if (!isOffsync) { if (!isOffsync)
for (strumLine in strumLines.members) { for (strumLine in strumLines.members)
if ((isOffsync = strumLine.vocals.loaded && Math.abs(instTime - strumLine.vocals.getActualTime()) > 100)) break; if ((isOffsync = strumLine.vocals.loaded && Math.abs(instTime - strumLine.vocals.getActualTime()) > 12))
} break;
}
if (isOffsync) resyncVocals(); if (isOffsync) resyncVocals();
} }
@@ -1587,11 +1605,13 @@ class PlayState extends MusicBeatState
var camera:FlxCamera = event.params[1] == "camHUD" ? camHUD : camGame; var camera:FlxCamera = event.params[1] == "camHUD" ? camHUD : camGame;
camera.zoom += event.params[0]; camera.zoom += event.params[0];
case "Camera Bop": case "Camera Bop":
if (useCamZoomMult) { if (Options.camZoomOnBeat) {
camZoomingMult += event.params[0]; if (useCamZoomMult) {
} else { camZoomingMult += event.params[0];
FlxG.camera.zoom += event.params[0] * camZoomingStrength; } else {
camHUD.zoom += event.params[0] * camZoomingStrength; FlxG.camera.zoom += event.params[0] * camZoomingStrength;
camHUD.zoom += event.params[0] * camZoomingStrength;
}
} }
case "Camera Zoom": case "Camera Zoom":
var cam = event.params[2] == "camHUD" ? camHUD : camGame; var cam = event.params[2] == "camHUD" ? camHUD : camGame;
@@ -1722,7 +1742,7 @@ class PlayState extends MusicBeatState
score: songScore, score: songScore,
misses: misses, misses: misses,
accuracy: accuracy, accuracy: accuracy,
hits: [], hits: hits,
date: Date.now().toString() date: Date.now().toString()
}, getSongChanges()); }, getSongChanges());
#end #end
@@ -1749,6 +1769,7 @@ class PlayState extends MusicBeatState
campaignMisses += misses; campaignMisses += misses;
campaignAccuracyTotal += accuracy; campaignAccuracyTotal += accuracy;
campaignAccuracyCount++; campaignAccuracyCount++;
for (k => v in hits) campaignHits[k] += v;
storyPlaylist.shift(); storyPlaylist.shift();
storyVariations.shift(); storyVariations.shift();
@@ -1762,7 +1783,7 @@ class PlayState extends MusicBeatState
score: campaignScore, score: campaignScore,
misses: campaignMisses, misses: campaignMisses,
accuracy: campaignAccuracy, accuracy: campaignAccuracy,
hits: [], hits: campaignHits,
date: Date.now().toString() date: Date.now().toString()
}); });
#end #end
@@ -1812,11 +1833,25 @@ class PlayState extends MusicBeatState
*/ */
public function noteMiss(strumLine:StrumLine, note:Note, ?direction:Int, ?player:Int):Void public function noteMiss(strumLine:StrumLine, note:Note, ?direction:Int, ?player:Int):Void
{ {
var playerID:Null<Int> = note == null ? player : strumLines.members.indexOf(strumLine); var hasNote:Bool = note != null;
var directionID:Null<Int> = note == null ? direction : note.strumID; 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; 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); strumLine.onMiss.dispatch(event);
if (event.cancelled) { if (event.cancelled) {
gameAndCharsEvent("onPostPlayerMiss", event); 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); strumLine.deleteNote(note);
gameAndCharsEvent("onPostPlayerMiss", event); gameAndCharsEvent("onPostPlayerMiss", event);
@@ -1876,43 +1911,49 @@ class PlayState extends MusicBeatState
note.wasGoodHit = true; note.wasGoodHit = true;
/** var noteDiff = Math.abs(Conductor.songPosition - note.strumTime), rating:Rating;
* CALCULATES RATING if (!Flags.USE_LEGACY_TIMING) rating = ratingManager.judgeNote(noteDiff);
*/ else {
var noteDiff = Math.abs(Conductor.songPosition - note.strumTime); (rating = _legacyRating).splash = false;
var daRating:String = "sick"; if (noteDiff > hitWindow * 0.9) {
var score:Int = 300; rating.window = hitWindow;
var accuracy:Float = 1; rating.name = "shit";
rating.score = 50;
if (noteDiff > hitWindow * 0.9) rating.accuracy = 0.25;
{ }
daRating = 'shit'; else if (noteDiff > hitWindow * 0.75) {
score = 50; rating.window = hitWindow * 0.9;
accuracy = 0.25; rating.name = "bad";
} rating.score = 100;
else if (noteDiff > hitWindow * 0.75) rating.accuracy = 0.45;
{ }
daRating = 'bad'; else if (noteDiff > hitWindow * 0.2) {
score = 100; rating.window = hitWindow * 0.75;
accuracy = 0.45; rating.name = "good";
} rating.score = 200;
else if (noteDiff > hitWindow * 0.2) rating.accuracy = 0.75;
{ }
daRating = 'good'; else {
score = 200; rating.window = hitWindow * 0.2;
accuracy = 0.75; rating.name = "sick";
rating.score = 300;
rating.accuracy = 1;
rating.splash = true;
}
} }
var event:NoteHitEvent; var event:NoteHitEvent;
if (strumLine != null && !strumLine.cpu) 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 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.deleteNote = !note.isSustainNote; // work around, to allow sustain notes to be deleted
event = scripts.event(strumLine != null && !strumLine.cpu ? "onPlayerHit" : "onDadHit", event); event = scripts.event(strumLine != null && !strumLine.cpu ? "onPlayerHit" : "onDadHit", event);
strumLine.onHit.dispatch(event); strumLine.onHit.dispatch(event);
gameAndCharsEvent("onNoteHit", event); gameAndCharsEvent("onNoteHit", event);
note.noSustainClip = !event.clipSustain;
if (!event.cancelled) { if (!event.cancelled) {
if (!note.isSustainNote) { if (!note.isSustainNote) {
if (event.countScore) songScore += event.score; if (event.countScore) songScore += event.score;
@@ -1930,6 +1971,7 @@ class PlayState extends MusicBeatState
displayRating(event.rating, event); displayRating(event.rating, event);
ratingNum += 1; ratingNum += 1;
} }
if (event.player) hits[rating.name] += 1;
} }
if (strumLine != null) strumLine.addHealth(event.healthGain); if (strumLine != null) strumLine.addHealth(event.healthGain);
@@ -1958,6 +2000,7 @@ class PlayState extends MusicBeatState
} }
if (event.deleteNote) strumLine.deleteNote(note); if (event.deleteNote) strumLine.deleteNote(note);
else note.updateSustainClip();
gameAndCharsEvent("onPostNoteHit", event); gameAndCharsEvent("onPostNoteHit", event);
} }
@@ -2165,6 +2208,7 @@ class PlayState extends MusicBeatState
campaignMisses = 0; campaignMisses = 0;
campaignAccuracyTotal = 0; campaignAccuracyTotal = 0;
campaignAccuracyCount = 0; campaignAccuracyCount = 0;
campaignHits = [];
chartingMode = coopMode = opponentMode = false; chartingMode = coopMode = opponentMode = false;
__loadSong(storyPlaylist[0], difficulty, storyVariations[0]); __loadSong(storyPlaylist[0], difficulty, storyVariations[0]);
} }
+8 -8
View File
@@ -121,7 +121,7 @@ class Strum extends FlxSprite {
public override function update(elapsed:Float) { public override function update(elapsed:Float) {
super.update(elapsed); super.update(elapsed);
if (cpu) { if (cpu) {
if (lastHit + (Conductor.crochet / 2) < Conductor.songPosition && getAnim() == "confirm") { if (lastHit + (Conductor.crochet * 0.5) < Conductor.songPosition && getAnim() == "confirm") {
playAnim("static"); 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 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. * Updates the position of a note.
@@ -162,16 +162,16 @@ class Strum extends FlxSprite {
if (shouldX || shouldY) { if (shouldX || shouldY) {
if (daNote.strumRelativePos) { if (daNote.strumRelativePos) {
if (shouldX) daNote.x = (this.width - daNote.width) / 2; if (shouldX) daNote.x = (this.width - daNote.width) * 0.5;
if (shouldY) { if (shouldY) {
daNote.y = (daNote.strumTime - Conductor.songPosition) * (0.45 * CoolUtil.quantize(getScrollSpeed(daNote), 100)); daNote.y = (daNote.strumTime - Conductor.songPosition) * (0.45 * getScrollSpeed(daNote));
if (daNote.isSustainNote) daNote.y += N_WIDTHDIV2; if (daNote.isSustainNote) daNote.y += height * 0.5;
} }
} else { } 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); 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) { if (Std.int(daNote.__noteAngle % 360) != 0) {
var noteAngleCos = FlxMath.fastCos(daNote.__noteAngle / PIX180); var noteAngleCos = FlxMath.fastCos(daNote.__noteAngle / PIX180);
@@ -257,4 +257,4 @@ class Strum extends FlxSprite {
public inline function getAnim() { public inline function getAnim() {
return animation.name; return animation.name;
} }
} }
+51 -38
View File
@@ -161,6 +161,9 @@ class StrumLine extends FlxTypedGroup<Strum> {
curLen = Math.min(len, Conductor.stepCrochet); curLen = Math.min(len, Conductor.stepCrochet);
notes.members[total-(il++)-1] = prev = new Note(this, note, true, curLen, note.sLen - len, prev); notes.members[total-(il++)-1] = prev = new Note(this, note, true, curLen, note.sLen - len, prev);
len -= curLen; 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.cancelled) return;
if (__updateNote_event.__updateHitWindow) { 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.canBeHit = (daNote.strumTime > __updateNote_songPos - (hitWindow * daNote.latePressWindow)
&& daNote.strumTime < __updateNote_songPos + (hitWindow * daNote.earlyPressWindow)); && daNote.strumTime < __updateNote_songPos + (hitWindow * daNote.earlyPressWindow));
@@ -221,9 +224,10 @@ class StrumLine extends FlxTypedGroup<Strum> {
daNote.tooLate = true; 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); deleteNote(daNote);
return; return;
} }
@@ -236,29 +240,38 @@ class StrumLine extends FlxTypedGroup<Strum> {
if (__updateNote_event.strum == null) return; if (__updateNote_event.strum == null) return;
if (__updateNote_event.__reposNote) __updateNote_event.strum.updateNotePosition(daNote); if (__updateNote_event.__reposNote) __updateNote_event.strum.updateNotePosition(daNote);
if (daNote.isSustainNote)
if (daNote.isSustainNote) {
daNote.updateSustain(__updateNote_event.strum); daNote.updateSustain(__updateNote_event.strum);
}
} }
var __funcsToExec:Array<Note->Void> = [];
var __pressed:Array<Bool> = []; var __pressed:Array<Bool> = [];
var __justPressed:Array<Bool> = []; var __justPressed:Array<Bool> = [];
var __justReleased:Array<Bool> = []; var __justReleased:Array<Bool> = [];
var __notePerStrum:Array<Note> = []; var __notePerStrum:Array<Note> = [];
function __inputProcessPressed(note: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); PlayState.instance.goodNoteHit(this, note);
note.updateSustainClip();
} }
} }
function __inputProcessJustPressed(note:Note) { function __inputProcessJustPressed(note:Note) {
if (__justPressed[note.strumID] && !note.isSustainNote && !note.wasGoodHit && note.canBeHit) { if (__justPressed[note.strumID] && !note.isSustainNote && !note.wasGoodHit && note.canBeHit) {
if (__notePerStrum[note.strumID] == null) __notePerStrum[note.strumID] = note; var cur = __notePerStrum[note.strumID];
else if (Math.abs(__notePerStrum[note.strumID].strumTime - note.strumTime) <= 2) deleteNote(note); var songPos = __updateNote_songPos;
else if (note.strumTime < __notePerStrum[note.strumID].strumTime) __notePerStrum[note.strumID] = note;
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; if (cpu) return;
__funcsToExec.clear(); if (__pressed.length != members.length) {
__pressed.clear(); __pressed.resize(members.length);
__justPressed.clear(); __justPressed.resize(members.length);
__justReleased.clear(); __justReleased.resize(members.length);
}
for(s in members) { for (i in 0...members.length) {
__pressed.push(s.__getPressed(this)); __pressed[i] = members[i].__getPressed(this);
__justPressed.push(s.__getJustPressed(this)); __justPressed[i] = members[i].__getJustPressed(this);
__justReleased.push(s.__getJustReleased(this)); __justReleased[i] = members[i].__getJustReleased(this);
} }
var event = EventManager.get(InputSystemEvent).recycle(__pressed, __justPressed, __justReleased, this, id); 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, []); __justPressed = CoolUtil.getDefault(event.justPressed, []);
__justReleased = CoolUtil.getDefault(event.justReleased, []); __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)) { 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) if (c.lastAnimContext != DANCE)
c.__lockAnimThisFrame = true; 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) { 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"); PlayState.instance.gameAndCharsCall("onPostInputUpdate");
} }
@@ -411,6 +422,8 @@ class StrumLine extends FlxTypedGroup<Strum> {
var event:SimpleNoteEvent = EventManager.get(SimpleNoteEvent).recycle(note); var event:SimpleNoteEvent = EventManager.get(SimpleNoteEvent).recycle(note);
onNoteDelete.dispatch(event); onNoteDelete.dispatch(event);
if (!event.cancelled) { if (!event.cancelled) {
if (note.isSustainNote && note.sustainParent != null && note.sustainParent.tailCount > 0)
note.sustainParent.tailCount--;
note.kill(); note.kill();
notes.remove(note, true); notes.remove(note, true);
note.destroy(); note.destroy();
@@ -95,18 +95,20 @@ class ScriptedCutscene extends Cutscene {
script.call("stepHit", [curStep]); script.call("stepHit", [curStep]);
} }
public override function openSubState(sub:FlxSubState) public override function openSubState(subState:FlxSubState)
{ {
var event = EventManager.get(StateEvent).recycle(sub); var event = EventManager.get(StateEvent).recycle(subState);
script.call("onSubstateClose", [event]); 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 : sub); if (!event.cancelled)
super.openSubState(event.substate is FlxSubState ? cast event.substate : subState);
} }
public override function closeSubState() public override function closeSubState()
{ {
var event = EventManager.get(StateEvent).recycle(subState); var event = EventManager.get(StateEvent).recycle(subState);
script.call("onSubstateOpen", [event]); script.call(Flags.MOD_API_VERSION <= 1 ? "onSubstateOpen" /*Remove this entirely*/ : "onCloseSubState", [event]);
if(!event.cancelled) super.closeSubState(); if (!event.cancelled)
super.closeSubState();
} }
public override function destroy() { public override function destroy() {
@@ -60,7 +60,9 @@ class VideoCutscene extends Cutscene {
add(video = new FlxVideoSprite()); add(video = new FlxVideoSprite());
video.antialiasing = true; 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 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.onEndReached.add(close);
video.bitmap.onFormatSetup.add(function() if (video.bitmap != null && video.bitmap.bitmapData != null) { video.bitmap.onFormatSetup.add(function() if (video.bitmap != null && video.bitmap.bitmapData != null) {
final width = video.bitmap.bitmapData.width; 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() { @:dox(hide) override public function onFocus() {
if(FlxG.autoPause && !paused) video.resume(); if(FlxG.autoPause && !paused) video.resume();
super.onFocus(); super.onFocus();
@@ -214,6 +217,7 @@ class VideoCutscene extends Cutscene {
if(FlxG.autoPause && !paused) video.pause(); if(FlxG.autoPause && !paused) video.pause();
super.onFocusLost(); super.onFocusLost();
} }
#end
public override function pauseCutscene() { public override function pauseCutscene() {
video.pause(); 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;
}
+161 -66
View File
@@ -9,6 +9,7 @@ import funkin.backend.scripting.events.menu.freeplay.*;
import funkin.backend.system.Conductor; import funkin.backend.system.Conductor;
import funkin.game.HealthIcon; import funkin.game.HealthIcon;
import funkin.savedata.FunkinSave; import funkin.savedata.FunkinSave;
import haxe.io.Path;
using StringTools; using StringTools;
@@ -34,6 +35,11 @@ class FreeplayState extends MusicBeatState
*/ */
public var curDiffMetaKeys:Array<String> = []; public var curDiffMetaKeys:Array<String> = [];
/*
* Array containing all labels for game modes.
*/
public var gameModeLabels:Array<FreeplayGameMode> = [];
/** /**
* Currently selected song * Currently selected song
*/ */
@@ -43,9 +49,9 @@ class FreeplayState extends MusicBeatState
*/ */
public var curDifficulty:Int = 1; public var curDifficulty:Int = 1;
/** /**
* Currently selected coop/opponent mode * Currently selected game mode
*/ */
public var curCoopMode:Int = 0; public var curGameMode:Int = 0;
/** /**
* Text containing the score info (PERSONAL BEST: 0) * Text containing the score info (PERSONAL BEST: 0)
@@ -58,9 +64,9 @@ class FreeplayState extends MusicBeatState
public var diffText:FlxText; public var diffText:FlxText;
/** /**
* Text containing the current coop/opponent mode ([KEYBINDS] Co-Op mode) * Text containing the current game mode, for example: ([KEYBINDS] Co-Op mode)
*/ */
public var coopText:FlxText; public var gameModeText:FlxText;
/** /**
* Currently lerped score. Is updated to go towards `intendedScore`. * Currently lerped score. Is updated to go towards `intendedScore`.
@@ -130,6 +136,7 @@ class FreeplayState extends MusicBeatState
} }
updateCurSong(); updateCurSong();
gameModeLabels = FreeplayGameMode.get();
DiscordUtil.call("onMenuLoaded", ["Freeplay"]); DiscordUtil.call("onMenuLoaded", ["Freeplay"]);
@@ -177,14 +184,15 @@ class FreeplayState extends MusicBeatState
diffText.font = scoreText.font; diffText.font = scoreText.font;
add(diffText); add(diffText);
coopText = new FlxText(diffText.x, diffText.y + diffText.height + 2, 0, "", 24); gameModeText = new FlxText(diffText.x, diffText.y + diffText.height + 2, 0, "", 24);
coopText.font = scoreText.font; gameModeText.font = scoreText.font;
add(coopText); add(gameModeText);
add(scoreText); add(scoreText);
changeSelection(0, true); changeSelection(0, true);
changeCoopMode(0, true); changeDiff(0, true);
changeGameMode(0, true);
interpColor = new FlxInterpolateColor(bg.color); interpColor = new FlxInterpolateColor(bg.color);
} }
@@ -239,17 +247,17 @@ class FreeplayState extends MusicBeatState
if (canSelect) { if (canSelect) {
changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0) - FlxG.mouse.wheel); changeSelection((controls.UP_P ? -1 : 0) + (controls.DOWN_P ? 1 : 0) - FlxG.mouse.wheel);
changeDiff((controls.LEFT_P ? -1 : 0) + (controls.RIGHT_P ? 1 : 0)); changeDiff((controls.LEFT_P ? -1 : 0) + (controls.RIGHT_P ? 1 : 0));
changeCoopMode((controls.CHANGE_MODE ? 1 : 0)); // TODO: make this configurable changeGameMode((controls.CHANGE_MODE ? 1 : 0));
// putting it before so that its actually smooth // putting it before so that its actually smooth
updateOptionsAlpha(); updateOptionsAlpha();
} }
scoreText.text = TEXT_FREEPLAY_SCORE.format([Math.round(lerpScore)]); scoreText.text = TEXT_FREEPLAY_SCORE.format([Math.round(lerpScore)]);
scoreBG.scale.set(MathUtil.maxSmart(diffText.width, scoreText.width, coopText.width) + 8, (coopText.visible ? coopText.y + coopText.height : 66)); scoreBG.scale.set(MathUtil.maxSmart(diffText.width, scoreText.width, gameModeText.width) + 8, (gameModeText.visible ? gameModeText.y + gameModeText.height : 66));
scoreBG.updateHitbox(); scoreBG.updateHitbox();
scoreBG.x = FlxG.width - scoreBG.width; scoreBG.x = FlxG.width - scoreBG.width;
scoreText.x = coopText.x = scoreBG.x + 4; scoreText.x = gameModeText.x = scoreBG.x + 4;
diffText.x = Std.int(scoreBG.x + ((scoreBG.width - diffText.width) / 2)); diffText.x = Std.int(scoreBG.x + ((scoreBG.width - diffText.width) / 2));
interpColor.fpsLerpTo(curSong.color, 0.0625); interpColor.fpsLerpTo(curSong.color, 0.0625);
@@ -310,31 +318,13 @@ class FreeplayState extends MusicBeatState
select(); select();
} }
var __opponentMode:Bool = false;
var __coopMode:Bool = false;
function updateCoopModes() {
__opponentMode = false;
__coopMode = false;
if (curSong.coopAllowed && curSong.opponentModeAllowed) {
__opponentMode = curCoopMode % 2 == 1;
__coopMode = curCoopMode >= 2;
} else if (curSong.coopAllowed) {
__coopMode = curCoopMode == 1;
} else if (curSong.opponentModeAllowed) {
__opponentMode = curCoopMode == 1;
}
}
/** /**
* Selects the current song. * Selects the current song.
*/ */
public function select() { public function select() {
updateCoopModes();
if (curDifficulties.length == 0) return; if (curDifficulties.length == 0) return;
var event = event("onSelect", EventManager.get(FreeplaySongSelectEvent).recycle(curSong.name, curDifficulties[curDifficulty], curSong.variant, __opponentMode, __coopMode)); var event = event("onSelect", EventManager.get(FreeplaySongSelectEvent).recycle(curSong.name, curDifficulties[curDifficulty], curSong.variant, gameModeLabels[curGameMode]));
if (event.cancelled) return; if (event.cancelled) return;
@@ -393,7 +383,7 @@ class FreeplayState extends MusicBeatState
intendedScore = 0; intendedScore = 0;
return; return;
} }
updateCoopModes();
var changes:Array<HighscoreChange> = []; var changes:Array<HighscoreChange> = [];
if (__coopMode) changes.push(CCoopMode); if (__coopMode) changes.push(CCoopMode);
if (__opponentMode) changes.push(COpponentMode); if (__opponentMode) changes.push(COpponentMode);
@@ -401,45 +391,37 @@ class FreeplayState extends MusicBeatState
intendedScore = saveData.score; intendedScore = saveData.score;
} }
/**
* Array containing all labels for Co-Op / Opponent modes.
*/
public var coopLabels:Array<String> = [
TU.translate("freeplay.solo"),
TU.translate("freeplay.opponentMode"),
TU.translate("freeplay.coopMode"),
TU.translate("freeplay.coopModeSwitched")
];
/** /**
* Change the current coop mode context. * Change the current coop mode context.
* @param change How much to change * @param change How much to change
* @param force Force the change, even if `change` is equal to 0. * @param force Force the change, even if `change` is equal to 0.
*/ */
public function changeCoopMode(change:Int = 0, force:Bool = false) { public function changeGameMode(change:Int = 0, force:Bool = false) {
if (change == 0 && !force) return; if (change == 0 && !force) return;
if (!curSong.coopAllowed && !curSong.opponentModeAllowed) return;
var bothEnabled = curSong.coopAllowed && curSong.opponentModeAllowed; var i = 0;
var event = event("onChangeCoopMode", EventManager.get(MenuChangeEvent).recycle(curCoopMode, FlxMath.wrap(curCoopMode + change, 0, bothEnabled ? 3 : 1), change)); var allowed = getAllowedGameModesID();
var wrapped = FlxMath.wrap(curGameMode + change, 0, gameModeLabels.length - 1);
if (event.cancelled) return; while (!allowed.contains(gameModeLabels[wrapped].modeID)) { // Skipping the blacklisted ones - Nex
wrapped = FlxMath.wrap(wrapped + change, 0, gameModeLabels.length - 1);
curCoopMode = event.value; if (i++ > allowed.length) {
curGameMode = 0; // Idk honestly if I should modify the other event's variables - Nex
updateScore(); break;
}
var coopBinds = [CoolUtil.keyToString(Options.P1_CHANGE_MODE[0]), CoolUtil.keyToString(Options.P2_CHANGE_MODE[0])].filter(x -> x != "---");
if (coopBinds.length == 2 && coopBinds[1] == coopBinds[0]) coopBinds.pop();
else if (coopBinds.length == 0) coopBinds.push("---");
var key = '[${coopBinds.join(" / ")}] ';
if (bothEnabled) {
coopText.text = key + coopLabels[curCoopMode];
} else {
coopText.text = key + coopLabels[curCoopMode * (curSong.coopAllowed ? 2 : 1)];
} }
var e = EventManager.get(MenuChangeEvent).recycle(curGameMode, wrapped, change);
event("onChangeCoopMode", e); // Backwards compat - Nex
if (event("onChangeGameMode", e).cancelled) return;
// Getting from scratch the allowed game modes just in case they changed when the event got called - Nex
if (gameModeText.visible = getAllowedGameModesID().length > 0) gameModeText.text = "[TAB] " + gameModeLabels[curGameMode = e.value].modeName;
updateScore();
}
public inline function getAllowedGameModesID() {
var excluded = songs[curSelected].excludedGameModes;
return [for (mode in gameModeLabels) if (!excluded.contains(mode.modeID)) mode.modeID];
} }
/** /**
@@ -465,13 +447,12 @@ class FreeplayState extends MusicBeatState
} }
changeDiff(0, true); changeDiff(0, true);
changeGameMode(0, true);
#if PRELOAD_ALL #if PRELOAD_ALL
autoplayElapsed = 0; autoplayElapsed = 0;
songInstPlaying = false; songInstPlaying = false;
#end #end
coopText.visible = curSong.coopAllowed || curSong.opponentModeAllowed;
} }
function updateOptionsAlpha() { function updateOptionsAlpha() {
@@ -486,7 +467,7 @@ class FreeplayState extends MusicBeatState
iconArray[curSelected].alpha = selectedAlpha; iconArray[curSelected].alpha = selectedAlpha;
for (i=>item in grpSongs.members) for (i => item in grpSongs.members)
{ {
item.targetY = i - curSelected; item.targetY = i - curSelected;
@@ -517,6 +498,118 @@ class FreeplayState extends MusicBeatState
else if ((curSong = song.metas.get(curDiffMetaKeys[curDifficulty])) == null) else if ((curSong = song.metas.get(curDiffMetaKeys[curDifficulty])) == null)
curSong = song; curSong = song;
} }
// Backwards compat
@:noCompletion public function changeCoopMode(change:Int = 0, force:Bool = false) return changeGameMode(change, force);
@:noCompletion public var coopText(get, set):FlxText;
@:noCompletion private function get_coopText() return gameModeText;
@:noCompletion private function set_coopText(val:FlxText) return gameModeText = val;
@:noCompletion function updateCoopModes() {}
@:noCompletion var __opponentMode(get, default):Bool = false; // God this is so cursed - Nex
@:noCompletion private function get___opponentMode() return getAllowedGameModesID().contains("codename.opponent");
@:noCompletion var __coopMode(get, default):Bool = false;
@:noCompletion private function get___coopMode() return getAllowedGameModesID().contains("codename.coop");
@:noCompletion var curCoopMode(get, set):Int;
@:noCompletion private function get_curCoopMode() return curGameMode;
@:noCompletion private function set_curCoopMode(val:Int) return curGameMode = val;
@:noCompletion var coopLabels(get, set):Array<String>;
@:noCompletion private function get_coopLabels() return [for(mode in gameModeLabels) mode.modeName];
@:noCompletion private function set_coopLabels(names:Array<String>) {
gameModeLabels = [for(name in names) {
if (name.startsWith("[TAB] ")) name = name.substr("[TAB] ".length);
new FreeplayGameMode(name, switch(name) {
case "Solo": "codename.solo";
case "Opponent Mode": "codename.opponent";
case "Co-Op Mode": "codename.coop";
case "Co-Op Mode (Switched)": "codename.coop-opponent";
default: name.toLowerCase().replace(" ", "-");
}, switch(name) {
case "Solo": ["solo"];
case "Opponent Mode": ["opponent"];
case "Co-Op Mode": ["coop"];
case "Co-Op Mode (Switched)": ["coop-switched", "opponent", "coop"];
default: null;
});
}];
return names;
}
}
/**
* Class used for the Freeplay menu game modes.
*
* **NOTE**: `fields` is useable not just for boolean values!!
*/
class FreeplayGameMode {
public var modeName:String;
public var modeID:String;
public var scripts(default, set):Array<String>;
public var fields(default, set):Dynamic;
@:noCompletion function set_scripts(val:Array<String>) return scripts = (val == null ? [] : val);
@:noCompletion function set_fields(val:Dynamic) return fields = (val == null ? {} : val);
public function new(modeName:String, modeID:String, ?scripts:Array<String>, ?fields:Dynamic) {
this.modeName = modeName;
this.modeID = modeID;
this.scripts = scripts;
this.fields = fields;
}
public function toModifiers():Array<Dynamic> {
var fields = this.fields;
var modifiers:Array<Dynamic> = [];
for (field in {var _ = Reflect.fields(fields); _.sort(Reflect.compare); _;}) {
var val:Dynamic = Reflect.field(fields, field);
if (val != null && val != false) { // allow true, and floats/ints
modifiers.push(field);
modifiers.push(val);
}
}
return modifiers;
}
public static inline function generateDefault() return new FreeplayGameMode("Solo Mode", "solo");
public static inline function getGameModesFromSource(source:AssetSource = BOTH, useTxt:Bool = true):Array<FreeplayGameMode> {
var path = 'data/gamemodes';
var txt = Paths.txt('gamemodes/list');
var list = useTxt && Paths.assetsTree.existsSpecific(txt, "TEXT", source) ? CoolUtil.coolTextFile(txt) : Paths.getFolderContent(path, false, source);
return [for (file in list) {
if (useTxt) file += ".json";
else if (Path.extension(file) != "json") continue;
var meta:FreeplayGameMode = null;
try {
var data = CoolUtil.parseJson(Paths.file(path + "/" + file)); var id = data.modeID;
meta = new FreeplayGameMode(CoolUtil.getDefault(data.displayName, id), id, [Path.withoutExtension(file)].concat(CoolUtil.getDefault(data.scripts, [])), data.fields);
} catch(e) Logs.trace('Failed to load game mode metadata for $file ($path): ${Std.string(e)}', ERROR);
if (meta != null) meta;
}];
}
public static function get(useTxt:Bool = true):Array<FreeplayGameMode> {
var list:Array<FreeplayGameMode>;
switch(Flags.GAME_MODES_LIST_MOD_MODE) {
case 'prepend':
list = getGameModesFromSource(MODS, useTxt).concat(getGameModesFromSource(SOURCE, useTxt));
case 'append':
list = getGameModesFromSource(SOURCE, useTxt).concat(getGameModesFromSource(MODS, useTxt));
case 'override':
list = getGameModesFromSource(BOTH, useTxt);
default /*case 'oneOFtwo'*/:
if ((list = getGameModesFromSource(MODS, useTxt)).length == 0)
list = getGameModesFromSource(SOURCE, useTxt);
}
return list;
}
} }
class FreeplaySonglist { class FreeplaySonglist {
@@ -553,7 +646,9 @@ class FreeplaySonglist {
case 'append': case 'append':
songList.getSongsFromSource(SOURCE, useTxt); songList.getSongsFromSource(SOURCE, useTxt);
songList.getSongsFromSource(MODS, useTxt); songList.getSongsFromSource(MODS, useTxt);
default /*case 'override'*/: case 'override':
songList.getSongsFromSource(BOTH, useTxt);
default /*case 'oneOFtwo'*/:
if (songList.getSongsFromSource(MODS, useTxt)) if (songList.getSongsFromSource(MODS, useTxt))
songList.getSongsFromSource(SOURCE, useTxt); songList.getSongsFromSource(SOURCE, useTxt);
} }
+2 -2
View File
@@ -81,8 +81,8 @@ class PauseSubState extends MusicBeatSubstate
bg.scrollFactor.set(); bg.scrollFactor.set();
add(bg); add(bg);
var multiplayerInfo:String = PlayState.opponentMode ? 'pause.coopMode' : var multiplayerInfo:String = PlayState.opponentMode ? 'pause.opponentMode' :
PlayState.coopMode ? 'pause.opponentMode' : PlayState.coopMode ? 'pause.coopMode' :
null; null;
levelInfo = new FunkinText(20, 15, 0, PlayState.SONG.meta.displayName, 32, false); levelInfo = new FunkinText(20, 15, 0, PlayState.SONG.meta.displayName, 32, false);
+11 -4
View File
@@ -342,10 +342,17 @@ class StoryWeeklist {
public function new() {} public function new() {}
public function getWeeksFromSource(source:funkin.backend.assets.AssetSource, useTxt:Bool = true, loadCharactersData:Bool = true) { public function getWeeksFromSource(source:funkin.backend.assets.AssetSource, useTxt:Bool = true, loadCharactersData:Bool = true) {
var path:String = Paths.txt('weeks/weeks'); var weeksFound:Array<String> = null;
var weeksFound:Array<String> = useTxt && Paths.assetsTree.existsSpecific(path, "TEXT", source) ? CoolUtil.coolTextFile(path) : if (useTxt) {
[for (c in Paths.getFolderContent('data/weeks/weeks/', false, source)) if (Path.extension(c).toLowerCase() == "xml") Path.withoutExtension(c)]; var oldPath:String = Paths.txt('weeks/weeks');
var newPath:String = Paths.txt('config/weeks');
if (Paths.assetsTree.existsSpecific(newPath, "TEXT", source)) weeksFound = CoolUtil.coolTextFile(newPath);
else if (Paths.assetsTree.existsSpecific(oldPath, "TEXT", source)) {
Logs.warn("data/weeks/weeks.txt is deprecated and will be removed in the future. Please move the file to data/config/", DARKYELLOW, "StoryWeeklist");
weeksFound = CoolUtil.coolTextFile(oldPath);
}
}
if (weeksFound == null) weeksFound = [for (c in Paths.getFolderContent('data/weeks/weeks/', false, source)) if (Path.extension(c).toLowerCase() == "xml") Path.withoutExtension(c)];
if (weeksFound.length > 0) { if (weeksFound.length > 0) {
for (w in weeksFound) { for (w in weeksFound) {
var week = Week.loadWeek(w, loadCharactersData); var week = Week.loadWeek(w, loadCharactersData);
+1 -1
View File
@@ -245,7 +245,7 @@ class TitleState extends MusicBeatState
if (parentFolder != "" && !parentFolder.endsWith("/")) parentFolder += "/"; if (parentFolder != "" && !parentFolder.endsWith("/")) parentFolder += "/";
for(sprNode in node.elements) { for(sprNode in node.elements) {
var spr = XMLUtil.createSpriteFromXML(sprNode, parentFolder); var spr = XMLUtil.createSpriteFromXML(sprNode, parentFolder);
switch(node.name) { switch(sprNode.name) {
case "press-enter": case "press-enter":
titleText = spr; titleText = spr;
default: default:
+4
View File
@@ -345,6 +345,10 @@ class Alphabet extends FlxSprite {
} }
function drawLetter(camera) { function drawLetter(camera) {
// i'll have to improve this with blit rendering. not sure how.
// i can't just store all the bitmaps in the component since it's also responsable for flips and colors.
if (FlxG.renderBlit)
updateFramePixels();
_frame.prepareMatrix(_matrix, ANGLE_0, checkFlipX() != camera.flipX, checkFlipY() != camera.flipY); _frame.prepareMatrix(_matrix, ANGLE_0, checkFlipX() != camera.flipX, checkFlipY() != camera.flipY);
_matrix.translate(_frame.frame.width * -0.5, _frame.frame.height * -0.5); _matrix.translate(_frame.frame.width * -0.5, _frame.frame.height * -0.5);

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