From 5201f679091b750e66a489599f221095d26f9cf6 Mon Sep 17 00:00:00 2001 From: Misa Date: Tue, 30 Jun 2020 14:08:14 -0700 Subject: [PATCH] Add being able to override the one-way recolor Disabling the one-way recolor if assets are mounted is needed to make existing levels not look bad, but what about levels that want to use the recolor anyway? The best solution here is to just introduce another bool into the XML, and make the re-color opt-in and only present if assets are mounted if that tag is present. --- desktop_version/src/Graphics.cpp | 8 ++++---- desktop_version/src/editor.cpp | 14 ++++++++++++++ desktop_version/src/editor.h | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index b1eee6da..f1a53382 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -640,7 +640,7 @@ void Graphics::drawtile( int x, int y, int t ) SDL_Rect rect = { Sint16(x), Sint16(y), tiles_rect.w, tiles_rect.h }; #if !defined(NO_CUSTOM_LEVELS) - if (t >= 14 && t <= 17 && !FILESYSTEM_assetsmounted) + if (t >= 14 && t <= 17 && (!FILESYSTEM_assetsmounted || ed.onewaycol_override)) { colourTransform thect = {ed.getonewaycol()}; BlitSurfaceTinted(tiles[t], NULL, backBuffer, &rect, thect); @@ -663,7 +663,7 @@ void Graphics::drawtile2( int x, int y, int t ) SDL_Rect rect = { Sint16(x), Sint16(y), tiles_rect.w, tiles_rect.h }; #if !defined(NO_CUSTOM_LEVELS) - if (t >= 14 && t <= 17 && !FILESYSTEM_assetsmounted) + if (t >= 14 && t <= 17 && (!FILESYSTEM_assetsmounted || ed.onewaycol_override)) { colourTransform thect = {ed.getonewaycol()}; BlitSurfaceTinted(tiles2[t], NULL, backBuffer, &rect, thect); @@ -3119,7 +3119,7 @@ void Graphics::drawforetile(int x, int y, int t) setRect(rect, x,y,tiles_rect.w, tiles_rect.h); #if !defined(NO_CUSTOM_LEVELS) - if (t >= 14 && t <= 17 && !FILESYSTEM_assetsmounted) + if (t >= 14 && t <= 17 && (!FILESYSTEM_assetsmounted || ed.onewaycol_override)) { colourTransform thect = {ed.getonewaycol()}; BlitSurfaceTinted(tiles[t], NULL, foregroundBuffer, &rect, thect); @@ -3142,7 +3142,7 @@ void Graphics::drawforetile2(int x, int y, int t) setRect(rect, x,y,tiles_rect.w, tiles_rect.h); #if !defined(NO_CUSTOM_LEVELS) - if (t >= 14 && t <= 17 && !FILESYSTEM_assetsmounted) + if (t >= 14 && t <= 17 && (!FILESYSTEM_assetsmounted || ed.onewaycol_override)) { colourTransform thect = {ed.getonewaycol()}; BlitSurfaceTinted(tiles2[t], NULL, foregroundBuffer, &rect, thect); diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index 0b7e0e9b..ba8435bd 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -398,6 +398,8 @@ void editorclass::reset() ghosts.clear(); currentghosts = 0; + + onewaycol_override = false; } void editorclass::gethooks() @@ -1708,6 +1710,11 @@ bool editorclass::load(std::string& _path) { website = pText; } + + if(pKey == "onewaycol_override") + { + onewaycol_override = atoi(pText); + } } } @@ -1993,6 +2000,13 @@ bool editorclass::save(std::string& _path) meta->LinkEndChild( doc.NewText( website.c_str() )); msg->LinkEndChild( meta ); + if (onewaycol_override) + { + meta = doc.NewElement( "onewaycol_override" ); + meta->LinkEndChild( doc.NewText( help.String(onewaycol_override).c_str() )); + msg->LinkEndChild( meta ); + } + data->LinkEndChild( msg ); msg = doc.NewElement( "mapwidth" ); diff --git a/desktop_version/src/editor.h b/desktop_version/src/editor.h index 9237693b..75d6fe7d 100644 --- a/desktop_version/src/editor.h +++ b/desktop_version/src/editor.h @@ -241,6 +241,7 @@ class editorclass{ Uint32 getonewaycol(const int rx, const int ry); Uint32 getonewaycol(); + bool onewaycol_override; int returneditoralpha; int oldreturneditoralpha;