mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-07-27 17:41:49 +03:00
c02f8e004c
* Load an unlimited amount of loose music Binary blobs can now store 128 tracks, and music can now be read from loose files. Unfortunately, the two cannot be used together -- loose music can still only use 16 tracks. This commit attempts to fix that, allowing for music playback by filename. * Rework music track loading The current "loose songs" system does not load files from custom assets. This is from the #412 PR, and is NOT the "extra loose songs" system that this PR implements, but they both work in the same area so I decided to squash both of these bugs at once (plus, it helped clean up the code and make a saner system, so...) This commit also allows "loose music" to override music stored in the `vvvvvvmusic.vvv` binary blob. When reading a blob, it will first check if a loose file exists at the current path it's trying to find a track at; if it exists, it will load that instead. If the blob does not exist, the system will try to locate all expected built-in tracks directly from the assets folder instead of doing that during blob loading. The `play` command has some safety removed due to an old exploit which needs to be kept -- `music(5b)` should play track 5. This is used in many levels and cannot be broken; unfortunately this means that we no longer get the nice error when a song fails to be played, but that's better than breaking a large amount of levels. This commit does NOT address loading a "extra" loose track overtop of a custom blob track, because with the current tooling, and the way it will most likely continue to work in the future, every single custom track in blobs have a completely empty path. If someone decides to modify their blob in a hex editor or makes their own tooling, this issue may show up again, but that is a problem which can and probably should be addressed at a later date. The required code to solve such a problem would be far more than what this PR should address, and for a situation so unlikely, it's easy enough to just avoid adding the same custom song twice, one in a music file, and one loose, because if you're making a level, you're probably going to use one or the other. * Fix mentioned issues from review
78 lines
2.7 KiB
C++
78 lines
2.7 KiB
C++
#ifndef FILESYSTEMUTILS_H
|
|
#define FILESYSTEMUTILS_H
|
|
|
|
/* Forward declaration */
|
|
class binaryBlob;
|
|
|
|
#include <stddef.h>
|
|
#include <SDL_rwops.h>
|
|
|
|
// Forward declaration, including the entirety of tinyxml2.h across all files this file is included in is unnecessary
|
|
namespace tinyxml2 { class XMLDocument; }
|
|
|
|
int FILESYSTEM_init(char *argvZero, char* baseDir, char* assetsPath, char* langDir, char* fontsDir);
|
|
bool FILESYSTEM_isInit(void);
|
|
void FILESYSTEM_deinit(void);
|
|
|
|
char *FILESYSTEM_getUserSaveDirectory(void);
|
|
char *FILESYSTEM_getUserLevelDirectory(void);
|
|
char *FILESYSTEM_getUserMainLangDirectory(void);
|
|
bool FILESYSTEM_isMainLangDirFromRepo(void);
|
|
bool FILESYSTEM_doesLangDirExist(void);
|
|
bool FILESYSTEM_doesFontsDirExist(void);
|
|
|
|
bool FILESYSTEM_setLangWriteDir(void);
|
|
bool FILESYSTEM_restoreWriteDir(void);
|
|
|
|
bool FILESYSTEM_isFile(const char* filename);
|
|
bool FILESYSTEM_isMounted(const char* filename);
|
|
|
|
void FILESYSTEM_loadZip(const char* filename);
|
|
bool FILESYSTEM_mountAssets(const char *path);
|
|
void FILESYSTEM_unmountAssets(void);
|
|
bool FILESYSTEM_isAssetMounted(const char* filename);
|
|
bool FILESYSTEM_areAssetsInSameRealDir(const char* filenameA, const char* filenameB);
|
|
|
|
bool FILESYSTEM_saveFile(const char* name, const unsigned char* data, size_t len);
|
|
void FILESYSTEM_loadFileToMemory(const char *name, unsigned char **mem,
|
|
size_t *len);
|
|
|
|
SDL_RWops* FILESYSTEM_loadAssetRWops(const char* name);
|
|
void FILESYSTEM_loadAssetToMemory(
|
|
const char* name,
|
|
unsigned char** mem,
|
|
size_t* len
|
|
);
|
|
|
|
bool FILESYSTEM_loadBinaryBlob(binaryBlob* blob, const char* filename);
|
|
|
|
bool FILESYSTEM_saveTiXml2Document(const char *name, tinyxml2::XMLDocument& doc, bool sync = true);
|
|
bool FILESYSTEM_loadTiXml2Document(const char *name, tinyxml2::XMLDocument& doc);
|
|
bool FILESYSTEM_loadAssetTiXml2Document(const char *name, tinyxml2::XMLDocument& doc);
|
|
|
|
void FILESYSTEM_enumerateLevelDirFileNames(void (*callback)(const char* filename));
|
|
|
|
struct EnumHandle
|
|
{
|
|
char** physfs_list;
|
|
char** _item;
|
|
};
|
|
|
|
const char* FILESYSTEM_enumerate(const char* folder, EnumHandle* handle);
|
|
const char* FILESYSTEM_enumerateAssets(const char* folder, EnumHandle* handle);
|
|
const char* FILESYSTEM_enumerateLanguageCodes(EnumHandle* handle);
|
|
void FILESYSTEM_freeEnumerate(EnumHandle* handle);
|
|
|
|
bool FILESYSTEM_levelDirHasError(void);
|
|
void FILESYSTEM_clearLevelDirError(void);
|
|
const char* FILESYSTEM_getLevelDirError(void);
|
|
void FILESYSTEM_setLevelDirError(const char* text, const char* args_index, ...);
|
|
|
|
bool FILESYSTEM_openDirectoryEnabled(void);
|
|
bool FILESYSTEM_openDirectory(const char *dname);
|
|
|
|
bool FILESYSTEM_delete(const char *name);
|
|
void FILESYSTEM_deleteLevelSaves(void);
|
|
|
|
#endif /* FILESYSTEMUTILS_H */
|