Make one-way recolors check for specific files

So, 2.3 added recoloring one-way tiles to no longer make them be always
yellow. However, custom levels that retexture the one-way tiles might
not want them to be recolored. So, if there are ANY custom assets
mounted, then the one-ways will not be recolored. However, if the XML
has a <onewaycol_override>1</onewaycol_override> tag, then the one-way
will be recolored again anyways.

When I added one-way recoloring, I didn't intend for any custom asset to
disable the recoloring; I only did it because I couldn't find a way to
check if a specific file was customized by the custom level or not.

However, I have figured out how to do so, and so now tiles.png one-way
recolors will only be disabled if there's a custom tiles.png, and
tiles2.png one-way recolors will only be disabled if there's a custom
tiles2.png.

In order to make sure we're not calling PhysFS functions on every single
deltaframe, I've added caching variables, tiles1_mounted and
tiles2_mounted, to Graphics; these get assigned every time
reloadresources() is called.
This commit is contained in:
Misa
2021-03-06 10:52:11 -08:00
committed by Ethan Lee
parent 34865a8ef1
commit c1572de9e2
4 changed files with 21 additions and 19 deletions

View File

@@ -241,8 +241,6 @@ void FILESYSTEM_loadZip(const char* filename)
}
}
bool FILESYSTEM_assetsmounted = false;
void FILESYSTEM_mountassets(const char* path)
{
const size_t path_size = SDL_strlen(path);
@@ -288,8 +286,6 @@ void FILESYSTEM_mountassets(const char* path)
FILESYSTEM_mount(zip_data);
graphics.reloadresources();
FILESYSTEM_assetsmounted = true;
}
else if (zip_normal != NULL && endsWith(zip_normal, ".zip"))
{
@@ -323,8 +319,6 @@ void FILESYSTEM_mountassets(const char* path)
SDL_strlcpy(assetDir, zip_data, sizeof(assetDir));
}
FILESYSTEM_assetsmounted = true;
graphics.reloadresources();
}
else if (FILESYSTEM_exists(dir))
@@ -334,14 +328,10 @@ void FILESYSTEM_mountassets(const char* path)
FILESYSTEM_mount(dir);
graphics.reloadresources();
FILESYSTEM_assetsmounted = true;
}
else
{
puts("Custom asset directory does not exist");
FILESYSTEM_assetsmounted = false;
}
}
@@ -358,7 +348,6 @@ void FILESYSTEM_unmountassets(void)
{
printf("Cannot unmount when no asset directory is mounted\n");
}
FILESYSTEM_assetsmounted = false;
}
bool FILESYSTEM_isAssetMounted(const char* filename)