Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom file playback to playef() #902

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Fussmatte
Copy link
Contributor

Changes:

This PR allows users to call custom filenames via the playef() command. For example, playef(mysfx) will play back either sounds/mysfx.ogg or sounds/mysfx.wav. Custom sounds are loaded with the level, and (for now) only the level's own sounds/ folder is read from.

This uses a new function called FILESYSTEM_enumerateAssets() which gets all the files from a specific folder of a custom level's assets folder. This could allow other possibilities for loading custom files (such as graphics) in the future.

Big thanks to @Dav999-v for helping me write this!

Legal Stuff:

By submitting this pull request, I confirm that...

  • My changes may be used in a future commercial release of VVVVVV
  • I will be credited in a CONTRIBUTORS file and the "GitHub Friends"
    section of the credits for all of said releases, but will NOT be compensated
    for these changes

@Fussmatte Fussmatte changed the title Added custom file playback to playef() Add custom file playback to playef() Nov 7, 2022
@InfoTeddy InfoTeddy self-assigned this Nov 7, 2022
@Fussmatte
Copy link
Contributor Author

Worth noting: if you run this version right now, .ogg files cannot be loaded this way. This is due to #900, so once that's fixed it should work with no issues.

desktop_version/src/Music.cpp Outdated Show resolved Hide resolved
desktop_version/src/Music.cpp Outdated Show resolved Hide resolved
desktop_version/src/Music.cpp Outdated Show resolved Hide resolved
desktop_version/src/FileSystemUtils.cpp Outdated Show resolved Hide resolved
desktop_version/src/Music.cpp Outdated Show resolved Hide resolved
desktop_version/src/Script.cpp Outdated Show resolved Hide resolved
Daaaav added a commit to Daaaav/VVVVVV that referenced this pull request Jan 11, 2023
All global fonts and all custom fonts in a level are now loaded, and
added to their respective "vectors". The selected font is still always
as the global font.png, and the custom level font also isn't selected
yet, but it's now easier to implement that.

Also, I added FILESYSTEM_enumerateAssets, which TerryCavanagh#902 already has but I
needed it now. I also rewrote it to not use std::vector<std::string>
(that was my idea, it's also how FILESYSTEM_getLanguageCodes works,
until the next commit...)
@Daaaav
Copy link
Contributor

Daaaav commented Jan 11, 2023

I just needed FILESYSTEM_enumerateAssets() for #922, so it's now in my PR as well - meaning if #922 gets merged before this one, all changes this makes to FileSystemUtils.[cpp/h] are no longer necessary and need to be undone. Also, I decided to change how it works, so this will also need to be replaced:

    std::vector<std::string> customSounds = FILESYSTEM_enumerateAssets("sounds/");
    for (int i = 0; i < customSounds.size(); i++)
    {
        // use customSounds[i]
    }

by something like this:

    EnumHandle* handle = {};
    const char* item;
    while ((item = FILESYSTEM_enumerateAssets("sounds/", &handle)) != NULL)
    {
        // use item
    }
    FILESYSTEM_freeEnumerate(&handle);

Daaaav added a commit to Daaaav/VVVVVV that referenced this pull request Jan 16, 2023
All global fonts and all custom fonts in a level are now loaded, and
added to their respective "vectors". The selected font is still always
as the global font.png, and the custom level font also isn't selected
yet, but it's now easier to implement that.

Also, I added FILESYSTEM_enumerateAssets, which TerryCavanagh#902 already has but I
needed it now. I also rewrote it to not use std::vector<std::string>
(that was my idea, it's also how FILESYSTEM_getLanguageCodes works,
until the next commit...)
Daaaav added a commit to Daaaav/VVVVVV that referenced this pull request Jan 19, 2023
All global fonts and all custom fonts in a level are now loaded, and
added to their respective "vectors". The selected font is still always
as the global font.png, and the custom level font also isn't selected
yet, but it's now easier to implement that.

Also, I added FILESYSTEM_enumerateAssets, which TerryCavanagh#902 already has but I
needed it now. I also rewrote it to not use std::vector<std::string>.
That was my idea, it's also how FILESYSTEM_getLanguageCodes worked,
so for symmetry, that function is getting changed as well.
Daaaav added a commit to Daaaav/VVVVVV that referenced this pull request Jan 20, 2023
All global fonts and all custom fonts in a level are now loaded, and
added to their respective "vectors". The selected font is still always
as the global font.png, and the custom level font also isn't selected
yet, but it's now easier to implement that.

