From d5cc1e83a2fde758086f283ff976c8b8dc919cba Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Mon, 2 May 2022 11:27:07 -0400 Subject: [PATCH] World selection screen now shows grass block for worlds without a thumbnail --- src/data.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/data.c b/src/data.c index 80b0470..098eb0c 100644 --- a/src/data.c +++ b/src/data.c @@ -1,4 +1,3 @@ -#include "data.h" #include #include #include @@ -8,6 +7,8 @@ #include #include #include +#include "data.h" +#include "textures.h" data_Options data_options = { 0 }; data_WorldListItem *data_worldList = NULL; @@ -206,11 +207,11 @@ int data_refreshWorldList () { item->name); SDL_Surface *image = SDL_LoadBMP(path); + int *pixel = item->thumbnail.buffer; // Do not accept vertical images if (image != NULL && image->h <= image->w) { int scale = image->h / 16; - int *pixel = item->thumbnail.buffer; for (int y = 0; y < 16; y ++) for (int x = 0; x < 16; x ++) { *pixel = getSurfacePixel (image, @@ -218,6 +219,16 @@ int data_refreshWorldList () { y * scale); pixel ++; } + } else { + for (int y = 0; y < 16; y ++) + for (int x = 0; x < 16; x ++) { + *pixel = textures [ + x + + y * BLOCK_TEXTURE_W + + (BLOCK_GRASS * 3 + 1) * + BLOCK_TEXTURE_W * BLOCK_TEXTURE_H]; + pixel ++; + } } SDL_FreeSurface(image);