Browse Source

Replace TTF with PCX font

pull/2985/head
Anders Jenbo 5 years ago
parent
commit
4dd8b121ec
  1. 197
      CMake/FindSDL2_ttf.cmake
  2. 2
      CMake/amiga_defs.cmake
  3. 65
      CMake/ctr/modules/FindBZIP2.cmake
  4. 59
      CMake/ctr/modules/FindFREETYPE.cmake
  5. 3
      CMake/ctr/n3ds_defs.cmake
  6. 53
      CMakeLists.txt
  7. 2
      Packaging/OpenDingux/build.sh
  8. 2
      Packaging/OpenDingux/package-opk.sh
  9. BIN
      Packaging/amiga/LiberationSerif-Bold.ttf
  10. 46
      Packaging/amiga/SIL Open Font License.txt
  11. 18
      Packaging/amiga/prep.sh
  12. 2
      Packaging/cpi-gamesh/build.sh
  13. 2
      Packaging/ctr/build.sh
  14. 1
      Packaging/debian/control
  15. 2
      Packaging/nix/AppRun
  16. 3
      Packaging/nix/LinuxReleasePackaging.sh
  17. 2
      Packaging/nix/README.txt
  18. 2
      Packaging/pi/README.txt
  19. BIN
      Packaging/resources/CharisSILB.ttf
  20. 173
      Packaging/resources/LICENSE.freetype.txt
  21. 41
      Packaging/resources/assets/fonts/22-00.bin
  22. BIN
      Packaging/resources/assets/fonts/22-00.pcx
  23. 38
      Packaging/resources/assets/fonts/22-01.bin
  24. BIN
      Packaging/resources/assets/fonts/22-01.pcx
  25. 38
      Packaging/resources/assets/fonts/22-02.bin
  26. BIN
      Packaging/resources/assets/fonts/22-02.pcx
  27. 12
      Packaging/resources/assets/fonts/22-03.bin
  28. BIN
      Packaging/resources/assets/fonts/22-03.pcx
  29. 33
      Packaging/resources/assets/fonts/22-04.bin
  30. BIN
      Packaging/resources/assets/fonts/22-04.pcx
  31. 5
      Packaging/resources/assets/fonts/22-05.bin
  32. BIN
      Packaging/resources/assets/fonts/22-05.pcx
  33. BIN
      Packaging/resources/assets/fonts/yellowdialog.trn
  34. 2
      Packaging/switch/README.txt
  35. 7
      Packaging/switch/build.sh
  36. 13
      Source/DiabloUI/button.cpp
  37. 95
      Source/DiabloUI/credits.cpp
  38. 13
      Source/DiabloUI/diabloui.cpp
  39. 63
      Source/DiabloUI/dialogs.cpp
  40. 53
      Source/DiabloUI/fonts.cpp
  41. 18
      Source/DiabloUI/fonts.h
  42. 28
      Source/DiabloUI/progress.cpp
  43. 67
      Source/DiabloUI/text_draw.cpp
  44. 20
      Source/DiabloUI/text_draw.h
  45. 154
      Source/DiabloUI/ttf_render_wrapped.cpp
  46. 24
      Source/DiabloUI/ttf_render_wrapped.h
  47. 68
      Source/DiabloUI/ui_item.h
  48. 2
      Source/appfat.h
  49. 8
      Source/diablo.cpp
  50. 1
      Source/diablo.h
  51. 17
      Source/engine/render/text_render.cpp
  52. 4
      Source/engine/render/text_render.hpp
  53. 35
      Source/utils/paths.cpp
  54. 4
      Source/utils/paths.h
  55. 29
      Source/utils/ttf_wrap.h
  56. 16
      android-project/3rdParty/SDL2_ttf/CMakeLists.txt
  57. 9
      android-project/CMake/FindFreetype.cmake
  58. 7
      android-project/CMake/android_defs.cmake
  59. 22
      docs/building.md
  60. 6
      vcpkg.json

197
CMake/FindSDL2_ttf.cmake

@ -1,197 +0,0 @@
# - Find SDL2_ttf
# Find the SDL2 headers and libraries
#
# SDL2::SDL2_ttf - Imported target
#
# SDL2_ttf_FOUND - True if SDL2_ttf was found.
# SDL2_ttf_DYNAMIC - If we found a DLL version of SDL2_ttf
#
# Modified for SDL2_ttf of FindSDL2.cmake
# Original Author:
# 2015 Ryan Pavlik <ryan.pavlik@gmail.com> <abiryan@ryand.net>
#
# Copyright Sensics, Inc. 2015.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# Set up architectures (for windows) and prefixes (for mingw builds)
if(WIN32)
if(MINGW)
include(MinGWSearchPathExtras OPTIONAL)
if(MINGWSEARCH_TARGET_TRIPLE)
set(SDL2_ttf_PREFIX ${MINGWSEARCH_TARGET_TRIPLE})
endif()
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(SDL2_ttf_LIB_PATH_SUFFIX lib/x64)
if(NOT MSVC AND NOT SDL2_ttf_PREFIX)
set(SDL2_ttf_PREFIX x86_64-w64-mingw32)
endif()
else()
set(SDL2_ttf_LIB_PATH_SUFFIX lib/x86)
if(NOT MSVC AND NOT SDL2_ttf_PREFIX)
set(SDL2_ttf_PREFIX i686-w64-mingw32)
endif()
endif()
endif()
if(SDL2_ttf_PREFIX)
set(SDL2_ttf_ORIGPREFIXPATH ${CMAKE_PREFIX_PATH})
if(SDL2_ttf_ROOT_DIR)
list(APPEND CMAKE_PREFIX_PATH "${SDL2_ttf_ROOT_DIR}")
endif()
if(CMAKE_PREFIX_PATH)
foreach(_prefix ${CMAKE_PREFIX_PATH})
list(APPEND CMAKE_PREFIX_PATH "${_prefix}/${SDL2_ttf_PREFIX}")
endforeach()
endif()
if(MINGWSEARCH_PREFIXES)
list(APPEND CMAKE_PREFIX_PATH ${MINGWSEARCH_PREFIXES})
endif()
endif()
# Invoke pkgconfig for hints
find_package(PkgConfig QUIET)
set(SDL2_ttf_INCLUDE_HINTS)
set(SDL2_ttf_LIB_HINTS)
if(PKG_CONFIG_FOUND)
pkg_search_module(SDL2_ttfPC QUIET SDL2_ttf)
if(SDL2_ttfPC_INCLUDE_DIRS)
set(SDL2_ttf_INCLUDE_HINTS ${SDL2_ttfPC_INCLUDE_DIRS})
endif()
if(SDL2_ttfPC_LIBRARY_DIRS)
set(SDL2_ttf_LIB_HINTS ${SDL2_ttfPC_LIBRARY_DIRS})
endif()
endif()
include(FindPackageHandleStandardArgs)
find_library(SDL2_ttf_LIBRARY
NAMES
SDL2_ttf
HINTS
${SDL2_ttf_LIB_HINTS}
PATHS
${SDL2_ttf_ROOT_DIR}
ENV SDL2DIR
PATH_SUFFIXES lib SDL2 ${SDL2_ttf_LIB_PATH_SUFFIX})
set(_sdl2_framework FALSE)
# Some special-casing if we've found/been given a framework.
# Handles whether we're given the library inside the framework or the framework itself.
if(APPLE AND "${SDL2_ttf_LIBRARY}" MATCHES "(/[^/]+)*.framework(/.*)?$")
set(_sdl2_framework TRUE)
set(SDL2_ttf_FRAMEWORK "${SDL2_ttf_LIBRARY}")
# Move up in the directory tree as required to get the framework directory.
while("${SDL2_ttf_FRAMEWORK}" MATCHES "(/[^/]+)*.framework(/.*)$" AND NOT "${SDL2_ttf_FRAMEWORK}" MATCHES "(/[^/]+)*.framework$")
get_filename_component(SDL2_ttf_FRAMEWORK "${SDL2_ttf_FRAMEWORK}" DIRECTORY)
endwhile()
if("${SDL2_ttf_FRAMEWORK}" MATCHES "(/[^/]+)*.framework$")
set(SDL2_ttf_FRAMEWORK_NAME ${CMAKE_MATCH_1})
# If we found a framework, do a search for the header ahead of time that will be more likely to get the framework header.
find_path(SDL2_ttf_INCLUDE_DIR
NAMES
SDL_ttf.h
HINTS
"${SDL2_ttf_FRAMEWORK}/Headers/")
else()
# For some reason we couldn't get the framework directory itself.
# Shouldn't happen, but might if something is weird.
unset(SDL2_ttf_FRAMEWORK)
endif()
endif()
find_path(SDL2_ttf_INCLUDE_DIR
NAMES
SDL_ttf.h
HINTS
${SDL2_ttf_INCLUDE_HINTS}
PATHS
${SDL2_ttf_ROOT_DIR}
ENV SDL2DIR
PATH_SUFFIXES include include/sdl2 include/SDL2 SDL2)
if(WIN32 AND SDL2_ttf_LIBRARY)
find_file(SDL2_ttf_RUNTIME_LIBRARY
NAMES
SDL2_ttf.dll
libSDL2_ttf.dll
HINTS
${SDL2_ttf_LIB_HINTS}
PATHS
${SDL2_ttf_ROOT_DIR}
ENV SDL2DIR
PATH_SUFFIXES bin lib ${SDL2_ttf_LIB_PATH_SUFFIX})
endif()
if(MINGW AND NOT SDL2_ttfPC_FOUND)
find_library(SDL2_ttf_MINGW_LIBRARY mingw32)
find_library(SDL2_ttf_MWINDOWS_LIBRARY mwindows)
endif()
if(SDL2_ttf_PREFIX)
# Restore things the way they used to be.
set(CMAKE_PREFIX_PATH ${SDL2_ttf_ORIGPREFIXPATH})
endif()
# handle the QUIETLY and REQUIRED arguments and set QUATLIB_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SDL2_ttf
DEFAULT_MSG
SDL2_ttf_LIBRARY
SDL2_ttf_INCLUDE_DIR
${SDL2_ttf_EXTRA_REQUIRED})
if(SDL2_ttf_FOUND)
if(NOT TARGET SDL2::SDL2_ttf)
# Create SDL2::SDL2_ttf
if(WIN32 AND SDL2_ttf_RUNTIME_LIBRARY)
set(SDL2_ttf_DYNAMIC TRUE)
add_library(SDL2::SDL2_ttf SHARED IMPORTED)
set_target_properties(SDL2::SDL2_ttf
PROPERTIES
IMPORTED_IMPLIB "${SDL2_ttf_LIBRARY}"
IMPORTED_LOCATION "${SDL2_ttf_RUNTIME_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_ttf_INCLUDE_DIR}"
)
else()
add_library(SDL2::SDL2_ttf UNKNOWN IMPORTED)
if(SDL2_ttf_FRAMEWORK AND SDL2_ttf_FRAMEWORK_NAME)
# Handle the case that SDL2_ttf is a framework and we were able to decompose it above.
set_target_properties(SDL2::SDL2_ttf PROPERTIES
IMPORTED_LOCATION "${SDL2_ttf_FRAMEWORK}/${SDL2_ttf_FRAMEWORK_NAME}")
elseif(_sdl2_framework AND SDL2_ttf_LIBRARY MATCHES "(/[^/]+)*.framework$")
# Handle the case that SDL2_ttf is a framework and SDL_LIBRARY is just the framework itself.
# This takes the basename of the framework, without the extension,
# and sets it (as a child of the framework) as the imported location for the target.
# This is the library symlink inside of the framework.
set_target_properties(SDL2::SDL2_ttf PROPERTIES
IMPORTED_LOCATION "${SDL2_ttf_LIBRARY}/${CMAKE_MATCH_1}")
else()
# Handle non-frameworks (including non-Mac), as well as the case that we're given the library inside of the framework
set_target_properties(SDL2::SDL2_ttf PROPERTIES
IMPORTED_LOCATION "${SDL2_ttf_LIBRARY}")
endif()
set_target_properties(SDL2::SDL2_ttf
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_ttf_INCLUDE_DIR}"
)
endif()
endif()
mark_as_advanced(SDL2_ttf_ROOT_DIR)
endif()
mark_as_advanced(SDL2_ttf_LIBRARY
SDL2_ttf_RUNTIME_LIBRARY
SDL2_ttf_INCLUDE_DIR
SDL2_ttf_SDLMAIN_LIBRARY
SDL2_ttf_COCOA_LIBRARY
SDL2_ttf_MINGW_LIBRARY
SDL2_ttf_MWINDOWS_LIBRARY)
find_package(SDL2 REQUIRED)
set_property(TARGET SDL2::SDL2_ttf APPEND PROPERTY
INTERFACE_LINK_LIBRARIES SDL2::SDL2)

2
CMake/amiga_defs.cmake

