diff --git a/cmake/scripts/Baseset.cmake b/cmake/scripts/Baseset.cmake new file mode 100644 index 0000000000..4329dbdf8c --- /dev/null +++ b/cmake/scripts/Baseset.cmake @@ -0,0 +1,53 @@ +cmake_minimum_required(VERSION 3.5) + +# +# Create a single baseset meta file with the correct translations. +# + +set(ARGC 1) +set(ARG_READ NO) + +# Read all the arguments given to CMake; we are looking for -- and everything +# that follows. Those are our language files. +while(ARGC LESS CMAKE_ARGC) + set(ARG ${CMAKE_ARGV${ARGC}}) + + if (ARG_READ) + list(APPEND LANG_SOURCE_FILES "${ARG}") + endif (ARG_READ) + + if (ARG STREQUAL "--") + set(ARG_READ YES) + endif (ARG STREQUAL "--") + + math(EXPR ARGC "${ARGC} + 1") +endwhile() + +# Place holder format is @_@ +file(STRINGS "${BASESET_SOURCE_FILE}" PLACE_HOLDER REGEX "^@") +string(REGEX REPLACE "@([^_]+).*@" "\\1" INI_KEY "${PLACE_HOLDER}") +string(REGEX REPLACE "@[^_]+_(.*)@" "\\1" STR_ID "${PLACE_HOLDER}") +string(REGEX REPLACE "@(.*)@" "\\1" PLACE_HOLDER "${PLACE_HOLDER}") + +# Get the translations +foreach(LANGFILE IN LISTS LANG_SOURCE_FILES) + file(STRINGS "${LANGFILE}" LANGLINES REGEX "^(##isocode|${STR_ID})" ENCODING UTF-8) + string(FIND "${LANGLINES}" "${STR_ID}" HAS_STR_ID) + if (HAS_STR_ID LESS 0) + continue() + endif (HAS_STR_ID LESS 0) + string(REGEX REPLACE "##isocode ([^;]+).*" "\\1" ISOCODE "${LANGLINES}") + if ("${ISOCODE}" STREQUAL "en_GB") + string(REGEX REPLACE "[^:]*:(.*)" "${INI_KEY} = \\1" LANGLINES "${LANGLINES}") + else() + string(REGEX REPLACE "[^:]*:(.*)" "${INI_KEY}.${ISOCODE} = \\1" LANGLINES "${LANGLINES}") + endif() + list(APPEND ${PLACE_HOLDER} ${LANGLINES}) +endforeach(LANGFILE) +list(SORT ${PLACE_HOLDER}) +string(REPLACE ";" "\n" ${PLACE_HOLDER} "${${PLACE_HOLDER}}") + +# Get the grf md5 +file(MD5 ${BASESET_EXTRAGRF_FILE} ORIG_EXTRA_GRF_MD5) + +configure_file(${BASESET_SOURCE_FILE} ${BASESET_BINARY_FILE}) diff --git a/cmake/scripts/CreateGRF.cmake b/cmake/scripts/CreateGRF.cmake new file mode 100644 index 0000000000..f5811daf9f --- /dev/null +++ b/cmake/scripts/CreateGRF.cmake @@ -0,0 +1,44 @@ +cmake_minimum_required(VERSION 3.5) + +# +# Create a single GRF file based on sprites/.nfo and sprites/*.png +# files. +# + +if (NOT NFORENUM_EXECUTABLE) + message(FATAL_ERROR "Script needs NFORENUM_EXECUTABLE defined") +endif (NOT NFORENUM_EXECUTABLE) +if (NOT GRFCODEC_EXECUTABLE) + message(FATAL_ERROR "Script needs GRFCODEC_EXECUTABLE defined") +endif (NOT GRFCODEC_EXECUTABLE) +if (NOT GRF_SOURCE_FOLDER) + message(FATAL_ERROR "Script needs GRF_SOURCE_FOLDER defined") +endif (NOT GRF_SOURCE_FOLDER) +if (NOT GRF_BINARY_FILE) + message(FATAL_ERROR "Script needs GRF_BINARY_FILE defined") +endif (NOT GRF_BINARY_FILE) + +get_filename_component(GRF_SOURCE_FOLDER_NAME "${GRF_SOURCE_FOLDER}" NAME) + +file(WRITE sprites/${GRF_SOURCE_FOLDER_NAME}.nfo "") +file(READ ${GRF_SOURCE_FOLDER}/${GRF_SOURCE_FOLDER_NAME}.nfo NFO_LINES) +# Replace ; with \;, and make a list out of this based on \n +string(REPLACE ";" "\\;" NFO_LINES "${NFO_LINES}") +string(REPLACE "\n" ";" NFO_LINES "${NFO_LINES}") + +foreach(NFO_LINE IN LISTS NFO_LINES) + # Recover the ; that was really in the text (and not a newline) + string(REPLACE "\\;" ";" NFO_LINE "${NFO_LINE}") + + if (NFO_LINE MATCHES "^#include") + string(REGEX REPLACE "^#include \"(.*)\"$" "\\1" INCLUDE_FILE ${NFO_LINE}) + file(READ ${GRF_SOURCE_FOLDER}/${INCLUDE_FILE} INCLUDE_LINES) + file(APPEND sprites/${GRF_SOURCE_FOLDER_NAME}.nfo "${INCLUDE_LINES}") + else (NFO_LINE MATCHES "^#include") + file(APPEND sprites/${GRF_SOURCE_FOLDER_NAME}.nfo "${NFO_LINE}\n") + endif (NFO_LINE MATCHES "^#include") +endforeach(NFO_LINE) + +execute_process(COMMAND ${NFORENUM_EXECUTABLE} -s sprites/${GRF_SOURCE_FOLDER_NAME}.nfo) +execute_process(COMMAND ${GRFCODEC_EXECUTABLE} -n -s -e -p1 ${GRF_SOURCE_FOLDER_NAME}.grf) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${GRF_SOURCE_FOLDER_NAME}.grf ${GRF_BINARY_FILE}) diff --git a/media/baseset/CMakeLists.txt b/media/baseset/CMakeLists.txt new file mode 100644 index 0000000000..309ac7a498 --- /dev/null +++ b/media/baseset/CMakeLists.txt @@ -0,0 +1,87 @@ +add_subdirectory(openttd) +add_subdirectory(orig_extra) + +set(BASESET_SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/orig_dos.obg + ${CMAKE_CURRENT_SOURCE_DIR}/orig_dos_de.obg + ${CMAKE_CURRENT_SOURCE_DIR}/orig_win.obg + ${CMAKE_CURRENT_SOURCE_DIR}/no_music.obm + ${CMAKE_CURRENT_SOURCE_DIR}/orig_dos.obm + ${CMAKE_CURRENT_SOURCE_DIR}/orig_tto.obm + ${CMAKE_CURRENT_SOURCE_DIR}/orig_win.obm + ${CMAKE_CURRENT_SOURCE_DIR}/no_sound.obs + ${CMAKE_CURRENT_SOURCE_DIR}/orig_dos.obs + ${CMAKE_CURRENT_SOURCE_DIR}/orig_win.obs +) +set(BASESET_OTHER_SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/openttd.grf + ${CMAKE_CURRENT_SOURCE_DIR}/opntitle.dat + ${CMAKE_CURRENT_SOURCE_DIR}/orig_extra.grf +) + +# Done by the subdirectories, if nforenum / grfcodec is installed +if (NFORENUM_FOUND AND GRFCODEC_FOUND) + set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/openttd.grf PROPERTIES GENERATED TRUE) + set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/orig_extra.grf PROPERTIES GENERATED TRUE) + + list(APPEND BASESET_BINARY_FILES openttd.grf) + list(APPEND BASESET_BINARY_FILES orig_extra.grf) +endif (NFORENUM_FOUND AND GRFCODEC_FOUND) + +set(BASESET_EXTRAGRF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/orig_extra.grf) + +# Walk over all the baseset files, and generate a command to configure them +foreach(BASESET_SOURCE_FILE IN LISTS BASESET_SOURCE_FILES) + get_filename_component(BASESET_SOURCE_FILE_NAME "${BASESET_SOURCE_FILE}" NAME) + set(BASESET_BINARY_FILE "${CMAKE_BINARY_DIR}/baseset/${BASESET_SOURCE_FILE_NAME}") + + get_target_property(LANG_SOURCE_FILES language_files LANG_SOURCE_FILES) + + add_custom_command_timestamp(OUTPUT ${BASESET_BINARY_FILE} + COMMAND ${CMAKE_COMMAND} + -DBASESET_SOURCE_FILE=${BASESET_SOURCE_FILE} + -DBASESET_BINARY_FILE=${BASESET_BINARY_FILE} + -DBASESET_EXTRAGRF_FILE=${BASESET_EXTRAGRF_FILE} + -P ${CMAKE_SOURCE_DIR}/cmake/scripts/Baseset.cmake + -- + ${LANG_SOURCE_FILES} + MAIN_DEPENDENCY ${BASESET_SOURCE_FILE} + DEPENDS ${LANG_SOURCE_FILES} + ${BASESET_EXTRAGRF_FILE} + ${CMAKE_SOURCE_DIR}/cmake/scripts/Baseset.cmake + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating ${BASESET_SOURCE_FILE_NAME} baseset metadata file" + ) + + list(APPEND BASESET_BINARY_FILES ${BASESET_BINARY_FILE}) +endforeach(BASESET_SOURCE_FILE) + +# Walk over all the other baseset files, and generate a command to copy them +foreach(BASESET_OTHER_SOURCE_FILE IN LISTS BASESET_OTHER_SOURCE_FILES) + get_filename_component(BASESET_OTHER_SOURCE_FILE_NAME "${BASESET_OTHER_SOURCE_FILE}" NAME) + set(BASESET_OTHER_BINARY_FILE "${CMAKE_BINARY_DIR}/baseset/${BASESET_OTHER_SOURCE_FILE_NAME}") + + add_custom_command(OUTPUT ${BASESET_OTHER_BINARY_FILE} + COMMAND ${CMAKE_COMMAND} -E copy + ${BASESET_OTHER_SOURCE_FILE} + ${BASESET_OTHER_BINARY_FILE} + MAIN_DEPENDENCY ${BASESET_OTHER_SOURCE_FILE} + COMMENT "Copying ${BASESET_OTHER_SOURCE_FILE_NAME} baseset file" + ) + + list(APPEND BASESET_BINARY_FILES ${BASESET_OTHER_BINARY_FILE}) +endforeach(BASESET_OTHER_SOURCE_FILE) + +# Create a new target which generates all baseset metadata files +add_custom_target_timestamp(baseset_files + DEPENDS + ${BASESET_BINARY_FILES} +) + +add_library(basesets + INTERFACE +) +add_dependencies(basesets + baseset_files +) +add_library(openttd::basesets ALIAS basesets) diff --git a/media/baseset/no_music.obm b/media/baseset/no_music.obm index e395ba0b0e..3b8b9657ae 100644 --- a/media/baseset/no_music.obm +++ b/media/baseset/no_music.obm @@ -5,7 +5,7 @@ name = NoMusic shortname = NULL version = 0 fallback = true -!! description STR_BASEMUSIC_NONE_DESCRIPTION +@description_STR_BASEMUSIC_NONE_DESCRIPTION@ [files] theme = diff --git a/media/baseset/no_sound.obs b/media/baseset/no_sound.obs index fd2430de54..3b546d5bb4 100644 --- a/media/baseset/no_sound.obs +++ b/media/baseset/no_sound.obs @@ -5,7 +5,7 @@ name = NoSound shortname = NULL version = 2 fallback = true -!! description STR_BASESOUNDS_NONE_DESCRIPTION +@description_STR_BASESOUNDS_NONE_DESCRIPTION@ [files] samples = diff --git a/bin/baseset/openttd.grf b/media/baseset/openttd.grf similarity index 100% rename from bin/baseset/openttd.grf rename to media/baseset/openttd.grf diff --git a/media/extra_grf/2ccmap.nfo b/media/baseset/openttd/2ccmap.nfo similarity index 100% rename from media/extra_grf/2ccmap.nfo rename to media/baseset/openttd/2ccmap.nfo diff --git a/media/baseset/openttd/CMakeLists.txt b/media/baseset/openttd/CMakeLists.txt new file mode 100644 index 0000000000..42d62dd7cc --- /dev/null +++ b/media/baseset/openttd/CMakeLists.txt @@ -0,0 +1,9 @@ +# In case both NFORenum and GRFCodec are found, generate the GRF. +# Otherwise, just use them from the cache (read: git). +# This is mainly because not many people have both of these tools installed, +# so it is cheaper to cache them in git, and only regenerate when you are +# working on it / have the tools installed. +if (NFORENUM_FOUND AND GRFCODEC_FOUND) + include(CreateGrfCommand REQUIRED) + create_grf_command() +endif (NFORENUM_FOUND AND GRFCODEC_FOUND) diff --git a/media/extra_grf/airport_preview.nfo b/media/baseset/openttd/airport_preview.nfo similarity index 100% rename from media/extra_grf/airport_preview.nfo rename to media/baseset/openttd/airport_preview.nfo diff --git a/media/extra_grf/airport_preview.png b/media/baseset/openttd/airport_preview.png similarity index 100% rename from media/extra_grf/airport_preview.png rename to media/baseset/openttd/airport_preview.png diff --git a/media/extra_grf/airports.nfo b/media/baseset/openttd/airports.nfo similarity index 100% rename from media/extra_grf/airports.nfo rename to media/baseset/openttd/airports.nfo diff --git a/media/extra_grf/airports.png b/media/baseset/openttd/airports.png similarity index 100% rename from media/extra_grf/airports.png rename to media/baseset/openttd/airports.png diff --git a/media/extra_grf/aqueduct.nfo b/media/baseset/openttd/aqueduct.nfo similarity index 100% rename from media/extra_grf/aqueduct.nfo rename to media/baseset/openttd/aqueduct.nfo diff --git a/media/extra_grf/aqueduct.png b/media/baseset/openttd/aqueduct.png similarity index 100% rename from media/extra_grf/aqueduct.png rename to media/baseset/openttd/aqueduct.png diff --git a/media/extra_grf/autorail.nfo b/media/baseset/openttd/autorail.nfo similarity index 100% rename from media/extra_grf/autorail.nfo rename to media/baseset/openttd/autorail.nfo diff --git a/media/extra_grf/autorail.png b/media/baseset/openttd/autorail.png similarity index 100% rename from media/extra_grf/autorail.png rename to media/baseset/openttd/autorail.png diff --git a/media/extra_grf/canal_locks.png b/media/baseset/openttd/canal_locks.png similarity index 100% rename from media/extra_grf/canal_locks.png rename to media/baseset/openttd/canal_locks.png diff --git a/media/extra_grf/canals.nfo b/media/baseset/openttd/canals.nfo similarity index 100% rename from media/extra_grf/canals.nfo rename to media/baseset/openttd/canals.nfo diff --git a/media/extra_grf/canals.png b/media/baseset/openttd/canals.png similarity index 100% rename from media/extra_grf/canals.png rename to media/baseset/openttd/canals.png diff --git a/media/extra_grf/chars.nfo b/media/baseset/openttd/chars.nfo similarity index 100% rename from media/extra_grf/chars.nfo rename to media/baseset/openttd/chars.nfo diff --git a/media/extra_grf/chars.png b/media/baseset/openttd/chars.png similarity index 100% rename from media/extra_grf/chars.png rename to media/baseset/openttd/chars.png diff --git a/media/extra_grf/elrails.nfo b/media/baseset/openttd/elrails.nfo similarity index 100% rename from media/extra_grf/elrails.nfo rename to media/baseset/openttd/elrails.nfo diff --git a/media/extra_grf/elrails.png b/media/baseset/openttd/elrails.png similarity index 100% rename from media/extra_grf/elrails.png rename to media/baseset/openttd/elrails.png diff --git a/media/extra_grf/flags.nfo b/media/baseset/openttd/flags.nfo similarity index 100% rename from media/extra_grf/flags.nfo rename to media/baseset/openttd/flags.nfo diff --git a/media/extra_grf/flags.png b/media/baseset/openttd/flags.png similarity index 100% rename from media/extra_grf/flags.png rename to media/baseset/openttd/flags.png diff --git a/media/extra_grf/foundations.nfo b/media/baseset/openttd/foundations.nfo similarity index 100% rename from media/extra_grf/foundations.nfo rename to media/baseset/openttd/foundations.nfo diff --git a/media/extra_grf/foundations.png b/media/baseset/openttd/foundations.png similarity index 100% rename from media/extra_grf/foundations.png rename to media/baseset/openttd/foundations.png diff --git a/media/extra_grf/mono.nfo b/media/baseset/openttd/mono.nfo similarity index 100% rename from media/extra_grf/mono.nfo rename to media/baseset/openttd/mono.nfo diff --git a/media/extra_grf/mono.png b/media/baseset/openttd/mono.png similarity index 100% rename from media/extra_grf/mono.png rename to media/baseset/openttd/mono.png diff --git a/media/extra_grf/oneway.nfo b/media/baseset/openttd/oneway.nfo similarity index 100% rename from media/extra_grf/oneway.nfo rename to media/baseset/openttd/oneway.nfo diff --git a/media/extra_grf/oneway.png b/media/baseset/openttd/oneway.png similarity index 100% rename from media/extra_grf/oneway.png rename to media/baseset/openttd/oneway.png diff --git a/media/extra_grf/openttd.nfo b/media/baseset/openttd/openttd.nfo similarity index 100% rename from media/extra_grf/openttd.nfo rename to media/baseset/openttd/openttd.nfo diff --git a/media/extra_grf/openttdgui.nfo b/media/baseset/openttd/openttdgui.nfo similarity index 100% rename from media/extra_grf/openttdgui.nfo rename to media/baseset/openttd/openttdgui.nfo diff --git a/media/extra_grf/openttdgui.png b/media/baseset/openttd/openttdgui.png similarity index 100% rename from media/extra_grf/openttdgui.png rename to media/baseset/openttd/openttdgui.png diff --git a/media/extra_grf/openttdgui_build_tram.png b/media/baseset/openttd/openttdgui_build_tram.png similarity index 100% rename from media/extra_grf/openttdgui_build_tram.png rename to media/baseset/openttd/openttdgui_build_tram.png diff --git a/media/extra_grf/openttdgui_convert_road.png b/media/baseset/openttd/openttdgui_convert_road.png similarity index 100% rename from media/extra_grf/openttdgui_convert_road.png rename to media/baseset/openttd/openttdgui_convert_road.png diff --git a/media/extra_grf/openttdgui_convert_tram.png b/media/baseset/openttd/openttdgui_convert_tram.png similarity index 100% rename from media/extra_grf/openttdgui_convert_tram.png rename to media/baseset/openttd/openttdgui_convert_tram.png diff --git a/media/extra_grf/openttdgui_group_livery.png b/media/baseset/openttd/openttdgui_group_livery.png similarity index 100% rename from media/extra_grf/openttdgui_group_livery.png rename to media/baseset/openttd/openttdgui_group_livery.png diff --git a/media/extra_grf/palette.nfo b/media/baseset/openttd/palette.nfo similarity index 100% rename from media/extra_grf/palette.nfo rename to media/baseset/openttd/palette.nfo diff --git a/media/extra_grf/roadstops.nfo b/media/baseset/openttd/roadstops.nfo similarity index 100% rename from media/extra_grf/roadstops.nfo rename to media/baseset/openttd/roadstops.nfo diff --git a/media/extra_grf/roadstops.png b/media/baseset/openttd/roadstops.png similarity index 100% rename from media/extra_grf/roadstops.png rename to media/baseset/openttd/roadstops.png diff --git a/media/extra_grf/signals.nfo b/media/baseset/openttd/signals.nfo similarity index 100% rename from media/extra_grf/signals.nfo rename to media/baseset/openttd/signals.nfo diff --git a/media/extra_grf/signals.png b/media/baseset/openttd/signals.png similarity index 100% rename from media/extra_grf/signals.png rename to media/baseset/openttd/signals.png diff --git a/media/extra_grf/sloped_tracks.nfo b/media/baseset/openttd/sloped_tracks.nfo similarity index 100% rename from media/extra_grf/sloped_tracks.nfo rename to media/baseset/openttd/sloped_tracks.nfo diff --git a/media/extra_grf/sloped_tracks.png b/media/baseset/openttd/sloped_tracks.png similarity index 100% rename from media/extra_grf/sloped_tracks.png rename to media/baseset/openttd/sloped_tracks.png diff --git a/media/extra_grf/tramtracks.nfo b/media/baseset/openttd/tramtracks.nfo similarity index 100% rename from media/extra_grf/tramtracks.nfo rename to media/baseset/openttd/tramtracks.nfo diff --git a/media/extra_grf/tramtracks.png b/media/baseset/openttd/tramtracks.png similarity index 100% rename from media/extra_grf/tramtracks.png rename to media/baseset/openttd/tramtracks.png diff --git a/media/extra_grf/tramtracks_bare_depot.png b/media/baseset/openttd/tramtracks_bare_depot.png similarity index 100% rename from media/extra_grf/tramtracks_bare_depot.png rename to media/baseset/openttd/tramtracks_bare_depot.png diff --git a/media/extra_grf/tunnel_portals.nfo b/media/baseset/openttd/tunnel_portals.nfo similarity index 100% rename from media/extra_grf/tunnel_portals.nfo rename to media/baseset/openttd/tunnel_portals.nfo diff --git a/media/extra_grf/tunnel_portals.png b/media/baseset/openttd/tunnel_portals.png similarity index 100% rename from media/extra_grf/tunnel_portals.png rename to media/baseset/openttd/tunnel_portals.png diff --git a/bin/baseset/opntitle.dat b/media/baseset/opntitle.dat similarity index 100% rename from bin/baseset/opntitle.dat rename to media/baseset/opntitle.dat diff --git a/media/baseset/orig_dos.obg b/media/baseset/orig_dos.obg index d56a63712f..ebb27ee7b5 100644 --- a/media/baseset/orig_dos.obg +++ b/media/baseset/orig_dos.obg @@ -6,7 +6,7 @@ name = original_dos shortname = TTDD version = 1 palette = DOS -!! description STR_BASEGRAPHICS_DOS_DESCRIPTION +@description_STR_BASEGRAPHICS_DOS_DESCRIPTION@ [files] base = TRG1.GRF @@ -22,7 +22,7 @@ TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8 TRGC.GRF = ed446637e034104c5559b32c18afe78d TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9 TRGT.GRF = e30e8a398ae86c03dc534a8ac7dfb3b6 -ORIG_EXTRA.GRF = +ORIG_EXTRA.GRF = ${ORIG_EXTRA_GRF_MD5} [origin] default = You can find it on your Transport Tycoon Deluxe CD-ROM. diff --git a/media/baseset/orig_dos.obm b/media/baseset/orig_dos.obm index 0b51c2db84..49c0f67703 100644 --- a/media/baseset/orig_dos.obm +++ b/media/baseset/orig_dos.obm @@ -5,7 +5,7 @@ name = original_dos shortname = TTDD version = 1 -!! description STR_BASEMUSIC_DOS_DESCRIPTION +@description_STR_BASEMUSIC_DOS_DESCRIPTION@ [files] theme = gm.cat diff --git a/media/baseset/orig_dos.obs b/media/baseset/orig_dos.obs index 60afc854f0..c500fe0e4d 100644 --- a/media/baseset/orig_dos.obs +++ b/media/baseset/orig_dos.obs @@ -5,7 +5,7 @@ name = original_dos shortname = TTDO version = 0 -!! description STR_BASESOUNDS_DOS_DESCRIPTION +@description_STR_BASESOUNDS_DOS_DESCRIPTION@ [files] samples = SAMPLE.CAT diff --git a/media/baseset/orig_dos_de.obg b/media/baseset/orig_dos_de.obg index 388d685025..b8251ab7b2 100644 --- a/media/baseset/orig_dos_de.obg +++ b/media/baseset/orig_dos_de.obg @@ -6,7 +6,7 @@ name = original_dos_de shortname = TTDD version = 0 palette = DOS -!! description STR_BASEGRAPHICS_DOS_DE_DESCRIPTION +@description_STR_BASEGRAPHICS_DOS_DE_DESCRIPTION@ [files] base = TRG1.GRF @@ -22,7 +22,7 @@ TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8 TRGC.GRF = ed446637e034104c5559b32c18afe78d TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9 TRGT.GRF = fcde1d7e8a74197d72a62695884b909e -ORIG_EXTRA.GRF = +ORIG_EXTRA.GRF = ${ORIG_EXTRA_GRF_MD5} [origin] default = You can find it on your Transport Tycoon Deluxe CD-ROM. diff --git a/bin/baseset/orig_extra.grf b/media/baseset/orig_extra.grf similarity index 100% rename from bin/baseset/orig_extra.grf rename to media/baseset/orig_extra.grf diff --git a/media/baseset/orig_extra/CMakeLists.txt b/media/baseset/orig_extra/CMakeLists.txt new file mode 100644 index 0000000000..f865a8dd0d --- /dev/null +++ b/media/baseset/orig_extra/CMakeLists.txt @@ -0,0 +1,14 @@ +# In case both NFORenum and GRFCodec are found, generate the GRF. +# Otherwise, just use them from the cache (read: git). +# This is mainly because not many people have both of these tools installed, +# so it is cheaper to cache them in git, and only regenerate when you are +# working on it / have the tools installed. +if (NFORENUM_FOUND AND GRFCODEC_FOUND) + include(CreateGrfCommand REQUIRED) + create_grf_command( + # We share some files with 'openttd' grf + ${CMAKE_CURRENT_SOURCE_DIR}/../openttd/airports.png + ${CMAKE_CURRENT_SOURCE_DIR}/../openttd/canals.png + ${CMAKE_CURRENT_SOURCE_DIR}/../openttd/chars.png + ) +endif (NFORENUM_FOUND AND GRFCODEC_FOUND) diff --git a/media/extra_grf/airports_orig_extra.nfo b/media/baseset/orig_extra/airports_orig_extra.nfo similarity index 100% rename from media/extra_grf/airports_orig_extra.nfo rename to media/baseset/orig_extra/airports_orig_extra.nfo diff --git a/media/extra_grf/canals_extra.nfo b/media/baseset/orig_extra/canals_extra.nfo similarity index 100% rename from media/extra_grf/canals_extra.nfo rename to media/baseset/orig_extra/canals_extra.nfo diff --git a/media/extra_grf/chars_orig_extra.nfo b/media/baseset/orig_extra/chars_orig_extra.nfo similarity index 100% rename from media/extra_grf/chars_orig_extra.nfo rename to media/baseset/orig_extra/chars_orig_extra.nfo diff --git a/media/extra_grf/fix_graphics.nfo b/media/baseset/orig_extra/fix_graphics.nfo similarity index 100% rename from media/extra_grf/fix_graphics.nfo rename to media/baseset/orig_extra/fix_graphics.nfo diff --git a/media/extra_grf/fix_graphics.png b/media/baseset/orig_extra/fix_graphics.png similarity index 100% rename from media/extra_grf/fix_graphics.png rename to media/baseset/orig_extra/fix_graphics.png diff --git a/media/extra_grf/orig_extra.nfo b/media/baseset/orig_extra/orig_extra.nfo similarity index 100% rename from media/extra_grf/orig_extra.nfo rename to media/baseset/orig_extra/orig_extra.nfo diff --git a/media/extra_grf/rivers/arctic.nfo b/media/baseset/orig_extra/rivers/arctic.nfo similarity index 100% rename from media/extra_grf/rivers/arctic.nfo rename to media/baseset/orig_extra/rivers/arctic.nfo diff --git a/media/extra_grf/rivers/arctic_brown.png b/media/baseset/orig_extra/rivers/arctic_brown.png similarity index 100% rename from media/extra_grf/rivers/arctic_brown.png rename to media/baseset/orig_extra/rivers/arctic_brown.png diff --git a/media/extra_grf/rivers/arctic_snowy.png b/media/baseset/orig_extra/rivers/arctic_snowy.png similarity index 100% rename from media/extra_grf/rivers/arctic_snowy.png rename to media/baseset/orig_extra/rivers/arctic_snowy.png diff --git a/media/extra_grf/rivers/rapids.nfo b/media/baseset/orig_extra/rivers/rapids.nfo similarity index 100% rename from media/extra_grf/rivers/rapids.nfo rename to media/baseset/orig_extra/rivers/rapids.nfo diff --git a/media/extra_grf/rivers/rapids.png b/media/baseset/orig_extra/rivers/rapids.png similarity index 100% rename from media/extra_grf/rivers/rapids.png rename to media/baseset/orig_extra/rivers/rapids.png diff --git a/media/extra_grf/rivers/temperate.nfo b/media/baseset/orig_extra/rivers/temperate.nfo similarity index 100% rename from media/extra_grf/rivers/temperate.nfo rename to media/baseset/orig_extra/rivers/temperate.nfo diff --git a/media/extra_grf/rivers/temperate.png b/media/baseset/orig_extra/rivers/temperate.png similarity index 100% rename from media/extra_grf/rivers/temperate.png rename to media/baseset/orig_extra/rivers/temperate.png diff --git a/media/extra_grf/rivers/toyland.nfo b/media/baseset/orig_extra/rivers/toyland.nfo similarity index 100% rename from media/extra_grf/rivers/toyland.nfo rename to media/baseset/orig_extra/rivers/toyland.nfo diff --git a/media/extra_grf/rivers/toyland.png b/media/baseset/orig_extra/rivers/toyland.png similarity index 100% rename from media/extra_grf/rivers/toyland.png rename to media/baseset/orig_extra/rivers/toyland.png diff --git a/media/extra_grf/rivers/tropic.nfo b/media/baseset/orig_extra/rivers/tropic.nfo similarity index 100% rename from media/extra_grf/rivers/tropic.nfo rename to media/baseset/orig_extra/rivers/tropic.nfo diff --git a/media/extra_grf/rivers/tropic_desert.png b/media/baseset/orig_extra/rivers/tropic_desert.png similarity index 100% rename from media/extra_grf/rivers/tropic_desert.png rename to media/baseset/orig_extra/rivers/tropic_desert.png diff --git a/media/extra_grf/rivers/tropic_forest.png b/media/baseset/orig_extra/rivers/tropic_forest.png similarity index 100% rename from media/extra_grf/rivers/tropic_forest.png rename to media/baseset/orig_extra/rivers/tropic_forest.png diff --git a/media/extra_grf/shore.nfo b/media/baseset/orig_extra/shore.nfo similarity index 100% rename from media/extra_grf/shore.nfo rename to media/baseset/orig_extra/shore.nfo diff --git a/media/extra_grf/shore.png b/media/baseset/orig_extra/shore.png similarity index 100% rename from media/extra_grf/shore.png rename to media/baseset/orig_extra/shore.png diff --git a/media/baseset/orig_tto.obm b/media/baseset/orig_tto.obm index c572bcf34b..ced9cf5807 100644 --- a/media/baseset/orig_tto.obm +++ b/media/baseset/orig_tto.obm @@ -5,7 +5,7 @@ name = original_tto shortname = TTOD version = 1 -!! description STR_BASEMUSIC_TTO_DESCRIPTION +@description_STR_BASEMUSIC_TTO_DESCRIPTION@ [files] theme = gm-tto.cat diff --git a/media/baseset/orig_win.obg b/media/baseset/orig_win.obg index f01624a25d..b1cc8437e2 100644 --- a/media/baseset/orig_win.obg +++ b/media/baseset/orig_win.obg @@ -6,7 +6,7 @@ name = original_windows shortname = TTDW version = 0 palette = Windows -!! description STR_BASEGRAPHICS_WIN_DESCRIPTION +@description_STR_BASEGRAPHICS_WIN_DESCRIPTION@ [files] base = TRG1R.GRF @@ -22,7 +22,7 @@ TRGIR.GRF = 0c2484ff6be49fc63a83be6ab5c38f32 TRGCR.GRF = 3668f410c761a050b5e7095a2b14879b TRGHR.GRF = 06bf2b7a31766f048baac2ebe43457b1 TRGTR.GRF = de53650517fe661ceaa3138c6edb0eb8 -ORIG_EXTRA.GRF = +ORIG_EXTRA.GRF = ${ORIG_EXTRA_GRF_MD5} [origin] default = You can find it on your Transport Tycoon Deluxe CD-ROM. diff --git a/media/baseset/orig_win.obm b/media/baseset/orig_win.obm index 11e363fabd..de269d65c8 100644 --- a/media/baseset/orig_win.obm +++ b/media/baseset/orig_win.obm @@ -5,7 +5,7 @@ name = original_windows shortname = TTDW version = 1 -!! description STR_BASEMUSIC_WIN_DESCRIPTION +@description_STR_BASEMUSIC_WIN_DESCRIPTION@ [files] theme = GM_TT00.GM diff --git a/media/baseset/orig_win.obs b/media/baseset/orig_win.obs index 7b02372207..66dd619a8a 100644 --- a/media/baseset/orig_win.obs +++ b/media/baseset/orig_win.obs @@ -5,7 +5,7 @@ name = original_windows shortname = TTDO version = 0 -!! description STR_BASESOUNDS_WIN_DESCRIPTION +@description_STR_BASESOUNDS_WIN_DESCRIPTION@ [files] samples = SAMPLE.CAT diff --git a/media/baseset/translations.awk b/media/baseset/translations.awk deleted file mode 100644 index af5f2b4a8d..0000000000 --- a/media/baseset/translations.awk +++ /dev/null @@ -1,67 +0,0 @@ -# This file is part of OpenTTD. -# OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. -# OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . - -# -# Awk script to extract translations for baseset descriptions -# from lang files for insertion into .obg/obs/obm files. -# If there is no translation, there is no output. -# -# The input file is scanned for the pattern -# !! -# -# The lang files (passed as variable 'langfiles') are scanned for and -# the translations are added to the output file: -# . = -# - -# Simple insertion sort since not all AWKs have a sort implementation -function isort(A) { - n = 0 - for (val in A) { - n++; - } - - for (i = 2; i <= n; i++) { - j = i; - hold = A[j] - while (A[j - 1] > hold) { - j--; - A[j + 1] = A[j] - } - A[j] = hold - } - - return n -} - -/^!!/ { - ini_key = $2; - str_id = $3; - - file = langfiles - while ((getline < file) > 0) { - if (match($0, "##isocode") > 0) { - lang = $2; - } else if (match($0, "^" str_id " *:") > 0) { - sub("^[^:]*:", "", $0) - i++; - if (lang == "en_GB") { - texts[i] = ini_key " = "$0; - } else { - texts[i] = ini_key "." lang " = "$0; - } - } - } - close(file); - - count = isort(texts); - for (i = 1; i <= count; i++) { - print texts[i] - } - - next -} - -{ print } diff --git a/media/baseset/translations.vbs b/media/baseset/translations.vbs deleted file mode 100644 index c167886930..0000000000 --- a/media/baseset/translations.vbs +++ /dev/null @@ -1,145 +0,0 @@ -Option Explicit - -' This file is part of OpenTTD. -' OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. -' OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -' See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . - -Dim FSO -Set FSO = CreateObject("Scripting.FileSystemObject") - -Dim inputfile, outputfile, langpath, extra_grf -inputfile = WScript.Arguments(0) -outputfile = WScript.Arguments(1) -langpath = WScript.Arguments(2) - -If WScript.Arguments.Length > 3 Then - extra_grf = WScript.Arguments(3) -End If - -Function GetExtraGrfHash - Dim WSO, exe, line - - Set WSO = WScript.CreateObject("WScript.Shell") - Set exe = WSO.Exec("certutil -hashfile " & extra_grf & " MD5") - - Do Until exe.StdOut.AtEndOfStream - line = exe.StdOut.ReadLine - If Len(line) = 32 Then GetExtraGrfHash = line - Loop - - Set WSO = Nothing -End Function - -' Simple insertion sort, copied from translations.awk -Sub ISort(a) - Dim i, j, n, hold - n = UBound(a) - - For i = 1 To n - j = i - hold = a(j) - Do While a(j - 1) > hold - j = j - 1 - a(j + 1) = a(j) - - If j = 0 Then Exit Do - Loop - a(j) = hold - Next -End Sub - -Sub Lookup(ini_key, str_id, outfile) - Dim folder, file, line, p, lang, i - - ' Ensure only complete string matches - str_id = str_id & " " - - Set folder = FSO.GetFolder(langpath) - - Dim output() - ReDim output(folder.Files.Count) - - For Each file In folder.Files - If UCase(FSO.GetExtensionName(file.Name)) = "TXT" Then - Dim f - Set f = CreateObject("ADODB.Stream") - f.Charset = "utf-8" - f.LineSeparator = 10 ' Assume lines end with \n even for \r\n files - f.Open - f.LoadFromFile(file.Path) - - Do Until f.EOS - line = Replace(f.ReadText(-2), Chr(13), "") ' Read a line and remove any \r - - If InStr(1, line, "##isocode ") = 1 Then - p = Split(line) - lang = p(1) - ElseIf InStr(1, line, str_id) = 1 Then - p = Split(line, ":", 2) - If lang = "en_GB" Then - output(i) = ini_key & " = " & p(1) - Else - output(i) = ini_key & "." & lang & " = " & p(1) - End If - i = i + 1 - End If - Loop - - f.Close - End If - Next - - ReDim Preserve output(i - 1) - ISort output - - For Each line In output - outfile.WriteText line, 1 - Next - -End Sub - -Dim line, p - -Dim infile -Set infile = FSO.OpenTextFile(inputfile) - -Dim outfile -Set outfile = CreateObject("ADODB.Stream") -outfile.Charset = "utf-8" -outfile.Open - -Do Until infile.atEndOfStream - - line = infile.ReadLine() - - If InStr(1, line, "ORIG_EXTRA.GRF ") = 1 Then - p = Split(line, "=") - If Trim(p(1)) = "" Then - outfile.WriteText "ORIG_EXTRA.GRF = " & GetExtraGrfHash(), 1 - Else - outfile.WriteText line, 1 - End If - ElseIf InStr(1, line, "!! ") = 1 Then - p = Split(line) - Lookup p(1), p(2), outfile - Else - outfile.WriteText line, 1 - End If - -Loop - -' UTF-8 Text ADO Stream includes BOM, so we need to remove it -Dim outfile_noBOM -Set outfile_noBOM = CreateObject("ADODB.Stream") -outfile_noBOM.Type = 1 -outfile_noBOM.Open - -' Copy Text stream to Binary stream, skiping the BOM -outfile.Position = 3 -outfile.CopyTo outfile_noBOM -outfile.Close - -' Write the Binary stream -outfile_noBOM.SaveToFile outputfile, 2 -outfile_noBOM.Close diff --git a/media/extra_grf/assemble_nfo.awk b/media/extra_grf/assemble_nfo.awk deleted file mode 100644 index f39e6b6b43..0000000000 --- a/media/extra_grf/assemble_nfo.awk +++ /dev/null @@ -1,30 +0,0 @@ -# This file is part of OpenTTD. -# OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. -# OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . - -BEGIN { - # Very basic variant function; barely any error checking. - # Just use the first argument as the file to start from when assembling everything - path = ARGV[1]; - gsub("[^/\\\\]*$", "", path); - assemble(ARGV[1]); -} - -# Recursive function for assembling by means of resolving the #includes. -function assemble(filename) { - while ((getline < filename) > 0) { - if (NF == 2 && $1 == "#include" ) { - # Remove the quotes. - gsub("[\"'<>]", "", $2); - assemble(path $2); - } else { - print $0; - } - } - - if (close(filename) < 0) { - print "Could not open " filename > "/dev/stderr"; - exit -1; - } -}