mirror of https://github.com/OpenRCT2/OpenRCT2.git
Sprite build command
build uses ../../data/g2.dat and all numbered images in ../../resources/g2/. No other parameters needed. Also changed speed button hyper arrows to support game speeds inbetween 4 and 8.
This commit is contained in:
parent
86a1ba3994
commit
c7e3639663
BIN
data/g2.dat
BIN
data/g2.dat
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 246 B After Width: | Height: | Size: 229 B |
|
@ -412,6 +412,75 @@ int cmdline_for_sprite(const char **argv, int argc)
|
|||
return -1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
else if (_strcmpi(argv[0], "build") == 0) {
|
||||
/*if (argc < 3) {
|
||||
fprintf(stderr, "usage: sprite build [spritefile] [resources]\n");
|
||||
return -1;
|
||||
}*/
|
||||
|
||||
const char *spriteFilePath = "../../data/g2.dat";
|
||||
const char *resourcePath = "../../resources/g2/";
|
||||
char imagePath[256], number[8];
|
||||
|
||||
bool fileExists = true;
|
||||
FILE *file;
|
||||
|
||||
spriteFileHeader.num_entries = 0;
|
||||
spriteFileHeader.total_size = 0;
|
||||
sprite_file_save(spriteFilePath);
|
||||
|
||||
//sprite_file_close();
|
||||
|
||||
printf("Building: %s\n", spriteFilePath);
|
||||
for (int i = 0; fileExists; i++) {
|
||||
itoa(i, number, 10);
|
||||
strcpy(imagePath, resourcePath);
|
||||
strcat(imagePath, number);
|
||||
strcat(imagePath, ".png");
|
||||
if (file = fopen(imagePath, "r")) {
|
||||
fclose(file);
|
||||
rct_g1_element spriteElement;
|
||||
uint8 *buffer;
|
||||
int bufferLength;
|
||||
if (!sprite_file_import(imagePath, &spriteElement, &buffer, &bufferLength)) {
|
||||
fprintf(stderr, "Could not import image file: %s\nCanceling\n", imagePath);
|
||||
printf("Could not import image file: %s\nCanceling\n", imagePath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!sprite_file_open(spriteFilePath)) {
|
||||
fprintf(stderr, "Unable to open sprite file: %s\nCanceling\n", spriteFilePath);
|
||||
printf("Unable to open sprite file: %s\nCanceling\n", spriteFilePath);
|
||||
return -1;
|
||||
}
|
||||
|
||||
spriteFileHeader.num_entries++;
|
||||
spriteFileHeader.total_size += bufferLength;
|
||||
spriteFileEntries = realloc(spriteFileEntries, spriteFileHeader.num_entries * sizeof(rct_g1_element));
|
||||
spriteFileData = realloc(spriteFileData, spriteFileHeader.total_size);
|
||||
spriteFileEntries[spriteFileHeader.num_entries - 1] = spriteElement;
|
||||
memcpy(spriteFileData + (spriteFileHeader.total_size - bufferLength), buffer, bufferLength);
|
||||
spriteFileEntries[spriteFileHeader.num_entries - 1].offset = spriteFileData + (spriteFileHeader.total_size - bufferLength);
|
||||
|
||||
free(buffer);
|
||||
|
||||
if (!sprite_file_save(spriteFilePath)) {
|
||||
printf("Could not save sprite file: %s\nCanceling\n", imagePath);
|
||||
return -1;
|
||||
}
|
||||
printf("Added: %s\n", imagePath);
|
||||
}
|
||||
else {
|
||||
|
||||
printf("Could not find file: %s\n", imagePath);
|
||||
fileExists = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("Finished\n", imagePath);
|
||||
return 1;
|
||||
} else {
|
||||
fprintf(stderr, "Unknown sprite command.");
|
||||
return -1;
|
||||
|
|
|
@ -351,7 +351,7 @@ enum {
|
|||
SPR_G2_TITLE = SPR_G2_BEGIN + 1,
|
||||
SPR_G2_FASTFORWARD = SPR_G2_BEGIN + 2,
|
||||
SPR_G2_SPEED_ARROW = SPR_G2_BEGIN + 3,
|
||||
SPR_G2_HYPER_ARROWS = SPR_G2_BEGIN + 4
|
||||
SPR_G2_HYPER_ARROW = SPR_G2_BEGIN + 4
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -647,9 +647,12 @@ static void window_top_toolbar_paint()
|
|||
for (int i = 0; i < gGameSpeed && gGameSpeed <= 4; i++) {
|
||||
gfx_draw_sprite(dpi, SPR_G2_SPEED_ARROW, x + 5 + i * 5, y + 15, 0);
|
||||
}
|
||||
if (gGameSpeed == 8) {
|
||||
gfx_draw_sprite(dpi, SPR_G2_HYPER_ARROWS, x + 5, y + 15, 0);
|
||||
for (int i = 0; i < 3 && i < gGameSpeed - 4 && gGameSpeed >= 5; i++) {
|
||||
gfx_draw_sprite(dpi, SPR_G2_HYPER_ARROW, x + 5 + i * 6, y + 15, 0);
|
||||
}
|
||||
/*if (gGameSpeed >= 8) {
|
||||
gfx_draw_sprite(dpi, SPR_G2_HYPER_ARROWS, x + 5, y + 15, 0);
|
||||
}*/
|
||||
}
|
||||
|
||||
// Draw cheats button
|
||||
|
|
Loading…
Reference in New Issue