@ -3,10 +3,8 @@ set(UBSAN OFF)
set(NONET ON) set(NONET ON)
set(USE_SDL1 ON) set(USE_SDL1 ON)
set(SDL1_VIDEO_MODE_BPP 8) set(SDL1_VIDEO_MODE_BPP 8)
set(TTF_FONT_NAME \"LiberationSerif-Bold.ttf\")
# Enable exception suport as they are used in dvlnet code # Enable exception suport as they are used in dvlnet code
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
find_package(Freetype REQUIRED)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
# Do not warn about unknown attributes, such as [[nodiscard]]. # Do not warn about unknown attributes, such as [[nodiscard]].

65
CMake/ctr/modules/FindBZIP2.cmake

@ -1,65 +0,0 @@
# - Try to find BZip2
# You can set BZIP2_ROOT to specify a certain directory to look in first.
# Once done this will define
# BZIP2_FOUND - System has BZip2
# BZIP2_INCLUDE_DIRS - The BZip2 include directories
# BZIP2_LIBRARIES - The libraries needed to use BZip2
# Unless we are unable to find ZLIB
# It also adds an imported target named `3ds::bzip2`, Linking against it is
# equivalent to:
# target_link_libraries(mytarget ${BZIP2_LIBRARIES})
# target_include_directories(mytarget PRIVATE ${BZIP2_INCLUDE_DIRS})
if(NOT NINTENDO_3DS)
message(FATAL_ERROR "This module can only be used if you are using the 3DS toolchain file. Please erase this build directory or create another one, and then use -DCMAKE_TOOLCHAIN_FILE=DevkitArm3DS.cmake when calling cmake for the 1st time. For more information, see the Readme.md for more information.")
endif()
if(BZIP2_INCLUDE_DIR)
# Already in cache, be silent
set(BZIP2_FIND_QUIETLY TRUE)
endif(BZIP2_INCLUDE_DIR)
include(LibFindMacros)
include(try_add_imported_target)
#libfind_package(BZIP2)
set(_BZIP2_SEARCHES)
# Search BZIP2_ROOT first if it is set.
if(BZIP2_ROOT)
set(_BZIP2_SEARCH_ROOT
PATHS ${BZIP2_ROOT}
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH)
list(APPEND _BZIP2_SEARCHES _BZIP2_SEARCH_ROOT)
endif()
# Search below ${DEVKITPRO}, ${DEVKITARM}, portlibs (if enabled) etc.
set(_BZIP2_SEARCH_NORMAL
PATHS /
NO_DEFAULT_PATH
ONLY_CMAKE_FIND_ROOT_PATH)
list(APPEND _BZIP2_SEARCHES _BZIP2_SEARCH_NORMAL)
foreach(search ${_BZIP2_SEARCHES})
find_path(BZIP2_INCLUDE_DIR NAMES bzlib.h
${${search}}
PATH_SUFFIXES include)
find_library(BZIP2_LIBRARY NAMES bzip2 libbz2.a
${${search}}
PATH_SUFFIXES lib)
endforeach()
#find_library(LIBM_LIBRARY NAMES m libm.a
# PATHS / /arm-none-eabi
# PATH_SUFFIXES lib/armv6k/fpu)
set(LIBM_LIBRARY m)
set(BZIP2_PROCESS_INCLUDES BZIP2_INCLUDE_DIR)
set(BZIP2_PROCESS_LIBS BZIP2_LIBRARY LIBM_LIBRARY)
libfind_process(BZIP2)
try_add_imported_target(BZIP2 m)

59
CMake/ctr/modules/FindFREETYPE.cmake

@ -1,59 +0,0 @@
# - Try to find freetype
# You can set FREETYPE_ROOT to specify a certain directory to look in first.
# Once done this will define
# FREETYPE_FOUND - System has freetype
# FREETYPE_INCLUDE_DIRS - The freetype include directories
# FREETYPE_LIBRARIES - The libraries needed to use freetype
# Unless we are unable to find ZLIB
# It also adds an imported target named `3ds::freetype`, Linking against it is
# equivalent to:
# target_link_libraries(mytarget ${FREETYPE_LIBRARIES})
# target_include_directories(mytarget PRIVATE ${FREETYPE_INCLUDE_DIRS})
if(NOT NINTENDO_3DS)
message(FATAL_ERROR "This module can only be used if you are using the 3DS toolchain file. Please erase this build directory or create another one, and then use -DCMAKE_TOOLCHAIN_FILE=DevkitArm3DS.cmake when calling cmake for the 1st time. For more information, see the Readme.md for more information.")
endif()
if(FREETYPE_INCLUDE_DIR)
# Already in cache, be silent
set(FREETYPE_FIND_QUIETLY TRUE)
endif(FREETYPE_INCLUDE_DIR)
include(LibFindMacros)
include(try_add_imported_target)
libfind_package(FREETYPE ZLIB)
set(_FREETYPE_SEARCHES)
# Search FREETYPE_ROOT first if it is set.
if(FREETYPE_ROOT)
set(_FREETYPE_SEARCH_ROOT
PATHS ${FREETYPE_ROOT}
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH)
list(APPEND _FREETYPE_SEARCHES _FREETYPE_SEARCH_ROOT)
endif()
# Search below ${DEVKITPRO}, ${DEVKITARM}, portlibs (if enabled) etc.
set(_FREETYPE_SEARCH_NORMAL
PATHS /
NO_DEFAULT_PATH
ONLY_CMAKE_FIND_ROOT_PATH)
list(APPEND _FREETYPE_SEARCHES _FREETYPE_SEARCH_NORMAL)
foreach(search ${_FREETYPE_SEARCHES})
find_path(FREETYPE_INCLUDE_DIR NAMES freetype/config/ftheader.h config/ftheader.h
${${search}}
PATH_SUFFIXES include/freetype2 include freetype2)
find_library(FREETYPE_LIBRARY NAMES freetype libfreetype.a
${${search}}
PATH_SUFFIXES lib)
endforeach()
set(FREETYPE_PROCESS_INCLUDES FREETYPE_INCLUDE_DIR)
set(FREETYPE_PROCESS_LIBS FREETYPE_LIBRARY)
libfind_process(FREETYPE)
try_add_imported_target(FREETYPE 3ds::zlib)

3
CMake/ctr/n3ds_defs.cmake

@ -12,12 +12,9 @@ set(PREFILL_PLAYER_NAME ON)
#3DS libraries #3DS libraries
list(APPEND CMAKE_MODULE_PATH "${DevilutionX_SOURCE_DIR}/CMake/ctr/modules") list(APPEND CMAKE_MODULE_PATH "${DevilutionX_SOURCE_DIR}/CMake/ctr/modules")
find_package(CITRO3D REQUIRED) find_package(CITRO3D REQUIRED)
find_package(FREETYPE REQUIRED)
find_package(BZIP2 REQUIRED)
#additional compilation definitions #additional compilation definitions
add_definitions(-D__3DS__) add_definitions(-D__3DS__)
set(TTF_FONT_DIR \"romfs:/\")
set(MO_LANG_DIR \"romfs:/\") set(MO_LANG_DIR \"romfs:/\")
#SDL video mode parameters #SDL video mode parameters

53
CMakeLists.txt

@ -263,10 +263,8 @@ endif()
if(ANDROID) if(ANDROID)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/android-project/3rdParty/SDL2) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/android-project/3rdParty/SDL2)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/android-project/3rdParty/SDL2_ttf)
elseif(USE_SDL1) elseif(USE_SDL1)
find_package(SDL REQUIRED) find_package(SDL REQUIRED)
find_package(SDL_ttf REQUIRED)
include_directories(${SDL_INCLUDE_DIR}) include_directories(${SDL_INCLUDE_DIR})
else() else()
find_package(SDL2 REQUIRED) find_package(SDL2 REQUIRED)
@ -290,7 +288,6 @@ else()
# Can't define an INTERFACE target with ::, so alias instead # Can't define an INTERFACE target with ::, so alias instead
add_library(SDL2::SDL2 ALIAS SDL2_lib) add_library(SDL2::SDL2 ALIAS SDL2_lib)
endif() endif()
find_package(SDL2_ttf REQUIRED)
endif() endif()
if(NOT NONET AND NOT DISABLE_TCP) if(NOT NONET AND NOT DISABLE_TCP)
@ -459,7 +456,6 @@ set(libdevilutionx_SRCS
Source/DiabloUI/diabloui.cpp Source/DiabloUI/diabloui.cpp
Source/DiabloUI/dialogs.cpp Source/DiabloUI/dialogs.cpp
Source/DiabloUI/errorart.cpp Source/DiabloUI/errorart.cpp
Source/DiabloUI/fonts.cpp
Source/DiabloUI/mainmenu.cpp Source/DiabloUI/mainmenu.cpp
Source/DiabloUI/progress.cpp Source/DiabloUI/progress.cpp
Source/DiabloUI/scrollbar.cpp Source/DiabloUI/scrollbar.cpp
@ -469,9 +465,7 @@ set(libdevilutionx_SRCS
Source/DiabloUI/selok.cpp Source/DiabloUI/selok.cpp
Source/DiabloUI/selyesno.cpp Source/DiabloUI/selyesno.cpp
Source/DiabloUI/support_lines.cpp Source/DiabloUI/support_lines.cpp
Source/DiabloUI/text_draw.cpp
Source/DiabloUI/title.cpp Source/DiabloUI/title.cpp
Source/DiabloUI/ttf_render_wrapped.cpp
Source/panels/charpanel.cpp Source/panels/charpanel.cpp
Source/panels/mainpanel.cpp Source/panels/mainpanel.cpp
Source/dvlnet/abstract_net.cpp Source/dvlnet/abstract_net.cpp
@ -595,7 +589,6 @@ else()
Source/main.cpp Source/main.cpp
Source/devilutionx.exe.manifest Source/devilutionx.exe.manifest
Packaging/macOS/AppIcon.icns Packaging/macOS/AppIcon.icns
Packaging/resources/CharisSILB.ttf
Packaging/windows/devilutionx.rc) Packaging/windows/devilutionx.rc)
endif() endif()
target_link_libraries(${BIN_TARGET} PRIVATE libdevilutionx) target_link_libraries(${BIN_TARGET} PRIVATE libdevilutionx)
@ -695,6 +688,18 @@ set(devilutionx_assets
fonts/12-03.pcx fonts/12-03.pcx
fonts/12-04.bin fonts/12-04.bin
fonts/12-04.pcx fonts/12-04.pcx
fonts/22-00.bin
fonts/22-00.pcx
fonts/22-01.bin
fonts/22-01.pcx
fonts/22-02.bin
fonts/22-02.pcx
fonts/22-03.bin
fonts/22-03.pcx
fonts/22-04.bin
fonts/22-04.pcx
fonts/22-05.bin
fonts/22-05.pcx
fonts/24-00.bin fonts/24-00.bin
fonts/24-00.pcx fonts/24-00.pcx
fonts/24-01.bin fonts/24-01.bin
@ -746,6 +751,7 @@ set(devilutionx_assets
fonts/red.trn fonts/red.trn
fonts/whitegold.trn fonts/whitegold.trn
fonts/white.trn fonts/white.trn
fonts/yellowdialog.trn
gendata/cutportlw.pcx gendata/cutportlw.pcx
gendata/cutportrw.pcx gendata/cutportrw.pcx
gendata/cutstartw.pcx gendata/cutstartw.pcx
@ -764,9 +770,6 @@ if(SMPQ)
file(COPY "Packaging/resources/devilutionx.mpq" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") file(COPY "Packaging/resources/devilutionx.mpq" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
endif() endif()
# Copy CharisSILB.ttf to the build directory so the game can run from the build directory
file(COPY "Packaging/resources/CharisSILB.ttf" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
target_include_directories(libdevilutionx PUBLIC target_include_directories(libdevilutionx PUBLIC
Source Source
${CMAKE_CURRENT_BINARY_DIR}) ${CMAKE_CURRENT_BINARY_DIR})
@ -834,8 +837,6 @@ foreach(
DEFAULT_AUDIO_BUFFER_SIZE DEFAULT_AUDIO_BUFFER_SIZE
DEFAULT_AUDIO_RESAMPLING_QUALITY DEFAULT_AUDIO_RESAMPLING_QUALITY
MO_LANG_DIR MO_LANG_DIR
TTF_FONT_DIR
TTF_FONT_NAME
SDL1_VIDEO_MODE_BPP SDL1_VIDEO_MODE_BPP
SDL1_VIDEO_MODE_FLAGS SDL1_VIDEO_MODE_FLAGS
SDL1_FORCE_SVID_VIDEO_MODE SDL1_FORCE_SVID_VIDEO_MODE
@ -908,14 +909,12 @@ endif()
if(USE_SDL1) if(USE_SDL1)
target_link_libraries(libdevilutionx PUBLIC target_link_libraries(libdevilutionx PUBLIC
${SDL_TTF_LIBRARY}
${SDL_LIBRARY}) ${SDL_LIBRARY})
target_compile_definitions(libdevilutionx PUBLIC USE_SDL1) target_compile_definitions(libdevilutionx PUBLIC USE_SDL1)
else() else()
target_link_libraries(libdevilutionx PUBLIC target_link_libraries(libdevilutionx PUBLIC
SDL2::SDL2 SDL2::SDL2
${SDL2_MAIN} ${SDL2_MAIN})
SDL2::SDL2_ttf)
endif() endif()
target_link_libraries(libdevilutionx PUBLIC SDL_image) target_link_libraries(libdevilutionx PUBLIC SDL_image)
@ -925,7 +924,6 @@ endif()
if(AMIGA) if(AMIGA)
target_link_libraries(libdevilutionx PUBLIC target_link_libraries(libdevilutionx PUBLIC
${FREETYPE_LIBRARY}
${ZLIB_LIBRARY}) ${ZLIB_LIBRARY})
if(NOT WARPOS) if(NOT WARPOS)
target_link_libraries(libdevilutionx PUBLIC -ldebug) target_link_libraries(libdevilutionx PUBLIC -ldebug)
@ -936,14 +934,11 @@ if (VITA)
target_link_libraries(libdevilutionx PUBLIC target_link_libraries(libdevilutionx PUBLIC
ScePower_stub ScePower_stub
SceAppUtil_stub SceAppUtil_stub
freetype
z
) )
target_compile_definitions(libdevilutionx PUBLIC VITA) target_compile_definitions(libdevilutionx PUBLIC VITA)
endif() endif()
if(NINTENDO_3DS) if(NINTENDO_3DS)
target_link_libraries(libdevilutionx PUBLIC 3ds::freetype 3ds::bzip2)
target_link_libraries(libdevilutionx PUBLIC 3ds::citro3d 3ds::ctrulib) target_link_libraries(libdevilutionx PUBLIC 3ds::citro3d 3ds::ctrulib)
endif() endif()
@ -1004,7 +999,6 @@ endif()
if(APPLE) if(APPLE)
set_source_files_properties("./Packaging/macOS/AppIcon.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources) set_source_files_properties("./Packaging/macOS/AppIcon.icns" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set_source_files_properties("./Packaging/resources/CharisSILB.ttf" PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
set(MACOSX_BUNDLE_GUI_IDENTIFIER com.diasurgical.devilutionx) set(MACOSX_BUNDLE_GUI_IDENTIFIER com.diasurgical.devilutionx)
set(MACOSX_BUNDLE_COPYRIGHT Unlicense) set(MACOSX_BUNDLE_COPYRIGHT Unlicense)
set(MACOSX_BUNDLE_BUNDLE_NAME devilutionx) set(MACOSX_BUNDLE_BUNDLE_NAME devilutionx)
@ -1031,13 +1025,6 @@ if(APPLE)
endif() endif()
if(NINTENDO_SWITCH) if(NINTENDO_SWITCH)
target_link_libraries(libdevilutionx PUBLIC
freetype
bz2
z
)
nx_generate_nacp (${BIN_TARGET}.nacp nx_generate_nacp (${BIN_TARGET}.nacp
NAME "DevilutionX" NAME "DevilutionX"
AUTHOR "Devilution Team" AUTHOR "Devilution Team"
@ -1067,7 +1054,6 @@ if(VITA)
FILE Packaging/vita/sce_sys/livearea/contents/startup.png sce_sys/livearea/contents/startup.png FILE Packaging/vita/sce_sys/livearea/contents/startup.png sce_sys/livearea/contents/startup.png
FILE Packaging/vita/sce_sys/livearea/contents/logo0.png sce_sys/livearea/contents/logo0.png FILE Packaging/vita/sce_sys/livearea/contents/logo0.png sce_sys/livearea/contents/logo0.png
FILE Packaging/vita/sce_sys/livearea/contents/template.xml sce_sys/livearea/contents/template.xml FILE Packaging/vita/sce_sys/livearea/contents/template.xml sce_sys/livearea/contents/template.xml
FILE Packaging/resources/CharisSILB.ttf CharisSILB.ttf
FILE Packaging/resources/devilutionx.mpq devilutionx.mpq FILE Packaging/resources/devilutionx.mpq devilutionx.mpq
${VITA_TRANSLATIONS_LIST} ${VITA_TRANSLATIONS_LIST}
) )
@ -1083,7 +1069,6 @@ if(NINTENDO_3DS)
set(APP_RSF "${PROJECT_SOURCE_DIR}/Packaging/ctr/template.rsf") set(APP_RSF "${PROJECT_SOURCE_DIR}/Packaging/ctr/template.rsf")
set(APP_ROMFS "${CMAKE_BINARY_DIR}/romfs") set(APP_ROMFS "${CMAKE_BINARY_DIR}/romfs")
list(APPEND APP_ROMFS_FILES list(APPEND APP_ROMFS_FILES
${PROJECT_SOURCE_DIR}/Packaging/resources/CharisSILB.ttf
${PROJECT_SOURCE_DIR}/Packaging/resources/devilutionx.mpq ${PROJECT_SOURCE_DIR}/Packaging/resources/devilutionx.mpq
${devilutionx_TRANSLATIONS}) ${devilutionx_TRANSLATIONS})
set(APP_VERSION ${PROJECT_VERSION}) set(APP_VERSION ${PROJECT_VERSION})
@ -1142,9 +1127,6 @@ if(CPACK)
install(FILES "${PROJECT_SOURCE_DIR}/Packaging/windows/README.txt" install(FILES "${PROJECT_SOURCE_DIR}/Packaging/windows/README.txt"
DESTINATION "." DESTINATION "."
) )
install(FILES "${PROJECT_SOURCE_DIR}/Packaging/resources/CharisSILB.ttf"
DESTINATION "."
)
install(FILES "${PROJECT_SOURCE_DIR}/Packaging/resources/devilutionx.mpq" install(FILES "${PROJECT_SOURCE_DIR}/Packaging/resources/devilutionx.mpq"
DESTINATION "." DESTINATION "."
) )
@ -1199,16 +1181,13 @@ if(CPACK)
DESTINATION "share/icons/hicolor/512x512/apps" DESTINATION "share/icons/hicolor/512x512/apps"
RENAME "${project_name}-hellfire.png" RENAME "${project_name}-hellfire.png"
) )
install(FILES "${PROJECT_SOURCE_DIR}/Packaging/resources/CharisSILB.ttf"
DESTINATION "share/fonts/truetype"
)
# -G DEB # -G DEB
set(CPACK_PACKAGE_CONTACT "anders@jenbo.dk") set(CPACK_PACKAGE_CONTACT "anders@jenbo.dk")
if(USE_SDL1) if(USE_SDL1)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl1.2debian, libsdl-ttf2.0-0") set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl1.2debian")
else() else()
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl2-2.0-0, libsdl2-ttf-2.0-0") set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl2-2.0-0")
endif() endif()
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)

2
Packaging/OpenDingux/build.sh

@ -66,7 +66,7 @@ prepare_buildroot() {
make_buildroot() { make_buildroot() {
cd "$BUILDROOT" cd "$BUILDROOT"
BR2_JLEVEL=0 make toolchain libzip sdl sdl_ttf BR2_JLEVEL=0 make toolchain sdl
cd - cd -
} }

2
Packaging/OpenDingux/package-opk.sh

@ -17,7 +17,7 @@ package_opk() {
mksquashfs "${BUILD_DIR}/devilutionx" \ mksquashfs "${BUILD_DIR}/devilutionx" \
"${tmp}/default.${ext}.desktop" "${tmp}/hellfire.${ext}.desktop" \ "${tmp}/default.${ext}.desktop" "${tmp}/hellfire.${ext}.desktop" \
"${tmp}/readme.${ext}.txt" Packaging/resources/icon_32.png \ "${tmp}/readme.${ext}.txt" Packaging/resources/icon_32.png \
Packaging/resources/hellfire_32.png Packaging/resources/CharisSILB.ttf \ Packaging/resources/hellfire_32.png \
Packaging/resources/devilutionx.mpq \ Packaging/resources/devilutionx.mpq \
"${BUILD_DIR}/devilutionx-${TARGET}.opk" \ "${BUILD_DIR}/devilutionx-${TARGET}.opk" \
-all-root -no-xattrs -noappend -no-exports -no-progress -all-root -no-xattrs -noappend -no-exports -no-progress

BIN
Packaging/amiga/LiberationSerif-Bold.ttf

Binary file not shown.

46
Packaging/amiga/SIL Open Font License.txt

@ -1,46 +0,0 @@
Digitized data copyright (c) 2010 Google Corporation
with Reserved Font Arimo, Tinos and Cousine.
Copyright (c) 2012 Red Hat, Inc.
with Reserved Font Name Liberation.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.

18
Packaging/amiga/prep.sh

@ -37,21 +37,3 @@ mkdir -p ${SYSROOT}/usr/include
cp -fvr libSDL.a ${SYSROOT}/usr/lib/ cp -fvr libSDL.a ${SYSROOT}/usr/lib/
cp -fvr include/* ${SYSROOT}/usr/include/ cp -fvr include/* ${SYSROOT}/usr/include/
cd .. cd ..
# FreeType
wget https://download.savannah.gnu.org/releases/freetype/freetype-2.10.1.tar.gz -O freetype-2.10.1.tar.gz
tar -xvf freetype-2.10.1.tar.gz
mkdir -p freetype-2.10.1/build
cd freetype-2.10.1/build
cmake .. -DUNIX=1 -DM68K_CPU="$M68K_CPU" -DM68K_FPU="$M68K_FPU" -DM68K_COMMON="${M68K_COMMON}"
cmake --build . --config Release --target install -- -j$(getconf _NPROCESSORS_ONLN)
cd ../..
# SDL_ttf
wget https://github.com/SDL-mirror/SDL_ttf/archive/SDL-1.2.tar.gz -O SDL_ttf-SDL-1.2.tar.gz
tar -xvf SDL_ttf-SDL-1.2.tar.gz
cd SDL_ttf-SDL-1.2
./autogen.sh
LDFLAGS="-L${SYSROOT}/usr/lib" SDL_LIBS='-lSDL -ldebug' SDL_CFLAGS="-L${SYSROOT}/usr/lib -I${SYSROOT}/usr/include/SDL -noixemul" CFLAGS="${M68K_CFLAGS}" CXXFLAGS="${M68K_CXXFLAGS}" FT2_CFLAGS="-L${SYSROOT}/usr/lib -I${SYSROOT}/usr/include/freetype2" FT2_LIBS="-lfreetype -lzlib" ./configure --disable-shared --enable-static --host=${TARGET} --prefix=${SYSROOT}/usr
make -j$(getconf _NPROCESSORS_ONLN)
make install

2
Packaging/cpi-gamesh/build.sh

@ -37,7 +37,7 @@ done
set -- "${POSITIONAL[@]}" # restore positional parameters set -- "${POSITIONAL[@]}" # restore positional parameters
install_deps() { install_deps() {
sudo apt install -y cmake libsdl2-ttf-dev libsdl2-mixer-dev sudo apt install -y cmake libsdl2-dev
} }
main() { main() {

2
Packaging/ctr/build.sh

@ -27,7 +27,7 @@ build() {
install_deps() { install_deps() {
"$DEVKITPRO/pacman/bin/pacman" -S --needed --noconfirm --quiet \ "$DEVKITPRO/pacman/bin/pacman" -S --needed --noconfirm --quiet \
devkitARM general-tools 3dstools devkitpro-pkgbuild-helpers \ devkitARM general-tools 3dstools devkitpro-pkgbuild-helpers \
libctru citro3d 3ds-sdl 3ds-sdl_ttf 3ds-freetype libctru citro3d 3ds-sdl
} }
prepare_devkitpro() { prepare_devkitpro() {

1
Packaging/debian/control vendored

@ -8,7 +8,6 @@ Build-Depends:
git, git,
g++, g++,
gettext, gettext,
libsdl2-ttf-dev,
libsodium-dev libsodium-dev
Standards-Version: 4.3.0 Standards-Version: 4.3.0
Homepage: https://github.com/diasurgical/devilutionX Homepage: https://github.com/diasurgical/devilutionX

2
Packaging/nix/AppRun

@ -1,2 +1,2 @@
#!/bin/sh #!/bin/sh
exec "$APPDIR/usr/bin/devilutionx" --ttf-dir "$APPDIR/usr/share/fonts/truetype/" "$@" exec "$APPDIR/usr/bin/devilutionx" "$@"

3
Packaging/nix/LinuxReleasePackaging.sh

@ -4,7 +4,6 @@ cp ./build/devilutionx ./build/package/devilutionx
cp ./Packaging/resources/devilutionx.mpq ./build/package/devilutionx.mpq cp ./Packaging/resources/devilutionx.mpq ./build/package/devilutionx.mpq
cp ./build/devilutionx*.deb ./build/package/devilutionx.deb cp ./build/devilutionx*.deb ./build/package/devilutionx.deb
cp ./build/devilutionx*.rpm ./build/package/devilutionx.rpm cp ./build/devilutionx*.rpm ./build/package/devilutionx.rpm
cp ./build/CharisSILB.ttf ./build/package/CharisSILB.ttf
cp ./Packaging/nix/README.txt ./build/package/README.txt cp ./Packaging/nix/README.txt ./build/package/README.txt
cp ./Packaging/resources/LICENSE.CharisSILB.txt ./build/package/LICENSE.CharisSILB.txt cp ./Packaging/resources/LICENSE.CharisSILB.txt ./build/package/LICENSE.CharisSILB.txt
cd ./build/package/ && tar -cavf ../../devilutionx.tar.xz * && cd ../../ cd ./build/package/ && tar -cavf ../../devilutionx.tar.xz * && cd ../../

2
Packaging/nix/README.txt

@ -10,7 +10,7 @@ For a full list of changes see our changelog: https://github.com/diasurgical/dev
# How To Install: # How To Install:
- Extract the files in the archive. - Extract the files in the archive.
- Install libsdl2 libsdl2-mixer libsdl2-ttf - Install libsdl2
- Copy DIABDAT.MPQ from the CD or GOG-installation (or extract it from the GoG installer) to the DevilutionX folder. - Copy DIABDAT.MPQ from the CD or GOG-installation (or extract it from the GoG installer) to the DevilutionX folder.
- To run the Diablo: Hellfire expansion you will need to also copy hellfire.mpq, hfmonk.mpq, hfmusic.mpq, hfvoice.mpq. - To run the Diablo: Hellfire expansion you will need to also copy hellfire.mpq, hfmonk.mpq, hfmusic.mpq, hfvoice.mpq.
- Run ./devilutionx - Run ./devilutionx

2
Packaging/pi/README.txt

@ -10,7 +10,7 @@ For a full list of changes see our changelog: https://github.com/diasurgical/dev
# How To Install: # How To Install:
- Extract the files in the archive. - Extract the files in the archive.
- Install libsdl2 libsdl2-mixer libsdl2-ttf - Install libsdl2
- Copy DIABDAT.MPQ from the CD or GOG-installation (or extract it from the GoG installer) to the DevilutionX folder. - Copy DIABDAT.MPQ from the CD or GOG-installation (or extract it from the GoG installer) to the DevilutionX folder.
- To run the Diablo: Hellfire expansion you will need to also copy hellfire.mpq, hfmonk.mpq, hfmusic.mpq, hfvoice.mpq. - To run the Diablo: Hellfire expansion you will need to also copy hellfire.mpq, hfmonk.mpq, hfmusic.mpq, hfvoice.mpq.
- Run ./devilutionx - Run ./devilutionx

BIN
Packaging/resources/CharisSILB.ttf

Binary file not shown.

173
Packaging/resources/LICENSE.freetype.txt

@ -1,173 +0,0 @@
The source code to this library used with SDL_ttf can be found here:
https://hg.libsdl.org/SDL_ttf/file/default/external
---
The FreeType Project LICENSE
----------------------------
2006-Jan-27
Copyright 1996-2002, 2006 by
David Turner, Robert Wilhelm, and Werner Lemberg
Introduction
============
The FreeType Project is distributed in several archive packages;
some of them may contain, in addition to the FreeType font engine,
various tools and contributions which rely on, or relate to, the
FreeType Project.
This license applies to all files found in such packages, and
which do not fall under their own explicit license. The license
affects thus the FreeType font engine, the test programs,
documentation and makefiles, at the very least.
This license was inspired by the BSD, Artistic, and IJG
(Independent JPEG Group) licenses, which all encourage inclusion
and use of free software in commercial and freeware products
alike. As a consequence, its main points are that:
o We don't promise that this software works. However, we will be
interested in any kind of bug reports. (`as is' distribution)
o You can use this software for whatever you want, in parts or
full form, without having to pay us. (`royalty-free' usage)
o You may not pretend that you wrote this software. If you use
it, or only parts of it, in a program, you must acknowledge
somewhere in your documentation that you have used the
FreeType code. (`credits')
We specifically permit and encourage the inclusion of this
software, with or without modifications, in commercial products.
We disclaim all warranties covering The FreeType Project and
assume no liability related to The FreeType Project.
Finally, many people asked us for a preferred form for a
credit/disclaimer to use in compliance with this license. We thus
encourage you to use the following text:
"""
Portions of this software are copyright © <year> The FreeType
Project (www.freetype.org). All rights reserved.
"""
Please replace <year> with the value from the FreeType version you
actually use.
Legal Terms
===========
0. Definitions
--------------
Throughout this license, the terms `package', `FreeType Project',
and `FreeType archive' refer to the set of files originally
distributed by the authors (David Turner, Robert Wilhelm, and
Werner Lemberg) as the `FreeType Project', be they named as alpha,
beta or final release.
`You' refers to the licensee, or person using the project, where
`using' is a generic term including compiling the project's source
code as well as linking it to form a `program' or `executable'.
This program is referred to as `a program using the FreeType
engine'.
This license applies to all files distributed in the original
FreeType Project, including all source code, binaries and
documentation, unless otherwise stated in the file in its
original, unmodified form as distributed in the original archive.
If you are unsure whether or not a particular file is covered by
this license, you must contact us to verify this.
The FreeType Project is copyright (C) 1996-2000 by David Turner,
Robert Wilhelm, and Werner Lemberg. All rights reserved except as
specified below.
1. No Warranty
--------------
THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
USE, OF THE FREETYPE PROJECT.
2. Redistribution
-----------------
This license grants a worldwide, royalty-free, perpetual and
irrevocable right and license to use, execute, perform, compile,
display, copy, create derivative works of, distribute and
sublicense the FreeType Project (in both source and object code
forms) and derivative works thereof for any purpose; and to
authorize others to exercise some or all of the rights granted
herein, subject to the following conditions:
o Redistribution of source code must retain this license file
(`FTL.TXT') unaltered; any additions, deletions or changes to
the original files must be clearly indicated in accompanying
documentation. The copyright notices of the unaltered,
original files must be preserved in all copies of source
files.
o Redistribution in binary form must provide a disclaimer that
states that the software is based in part of the work of the
FreeType Team, in the distribution documentation. We also
encourage you to put an URL to the FreeType web page in your
documentation, though this isn't mandatory.
These conditions apply to any software derived from or based on
the FreeType Project, not just the unmodified files. If you use
our work, you must acknowledge us. However, no fee need be paid
to us.
3. Advertising
--------------
Neither the FreeType authors and contributors nor you shall use
the name of the other for commercial, advertising, or promotional
purposes without specific prior written permission.
We suggest, but do not require, that you use one or more of the
following phrases to refer to this software in your documentation
or advertising materials: `FreeType Project', `FreeType Engine',
`FreeType library', or `FreeType Distribution'.
As you have not signed this license, you are not required to
accept it. However, as the FreeType Project is copyrighted
material, only this license, or another one contracted with the
authors, grants you the right to use, distribute, and modify it.
Therefore, by using, distributing, or modifying the FreeType
Project, you indicate that you understand and accept all the terms
of this license.
4. Contacts
-----------
There are two mailing lists related to FreeType:
o freetype@nongnu.org
Discusses general use and applications of FreeType, as well as
future and wanted additions to the library and distribution.
If you are looking for support, start in this list if you
haven't found anything to help you in the documentation.
o freetype-devel@nongnu.org
Discusses bugs, as well as engine internals, design issues,
specific licenses, porting, etc.
Our home page can be found at
https://www.freetype.org
--- end of FTL.TXT ---

41
Packaging/resources/assets/fonts/22-00.bin

@ -0,0 +1,41 @@

  
 





 
   

     


BIN
Packaging/resources/assets/fonts/22-00.pcx

Binary file not shown.

38
Packaging/resources/assets/fonts/22-01.bin

@ -0,0 +1,38 @@






  
     
     

 
   
    
 





 


BIN
Packaging/resources/assets/fonts/22-01.pcx

Binary file not shown.

38
Packaging/resources/assets/fonts/22-02.bin

@ -0,0 +1,38 @@
 


   

 

 
 

 
 
 



     
 
 



BIN
Packaging/resources/assets/fonts/22-02.pcx

Binary file not shown.

12
Packaging/resources/assets/fonts/22-03.bin

@ -0,0 +1,12 @@
 

   




          

 

BIN
Packaging/resources/assets/fonts/22-03.pcx

Binary file not shown.

33
Packaging/resources/assets/fonts/22-04.bin

@ -0,0 +1,33 @@

   
 

    
 
   



     
 
  



 
  


BIN
Packaging/resources/assets/fonts/22-04.pcx

Binary file not shown.

5
Packaging/resources/assets/fonts/22-05.bin

@ -0,0 +1,5 @@

  
 
 

BIN
Packaging/resources/assets/fonts/22-05.pcx

Binary file not shown.

BIN
Packaging/resources/assets/fonts/yellowdialog.trn

Binary file not shown.

2
Packaging/switch/README.txt

@ -1,7 +1,7 @@
# Nintendo Switch Port of DevilutionX (Diablo) # Nintendo Switch Port of DevilutionX (Diablo)
# How To Install: # How To Install:
- Put `devilutionx.nro` and `CharisSILB.ttf` in into `/switch/devilutionx` - Put `devilutionx.nro` in into `/switch/devilutionx`
- Copy diabdat.mpq from your CD (or GoG install folder) to `/switch/devilutionx`. - Copy diabdat.mpq from your CD (or GoG install folder) to `/switch/devilutionx`.
- To run the Diablo: Hellfire expansion you will need to also copy hellfire.mpq, hfmonk.mpq, hfmusic.mpq, hfvoice.mpq. - To run the Diablo: Hellfire expansion you will need to also copy hellfire.mpq, hfmonk.mpq, hfmusic.mpq, hfvoice.mpq.
- Launch `devilutionx.nro`. (Do not use album to launch; see the note below.) - Launch `devilutionx.nro`. (Do not use album to launch; see the note below.)

7
Packaging/switch/build.sh

@ -26,10 +26,9 @@ build() {
install_deps() { install_deps() {
"$DEVKITPRO/pacman/bin/pacman" -S --needed --noconfirm --quiet \ "$DEVKITPRO/pacman/bin/pacman" -S --needed --noconfirm --quiet \
switch-freetype switch-mesa switch-glad switch-glm switch-libpng \ switch-mesa switch-glad switch-glm switch-libpng \
switch-sdl2 switch-sdl2_ttf switch-libvorbis switch-libmikmod \ switch-sdl2 switch-libsodium libnx devkitA64 devkitA64 \
switch-libsodium libnx devkitA64 devkitA64 general-tools \ general-tools switch-tools devkitpro-pkgbuild-helpers
switch-tools devkitpro-pkgbuild-helpers
} }
prepare_devkitpro() { prepare_devkitpro() {

13
Source/DiabloUI/button.cpp

@ -1,7 +1,8 @@
#include "DiabloUI/art_draw.h" #include "DiabloUI/art_draw.h"
#include "DiabloUI/button.h" #include "DiabloUI/button.h"
#include "DiabloUI/diabloui.h"
#include "DiabloUI/errorart.h" #include "DiabloUI/errorart.h"
#include "DiabloUI/text_draw.h" #include "engine/render/text_render.hpp"
#include "utils/display.h" #include "utils/display.h"
namespace devilution { namespace devilution {
@ -23,14 +24,12 @@ void RenderButton(UiButton *button)
} }
DrawArt({ button->m_rect.x, button->m_rect.y }, button->m_art, frame, button->m_rect.w, button->m_rect.h); DrawArt({ button->m_rect.x, button->m_rect.y }, button->m_art, frame, button->m_rect.w, button->m_rect.h);
SDL_Rect textRect = button->m_rect; Rectangle textRect { { button->m_rect.x, button->m_rect.y }, { button->m_rect.w, button->m_rect.h } };
if (!button->m_pressed) if (!button->m_pressed)
--textRect.y; --textRect.position.y;
SDL_Color color1 = { 243, 243, 243, 0 }; const Surface &out = Surface(DiabloUiSurface());
SDL_Color color2 = { 0, 0, 0, 0 }; DrawString(out, button->m_text, textRect, UiFlags::AlignCenter | UiFlags::FontSizeDialog | UiFlags::ColorDialogWhite, 0);
DrawTTF(button->m_text, textRect, UiFlags::AlignCenter,
color1, color2, button->m_render_cache);
} }
bool HandleMouseEventButton(const SDL_Event &event, UiButton *button) bool HandleMouseEventButton(const SDL_Event &event, UiButton *button)

95
Source/DiabloUI/credits.cpp

@ -6,16 +6,15 @@
#include "DiabloUI/art_draw.h" #include "DiabloUI/art_draw.h"
#include "DiabloUI/credits_lines.h" #include "DiabloUI/credits_lines.h"
#include "DiabloUI/diabloui.h" #include "DiabloUI/diabloui.h"
#include "DiabloUI/fonts.h"
#include "DiabloUI/support_lines.h" #include "DiabloUI/support_lines.h"
#include "control.h" #include "control.h"
#include "controls/menu_controls.h" #include "controls/menu_controls.h"
#include "engine/render/text_render.hpp"
#include "hwcursor.hpp" #include "hwcursor.hpp"
#include "utils/display.h" #include "utils/display.h"
#include "utils/language.h" #include "utils/language.h"
#include "utils/log.hpp" #include "utils/log.hpp"
#include "utils/sdl_compat.h" #include "utils/sdl_compat.h"
#include "utils/ttf_wrap.h"
namespace devilution { namespace devilution {
@ -34,72 +33,11 @@ std::size_t textLines;
// a line is leaving the screen while another one is entering. // a line is leaving the screen while another one is entering.
#define MAX_VISIBLE_LINES ((VIEWPORT.h - 1) / LINE_H + 2) #define MAX_VISIBLE_LINES ((VIEWPORT.h - 1) / LINE_H + 2)
struct CachedLine {
CachedLine()
{
mIndex = 0;
paletteVersion = pal_surface_palette_version;
}
CachedLine(std::size_t index, SDLSurfaceUniquePtr surface)
{
mIndex = index;
mSurface = std::move(surface);
paletteVersion = pal_surface_palette_version;
}
std::size_t mIndex;
SDLSurfaceUniquePtr mSurface;
unsigned int paletteVersion;
};
CachedLine PrepareLine(std::size_t index)
{
const char *contents = _(Text[index]);
while (contents[0] == '\t')
++contents;
// Precompose shadow and text:
SDLSurfaceUniquePtr surface;
if (contents[0] != '\0') {
const SDL_Color shadowColor = { 0, 0, 0, 0 };
SDLSurfaceUniquePtr text = TTFWrap::RenderUTF8_Solid(font, contents, shadowColor);
// Set up the target surface to have 3 colors: mask, text, and shadow.
surface = SDLWrap::CreateRGBSurfaceWithFormat(0, text->w + ShadowOffsetX, text->h + ShadowOffsetY, 8, SDL_PIXELFORMAT_INDEX8);
const SDL_Color maskColor = { 0, 255, 0, 0 }; // Any color different from both shadow and text
const SDL_Color &textColor = Palette->colors[224];
SDL_Color colors[3] = { maskColor, textColor, shadowColor };
if (SDLC_SetSurfaceColors(surface.get(), colors, 0, 3) <= -1)
Log("{}", SDL_GetError());
SDLC_SetColorKey(surface.get(), 0);
// Blit the shadow first:
SDL_Rect shadowRect = { ShadowOffsetX, ShadowOffsetY, 0, 0 };
if (SDL_BlitSurface(text.get(), nullptr, surface.get(), &shadowRect) <= -1)
ErrSdl();
// Change the text surface color and blit again:
SDL_Color textColors[2] = { maskColor, textColor };
if (SDLC_SetSurfaceColors(text.get(), textColors, 0, 2) <= -1)
ErrSdl();
SDLC_SetColorKey(text.get(), 0);
if (SDL_BlitSurface(text.get(), nullptr, surface.get(), nullptr) <= -1)
ErrSdl();
surface = ScaleSurfaceToOutput(std::move(surface));
}
return CachedLine(index, std::move(surface));
}
class CreditsRenderer { class CreditsRenderer {
public: public:
CreditsRenderer() CreditsRenderer()
{ {
LoadTtfFont();
ticks_begin_ = SDL_GetTicks(); ticks_begin_ = SDL_GetTicks();
prev_offset_y_ = 0; prev_offset_y_ = 0;
finished_ = false; finished_ = false;
@ -109,8 +47,6 @@ public:
{ {
ArtBackgroundWidescreen.Unload(); ArtBackgroundWidescreen.Unload();
ArtBackground.Unload(); ArtBackground.Unload();
UnloadTtfFont();
lines_.clear();
} }
void Render(); void Render();
@ -121,7 +57,6 @@ public:
} }
private: private:
std::vector<CachedLine> lines_;
bool finished_; bool finished_;
Uint32 ticks_begin_; Uint32 ticks_begin_;
int prev_offset_y_; int prev_offset_y_;
@ -137,8 +72,6 @@ void CreditsRenderer::Render()
SDL_FillRect(DiabloUiSurface(), nullptr, 0x000000); SDL_FillRect(DiabloUiSurface(), nullptr, 0x000000);
DrawArt({ PANEL_LEFT - 320, UI_OFFSET_Y }, &ArtBackgroundWidescreen); DrawArt({ PANEL_LEFT - 320, UI_OFFSET_Y }, &ArtBackgroundWidescreen);
DrawArt({ PANEL_LEFT, UI_OFFSET_Y }, &ArtBackground); DrawArt({ PANEL_LEFT, UI_OFFSET_Y }, &ArtBackground);
if (font == nullptr)
return;
const std::size_t linesBegin = std::max(offsetY / LINE_H, 0); const std::size_t linesBegin = std::max(offsetY / LINE_H, 0);
const std::size_t linesEnd = std::min(linesBegin + MAX_VISIBLE_LINES, textLines); const std::size_t linesEnd = std::min(linesBegin + MAX_VISIBLE_LINES, textLines);
@ -149,9 +82,6 @@ void CreditsRenderer::Render()
return; return;
} }
while (linesEnd > lines_.size())
lines_.push_back(PrepareLine(lines_.size()));
SDL_Rect viewport = VIEWPORT; SDL_Rect viewport = VIEWPORT;
viewport.x += PANEL_LEFT; viewport.x += PANEL_LEFT;
viewport.y += UI_OFFSET_Y; viewport.y += UI_OFFSET_Y;
@ -161,26 +91,19 @@ void CreditsRenderer::Render()
// We use unscaled coordinates for calculation throughout. // We use unscaled coordinates for calculation throughout.
Sint16 destY = UI_OFFSET_Y + VIEWPORT.y - (offsetY - linesBegin * LINE_H); Sint16 destY = UI_OFFSET_Y + VIEWPORT.y - (offsetY - linesBegin * LINE_H);
for (std::size_t i = linesBegin; i < linesEnd; ++i, destY += LINE_H) { for (std::size_t i = linesBegin; i < linesEnd; ++i, destY += LINE_H) {
CachedLine &line = lines_[i];
if (line.mSurface == nullptr)
continue;
// Still fading in: the cached line was drawn with a different fade level.
if (line.paletteVersion != pal_surface_palette_version) {
line = PrepareLine(line.mIndex);
}
Sint16 destX = PANEL_LEFT + VIEWPORT.x + 31; Sint16 destX = PANEL_LEFT + VIEWPORT.x + 31;
int j = 0; int j = 0;
while (Text[line.mIndex][j++] == '\t') while (Text[i][j] == '\t') {
destX += 40; destX += 40;
j++;
}
SDL_Rect dstRect = { destX, destY, 0, 0 }; SDL_Rect dstRect { destX, destY, 0, 0 };
ScaleOutputRect(&dstRect); ScaleOutputRect(&dstRect);
dstRect.w = line.mSurface->w; if (Text[i][j] != '\0') {
dstRect.h = line.mSurface->h; const Surface &out = Surface(DiabloUiSurface());
if (SDL_BlitSurface(line.mSurface.get(), nullptr, DiabloUiSurface(), &dstRect) < 0) DrawString(out, _(Text[i]), Point { dstRect.x, dstRect.y }, UiFlags::FontSizeDialog | UiFlags::ColorDialogWhite, 0);
ErrSdl(); }
} }
SDL_SetClipRect(DiabloUiSurface(), nullptr); SDL_SetClipRect(DiabloUiSurface(), nullptr);
} }

13
Source/DiabloUI/diabloui.cpp

@ -11,9 +11,7 @@
#include "DiabloUI/art_draw.h" #include "DiabloUI/art_draw.h"
#include "DiabloUI/button.h" #include "DiabloUI/button.h"
#include "DiabloUI/dialogs.h" #include "DiabloUI/dialogs.h"
#include "DiabloUI/fonts.h"
#include "DiabloUI/scrollbar.h" #include "DiabloUI/scrollbar.h"
#include "DiabloUI/text_draw.h"
#include "controls/controller.h" #include "controls/controller.h"
#include "controls/menu_controls.h" #include "controls/menu_controls.h"
#include "dx.h" #include "dx.h"
@ -550,7 +548,6 @@ void UiInitialize()
void UiDestroy() void UiDestroy()
{ {
UnloadTtfFont();
UnloadFonts(); UnloadFonts();
UnloadUiGFX(); UnloadUiGFX();
} }
@ -715,12 +712,10 @@ namespace {
void Render(UiText *uiText) void Render(UiText *uiText)
{ {
DrawTTF(uiText->m_text, Rectangle rect { { uiText->m_rect.x, uiText->m_rect.y }, { uiText->m_rect.w, uiText->m_rect.h } };
uiText->m_rect,
uiText->m_iFlags, const Surface &out = Surface(DiabloUiSurface());
uiText->m_color, DrawString(out, uiText->m_text, rect, uiText->m_iFlags | UiFlags::FontSizeDialog, 0);
uiText->m_shadow_color,
uiText->m_render_cache);
} }
void Render(const UiArtText *uiArtText) void Render(const UiArtText *uiArtText)

63
Source/DiabloUI/dialogs.cpp

@ -5,7 +5,6 @@
#include "DiabloUI/button.h" #include "DiabloUI/button.h"
#include "DiabloUI/diabloui.h" #include "DiabloUI/diabloui.h"
#include "DiabloUI/errorart.h" #include "DiabloUI/errorart.h"
#include "DiabloUI/fonts.h"
#include "control.h" #include "control.h"
#include "controls/menu_controls.h" #include "controls/menu_controls.h"
#include "dx.h" #include "dx.h"
@ -20,7 +19,6 @@ namespace devilution {
namespace { namespace {
Art dialogArt; Art dialogArt;
bool fontWasLoaded;
bool dialogEnd; bool dialogEnd;
@ -157,6 +155,7 @@ void LoadFallbackPalette()
}; };
// clang-format on // clang-format on
ApplyGamma(logical_palette, FallbackPalette, 256); ApplyGamma(logical_palette, FallbackPalette, 256);
BlackPalette();
} }
void Init(const char *text, const char *caption, bool error, bool renderBehind) void Init(const char *text, const char *caption, bool error, bool renderBehind)
@ -166,7 +165,7 @@ void Init(const char *text, const char *caption, bool error, bool renderBehind)
vecOkDialog.push_back(std::make_unique<UiImage>(&dialogArt, rect1)); vecOkDialog.push_back(std::make_unique<UiImage>(&dialogArt, rect1));
SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 200), (Sint16)(UI_OFFSET_Y + 211), 240, 80 }; SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 200), (Sint16)(UI_OFFSET_Y + 211), 240, 80 };
vecOkDialog.push_back(std::make_unique<UiText>(text, rect2, UiFlags::AlignCenter)); vecOkDialog.push_back(std::make_unique<UiText>(text, rect2, UiFlags::AlignCenter | UiFlags::ColorDialogWhite));
SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 265), (Sint16)(UI_OFFSET_Y + 265), SML_BUTTON_WIDTH, SML_BUTTON_HEIGHT }; SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 265), (Sint16)(UI_OFFSET_Y + 265), SML_BUTTON_WIDTH, SML_BUTTON_HEIGHT };
vecOkDialog.push_back(std::make_unique<UiButton>(&SmlButton, _("OK"), &DialogActionOK, rect3)); vecOkDialog.push_back(std::make_unique<UiButton>(&SmlButton, _("OK"), &DialogActionOK, rect3));
@ -174,48 +173,42 @@ void Init(const char *text, const char *caption, bool error, bool renderBehind)
SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 127), (Sint16)(UI_OFFSET_Y + 100), 385, 280 }; SDL_Rect rect1 = { (Sint16)(PANEL_LEFT + 127), (Sint16)(UI_OFFSET_Y + 100), 385, 280 };
vecOkDialog.push_back(std::make_unique<UiImage>(&dialogArt, rect1)); vecOkDialog.push_back(std::make_unique<UiImage>(&dialogArt, rect1));
SDL_Color color = { 255, 255, 0, 0 };
SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 147), (Sint16)(UI_OFFSET_Y + 110), 345, 20 }; SDL_Rect rect2 = { (Sint16)(PANEL_LEFT + 147), (Sint16)(UI_OFFSET_Y + 110), 345, 20 };
vecOkDialog.push_back(std::make_unique<UiText>(text, rect2, UiFlags::AlignCenter, color)); vecOkDialog.push_back(std::make_unique<UiText>(text, rect2, UiFlags::AlignCenter | UiFlags::ColorDialogYellow));
SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 147), (Sint16)(UI_OFFSET_Y + 141), 345, 190 }; SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 147), (Sint16)(UI_OFFSET_Y + 141), 345, 190 };
vecOkDialog.push_back(std::make_unique<UiText>(caption, rect3, UiFlags::AlignCenter)); vecOkDialog.push_back(std::make_unique<UiText>(caption, rect3, UiFlags::AlignCenter | UiFlags::ColorDialogWhite));
SDL_Rect rect4 = { (Sint16)(PANEL_LEFT + 264), (Sint16)(UI_OFFSET_Y + 335), SML_BUTTON_WIDTH, SML_BUTTON_HEIGHT }; SDL_Rect rect4 = { (Sint16)(PANEL_LEFT + 264), (Sint16)(UI_OFFSET_Y + 335), SML_BUTTON_WIDTH, SML_BUTTON_HEIGHT };
vecOkDialog.push_back(std::make_unique<UiButton>(&SmlButton, _("OK"), &DialogActionOK, rect4)); vecOkDialog.push_back(std::make_unique<UiButton>(&SmlButton, _("OK"), &DialogActionOK, rect4));
} }
if (!renderBehind) { if (!renderBehind) {
ArtBackground.Unload();
LoadBackgroundArt("ui_art\\black.pcx"); LoadBackgroundArt("ui_art\\black.pcx");
if (ArtBackground.surface == nullptr) { if (ArtBackground.surface == nullptr) {
LoadFallbackPalette(); LoadFallbackPalette();
if (SDL_ShowCursor(SDL_ENABLE) <= -1)
Log("{}", SDL_GetError());
} }
} }
SetFadeLevel(256);
if (caption == nullptr) { if (caption == nullptr) {
LoadMaskedArt(error ? "ui_art\\srpopup.pcx" : "ui_art\\spopup.pcx", &dialogArt); LoadMaskedArt(error ? "ui_art\\srpopup.pcx" : "ui_art\\spopup.pcx", &dialogArt);
} else if (error) {
LoadArt(&dialogArt, PopupData, 385, 280);
} else { } else {
if (error) { LoadMaskedArt("ui_art\\lpopup.pcx", &dialogArt);
LoadArt(&dialogArt, PopupData, 385, 280);
} else {
LoadMaskedArt("ui_art\\lpopup.pcx", &dialogArt);
}
} }
LoadSmlButtonArt(); LoadSmlButtonArt();
fontWasLoaded = font != nullptr;
if (!fontWasLoaded)
LoadTtfFont();
} }
void Deinit() void Deinit()
{ {
dialogArt.Unload(); dialogArt.Unload();
UnloadSmlButtonArt(); UnloadSmlButtonArt();
if (!fontWasLoaded)
UnloadTtfFont();
vecOkDialog.clear(); vecOkDialog.clear();
ArtBackground.Unload();
} }
void DialogLoop(const std::vector<std::unique_ptr<UiItemBase>> &items, const std::vector<std::unique_ptr<UiItemBase>> &renderBehind) void DialogLoop(const std::vector<std::unique_ptr<UiItemBase>> &items, const std::vector<std::unique_ptr<UiItemBase>> &renderBehind)
@ -244,12 +237,14 @@ void DialogLoop(const std::vector<std::unique_ptr<UiItemBase>> &items, const std
} }
if (renderBehind.empty()) { if (renderBehind.empty()) {
SDL_FillRect(DiabloUiSurface(), nullptr, 0); SDL_FillRect(DiabloUiSurface(), nullptr, 0x000000);
} else { } else {
UiRenderItems(renderBehind); UiRenderItems(renderBehind);
} }
UiRenderItems(items); UiRenderItems(items);
DrawMouse(); if (ArtBackground.surface != nullptr) {
DrawMouse();
}
UiFadeIn(); UiFadeIn();
} while (!dialogEnd); } while (!dialogEnd);
} }
@ -260,28 +255,32 @@ void UiOkDialog(const char *text, const char *caption, bool error, const std::ve
{ {
static bool inDialog = false; static bool inDialog = false;
if (caption != nullptr) {
LogError("{}\n{}", text, caption);
} else {
LogError("{}", text);
}
if (!gbActive || inDialog) { if (!gbActive || inDialog) {
if (!IsHardwareCursor()) {
if (SDL_ShowCursor(SDL_ENABLE) <= -1) {
Log("{}", SDL_GetError());
}
}
if (!gbQuietMode) { if (!gbQuietMode) {
if (SDL_ShowCursor(SDL_ENABLE) <= -1)
Log("{}", SDL_GetError());
if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, text, caption, nullptr) <= -1) { if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, text, caption, nullptr) <= -1) {
Log("{}", SDL_GetError()); Log("{}", SDL_GetError());
} }
} }
Log("{}", text);
Log("{}", caption);
return; return;
} }
if (IsHardwareCursor()) {
if (SDL_ShowCursor(SDL_ENABLE) <= -1)
Log("{}", SDL_GetError());
}
inDialog = true; inDialog = true;
SDL_SetClipRect(DiabloUiSurface(), nullptr);
Init(text, caption, error, !renderBehind.empty()); Init(text, caption, error, !renderBehind.empty());
if (font != nullptr) DialogLoop(vecOkDialog, renderBehind);
DialogLoop(vecOkDialog, renderBehind);
else
UiOkDialog(text, caption, error, renderBehind);
Deinit(); Deinit();
inDialog = false; inDialog = false;
} }

53
Source/DiabloUI/fonts.cpp

@ -1,53 +0,0 @@
#include "DiabloUI/fonts.h"
#include "diablo.h"
#include "engine/load_file.hpp"
#include "utils/file_util.h"
#include "utils/log.hpp"
#include "utils/paths.h"
namespace devilution {
TTF_Font *font = nullptr;
/** This is so we know ttf has been init when we get to the diablo_deinit() function */
bool was_fonts_init = false;
void LoadTtfFont()
{
if (TTF_WasInit() == 0) {
if (TTF_Init() == -1) {
Log("TTF_Init: {}", TTF_GetError());
diablo_quit(1);
}
was_fonts_init = true;
}
std::string ttfFontPath = paths::TtfPath() + paths::TtfName();
#if defined(__linux__) && !defined(__ANDROID__)
if (!FileExists(ttfFontPath.c_str())) {
ttfFontPath = "/usr/share/fonts/truetype/" + paths::TtfName();
}
#endif
font = TTF_OpenFont(ttfFontPath.c_str(), 17);
if (font == nullptr) {
Log("TTF_OpenFont: {}", TTF_GetError());
return;
}
TTF_SetFontKerning(font, 0);
TTF_SetFontHinting(font, TTF_HINTING_MONO);
}
void UnloadTtfFont()
{
if (font != nullptr && TTF_WasInit() != 0)
TTF_CloseFont(font);
font = nullptr;
}
void FontsCleanup()
{
TTF_Quit();
}
} // namespace devilution

18
Source/DiabloUI/fonts.h

@ -1,18 +0,0 @@
#pragma once
#include <cstdint>
#include <memory>
#include <SDL_ttf.h>
#include "DiabloUI/art.h"
namespace devilution {
extern TTF_Font *font;
void LoadTtfFont();
void UnloadTtfFont();
void FontsCleanup();
} // namespace devilution

28
Source/DiabloUI/progress.cpp

@ -1,7 +1,6 @@
#include "DiabloUI/art_draw.h" #include "DiabloUI/art_draw.h"
#include "DiabloUI/button.h" #include "DiabloUI/button.h"
#include "DiabloUI/diabloui.h" #include "DiabloUI/diabloui.h"
#include "DiabloUI/fonts.h"
#include "control.h" #include "control.h"
#include "controls/menu_controls.h" #include "controls/menu_controls.h"
#include "dx.h" #include "dx.h"
@ -9,7 +8,6 @@
#include "palette.h" #include "palette.h"
#include "utils/display.h" #include "utils/display.h"
#include "utils/language.h" #include "utils/language.h"
#include "utils/ttf_wrap.h"
namespace devilution { namespace devilution {
namespace { namespace {
@ -18,8 +16,6 @@ Art progressArt;
Art ArtPopupSm; Art ArtPopupSm;
Art ArtProgBG; Art ArtProgBG;
Art ProgFil; Art ProgFil;
SDLSurfaceUniquePtr msgSurface;
SDLSurfaceUniquePtr msgShadow;
std::vector<std::unique_ptr<UiItemBase>> vecProgress; std::vector<std::unique_ptr<UiItemBase>> vecProgress;
bool endMenu; bool endMenu;
@ -35,15 +31,7 @@ void ProgressLoad(const char *msg)
LoadArt("ui_art\\prog_bg.pcx", &ArtProgBG); LoadArt("ui_art\\prog_bg.pcx", &ArtProgBG);
LoadArt("ui_art\\prog_fil.pcx", &ProgFil); LoadArt("ui_art\\prog_fil.pcx", &ProgFil);
LoadSmlButtonArt(); LoadSmlButtonArt();
LoadTtfFont();
if (font != nullptr) {
SDL_Color color = { 243, 243, 243, 0 };
SDL_Color black = { 0, 0, 0, 0 };
msgSurface = TTFWrap::RenderUTF8_Solid(font, msg, color);
msgShadow = TTFWrap::RenderUTF8_Solid(font, msg, black);
}
SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 265), (Sint16)(UI_OFFSET_Y + 267), SML_BUTTON_WIDTH, SML_BUTTON_HEIGHT }; SDL_Rect rect3 = { (Sint16)(PANEL_LEFT + 265), (Sint16)(UI_OFFSET_Y + 267), SML_BUTTON_WIDTH, SML_BUTTON_HEIGHT };
vecProgress.push_back(std::make_unique<UiButton>(&SmlButton, _("Cancel"), &DialogActionCancel, rect3)); vecProgress.push_back(std::make_unique<UiButton>(&SmlButton, _("Cancel"), &DialogActionCancel, rect3));
} }
@ -55,9 +43,6 @@ void ProgressFree()
ArtProgBG.Unload(); ArtProgBG.Unload();
ProgFil.Unload(); ProgFil.Unload();
UnloadSmlButtonArt(); UnloadSmlButtonArt();
msgSurface = nullptr;
msgShadow = nullptr;
UnloadTtfFont();
} }
void ProgressRender(BYTE progress) void ProgressRender(BYTE progress)
@ -73,19 +58,6 @@ void ProgressRender(BYTE progress)
DrawArt({ GetCenterOffset(227), position.y + 52 }, &ProgFil, 0, 227 * progress / 100); DrawArt({ GetCenterOffset(227), position.y + 52 }, &ProgFil, 0, 227 * progress / 100);
} }
DrawArt({ GetCenterOffset(110), position.y + 99 }, &SmlButton, 2, 110); DrawArt({ GetCenterOffset(110), position.y + 99 }, &SmlButton, 2, 110);
if (msgSurface != nullptr) {
SDL_Rect dscRect = {
static_cast<Sint16>(position.x + 50 + 1),
static_cast<Sint16>(position.y + 8 + 1),
static_cast<Uint16>(msgSurface->w),
static_cast<Uint16>(msgSurface->h)
};
Blit(msgShadow.get(), nullptr, &dscRect);
dscRect.x -= 1;
dscRect.y -= 1;
Blit(msgSurface.get(), nullptr, &dscRect);
}
} }
} // namespace } // namespace

