mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 06:53:43 +00:00
Add ConvertColorCursors to CMake, port to *nix
- Includes WindowsUnicodeToolShim.h. - Replaces sprintf_s() with std::ostringstream. - Replaces fopen_s() with fopen_utf8(). - Switches to the toolMain() wrapper, which is a no-op on except on Windows, where it should improve Unicode support, though I can't test that on my end. - Replaces \ with / in paths, which should still be Windows-compatible.
This commit is contained in:
@@ -472,5 +472,21 @@ if(FREETYPE_FOUND)
|
|||||||
target_link_libraries(GenerateFonts PortabilityLayer GpFontHandler_FreeType2)
|
target_link_libraries(GenerateFonts PortabilityLayer GpFontHandler_FreeType2)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_executable(ConvertColorCursors
|
||||||
|
ConvertColorCursors/ConvertColorCursors.cpp
|
||||||
|
AerofoilPortable/GpAllocator_C.cpp
|
||||||
|
stb/stb_image_write.c
|
||||||
|
WindowsUnicodeToolShim/UnixUnicodeToolShim.cpp
|
||||||
|
)
|
||||||
|
target_include_directories(ConvertColorCursors PRIVATE
|
||||||
|
Common
|
||||||
|
GpCommon
|
||||||
|
PortabilityLayer
|
||||||
|
AerofoilPortable
|
||||||
|
stb
|
||||||
|
WindowsUnicodeToolShim
|
||||||
|
)
|
||||||
|
target_link_libraries(ConvertColorCursors PortabilityLayer)
|
||||||
|
|
||||||
|
|
||||||
install (TARGETS ${EXECNAME})
|
install (TARGETS ${EXECNAME})
|
||||||
|
@@ -8,8 +8,11 @@
|
|||||||
#include "QDStandardPalette.h"
|
#include "QDStandardPalette.h"
|
||||||
#include "PLBigEndian.h"
|
#include "PLBigEndian.h"
|
||||||
#include "PLDrivers.h"
|
#include "PLDrivers.h"
|
||||||
#include <assert.h>
|
#include "WindowsUnicodeToolShim.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -92,12 +95,12 @@ void ConvertIconFamily(PortabilityLayer::ResourceFile *resFile, int32_t iconBitm
|
|||||||
item.a = 0;
|
item.a = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char outPath[256];
|
std::string outPath = (
|
||||||
sprintf_s(outPath, "Aerofoil\\ConvertedResources\\%s%i.ico", prefix, resID);
|
std::ostringstream() << "Aerofoil/ConvertedResources/" << prefix << resID << ".ico"
|
||||||
|
).str();
|
||||||
|
|
||||||
FILE *outF = nullptr;
|
FILE *outF = fopen_utf8(outPath.c_str(), "wb");
|
||||||
errno_t outErr = fopen_s(&outF, outPath, "wb");
|
if (outF)
|
||||||
if (!outErr)
|
|
||||||
{
|
{
|
||||||
IconDir iconDir;
|
IconDir iconDir;
|
||||||
iconDir.m_reserved = 0;
|
iconDir.m_reserved = 0;
|
||||||
@@ -127,6 +130,8 @@ void ConvertIconFamily(PortabilityLayer::ResourceFile *resFile, int32_t iconBitm
|
|||||||
fwrite(&iconDirEntry, 1, sizeof(IconDirEntry), outF);
|
fwrite(&iconDirEntry, 1, sizeof(IconDirEntry), outF);
|
||||||
fclose(outF);
|
fclose(outF);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
perror(outPath.c_str());
|
||||||
|
|
||||||
delete[] pixelData;
|
delete[] pixelData;
|
||||||
bwBlock.Dispose();
|
bwBlock.Dispose();
|
||||||
@@ -134,12 +139,14 @@ void ConvertIconFamily(PortabilityLayer::ResourceFile *resFile, int32_t iconBitm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
int toolMain(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
FILE *f = nullptr;
|
FILE *f = fopen_utf8("Packaged/ApplicationResources.gpr", "rb");
|
||||||
errno_t err = fopen_s(&f, "Packaged\\ApplicationResources.gpr", "rb");
|
if (!f)
|
||||||
if (err)
|
{
|
||||||
return err;
|
perror("Cannot open Packaged/ApplicationResources.gpr");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
PortabilityLayer::CFileStream stream(f);
|
PortabilityLayer::CFileStream stream(f);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user