From e84194db5523e60d92adf9611ef9920b7c4a31ec Mon Sep 17 00:00:00 2001 From: Misa Date: Tue, 30 Jun 2020 11:47:22 -0700 Subject: [PATCH] Re-color one-way tiles to match their tileset One-ways have always had this problem where they're always yellow. That means unless you specifically use yellow, it'll never match the tileset. The best way to fix this without requiring new graphics or changing existing ones is to simply re-tint the one-way with the given color of the room. That way, the black part of the tile is still black, but the yellow is now some other color. --- desktop_version/src/Graphics.cpp | 54 +++++++++- desktop_version/src/editor.cpp | 177 +++++++++++++++++++++++++++++++ desktop_version/src/editor.h | 3 + 3 files changed, 230 insertions(+), 4 deletions(-) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 8ea37492..4bc043ab 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -636,8 +636,20 @@ void Graphics::drawtile( int x, int y, int t ) { return; } + SDL_Rect rect = { Sint16(x), Sint16(y), tiles_rect.w, tiles_rect.h }; - BlitSurfaceStandard(tiles[t], NULL, backBuffer, &rect); + +#if !defined(NO_CUSTOM_LEVELS) + if (t >= 14 && t <= 17) + { + colourTransform thect = {ed.getonewaycol()}; + BlitSurfaceTinted(tiles[t], NULL, backBuffer, &rect, thect); + } + else +#endif + { + BlitSurfaceStandard(tiles[t], NULL, backBuffer, &rect); + } } @@ -647,8 +659,20 @@ void Graphics::drawtile2( int x, int y, int t ) { return; } + SDL_Rect rect = { Sint16(x), Sint16(y), tiles_rect.w, tiles_rect.h }; - BlitSurfaceStandard(tiles2[t], NULL, backBuffer, &rect); + +#if !defined(NO_CUSTOM_LEVELS) + if (t >= 14 && t <= 17) + { + colourTransform thect = {ed.getonewaycol()}; + BlitSurfaceTinted(tiles2[t], NULL, backBuffer, &rect, thect); + } + else +#endif + { + BlitSurfaceStandard(tiles2[t], NULL, backBuffer, &rect); + } } @@ -3088,14 +3112,36 @@ void Graphics::drawforetile(int x, int y, int t) { SDL_Rect rect; setRect(rect, x,y,tiles_rect.w, tiles_rect.h); - BlitSurfaceStandard(tiles[t],NULL, foregroundBuffer, &rect ); + +#if !defined(NO_CUSTOM_LEVELS) + if (t >= 14 && t <= 17) + { + colourTransform thect = {ed.getonewaycol()}; + BlitSurfaceTinted(tiles[t], NULL, foregroundBuffer, &rect, thect); + } + else +#endif + { + BlitSurfaceStandard(tiles[t],NULL, foregroundBuffer, &rect ); + } } void Graphics::drawforetile2(int x, int y, int t) { SDL_Rect rect; setRect(rect, x,y,tiles_rect.w, tiles_rect.h); - BlitSurfaceStandard(tiles2[t],NULL, foregroundBuffer, &rect ); + +#if !defined(NO_CUSTOM_LEVELS) + if (t >= 14 && t <= 17) + { + colourTransform thect = {ed.getonewaycol()}; + BlitSurfaceTinted(tiles2[t], NULL, foregroundBuffer, &rect, thect); + } + else +#endif + { + BlitSurfaceStandard(tiles2[t],NULL, foregroundBuffer, &rect ); + } } void Graphics::drawforetile3(int x, int y, int t, int off) diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index a20bc247..0b7e0e9b 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -5598,6 +5598,183 @@ void editorinput() } #endif /* NO_EDITOR */ +// Return a graphics-ready color based off of the given tileset and tilecol +// Much kudos to Dav999 for saving me a lot of work, because I stole these colors from const.lua in Ved! -Info Teddy +Uint32 editorclass::getonewaycol(const int rx, const int ry) +{ + const int roomnum = rx + ry*maxwidth; + if (roomnum < 0 || roomnum >= 400) + { + return graphics.getRGB(255, 255, 255); + } + const edlevelclass& room = level[roomnum]; + switch (room.tileset) { + + case 0: // Space Station + switch (room.tilecol) { + case -1: + return graphics.getRGB(109, 109, 109); + case 0: + return graphics.getRGB(131, 141, 235); + case 1: + return graphics.getRGB(227, 140, 227); + case 2: + return graphics.getRGB(242, 126, 151); + case 3: + return graphics.getRGB(229, 235, 133); + case 4: + return graphics.getRGB(148, 238, 130); + case 5: + return graphics.getRGB(140, 165, 227); + case 6: + return graphics.getRGB(227, 140, 148); + case 7: + return graphics.getRGB(140, 173, 228); + case 8: + return graphics.getRGB(142, 235, 137); + case 9: + return graphics.getRGB(137, 235, 206); + case 10: + return graphics.getRGB(235, 139, 223); + case 11: + return graphics.getRGB(238, 130, 138); + case 12: + return graphics.getRGB(137, 235, 178); + case 13: + return graphics.getRGB(125, 205, 247); + case 14: + return graphics.getRGB(190, 137, 235); + case 15: + return graphics.getRGB(235, 137, 206); + case 16: + return graphics.getRGB(229, 247, 127); + case 17: + return graphics.getRGB(127, 200, 247); + case 18: + return graphics.getRGB(197, 137, 235); + case 19: + return graphics.getRGB(235, 131, 175); + case 20: + return graphics.getRGB(242, 210, 123); + case 21: + return graphics.getRGB(131, 235, 158); + case 22: + return graphics.getRGB(242, 126, 151); + case 23: + return graphics.getRGB(219, 243, 123); + case 24: + return graphics.getRGB(131, 234, 145); + case 25: + return graphics.getRGB(131, 199, 234); + case 26: + return graphics.getRGB(141, 131, 234); + case 27: + return graphics.getRGB(226, 140, 144); + case 28: + return graphics.getRGB(129, 236, 144); + case 29: + return graphics.getRGB(235, 231, 131); + case 30: + return graphics.getRGB(153, 235, 131); + case 31: + return graphics.getRGB(207, 131, 235); + } + break; + + case 1: // Outside + switch (room.tilecol) { + case 0: + return graphics.getRGB(57, 86, 140); + case 1: + return graphics.getRGB(156, 42, 42); + case 2: + return graphics.getRGB(42, 156, 155); + case 3: + return graphics.getRGB(125, 36, 162); + case 4: + return graphics.getRGB(191, 198, 0); + case 5: + return graphics.getRGB(0, 198, 126); + case 6: + return graphics.getRGB(224, 110, 177); + case 7: + return graphics.getRGB(255, 142, 87); + } + break; + + case 2: // Lab + switch (room.tilecol) { + case 0: + return graphics.getRGB(0, 165, 206); + case 1: + return graphics.getRGB(206, 5, 0); + case 2: + return graphics.getRGB(222, 0, 173); + case 3: + return graphics.getRGB(27, 67, 255); + case 4: + return graphics.getRGB(194, 206, 0); + case 5: + return graphics.getRGB(0, 206, 39); + case 6: + return graphics.getRGB(0, 165, 206); + } + break; + + case 3: // Warp Zone + switch (room.tilecol) { + case 0: + return graphics.getRGB(113, 178, 197); + case 1: + return graphics.getRGB(197, 113, 119); + case 2: + return graphics.getRGB(196, 113, 197); + case 3: + return graphics.getRGB(149, 113, 197); + case 4: + return graphics.getRGB(197, 182, 113); + case 5: + return graphics.getRGB(141, 197, 113); + case 6: + return graphics.getRGB(109, 109, 109); + } + break; + + case 4: // Ship + switch (room.tilecol) { + case 0: + return graphics.getRGB(0, 206, 39); + case 1: + return graphics.getRGB(0, 165, 206); + case 2: + return graphics.getRGB(194, 206, 0); + case 3: + return graphics.getRGB(206, 0, 160); + case 4: + return graphics.getRGB(27, 67, 255); + case 5: + return graphics.getRGB(206, 5, 0); + } + break; + + } + + // Uh, I guess return solid white + return graphics.getRGB(255, 255, 255); +} + +// This version detects the room automatically +Uint32 editorclass::getonewaycol() +{ + if (game.gamestate == EDITORMODE) + return getonewaycol(ed.levx, ed.levy); + else if (map.custommode) + return getonewaycol(game.roomx - 100, game.roomy - 100); + + // Uh, I guess return solid white + return graphics.getRGB(255, 255, 255); +} + int editorclass::numtrinkets() { int temp = 0; diff --git a/desktop_version/src/editor.h b/desktop_version/src/editor.h index e1436c06..9237693b 100644 --- a/desktop_version/src/editor.h +++ b/desktop_version/src/editor.h @@ -239,6 +239,9 @@ class editorclass{ int dmtile; int dmtileeditor; + Uint32 getonewaycol(const int rx, const int ry); + Uint32 getonewaycol(); + int returneditoralpha; int oldreturneditoralpha;