67
Source/DiabloUI/text_draw.cpp

@ -1,67 +0,0 @@
#include "DiabloUI/text_draw.h"
#include "DiabloUI/art_draw.h"
#include "DiabloUI/diabloui.h"
#include "DiabloUI/fonts.h"
#include "DiabloUI/ttf_render_wrapped.h"
#include "DiabloUI/ui_item.h"
#include "utils/display.h"
namespace devilution {
namespace {
TextAlignment XAlignmentFromFlags(UiFlags flags)
{
if (HasAnyOf(flags, UiFlags::AlignCenter))
return TextAlignment_CENTER;
if (HasAnyOf(flags, UiFlags::AlignRight))
return TextAlignment_END;
return TextAlignment_BEGIN;
}
int AlignXOffset(UiFlags flags, const SDL_Rect &dest, int w)
{
if (HasAnyOf(flags, UiFlags::AlignCenter))
return (dest.w - w) / 2;
if (HasAnyOf(flags, UiFlags::AlignRight))
return dest.w - w;
return 0;
}
} // namespace
void DrawTTF(const char *text, const SDL_Rect &rectIn, UiFlags flags,
const SDL_Color &textColor, const SDL_Color &shadowColor,
TtfSurfaceCache &renderCache)
{
SDL_Rect rect(rectIn);
if (font == nullptr || text == nullptr || *text == '\0')
return;
const auto xAlign = XAlignmentFromFlags(flags);
if (renderCache.text == nullptr)
renderCache.text = ScaleSurfaceToOutput(RenderUTF8_Solid_Wrapped(font, text, textColor, rect.w, xAlign));
if (renderCache.shadow == nullptr)
renderCache.shadow = ScaleSurfaceToOutput(RenderUTF8_Solid_Wrapped(font, text, shadowColor, rect.w, xAlign));
SDL_Surface *textSurface = renderCache.text.get();
SDL_Surface *shadowSurface = renderCache.shadow.get();
if (textSurface == nullptr)
return;
SDL_Rect destRect = rect;
ScaleOutputRect(&destRect);
destRect.x += AlignXOffset(flags, destRect, textSurface->w);
destRect.y += HasAnyOf(flags, UiFlags::VerticalCenter) ? (destRect.h - textSurface->h) / 2 : 0;
SDL_Rect shadowRect = destRect;
++shadowRect.x;
++shadowRect.y;
if (SDL_BlitSurface(shadowSurface, nullptr, DiabloUiSurface(), &shadowRect) < 0)
ErrSdl();
if (SDL_BlitSurface(textSurface, nullptr, DiabloUiSurface(), &destRect) < 0)
ErrSdl();
}
} // namespace devilution

