1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2025-01-09 18:39:45 +01:00

De-duplicate one-way recolor conditional

Now you only have to call one function (and pass it a tile number) to
figure out if you should recolor a one-way tile or not, and you don't
have to copy-paste.
This commit is contained in:
Misa 2021-03-05 23:55:35 -08:00 committed by Ethan Lee
parent b4dd516d7d
commit ca4afcc140
2 changed files with 16 additions and 4 deletions

View file

@ -709,6 +709,15 @@ void Graphics::drawsprite(int x, int y, int t, Uint32 c)
BlitSurfaceColoured(sprites[t], NULL, backBuffer, &rect, ct); BlitSurfaceColoured(sprites[t], NULL, backBuffer, &rect, ct);
} }
#ifndef NO_CUSTOM_LEVELS
bool Graphics::shouldrecoloroneway(const int tilenum)
{
return (tilenum >= 14 && tilenum <= 17
&& (!FILESYSTEM_assetsmounted
|| ed.onewaycol_override));
}
#endif
void Graphics::drawtile( int x, int y, int t ) void Graphics::drawtile( int x, int y, int t )
{ {
if (!INBOUNDS_VEC(t, tiles)) if (!INBOUNDS_VEC(t, tiles))
@ -720,7 +729,7 @@ void Graphics::drawtile( int x, int y, int t )
SDL_Rect rect = { Sint16(x), Sint16(y), tiles_rect.w, tiles_rect.h }; SDL_Rect rect = { Sint16(x), Sint16(y), tiles_rect.w, tiles_rect.h };
#if !defined(NO_CUSTOM_LEVELS) #if !defined(NO_CUSTOM_LEVELS)
if (t >= 14 && t <= 17 && (!FILESYSTEM_assetsmounted || ed.onewaycol_override)) if (shouldrecoloroneway(t))
{ {
colourTransform thect = {ed.getonewaycol()}; colourTransform thect = {ed.getonewaycol()};
BlitSurfaceTinted(tiles[t], NULL, backBuffer, &rect, thect); BlitSurfaceTinted(tiles[t], NULL, backBuffer, &rect, thect);
@ -744,7 +753,7 @@ void Graphics::drawtile2( int x, int y, int t )
SDL_Rect rect = { Sint16(x), Sint16(y), tiles_rect.w, tiles_rect.h }; SDL_Rect rect = { Sint16(x), Sint16(y), tiles_rect.w, tiles_rect.h };
#if !defined(NO_CUSTOM_LEVELS) #if !defined(NO_CUSTOM_LEVELS)
if (t >= 14 && t <= 17 && (!FILESYSTEM_assetsmounted || ed.onewaycol_override)) if (shouldrecoloroneway(t))
{ {
colourTransform thect = {ed.getonewaycol()}; colourTransform thect = {ed.getonewaycol()};
BlitSurfaceTinted(tiles2[t], NULL, backBuffer, &rect, thect); BlitSurfaceTinted(tiles2[t], NULL, backBuffer, &rect, thect);
@ -3144,7 +3153,7 @@ void Graphics::drawforetile(int x, int y, int t)
setRect(rect, x,y,tiles_rect.w, tiles_rect.h); setRect(rect, x,y,tiles_rect.w, tiles_rect.h);
#if !defined(NO_CUSTOM_LEVELS) #if !defined(NO_CUSTOM_LEVELS)
if (t >= 14 && t <= 17 && (!FILESYSTEM_assetsmounted || ed.onewaycol_override)) if (shouldrecoloroneway(t))
{ {
colourTransform thect = {ed.getonewaycol()}; colourTransform thect = {ed.getonewaycol()};
BlitSurfaceTinted(tiles[t], NULL, foregroundBuffer, &rect, thect); BlitSurfaceTinted(tiles[t], NULL, foregroundBuffer, &rect, thect);
@ -3168,7 +3177,7 @@ void Graphics::drawforetile2(int x, int y, int t)
setRect(rect, x,y,tiles_rect.w, tiles_rect.h); setRect(rect, x,y,tiles_rect.w, tiles_rect.h);
#if !defined(NO_CUSTOM_LEVELS) #if !defined(NO_CUSTOM_LEVELS)
if (t >= 14 && t <= 17 && (!FILESYSTEM_assetsmounted || ed.onewaycol_override)) if (shouldrecoloroneway(t))
{ {
colourTransform thect = {ed.getonewaycol()}; colourTransform thect = {ed.getonewaycol()};
BlitSurfaceTinted(tiles2[t], NULL, foregroundBuffer, &rect, thect); BlitSurfaceTinted(tiles2[t], NULL, foregroundBuffer, &rect, thect);

View file

@ -161,6 +161,9 @@ public:
void drawbackground(int t); void drawbackground(int t);
void updatebackground(int t); void updatebackground(int t);
#ifndef NO_CUSTOM_LEVELS
bool shouldrecoloroneway(const int tilenum);
#endif
void drawtile3( int x, int y, int t, int off, int height_subtract = 0 ); void drawtile3( int x, int y, int t, int off, int height_subtract = 0 );
void drawtile2( int x, int y, int t ); void drawtile2( int x, int y, int t );
void drawtile( int x, int y, int t ); void drawtile( int x, int y, int t );