diff --git a/.travis.yml b/.travis.yml index b4e4ea8f..e536a1d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,13 +26,13 @@ matrix: - scripts/docker/docker_travis.sh "conan_base.docker" - os: osx env: NAME="Apple macOS" NAME_SUFFIX="mac" - osx_image: xcode9.2 + osx_image: xcode9.4 install: - brew update - /usr/bin/yes | pip2 uninstall numpy # see https://github.com/travis-ci/travis-ci/issues/6688 - brew upgrade python - brew upgrade - - brew install boost cmake bullet ffmpeg glm openal-soft qt5 sdl2 jack + - brew install boost cmake bullet ffmpeg glm openal-soft qt5 sdl2 jack freetype - export PATH="/usr/local/opt/qt/bin:$PATH" script: - mkdir -p "$TRAVIS_BUILD_DIR/build" diff --git a/CMakeLists.txt b/CMakeLists.txt index 576167b3..be2cbc7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,9 @@ else() if(BUILD_TESTS) find_package(Boost COMPONENTS unit_test_framework REQUIRED) endif() + if(BUILD_TOOLS) + find_package(Freetype REQUIRED) + endif() # Do not link to SDL2main library set(SDL2_BUILDING_LIBRARY True) diff --git a/cmake/ctest/build.ctest b/cmake/ctest/build.ctest index 7d75eac2..ffa60618 100644 --- a/cmake/ctest/build.ctest +++ b/cmake/ctest/build.ctest @@ -8,6 +8,7 @@ set(_ARGS_BOOL USE_CONAN DEBUG CHECK_INCLUDES + BUILD_TOOLS BUILD_VIEWER RUN_TESTS @@ -142,6 +143,7 @@ else() endif() set(_CONFIGURE_OPTIONS + "-DBUILD_TOOLS=${BUILD_TOOLS}" "-DBUILD_VIEWER=${BUILD_VIEWER}" "-DBUILD_TESTS=TRUE" "-DTESTS_NODATA=${TESTS_NODATA}" diff --git a/cmake/ctest/configure_darwin.ctest b/cmake/ctest/configure_darwin.ctest index 4aca514e..39cdab58 100644 --- a/cmake/ctest/configure_darwin.ctest +++ b/cmake/ctest/configure_darwin.ctest @@ -1,6 +1,7 @@ set(CMAKE_GENERATOR "Xcode") set(DEBUG FALSE) set(CONFIGURE_EXTRA_OPTIONS ";") +set(BUILD_TOOLS TRUE) set(BUILD_VIEWER TRUE) set(COVERAGE_COMMAND gcov) set(CHECK_INCLUDES FALSE) diff --git a/cmake/ctest/configure_linux.ctest b/cmake/ctest/configure_linux.ctest index a6d6d19c..0690718c 100644 --- a/cmake/ctest/configure_linux.ctest +++ b/cmake/ctest/configure_linux.ctest @@ -1,6 +1,7 @@ set(CMAKE_GENERATOR "Unix Makefiles") set(DEBUG FALSE) set(CONFIGURE_EXTRA_OPTIONS ";") +set(BUILD_TOOLS TRUE) set(BUILD_VIEWER TRUE) set(COVERAGE_COMMAND gcov) set(CHECK_INCLUDES FALSE) diff --git a/cmake/ctest/configure_windows.ctest b/cmake/ctest/configure_windows.ctest index a3d4281b..2b9080b3 100644 --- a/cmake/ctest/configure_windows.ctest +++ b/cmake/ctest/configure_windows.ctest @@ -35,6 +35,7 @@ endif() set(CONAN_PROFILE "${CTEST_SOURCE_DIRECTORY}/scripts/conan/windows") set(CONAN_ARCH "x86_64") +set(BUILD_TOOLS TRUE) set(BUILD_VIEWER TRUE) set(COVERAGE_COMMAND "echo") #FIXME: ENABLE set(CHECK_INCLUDES FALSE) #FIXME: ENABLE diff --git a/cmake/modules/WrapTargets.cmake b/cmake/modules/WrapTargets.cmake index c4e36991..34579d45 100644 --- a/cmake/modules/WrapTargets.cmake +++ b/cmake/modules/WrapTargets.cmake @@ -47,6 +47,9 @@ function(rwdep_wrap_find_packages) if(Boost_UNIT_TEST_FRAMEWORK_FOUND) rwdep_wrap_find_package(boost_unit_test_framework "${Boost_INCLUDE_DIRS}" "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}") endif() + if(FREETYPE_FOUND) + rwdep_wrap_find_package(freetype "${FREETYPE_INCLUDE_DIRS}" "${FREETYPE_LIBRARIES}") + endif() endfunction() function(rwdep_wrap_conan_target TARGET CONAN_NAME) @@ -66,4 +69,7 @@ function(rwdep_wrap_conan_targets) rwdep_wrap_conan_target(glm glm) rwdep_wrap_conan_target(ffmpeg ffmpeg) rwdep_wrap_conan_target(SDL2 sdl2) + if(BUILD_TOOLS) + rwdep_wrap_conan_target(freetype freetype) + endif() endfunction() diff --git a/rwengine/CMakeLists.txt b/rwengine/CMakeLists.txt index fc27149b..523f1a2d 100644 --- a/rwengine/CMakeLists.txt +++ b/rwengine/CMakeLists.txt @@ -3,11 +3,6 @@ ########################################################### set(RWENGINE_SOURCES - src/BinaryStream.cpp - src/BinaryStream.hpp - src/TextureArchive.cpp - src/TextureArchive.hpp - src/ai/AIGraph.cpp src/ai/AIGraph.hpp src/ai/AIGraphNode.cpp diff --git a/rwengine/src/BinaryStream.cpp b/rwengine/src/BinaryStream.cpp deleted file mode 100644 index 7ca1f157..00000000 --- a/rwengine/src/BinaryStream.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include "BinaryStream.hpp" - -#include -#include -#include - -namespace RW { - -std::unique_ptr BinaryStream::parse(const std::string &filename) { - std::ifstream dfile(filename, std::ios_base::binary); - if (!dfile.is_open()) { - RW_ERROR("Error opening file " << filename); - return nullptr; - } - - dfile.seekg(0, std::ios_base::end); - size_t length = dfile.tellg(); - dfile.seekg(0); - char *data = new char[length]; - dfile.read(data, length); - // RW_MESSAGE("File is " << length << " bytes"); - - auto BS = std::make_unique(); - - // Set file's ACTUAL length - auto header = reinterpret_cast(data); - length = header->size + sizeof(nativeSectionHeader_t); - - sectionHeader_t *prevHeader = nullptr; - - size_t offset = 0; - while (offset < length) { - nativeSectionHeader_t *sectionHeader = - reinterpret_cast(data + offset); - sectionHeader_t *sec = new sectionHeader_t; - sec->ID = sectionHeader->ID; - sec->size = sectionHeader->size; - sec->version = sectionHeader->version; - if (prevHeader == nullptr) - BS->rootHeader = sec; - else - prevHeader->next = sec; - - if (sectionHeader->ID == 0) { - RW_ERROR("Section ID is ZERO! Abort!"); - break; - } - - RW_MESSAGE("Section " << std::hex << sectionHeader->ID << " (" - << sectionIdString(sectionHeader->ID) << ")" - << " - " << std::dec << sectionHeader->size << " bytes"); - /* - RW_MESSAGE("Offset " << std::hex << offset); - */ - - size_t bytesOfData = 0; - switch (sectionHeader->ID) { - case STRUCT: - bytesOfData = sectionHeader->size; - sec->data = new uint8_t[bytesOfData]; - memcpy(sec->data, data + offset + sizeof(nativeSectionHeader_t), - bytesOfData); - break; - } - // RW_MESSAGE("It has " << std::dec << bytesOfData - // << " bytes of data!"); - offset += sizeof(nativeSectionHeader_t) + bytesOfData; - - prevHeader = sec; - } - - delete[] data; - - return BS; -} - -std::string BinaryStream::sectionIdString(uint32_t id) { - switch (id) { - case STRUCT: - return "STRUCT"; - case EXTENSION: - return "EXTENSION"; - case TEXTURE_NATIVE: - return "TEXTURE_NATIVE"; - case TEXTURE_DICTIONARY: - return "TEXTURE_DICTIONARY"; - default: - return "UNKNOWN"; - } -} -} diff --git a/rwengine/src/BinaryStream.hpp b/rwengine/src/BinaryStream.hpp deleted file mode 100644 index d0a197e8..00000000 --- a/rwengine/src/BinaryStream.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _RWENGINE_BINARYSTREAM_HPP_ -#define _RWENGINE_BINARYSTREAM_HPP_ - -#include -#include -#include - -namespace RW { - -class BinaryStream { -private: - struct nativeSectionHeader_t { - uint32_t ID; - uint32_t size; - uint32_t version; - }; - -public: - enum { - STRUCT = 0x0001, - EXTENSION = 0x0003, - TEXTURE_NATIVE = 0x0015, - TEXTURE_DICTIONARY = 0x0016, - }; - - struct sectionHeader_t { - uint32_t ID; - uint32_t size; - uint32_t version; - - uint8_t *data = nullptr; - sectionHeader_t *next = nullptr; - } * rootHeader; - - static std::unique_ptr parse(const std::string &filename); - - static std::string sectionIdString(uint32_t id); -}; -} - -#endif diff --git a/rwengine/src/TextureArchive.cpp b/rwengine/src/TextureArchive.cpp deleted file mode 100644 index b9d3ccb1..00000000 --- a/rwengine/src/TextureArchive.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "TextureArchive.hpp" - -#include -#include -#include - -#include - -#include "BinaryStream.hpp" - -namespace RW { - -std::unique_ptr TextureArchive::create( - BinaryStream &binaryStream) { - auto textureArchive = std::make_unique(); - - auto section = binaryStream.rootHeader; - - RW_ASSERT(section->ID == BinaryStream::TEXTURE_DICTIONARY && - "BinaryStream passed to this function must be a TEXTURE DICTIONARY"); - - // Struct - section = section->next; - textureArchive->numTextures = - reinterpret_cast(section->data)[0]; - - for (size_t i = 0; i < textureArchive->numTextures; i++) { - section = section->next; // Texture Native - section = section->next; // Struct - - Texture texture = *reinterpret_cast(section->data); - - if (texture.header.rasterFormat & 0x2000) { - memcpy(texture.body.palette, - section->data + sizeof(TextureHeader) - 4, 1024); - - texture.body.pixels = - new uint8_t[texture.header.width * texture.header.height]; - memcpy(texture.body.pixels, - section->data + sizeof(TextureHeader) + 1024, - texture.header.width * texture.header.height); - } else { - size_t bufSize = texture.header.width * texture.header.height * - texture.header.bpp / 8; - texture.body.pixels = new uint8_t[bufSize]; - memcpy(texture.body.pixels, section->data + sizeof(TextureHeader), - bufSize); - } - - textureArchive->textures.push_back(texture); - - section = section->next; // Extension - } - - return textureArchive; -} -} diff --git a/rwengine/src/TextureArchive.hpp b/rwengine/src/TextureArchive.hpp deleted file mode 100644 index c1593d95..00000000 --- a/rwengine/src/TextureArchive.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef _RWENGINE_TEXTUREARCHIVE_HPP_ -#define _RWENGINE_TEXTUREARCHIVE_HPP_ - -#include -#include -#include -#include - -namespace RW { - -class BinaryStream; - -class TextureArchive { -public: - struct TextureHeader { - uint32_t platformID; - uint16_t filterFlags; - uint8_t textureWrapV; - uint8_t textureWrapU; - uint8_t diffuseName[32]; - uint8_t alphaName[32]; - uint32_t rasterFormat; - uint32_t alpha; - uint16_t width; - uint16_t height; - uint8_t bpp; - uint8_t numMipmap; - uint8_t rasterType; - uint8_t compression; - uint32_t dataSize; - }; - struct TextureBody { - uint8_t palette[1024]; - uint8_t *pixels; - }; - struct Texture { - TextureHeader header; - TextureBody body; - }; - - size_t numTextures; - std::vector textures; - - static std::unique_ptr create(BinaryStream &binaryStream); -}; -} - -#endif diff --git a/rwtools/rwfont/CMakeLists.txt b/rwtools/rwfont/CMakeLists.txt index 57608113..be0a8167 100644 --- a/rwtools/rwfont/CMakeLists.txt +++ b/rwtools/rwfont/CMakeLists.txt @@ -1,5 +1,4 @@ # fixme: conan support -find_package(Freetype REQUIRED) find_package(Qt5 REQUIRED COMPONENTS Gui) add_executable(rwfontmap rwfontmap.cpp @@ -7,8 +6,13 @@ add_executable(rwfontmap target_link_libraries(rwfontmap PUBLIC - rwlib - Freetype::Freetype + rwcore + rwdep::freetype + rwdep::boost_program_options Qt5::Gui - Boost::program_options ) + +install(TARGETS rwfontmap + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + ) + \ No newline at end of file diff --git a/rwtools/rwfont/rwfontmap.cpp b/rwtools/rwfont/rwfontmap.cpp index 1fdf779f..8850ce03 100644 --- a/rwtools/rwfont/rwfontmap.cpp +++ b/rwtools/rwfont/rwfontmap.cpp @@ -183,9 +183,9 @@ public: } void write(const rwfs::path &bitmap_path, const rwfs::path &advance_path) { - QImageWriter writer(bitmap_path.c_str()); + QImageWriter writer(QString::fromStdString(bitmap_path.string())); writer.write(m_texture); - std::ofstream ofs(advance_path.c_str(), std::ios_base::out); + std::ofstream ofs(advance_path.string(), std::ios_base::out); ofs << m_aspectratio << '\n'; for (auto adv : m_advances) { ofs << int(adv) << '\n'; diff --git a/scripts/conan/darwin b/scripts/conan/darwin index a57148d2..75a54c8d 100644 --- a/scripts/conan/darwin +++ b/scripts/conan/darwin @@ -1,6 +1,7 @@ include(default) [options] +openrw:tools=True openrw:viewer=True # https://github.com/bincrafters/community/issues/120 ffmpeg:vdpau=False diff --git a/scripts/conan/linux b/scripts/conan/linux index 26f24058..d42b330e 100644 --- a/scripts/conan/linux +++ b/scripts/conan/linux @@ -1,6 +1,7 @@ include(default) [options] +openrw:tools=True openrw:viewer=True sdl2:esd=False sdl2:wayland=True diff --git a/scripts/conan/windows b/scripts/conan/windows index d75443aa..1eccbc8e 100644 --- a/scripts/conan/windows +++ b/scripts/conan/windows @@ -1,5 +1,6 @@ include(default) [options] +openrw:tools=True openrw:viewer=True ffmpeg:qsv=False diff --git a/scripts/docker/arch_latest.docker b/scripts/docker/arch_latest.docker index 89e82079..40378719 100644 --- a/scripts/docker/arch_latest.docker +++ b/scripts/docker/arch_latest.docker @@ -10,6 +10,7 @@ RUN pacman -Syy --noconfirm \ community/glm \ extra/openal \ extra/sdl2 \ - extra/qt5-base + extra/qt5-base \ + extra/freetype2 CMD ["/bin/bash"] diff --git a/scripts/docker/fedora_latest.docker b/scripts/docker/fedora_latest.docker index 4cad6257..f190f4f2 100644 --- a/scripts/docker/fedora_latest.docker +++ b/scripts/docker/fedora_latest.docker @@ -17,6 +17,7 @@ RUN dnf update -y \ openal-soft-devel \ SDL2-devel \ qt5-devel \ + freetype-devel \ libasan CMD ["/bin/bash"] diff --git a/scripts/docker/ubuntu_latest.docker b/scripts/docker/ubuntu_latest.docker index 811b61be..5fbfad23 100644 --- a/scripts/docker/ubuntu_latest.docker +++ b/scripts/docker/ubuntu_latest.docker @@ -16,6 +16,7 @@ RUN apt-get update \ libsdl2-dev \ libboost-test-dev \ libqt5opengl5-dev \ + libfreetype6-dev \ iwyu \ qt5-default