diff --git a/.gitignore b/.gitignore index 6486216ed8..c34bf9e3e5 100644 --- a/.gitignore +++ b/.gitignore @@ -231,3 +231,4 @@ pip-log.txt openrct2.id* openrct2.nam openrct2.til +data/g2.dat diff --git a/build_g2.bat b/build_g2.bat new file mode 100644 index 0000000000..3cdef7917c --- /dev/null +++ b/build_g2.bat @@ -0,0 +1,2 @@ +.\build\release\openrct2.exe sprite build "data/g2.dat" "resources/g2/" +pause \ No newline at end of file diff --git a/data/g2.dat b/data/g2.dat index ce7d217b48..697d7bbdf8 100644 Binary files a/data/g2.dat and b/data/g2.dat differ diff --git a/projects/openrct2.vcxproj b/projects/openrct2.vcxproj index 0e3320b342..02c1ab98ec 100644 --- a/projects/openrct2.vcxproj +++ b/projects/openrct2.vcxproj @@ -264,6 +264,8 @@ $(SolutionDir)..\lib\sdl\lib\x86;$(LibraryPath) $(SolutionDir)..\build\$(Configuration)\ $(SolutionDir)..\obj\$(ProjectName)\$(Configuration)\ + + @@ -304,8 +306,18 @@ winmm.lib;sdl2.lib;Dsound.lib;%(AdditionalDependencies) - xcopy /Y "$(SolutionDir)\..\Data\*.*" "$(TargetDir)\Data\" + "$(TargetDir)\openrct2.exe" sprite build "$(SolutionDir)\..\Data\g2.dat" "$(SolutionDir)\..\Resources\g2\" +xcopy /Y "$(SolutionDir)\..\Data\*.*" "$(TargetDir)\Data\" + Build g2.dat and copy the Data directory. + + + + + + + + diff --git a/projects/openrct2.vcxproj.filters b/projects/openrct2.vcxproj.filters index c39a466b58..eb0498021c 100644 --- a/projects/openrct2.vcxproj.filters +++ b/projects/openrct2.vcxproj.filters @@ -378,7 +378,6 @@ Source\Windows - Source\Localisation diff --git a/resources/g2/4.png b/resources/g2/4.png index 29118138d8..24395cc1b7 100644 Binary files a/resources/g2/4.png and b/resources/g2/4.png differ diff --git a/src/cmdline_sprite.c b/src/cmdline_sprite.c index d98fb2eb1b..83c2d1b536 100644 --- a/src/cmdline_sprite.c +++ b/src/cmdline_sprite.c @@ -412,9 +412,79 @@ 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 [silent]\n"); + return -1; + } + + const char *spriteFilePath = argv[1]; + const char *resourcePath = argv[2]; + char imagePath[256], number[8]; + int resourceLength = strlen(resourcePath); + + bool silent = (argc >= 4 && strcmp(argv[3], "silent") == 0); + bool fileExists = true; + FILE *file; + + spriteFileHeader.num_entries = 0; + spriteFileHeader.total_size = 0; + sprite_file_save(spriteFilePath); + + fprintf(stderr, "Building: %s\n", spriteFilePath); + for (int i = 0; fileExists; i++) { + itoa(i, number, 10); + strcpy(imagePath, resourcePath); + if (resourceLength == 0 || (resourcePath[resourceLength - 1] != '/' && resourcePath[resourceLength - 1] != '\\')) + strcat(imagePath, "/"); + 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); + return -1; + } + + if (!sprite_file_open(spriteFilePath)) { + fprintf(stderr, "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)) { + fprintf(stderr, "Could not save sprite file: %s\nCanceling\n", imagePath); + return -1; + } + if (!silent) + fprintf(stderr, "Added: %s\n", imagePath); + } + else { + + fprintf(stderr, "Could not find file: %s\n", imagePath); + fileExists = false; + } + } + + + fprintf(stderr, "Finished\n", imagePath); + return 1; } else { fprintf(stderr, "Unknown sprite command."); - return -1; + return 1; } } diff --git a/src/sprites.h b/src/sprites.h index 6b30a0f6fb..cb48b5c5ce 100644 --- a/src/sprites.h +++ b/src/sprites.h @@ -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 diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index 7ad7199397..e2984ac975 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -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