Also, I added FILESYSTEM_enumerateAssets, which TerryCavanagh#902 already has but I
needed it now. I also rewrote it to not use std::vector<std::string>.
That was my idea, it's also how FILESYSTEM_getLanguageCodes worked,
so for symmetry, that function is getting changed as well.
Daaaav added a commit to Daaaav/VVVVVV that referenced this pull request Jan 20, 2023
All global fonts and all custom fonts in a level are now loaded, and
added to their respective "vectors". The selected font is still always
as the global font.png, and the custom level font also isn't selected
yet, but it's now easier to implement that.

Also, I added FILESYSTEM_enumerateAssets, which TerryCavanagh#902 already has but I
needed it now. I also rewrote it to not use std::vector<std::string>.
That was my idea, it's also how FILESYSTEM_getLanguageCodes worked,
so for symmetry, that function is getting changed as well.
Daaaav added a commit to Daaaav/VVVVVV that referenced this pull request Jan 23, 2023
All global fonts and all custom fonts in a level are now loaded, and
added to their respective "vectors". The selected font is still always
as the global font.png, and the custom level font also isn't selected
yet, but it's now easier to implement that.

Also, I added FILESYSTEM_enumerateAssets, which TerryCavanagh#902 already has but I
needed it now. I also rewrote it to not use std::vector<std::string>.
That was my idea, it's also how FILESYSTEM_getLanguageCodes worked,
so for symmetry, that function is getting changed as well.
Daaaav added a commit to Daaaav/VVVVVV that referenced this pull request Jan 29, 2023
All global fonts and all custom fonts in a level are now loaded, and
added to their respective "vectors". The selected font is still always
as the global font.png, and the custom level font also isn't selected
yet, but it's now easier to implement that.

Also, I added FILESYSTEM_enumerateAssets, which TerryCavanagh#902 already has but I
needed it now. I also rewrote it to not use std::vector<std::string>.
That was my idea, it's also how FILESYSTEM_getLanguageCodes worked,
so for symmetry, that function is getting changed as well.
Daaaav added a commit to Daaaav/VVVVVV that referenced this pull request Jan 30, 2023
All global fonts and all custom fonts in a level are now loaded, and
added to their respective "vectors". The selected font is still always
as the global font.png, and the custom level font also isn't selected
yet, but it's now easier to implement that.

Also, I added FILESYSTEM_enumerateAssets, which TerryCavanagh#902 already has but I
needed it now. I also rewrote it to not use std::vector<std::string>.
That was my idea, it's also how FILESYSTEM_getLanguageCodes worked,
so for symmetry, that function is getting changed as well.
Daaaav added a commit to Daaaav/VVVVVV that referenced this pull request Jan 31, 2023
All global fonts and all custom fonts in a level are now loaded, and
added to their respective "vectors". The selected font is still always
as the global font.png, and the custom level font also isn't selected
yet, but it's now easier to implement that.

Also, I added FILESYSTEM_enumerateAssets, which TerryCavanagh#902 already has but I
needed it now. I also rewrote it to not use std::vector<std::string>.
That was my idea, it's also how FILESYSTEM_getLanguageCodes worked,
so for symmetry, that function is getting changed as well.
Daaaav added a commit to Daaaav/VVVVVV that referenced this pull request Feb 1, 2023
All global fonts and all custom fonts in a level are now loaded, and
added to their respective "vectors". The selected font is still always
as the global font.png, and the custom level font also isn't selected
yet, but it's now easier to implement that.

Also, I added FILESYSTEM_enumerateAssets, which TerryCavanagh#902 already has but I
needed it now. I also rewrote it to not use std::vector<std::string>.
That was my idea, it's also how FILESYSTEM_getLanguageCodes worked,
so for symmetry, that function is getting changed as well.
Daaaav added a commit to Daaaav/VVVVVV that referenced this pull request Feb 2, 2023
All global fonts and all custom fonts in a level are now loaded, and
added to their respective "vectors". The selected font is still always
as the global font.png, and the custom level font also isn't selected
yet, but it's now easier to implement that.