20
Source/DiabloUI/text_draw.h

@ -1,20 +0,0 @@
#pragma once
#include <SDL.h>
#include "utils/sdl_ptrs.h"
namespace devilution {
struct TtfSurfaceCache {
SDLSurfaceUniquePtr text;
SDLSurfaceUniquePtr shadow;
};
enum class UiFlags; // Defined in ui_item.h, declared here to avoid circular dependency
void DrawTTF(const char *text, const SDL_Rect &rect, UiFlags flags,
const SDL_Color &textColor, const SDL_Color &shadowColor,
TtfSurfaceCache &renderCache);
} // namespace devilution

154
Source/DiabloUI/ttf_render_wrapped.cpp

@ -1,154 +0,0 @@
#include "DiabloUI/ttf_render_wrapped.h"
#include <cstddef>
#include <cstring>
#include <vector>
#include <algorithm>
#include <SDL.h>
#ifdef USE_SDL1
#include "utils/sdl2_to_1_2_backports.h"
#else
#include "utils/sdl2_backports.h"
#endif
#include "utils/log.hpp"
#include "utils/sdl_compat.h"
#include "utils/sdl_wrap.h"
#include "utils/ttf_wrap.h"
namespace devilution {
namespace {
bool CharacterIsDelimiter(char c)
{
constexpr char Delimiters[] = { ' ', '\t', '\r', '\n' };
return std::find(std::begin(Delimiters), std::end(Delimiters), c) != std::end(Delimiters);
}
} // namespace
// Based on SDL 2.0.12 TTF_RenderUTF8_Blended_Wrapped
SDLSurfaceUniquePtr RenderUTF8_Solid_Wrapped(TTF_Font *font, const char *text, SDL_Color fg, Uint32 wrapLength, const int xAlign)
{
int width = 0;
int height = 0;
const int lineSpace = 2;
/* Get the dimensions of the text surface */
if (TTF_SizeUTF8(font, text, &width, &height) < 0 || width == 0) {
TTF_SetError("Text has zero width");
return {};
}
std::unique_ptr<char[]> str;
std::vector<char *> strLines;
if (wrapLength > 0 && *text != '\0') {
const std::size_t strLen = std::strlen(text);
str.reset(new char[strLen + 1]);
std::memcpy(str.get(), text, strLen + 1);
char *tok = str.get();
char *end = str.get() + strLen;
do {
strLines.push_back(tok);
/* Look for the end of the line */
char *spot;
if ((spot = SDL_strchr(tok, '\r')) != nullptr || (spot = SDL_strchr(tok, '\n')) != nullptr) {
if (*spot == '\r') {
++spot;
}
if (*spot == '\n') {
++spot;
}
} else {
spot = end;
}
char *nextTok = spot;
/* Get the longest string that will fit in the desired space */
for (;;) {
/* Strip trailing whitespace */
while (spot > tok && CharacterIsDelimiter(spot[-1])) {
--spot;
}
if (spot == tok) {
if (CharacterIsDelimiter(*spot)) {
*spot = '\0';
}
break;
}
char delim = *spot;
*spot = '\0';
int w = 0;
int h = 0;
TTF_SizeUTF8(font, tok, &w, &h);
if ((Uint32)w <= wrapLength) {
break;
}
/* Back up and try again... */
*spot = delim;
while (spot > tok && !CharacterIsDelimiter(spot[-1])) {
--spot;
}
if (spot > tok) {
nextTok = spot;
}
}
tok = nextTok;
} while (tok < end);
}
if (strLines.empty())
return TTFWrap::RenderUTF8_Solid(font, text, fg);
/* Create the target surface */
auto textbuf = SDLWrap::CreateRGBSurface(SDL_SWSURFACE, (strLines.size() > 1) ? wrapLength : width, height * strLines.size() + (lineSpace * (strLines.size() - 1)), 8, 0, 0, 0, 0);
/* Fill the palette with the foreground color */
SDL_Palette *palette = textbuf->format->palette;
palette->colors[0].r = 255 - fg.r;
palette->colors[0].g = 255 - fg.g;
palette->colors[0].b = 255 - fg.b;
palette->colors[1].r = fg.r;
palette->colors[1].g = fg.g;
palette->colors[1].b = fg.b;
SDLC_SetColorKey(textbuf.get(), 0);
// Reduced space between lines to roughly match Diablo.
const int lineskip = TTF_FontLineSkip(font) * 7 / 10; // avoids forced int > float > int conversion
SDL_Rect dest = { 0, 0, 0, 0 };
for (auto text : strLines) {
if (*text == '\0') {
dest.y += lineskip;
continue;
}
SDLSurfaceUniquePtr tmp = TTFWrap::RenderUTF8_Solid(font, text, fg);
dest.w = static_cast<Uint16>(tmp->w);
dest.h = static_cast<Uint16>(tmp->h);
switch (xAlign) {
case TextAlignment_END:
dest.x = textbuf->w - tmp->w;
break;
case TextAlignment_CENTER:
dest.x = (textbuf->w - tmp->w) / 2;
break;
case TextAlignment_BEGIN:
dest.x = 0;
break;
}
SDL_BlitSurface(tmp.get(), nullptr, textbuf.get(), &dest);
dest.y += lineskip;
}
return textbuf;
}
} // namespace devilution

24
Source/DiabloUI/ttf_render_wrapped.h

@ -1,24 +0,0 @@
#pragma once
#include <SDL_ttf.h>
#include <cstdint>
#include "utils/sdl_ptrs.h"
namespace devilution {
enum TextAlignment : uint8_t {
TextAlignment_BEGIN,
TextAlignment_CENTER,
TextAlignment_END,
};
/**
* Renders UTF-8, wrapping lines to avoid exceeding wrapLength, and aligning
* according to the `x_align` argument.
*
* This method is slow. Caching the result is recommended.
*/
SDLSurfaceUniquePtr RenderUTF8_Solid_Wrapped(
TTF_Font *font, const char *text, SDL_Color fg, Uint32 wrapLength, const int xAlign = TextAlignment_BEGIN);
} // namespace devilution

68
Source/DiabloUI/ui_item.h

@ -6,7 +6,6 @@
#include <vector> #include <vector>
#include "DiabloUI/art.h" #include "DiabloUI/art.h"
#include "DiabloUI/text_draw.h"
#include "utils/stubs.h" #include "utils/stubs.h"
namespace devilution { namespace devilution {
@ -31,31 +30,34 @@ enum class UiFlags {
FontSize30 = 1 << 2, FontSize30 = 1 << 2,
FontSize42 = 1 << 3, FontSize42 = 1 << 3,
FontSize46 = 1 << 4, FontSize46 = 1 << 4,
FontSizeDialog = 1 << 5,
ColorUiGold = 1 << 5,
ColorUiSilver = 1 << 6, ColorUiGold = 1 << 6,
ColorUiGoldDark = 1 << 7, ColorUiSilver = 1 << 7,
ColorUiSilverDark = 1 << 8, ColorUiGoldDark = 1 << 8,
ColorGold = 1 << 9, ColorUiSilverDark = 1 << 9,
ColorBlack = 1 << 10, ColorDialogWhite = 1 << 10,
ColorWhite = 1 << 11, ColorDialogYellow = 1 << 11,
ColorWhitegold = 1 << 12, ColorGold = 1 << 12,
ColorRed = 1 << 13, ColorBlack = 1 << 13,
ColorBlue = 1 << 14, ColorWhite = 1 << 14,
ColorButtonface = 1 << 15, ColorWhitegold = 1 << 15,
ColorButtonpushed = 1 << 16, ColorRed = 1 << 16,
ColorBlue = 1 << 17,
AlignCenter = 1 << 17, ColorButtonface = 1 << 18,
AlignRight = 1 << 18, ColorButtonpushed = 1 << 19,
VerticalCenter = 1 << 19,
AlignCenter = 1 << 20,
KerningFitSpacing = 1 << 20, AlignRight = 1 << 21,
VerticalCenter = 1 << 22,
ElementDisabled = 1 << 21,
ElementHidden = 1 << 22, KerningFitSpacing = 1 << 23,
PentaCursor = 1 << 23, ElementDisabled = 1 << 24,
TextCursor = 1 << 24, ElementHidden = 1 << 25,
PentaCursor = 1 << 26,
TextCursor = 1 << 27,
// clang-format on // clang-format on
}; };
@ -271,26 +273,18 @@ public:
//============================================================================= //=============================================================================
// Plain text (TTF) // Plain text
class UiText : public UiItemBase { class UiText : public UiItemBase {
public: public:
UiText(const char *text, SDL_Rect rect, UiFlags flags = UiFlags::None, SDL_Color color = { 243, 243, 243, 0 }) UiText(const char *text, SDL_Rect rect, UiFlags flags = UiFlags::ColorDialogWhite)
: UiItemBase(UiType::Text, rect, flags) : UiItemBase(UiType::Text, rect, flags)
, m_color(color)
, m_shadow_color({ 0, 0, 0, 0 })
, m_text(text) , m_text(text)
, m_render_cache()
{ {
} }
//private: //private:
SDL_Color m_color;
SDL_Color m_shadow_color;
const char *m_text; const char *m_text;
// State:
TtfSurfaceCache m_render_cache;
}; };
//============================================================================= //=============================================================================
@ -305,7 +299,6 @@ public:
, m_text(text) , m_text(text)
, m_action(action) , m_action(action)
, m_pressed(false) , m_pressed(false)
, m_render_cache()
{ {
} }
@ -322,7 +315,6 @@ public:
// State // State
bool m_pressed; bool m_pressed;
TtfSurfaceCache m_render_cache;
}; };
//============================================================================= //=============================================================================

