World selection screen now shows grass block for worlds without a thumbnail
This commit is contained in:
15
src/data.c
15
src/data.c
@@ -1,4 +1,3 @@
|
||||
#include "data.h"
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -8,6 +7,8 @@
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#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);
|
||||
|
||||
Reference in New Issue
Block a user