Also, I added FILESYSTEM_enumerateAssets, which TerryCavanagh#902 already has but I
needed it now. I also rewrote it to not use std::vector<std::string>.
That was my idea, it's also how FILESYSTEM_getLanguageCodes worked,
so for symmetry, that function is getting changed as well.
Daaaav added a commit to Daaaav/VVVVVV that referenced this pull request Feb 2, 2023
All global fonts and all custom fonts in a level are now loaded, and
added to their respective "vectors". The selected font is still always
as the global font.png, and the custom level font also isn't selected
yet, but it's now easier to implement that.

Also, I added FILESYSTEM_enumerateAssets, which TerryCavanagh#902 already has but I
needed it now. I also rewrote it to not use std::vector<std::string>.
That was my idea, it's also how FILESYSTEM_getLanguageCodes worked,
so for symmetry, that function is getting changed as well.
Daaaav added a commit to Daaaav/VVVVVV that referenced this pull request Feb 5, 2023
All global fonts and all custom fonts in a level are now loaded, and
added to their respective "vectors". The selected font is still always
as the global font.png, and the custom level font also isn't selected
yet, but it's now easier to implement that.

Also, I added FILESYSTEM_enumerateAssets, which TerryCavanagh#902 already has but I
needed it now. I also rewrote it to not use std::vector<std::string>.
That was my idea, it's also how FILESYSTEM_getLanguageCodes worked,
so for symmetry, that function is getting changed as well.
Daaaav added a commit to Daaaav/VVVVVV that referenced this pull request Feb 9, 2023
All global fonts and all custom fonts in a level are now loaded, and
added to their respective "vectors". The selected font is still always
as the global font.png, and the custom level font also isn't selected
yet, but it's now easier to implement that.

Also, I added FILESYSTEM_enumerateAssets, which TerryCavanagh#902 already has but I
needed it now. I also rewrote it to not use std::vector<std::string>.
That was my idea, it's also how FILESYSTEM_getLanguageCodes worked,
so for symmetry, that function is getting changed as well.
Daaaav added a commit to Daaaav/VVVVVV that referenced this pull request Feb 14, 2023
All global fonts and all custom fonts in a level are now loaded, and
added to their respective "vectors". The selected font is still always
as the global font.png, and the custom level font also isn't selected
yet, but it's now easier to implement that.

Also, I added FILESYSTEM_enumerateAssets, which TerryCavanagh#902 already has but I
needed it now. I also rewrote it to not use std::vector<std::string>.
That was my idea, it's also how FILESYSTEM_getLanguageCodes worked,
so for symmetry, that function is getting changed as well.
InfoTeddy pushed a commit that referenced this pull request Feb 14, 2023
All global fonts and all custom fonts in a level are now loaded, and
added to their respective "vectors". The selected font is still always
as the global font.png, and the custom level font also isn't selected
yet, but it's now easier to implement that.

Also, I added FILESYSTEM_enumerateAssets, which #902 already has but I
needed it now. I also rewrote it to not use std::vector<std::string>.
That was my idea, it's also how FILESYSTEM_getLanguageCodes worked,
so for symmetry, that function is getting changed as well.
@Fussmatte
Copy link
Contributor Author

Everything here should be in order now; I've squashed it all to one commit and made sure it's building and functional. @InfoTeddy could you look at this?

@InfoTeddy
Copy link
Contributor

Yes.

Previously, any number would be interpreted as a stock sound effect ID,
causing the side effect of being able to call custom sound effects using
numbers over 27 (which is unreliable).

Now only numbers that correspond to a stock sound effect ID will be
considered (leading zeroes work as well), and everything else will be
interpreted as a custom sound effect file name.
@Fussmatte
Copy link
Contributor Author

So apparently OGG files don't work here after all, even though OGG playback was fixed. Will have to look into this before it can be merged...

When OGG files got loaded, they weren't given a name in the
function LoadOGG(). This caused playef_name() to fail since
it couldn't match any of the custom pushed OGGs' filenames
with what the user called using playef. This was fixed by
copying the name definition from LoadWAV().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants