mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Merge pull request #1112 from trigger-death/sprite-build-command
Sprite build command
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -231,3 +231,4 @@ pip-log.txt
|
||||
openrct2.id*
|
||||
openrct2.nam
|
||||
openrct2.til
|
||||
data/g2.dat
|
||||
|
||||
2
build_g2.bat
Normal file
2
build_g2.bat
Normal file
@@ -0,0 +1,2 @@
|
||||
.\build\release\openrct2.exe sprite build "data/g2.dat" "resources/g2/"
|
||||
pause
|
||||
BIN
data/g2.dat
BIN
data/g2.dat
Binary file not shown.
@@ -264,6 +264,8 @@
|
||||
<LibraryPath>$(SolutionDir)..\lib\sdl\lib\x86;$(LibraryPath)</LibraryPath>
|
||||
<OutDir>$(SolutionDir)..\build\$(Configuration)\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\obj\$(ProjectName)\$(Configuration)\</IntDir>
|
||||
<CustomBuildBeforeTargets>
|
||||
</CustomBuildBeforeTargets>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -304,8 +306,18 @@
|
||||
<AdditionalDependencies>winmm.lib;sdl2.lib;Dsound.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>xcopy /Y "$(SolutionDir)\..\Data\*.*" "$(TargetDir)\Data\"</Command>
|
||||
<Command>"$(TargetDir)\openrct2.exe" sprite build "$(SolutionDir)\..\Data\g2.dat" "$(SolutionDir)\..\Resources\g2\"
|
||||
xcopy /Y "$(SolutionDir)\..\Data\*.*" "$(TargetDir)\Data\"</Command>
|
||||
<Message>Build g2.dat and copy the Data directory.</Message>
|
||||
</PostBuildEvent>
|
||||
<CustomBuildStep>
|
||||
<Command>
|
||||
</Command>
|
||||
</CustomBuildStep>
|
||||
<CustomBuildStep>
|
||||
<Outputs>
|
||||
</Outputs>
|
||||
</CustomBuildStep>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
||||
@@ -378,7 +378,6 @@
|
||||
<ClCompile Include="..\src\windows\editor_object_selection.c">
|
||||
<Filter>Source\Windows</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
||||
<ClCompile Include="..\src\localisation\user.c">
|
||||
<Filter>Source\Localisation</Filter>
|
||||
</ClCompile>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 246 B After Width: | Height: | Size: 229 B |
@@ -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 <spritefile> <resourcedir> [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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user