2
Source/appfat.h

@ -13,8 +13,6 @@ namespace devilution {
#define ErrSdl() ErrDlg("SDL Error", SDL_GetError(), __FILE__, __LINE__) #define ErrSdl() ErrDlg("SDL Error", SDL_GetError(), __FILE__, __LINE__)
#define ErrTtf() ErrDlg("TTF Error", TTF_GetError(), __FILE__, __LINE__)
#undef assert #undef assert
#ifndef _DEBUG #ifndef _DEBUG

8
Source/diablo.cpp

@ -781,8 +781,6 @@ void RunGameLoop(interface_mode uMsg)
printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--data-dir", _("Specify the folder of diabdat.mpq")); printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--data-dir", _("Specify the folder of diabdat.mpq"));
printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--save-dir", _("Specify the folder of save files")); printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--save-dir", _("Specify the folder of save files"));
printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--config-dir", _("Specify the location of diablo.ini")); printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--config-dir", _("Specify the location of diablo.ini"));
printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--ttf-dir", _("Specify the location of the .ttf font"));
printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--ttf-name", _("Specify the name of a custom .ttf font"));
printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "-n", _("Skip startup videos")); printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "-n", _("Skip startup videos"));
printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "-f", _("Display frames per second")); printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "-f", _("Display frames per second"));
printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "-x", _("Run in windowed mode")); printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "-x", _("Run in windowed mode"));
@ -833,10 +831,6 @@ void DiabloParseFlags(int argc, char **argv)
paths::SetConfigPath(argv[++i]); paths::SetConfigPath(argv[++i]);
} else if (strcasecmp("--lang-dir", argv[i]) == 0) { } else if (strcasecmp("--lang-dir", argv[i]) == 0) {
paths::SetLangPath(argv[++i]); paths::SetLangPath(argv[++i]);
} else if (strcasecmp("--ttf-dir", argv[i]) == 0) {
paths::SetTtfPath(argv[++i]);
} else if (strcasecmp("--ttf-name", argv[i]) == 0) {
paths::SetTtfName(argv[++i]);
} else if (strcasecmp("-n", argv[i]) == 0) { } else if (strcasecmp("-n", argv[i]) == 0) {
gbShowIntro = false; gbShowIntro = false;
} else if (strcasecmp("-f", argv[i]) == 0) { } else if (strcasecmp("-f", argv[i]) == 0) {
@ -986,8 +980,6 @@ void DiabloDeinit()
init_cleanup(); init_cleanup();
if (was_window_init) if (was_window_init)
dx_cleanup(); // Cleanup SDL surfaces stuff, so we have to do it before SDL_Quit(). dx_cleanup(); // Cleanup SDL surfaces stuff, so we have to do it before SDL_Quit().
if (was_fonts_init)
FontsCleanup();
UnloadFonts(); UnloadFonts();
if (SDL_WasInit(SDL_INIT_EVERYTHING & ~SDL_INIT_HAPTIC) != 0) if (SDL_WasInit(SDL_INIT_EVERYTHING & ~SDL_INIT_HAPTIC) != 0)
SDL_Quit(); SDL_Quit();

1
Source/diablo.h

@ -67,7 +67,6 @@ extern bool gbLoadGame;
extern bool cineflag; extern bool cineflag;
extern int force_redraw; extern int force_redraw;
/* These are defined in fonts.h */ /* These are defined in fonts.h */
extern bool was_fonts_init;
extern void FontsCleanup(); extern void FontsCleanup();
extern int PauseMode; extern int PauseMode;
extern bool gbNestArt; extern bool gbNestArt;

17
Source/engine/render/text_render.cpp

@ -28,16 +28,19 @@ namespace {
std::unordered_map<uint32_t, Art> Fonts; std::unordered_map<uint32_t, Art> Fonts;
std::unordered_map<uint32_t, std::array<uint8_t, 256>> FontKerns; std::unordered_map<uint32_t, std::array<uint8_t, 256>> FontKerns;
std::array<int, 5> FontSizes = { 12, 24, 30, 42, 46 }; std::array<int, 6> FontSizes = { 12, 24, 30, 42, 46, 22 };
std::array<int, 5> LineHeights = { 12, 26, 38, 42, 50 }; std::array<int, 6> LineHeights = { 12, 26, 38, 42, 50, 22 };
std::array<int, 5> BaseLineOffset = { -3, -2, -3, -6, -7 }; std::array<int, 6> BaseLineOffset = { -3, -2, -3, -6, -7, 3 };
std::array<const char *, 12> ColorTranlations = { std::array<const char *, 14> ColorTranlations = {
"fonts\\goldui.trn", "fonts\\goldui.trn",
"fonts\\grayui.trn", "fonts\\grayui.trn",
"fonts\\golduis.trn", "fonts\\golduis.trn",
"fonts\\grayuis.trn", "fonts\\grayuis.trn",
nullptr,
"fonts\\yellowdialog.trn",
nullptr, nullptr,
"fonts\\black.trn", "fonts\\black.trn",
@ -60,6 +63,8 @@ GameFontTables GetSizeFromFlags(UiFlags flags)
return GameFont42; return GameFont42;
else if (HasAnyOf(flags, UiFlags::FontSize46)) else if (HasAnyOf(flags, UiFlags::FontSize46))
return GameFont46; return GameFont46;
else if (HasAnyOf(flags, UiFlags::FontSizeDialog))
return FontSizeDialog;
return GameFont12; return GameFont12;
} }
@ -84,6 +89,10 @@ text_color GetColorFromFlags(UiFlags flags)
return ColorUiGoldDark; return ColorUiGoldDark;
else if (HasAnyOf(flags, UiFlags::ColorUiSilverDark)) else if (HasAnyOf(flags, UiFlags::ColorUiSilverDark))
return ColorUiSilverDark; return ColorUiSilverDark;
else if (HasAnyOf(flags, UiFlags::ColorDialogWhite))
return ColorDialogWhite;
else if (HasAnyOf(flags, UiFlags::ColorDialogYellow))
return ColorDialogYellow;
else if (HasAnyOf(flags, UiFlags::ColorButtonface)) else if (HasAnyOf(flags, UiFlags::ColorButtonface))
return ColorButtonface; return ColorButtonface;
else if (HasAnyOf(flags, UiFlags::ColorButtonpushed)) else if (HasAnyOf(flags, UiFlags::ColorButtonpushed))

4
Source/engine/render/text_render.hpp

@ -24,6 +24,7 @@ enum GameFontTables : uint8_t {
GameFont30, GameFont30,
GameFont42, GameFont42,
GameFont46, GameFont46,
FontSizeDialog,
}; };
enum text_color : uint8_t { enum text_color : uint8_t {
@ -32,6 +33,9 @@ enum text_color : uint8_t {
ColorUiGoldDark, ColorUiGoldDark,
ColorUiSilverDark, ColorUiSilverDark,
ColorDialogWhite,
ColorDialogYellow,
ColorGold, ColorGold,
ColorBlack, ColorBlack,

35
Source/utils/paths.cpp

@ -11,14 +11,6 @@
#include "utils/sdl2_to_1_2_backports.h" #include "utils/sdl2_to_1_2_backports.h"
#endif #endif
#ifndef TTF_FONT_DIR
#define TTF_FONT_DIR ""
#endif
#ifndef TTF_FONT_NAME
#define TTF_FONT_NAME "CharisSILB.ttf"
#endif
#ifndef MO_LANG_DIR #ifndef MO_LANG_DIR
#define MO_LANG_DIR "" #define MO_LANG_DIR ""
#endif #endif
@ -33,8 +25,6 @@ std::optional<std::string> basePath;
std::optional<std::string> prefPath; std::optional<std::string> prefPath;
std::optional<std::string> configPath; std::optional<std::string> configPath;
std::optional<std::string> langPath; std::optional<std::string> langPath;
std::optional<std::string> ttfPath;
std::optional<std::string> ttfName;
void AddTrailingSlash(std::string &path) void AddTrailingSlash(std::string &path)
{ {
@ -97,20 +87,6 @@ const std::string &LangPath()
return *langPath; return *langPath;
} }
const std::string &TtfPath()
{
if (!ttfPath)
ttfPath.emplace(TTF_FONT_DIR);
return *ttfPath;
}
const std::string &TtfName()
{
if (!ttfName)
ttfName.emplace(TTF_FONT_NAME);
return *ttfName;
}
void SetBasePath(const std::string &path) void SetBasePath(const std::string &path)
{ {
basePath = path; basePath = path;
@ -135,17 +111,6 @@ void SetLangPath(const std::string &path)
AddTrailingSlash(*langPath); AddTrailingSlash(*langPath);
} }
void SetTtfPath(const std::string &path)
{
ttfPath = path;
AddTrailingSlash(*ttfPath);
}
void SetTtfName(const std::string &name)
{
ttfName = name;
}
} // namespace paths } // namespace paths
} // namespace devilution } // namespace devilution

4
Source/utils/paths.h

@ -10,15 +10,11 @@ const std::string &BasePath();
const std::string &PrefPath(); const std::string &PrefPath();
const std::string &ConfigPath(); const std::string &ConfigPath();
const std::string &LangPath(); const std::string &LangPath();
const std::string &TtfPath();
const std::string &TtfName();
void SetBasePath(const std::string &path); void SetBasePath(const std::string &path);
void SetPrefPath(const std::string &path); void SetPrefPath(const std::string &path);
void SetConfigPath(const std::string &path); void SetConfigPath(const std::string &path);
void SetLangPath(const std::string &path); void SetLangPath(const std::string &path);
void SetTtfPath(const std::string &path);
void SetTtfName(const std::string &name);
} // namespace paths } // namespace paths

29
Source/utils/ttf_wrap.h

@ -1,29 +0,0 @@
#pragma once
#include <SDL_ttf.h>
#include <SDL.h>
#ifdef USE_SDL1
#include "utils/sdl2_to_1_2_backports.h"
#else
#include "utils/sdl2_backports.h"
#endif
#include "appfat.h"
#include "utils/sdl_ptrs.h"
namespace devilution {
namespace TTFWrap {
inline SDLSurfaceUniquePtr RenderUTF8_Solid(TTF_Font *font, const char *text, SDL_Color fg)
{
SDLSurfaceUniquePtr ret { TTF_RenderUTF8_Solid(font, text, fg) };
if (ret == nullptr)
ErrTtf();
return ret;
}
} //namespace TTFWrap
} //namespace devilution

16
android-project/3rdParty/SDL2_ttf/CMakeLists.txt vendored

@ -1,16 +0,0 @@
set(BUILD_SHARED_LIBS ON)
include(FetchContent_MakeAvailableExcludeFromAll)
include(FetchContent)
FetchContent_Declare(SDL2_ttf
URL https://github.com/libsdl-org/SDL_ttf/archive/33cdd1881e31184b49a68b4890d1d256fc0c6dc1.tar.gz
URL_HASH MD5=7cfa28e6170618acf50d6a9cd27091ab
)
FetchContent_MakeAvailableExcludeFromAll(SDL2_ttf)
# SDL2_ttf only provides an INSTALL_INTERFACE directory
# so use the source directory for the BUILD_INTERFACE
target_include_directories(SDL2_ttf PUBLIC $<BUILD_INTERFACE:${SDL_ttf_SOURCE_DIR}>)
add_library(SDL2::SDL2_ttf ALIAS SDL2_ttf)

9
android-project/CMake/FindFreetype.cmake

@ -1,9 +0,0 @@
# Use globbing to find the source directory regardless of the version number
file(GLOB freetype_SOURCE_DIR ${SDL_ttf_SOURCE_DIR}/external/freetype*)
add_subdirectory(${freetype_SOURCE_DIR})
# freetype only provides an INSTALL_INTERFACE directory
# so use the source directory for the BUILD_INTERFACE
target_include_directories(freetype PUBLIC $<BUILD_INTERFACE:${freetype_SOURCE_DIR}/include>)
add_library(Freetype::Freetype ALIAS freetype)

7
android-project/CMake/android_defs.cmake

@ -11,12 +11,5 @@ if(BINARY_RELEASE OR CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -flto=full") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -flto=full")
endif() endif()
#additional compilation definitions
set(TTF_FONT_DIR \"\")
file(
COPY "${DevilutionX_SOURCE_DIR}/Packaging/resources/CharisSILB.ttf"
DESTINATION "${DevilutionX_SOURCE_DIR}/android-project/app/src/main/assets")
file(GLOB VirtualGamepadArt "${DevilutionX_SOURCE_DIR}/Packaging/resources/assets/ui_art/*") file(GLOB VirtualGamepadArt "${DevilutionX_SOURCE_DIR}/Packaging/resources/assets/ui_art/*")
file(COPY ${VirtualGamepadArt} DESTINATION "${DevilutionX_SOURCE_DIR}/android-project/app/src/main/assets/ui_art") file(COPY ${VirtualGamepadArt} DESTINATION "${DevilutionX_SOURCE_DIR}/android-project/app/src/main/assets/ui_art")

22
docs/building.md

@ -12,11 +12,11 @@ although we have a fallback if necessary.
### Installing dependencies on Debian and Ubuntu ### Installing dependencies on Debian and Ubuntu
``` ```
sudo apt-get install cmake g++ libsdl2-ttf-dev libsodium-dev libpng-dev sudo apt-get install cmake g++ libsdl2-dev libsodium-dev libpng-dev
``` ```
### Installing dependencies on Fedora ### Installing dependencies on Fedora
``` ```
sudo dnf install cmake gcc-c++ glibc-devel SDL2-devel SDL2_ttf-devel libsodium-devel libpng-devel libasan libubsan sudo dnf install cmake gcc-c++ glibc-devel SDL2-devel libsodium-devel libpng-devel libasan libubsan
``` ```
### Compiling ### Compiling
``` ```
@ -41,7 +41,7 @@ cmake --build . -j $(sysctl -n hw.physicalcpu)
### Installing dependencies ### Installing dependencies
``` ```
pkg install cmake sdl2_ttf libsodium libpng pkg install cmake sdl2 libsodium libpng
``` ```
### Compiling ### Compiling
``` ```
@ -54,7 +54,7 @@ cmake --build . -j $(sysctl -n hw.ncpu)
### Installing dependencies ### Installing dependencies
``` ```
pkgin install cmake SDL2_ttf libsodium libpng pkgin install cmake SDL2 libsodium libpng
``` ```
### Compiling ### Compiling
``` ```
@ -68,7 +68,7 @@ cmake --build . -j $(sysctl -n hw.ncpu)
### Installing dependencies ### Installing dependencies
``` ```
pkg_add cmake sdl2-ttf libsodium libpng gmake pkg_add cmake sdl2 libsodium libpng gmake
``` ```
### Compiling ### Compiling
``` ```
@ -84,7 +84,7 @@ cmake --build . -j $(sysctl -n hw.ncpuonline)
### 32-bit ### 32-bit
Download the 32bit MinGW Development Libraries of [SDL2](https://www.libsdl.org/download-2.0.php), [SDL2_ttf](https://www.libsdl.org/projects/SDL_ttf/) and [Libsodium](https://github.com/jedisct1/libsodium/releases) as well as headers for [zlib](https://zlib.net/zlib-1.2.11.tar.gz) and place them in `/usr/i686-w64-mingw32`. This can be done automatically by running `Packaging/windows/mingw-prep.sh`. Download the 32bit MinGW Development Libraries of [SDL2](https://www.libsdl.org/download-2.0.php) and [Libsodium](https://github.com/jedisct1/libsodium/releases) as well as headers for [zlib](https://zlib.net/zlib-1.2.11.tar.gz) and place them in `/usr/i686-w64-mingw32`. This can be done automatically by running `Packaging/windows/mingw-prep.sh`.
``` ```
sudo apt-get install cmake gcc-mingw-w64-i686 g++-mingw-w64-i686 pkg-config-mingw-w64-i686 sudo apt-get install cmake gcc-mingw-w64-i686 g++-mingw-w64-i686 pkg-config-mingw-w64-i686
@ -92,7 +92,7 @@ sudo apt-get install cmake gcc-mingw-w64-i686 g++-mingw-w64-i686 pkg-config-ming
### 64-bit ### 64-bit
Download the 64bit MinGW Development Libraries of [SDL2](https://www.libsdl.org/download-2.0.php), [SDL2_ttf](https://www.libsdl.org/projects/SDL_ttf/) and [Libsodium](https://github.com/jedisct1/libsodium/releases) as well as headers for [zlib](https://zlib.net/zlib-1.2.11.tar.gz) and place them in `/usr/x86_64-w64-mingw32`. This can be done automatically by running `Packaging/windows/mingw-prep64.sh`. Download the 64bit MinGW Development Libraries of [SDL2](https://www.libsdl.org/download-2.0.php) and [Libsodium](https://github.com/jedisct1/libsodium/releases) as well as headers for [zlib](https://zlib.net/zlib-1.2.11.tar.gz) and place them in `/usr/x86_64-w64-mingw32`. This can be done automatically by running `Packaging/windows/mingw-prep64.sh`.
``` ```
sudo apt-get install cmake gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 pkg-config-mingw-w64-x86-64 sudo apt-get install cmake gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 pkg-config-mingw-w64-x86-64
@ -190,7 +190,7 @@ https://devkitpro.org/wiki/Getting_Started
``` ```
sudo (dkp-)pacman -S \ sudo (dkp-)pacman -S \
devkitARM general-tools 3dstools devkitpro-pkgbuild-helpers \ devkitARM general-tools 3dstools devkitpro-pkgbuild-helpers \
libctru citro3d 3ds-sdl 3ds-sdl_ttf 3ds-freetype 3ds-libpng \ libctru citro3d 3ds-sdl 3ds-libpng \
3ds-cmake 3ds-pkg-config picasso 3dslink 3ds-cmake 3ds-pkg-config picasso 3dslink
``` ```
- Download or compile [bannertool](https://github.com/Steveice10/bannertool/releases) and [makerom](https://github.com/jakcron/Project_CTR/releases) - Download or compile [bannertool](https://github.com/Steveice10/bannertool/releases) and [makerom](https://github.com/jakcron/Project_CTR/releases)
@ -226,11 +226,11 @@ make
### Installing dependencies on 32 bit Haiku ### Installing dependencies on 32 bit Haiku
``` ```
pkgman install cmake_x86 devel:libsdl2_x86 devel:libsdl2_ttf_x86 devel:libsodium_x86 devel:libpng_x86 pkgman install cmake_x86 devel:libsdl2_x86 devel:libsodium_x86 devel:libpng_x86
``` ```
### Installing dependencies on 64 bit Haiku ### Installing dependencies on 64 bit Haiku
``` ```
pkgman install cmake devel:libsdl2 devel:libsdl2_ttf devel:libsodium devel:libpng pkgman install cmake devel:libsdl2 devel:libsodium devel:libpng
``` ```
### Compiling on 32 bit Haiku ### Compiling on 32 bit Haiku
``` ```
@ -321,7 +321,7 @@ Outside of the Docker container, from the DevilutionX directory, run:
~~~ bash ~~~ bash
sudo chown -R "${USER}:" build-amiga sudo chown -R "${USER}:" build-amiga
cp Packaging/amiga/devilutionx.info Packaging/amiga/LiberationSerif-Bold.ttf build-amiga/ cp Packaging/amiga/devilutionx.info build-amiga/
~~~ ~~~
To actually start DevilutionX, increase the stack size to 50KiB in Amiga. To actually start DevilutionX, increase the stack size to 50KiB in Amiga.

6
vcpkg.json

@ -3,11 +3,9 @@
"version-string": "1.2.1", "version-string": "1.2.1",
"dependencies": [ "dependencies": [
"fmt", "fmt",
"freetype",
"libpng", "libpng",
"libsodium", "libsodium",
"sdl2", "sdl2"
"sdl2-ttf"
], ],
"features": { "features": {
"translations": { "translations": {
@ -24,4 +22,4 @@
"dependencies": [ "gtest" ] "dependencies": [ "gtest" ]
} }
} }
} }

Loading…
Cancel
Save