mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-09 11:33:25 -08:00
* [Card] Import Scryfall Tagger tags from MTGJson * [Card] Search cards by Scryfall Tagger tag * [Card] Add a Tag attribute to the card filter tree * [Card] Add a Tags filter to the visual card database * [Oracle] Add a script to inject Scryfall tags into AllPrintings * [Card] Elide long tag lists in the card info and drop the Scryfall label from the tag filter tooltip * [Oracle] Load card tags from a tag database during import Add a TagDatabase loader that understands Scryfall's Oracle Tags bulk data and user-supplied tag files (tag objects, flat oracle-id or name maps, optional manifest, JSON or JSONL, gzip/xz/zip). The importer joins the slugs on identifiers.scryfallOracleId while the identifiers are still available, falls back to the card name, and unions them with any tags the source already provides. Split-card faces merge through the existing tag union path. This replaces oracle/scripts/inject_scryfall_tags.py, which patched AllPrintings.json before import. Loading during import keeps tags on by default for every source and lets users pair Oracle with any tag database. * [Oracle] Add a tag data step to the import wizard Insert a Tags page between set selection and the import. It downloads Scryfall's Oracle Tags by default (or a user-supplied file/URL), can include parent tags, and persists tagsenabled, tagssource and tagsparents in oracle.ini. The page loads asynchronously and soft-fails in background mode, so a tag download or parse error never aborts the card database import. * [Help] Describe tag search without naming Scryfall Tags can come from Scryfall's Oracle Tags or any user-supplied tag database, so the search help should not claim a single source. * [Oracle] Fix Scryfall tag requests and the retry loop api.scryfall.com rejects requests that lack an Accept header with HTTP 400, and QNetworkAccessManager does not add one. Send application/json for the bulk metadata request and */* for the tag file, and surface the URL plus Scryfall's JSON error body when a request fails. A failed tag load used to call next(), which re-ran validatePage() and started the same failing download again, trapping the user in an error loop. Stay on the page instead, drop the unusable database, and tell the user they can retry, change the source, or untick the option to import without tags. Also explain parent tags inline with a real Scryfall hierarchy example. * [Oracle] Give the parent-tag explainer room to breathe The wrapped explainer sat flush under the checkbox with no separation from the status label, which made the paragraph look cramped. Indent it under the checkbox and add a little vertical margin. * [Oracle] Stop the parent-tag explainer from being clipped A word-wrapped QLabel reports a one-line sizeHint, so the wizard page reserved too little height and the explanation lost its top and bottom lines. Pin the vertical size policy to Minimum on the explainer and on the status label, so the wrapped height becomes part of the page minimum. Verified with a layout probe: the label went from 28 px tall (needed 56) to its full height. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
329 lines
10 KiB
CMake
329 lines
10 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
project(Oracle VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
|
|
|
# ------------------------
|
|
# Paths and directories
|
|
# ------------------------
|
|
set(DESKTOPDIR
|
|
share/applications
|
|
CACHE STRING "path to .desktop files"
|
|
)
|
|
|
|
set(ORACLE_MAC_QM_INSTALL_DIR "oracle.app/Contents/Resources/translations")
|
|
set(ORACLE_UNIX_QM_INSTALL_DIR "share/oracle/translations")
|
|
set(ORACLE_WIN32_QM_INSTALL_DIR "translations")
|
|
|
|
# ------------------------
|
|
# Sources
|
|
# ------------------------
|
|
set(oracle_SOURCES
|
|
src/database_writer.cpp
|
|
src/main.cpp
|
|
src/oraclewizard.cpp
|
|
src/oracleimporter.cpp
|
|
src/pages.cpp
|
|
src/pagetemplates.cpp
|
|
src/parsehelpers.cpp
|
|
src/raw_json_scanner.cpp
|
|
src/tag_database.cpp
|
|
../cockatrice/src/client/settings/cache_settings.cpp
|
|
../cockatrice/src/client/settings/card_counter_settings.cpp
|
|
../cockatrice/src/client/settings/shortcuts_settings.cpp
|
|
../cockatrice/src/client/network/update/client/release_channel.cpp
|
|
../cockatrice/src/interface/pixel_map_generator.cpp
|
|
../cockatrice/src/interface/theme_config.cpp
|
|
../cockatrice/src/interface/theme_icon.cpp
|
|
../cockatrice/src/interface/theme_icon_badge.cpp
|
|
../cockatrice/src/interface/theme_icon_fill.cpp
|
|
../cockatrice/src/interface/theme_icon_ink.cpp
|
|
../cockatrice/src/interface/theme_icon_sticker.cpp
|
|
../cockatrice/src/interface/theme_manager.cpp
|
|
${VERSION_STRING_CPP}
|
|
)
|
|
|
|
# ------------------------
|
|
# Translations
|
|
# ------------------------
|
|
|
|
if(UPDATE_TRANSLATIONS)
|
|
file(GLOB_RECURSE translate_oracle_SRCS src/*.cpp src/*.h ../cockatrice/src/settingscache.cpp)
|
|
set(translate_SRCS ${translate_oracle_SRCS})
|
|
set(oracle_TS "${CMAKE_CURRENT_SOURCE_DIR}/oracle_en@source.ts")
|
|
else()
|
|
file(GLOB oracle_TS "${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts")
|
|
endif(UPDATE_TRANSLATIONS)
|
|
|
|
if(WIN32)
|
|
set(oracle_SOURCES ${oracle_SOURCES} oracle.rc)
|
|
endif(WIN32)
|
|
|
|
if(APPLE)
|
|
set(MACOSX_BUNDLE_ICON_FILE appicon.icns)
|
|
set_source_files_properties(
|
|
${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources
|
|
)
|
|
set(oracle_SOURCES ${oracle_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/resources/appicon.icns)
|
|
endif(APPLE)
|
|
|
|
set(oracle_RESOURCES oracle.qrc)
|
|
|
|
# ------------------------
|
|
# Qt resources
|
|
# ------------------------
|
|
qt_add_resources(oracle_RESOURCES_RCC ${oracle_RESOURCES})
|
|
|
|
# ------------------------
|
|
# Include directories
|
|
# ------------------------
|
|
include_directories(../cockatrice/src)
|
|
|
|
# ------------------------
|
|
# Optional libraries
|
|
# ------------------------
|
|
# ZLIB
|
|
find_package(ZLIB)
|
|
if(ZLIB_FOUND)
|
|
include_directories(${ZLIB_INCLUDE_DIRS})
|
|
add_definitions("-DHAS_ZLIB")
|
|
list(APPEND oracle_SOURCES src/zip/unzip.cpp src/zip/zipglobal.cpp)
|
|
# minizip and zlib are vendored.
|
|
cockatrice_disable_sanitizers_for(src/zip/unzip.cpp src/zip/zipglobal.cpp)
|
|
cockatrice_disable_coverage_for(src/zip/unzip.cpp src/zip/zipglobal.cpp)
|
|
else()
|
|
message(STATUS "Oracle: zlib not found; ZIP support disabled")
|
|
endif()
|
|
|
|
# LZMA
|
|
find_package(LibLZMA)
|
|
if(LIBLZMA_FOUND)
|
|
include_directories(${LIBLZMA_INCLUDE_DIRS})
|
|
add_definitions("-DHAS_LZMA")
|
|
list(APPEND oracle_SOURCES src/lzma/decompress.cpp)
|
|
# The LZMA SDK is vendored.
|
|
cockatrice_disable_sanitizers_for(src/lzma/decompress.cpp)
|
|
cockatrice_disable_coverage_for(src/lzma/decompress.cpp)
|
|
else()
|
|
message(STATUS "Oracle: LibLZMA not found; xz support disabled")
|
|
endif()
|
|
|
|
# ------------------------
|
|
# Build executable
|
|
# ------------------------
|
|
|
|
set(ORACLE_MAC_QM_INSTALL_DIR "oracle.app/Contents/Resources/translations")
|
|
set(ORACLE_UNIX_QM_INSTALL_DIR "share/oracle/translations")
|
|
set(ORACLE_WIN32_QM_INSTALL_DIR "translations")
|
|
|
|
# Qt6 Translations are linked after the executable is created in manual mode
|
|
qt_add_executable(
|
|
oracle
|
|
WIN32
|
|
MACOSX_BUNDLE
|
|
${oracle_SOURCES}
|
|
${oracle_RESOURCES_RCC}
|
|
${oracle_MOC_SRCS}
|
|
MANUAL_FINALIZATION
|
|
)
|
|
|
|
target_precompile_headers(oracle PRIVATE "${CMAKE_SOURCE_DIR}/cmake/pch/qtwidgets_pch.h")
|
|
|
|
# ------------------------
|
|
# Link libraries
|
|
# ------------------------
|
|
target_link_libraries(
|
|
oracle
|
|
PUBLIC libcockatrice_card
|
|
PUBLIC libcockatrice_settings
|
|
PUBLIC libcockatrice_protocol
|
|
PUBLIC ${ORACLE_QT_MODULES}
|
|
)
|
|
|
|
# Only user_level.h is needed from the network headers (pulled in transitively
|
|
# by pixel_map_generator.h); nothing from the network libraries is linked.
|
|
target_include_directories(oracle PRIVATE ${CMAKE_SOURCE_DIR}/libcockatrice_network)
|
|
|
|
if(ZLIB_FOUND)
|
|
target_link_libraries(oracle PUBLIC ${ZLIB_LIBRARIES})
|
|
endif()
|
|
|
|
if(LIBLZMA_FOUND)
|
|
target_link_libraries(oracle PUBLIC ${LIBLZMA_LIBRARIES})
|
|
endif()
|
|
|
|
# ------------------------
|
|
# Install rules
|
|
# ------------------------
|
|
if(UNIX)
|
|
if(APPLE)
|
|
set(MACOSX_BUNDLE_INFO_STRING "${PROJECT_NAME}")
|
|
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.cockatrice.${PROJECT_NAME}")
|
|
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_NAME}-${PROJECT_VERSION}")
|
|
set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
|
|
set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION})
|
|
set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION})
|
|
set_target_properties(oracle PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/Info.plist)
|
|
|
|
install(TARGETS oracle BUNDLE DESTINATION ./)
|
|
else()
|
|
# Assume linux
|
|
install(TARGETS oracle RUNTIME DESTINATION bin/)
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/oracle.png DESTINATION ${ICONDIR}/hicolor/48x48/apps)
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/oracle.svg DESTINATION ${ICONDIR}/hicolor/scalable/apps)
|
|
endif()
|
|
elseif(WIN32)
|
|
install(TARGETS oracle RUNTIME DESTINATION ./)
|
|
endif()
|
|
|
|
if(NOT WIN32 AND NOT APPLE)
|
|
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/oracle.desktop DESTINATION ${DESKTOPDIR})
|
|
endif(NOT WIN32 AND NOT APPLE)
|
|
|
|
# ------------------------
|
|
# Qt plugin handling
|
|
# ------------------------
|
|
if(APPLE)
|
|
# these needs to be relative to CMAKE_INSTALL_PREFIX
|
|
set(plugin_dest_dir oracle.app/Contents/Plugins)
|
|
set(qtconf_dest_dir oracle.app/Contents/Resources)
|
|
|
|
# Qt plugins: iconengines, platforms, styles, tls (Qt6)
|
|
install(
|
|
DIRECTORY "${QT_PLUGINS_DIR}/"
|
|
DESTINATION ${plugin_dest_dir}
|
|
COMPONENT Runtime
|
|
FILES_MATCHING
|
|
PATTERN "*.dSYM" EXCLUDE
|
|
PATTERN "*_debug.dylib" EXCLUDE
|
|
PATTERN "iconengines/*.dylib"
|
|
PATTERN "platforms/*.dylib"
|
|
PATTERN "styles/*.dylib"
|
|
PATTERN "tls/*.dylib"
|
|
)
|
|
|
|
install(
|
|
CODE "
|
|
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
|
|
Plugins = Plugins
|
|
Translations = Resources/translations\")
|
|
"
|
|
COMPONENT Runtime
|
|
)
|
|
|
|
install(
|
|
CODE "
|
|
file(GLOB_RECURSE QTPLUGINS
|
|
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dylib\")
|
|
set(BU_CHMOD_BUNDLE_ITEMS ON)
|
|
include(BundleUtilities)
|
|
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/oracle.app\" \"\${QTPLUGINS}\" \"${QT_LIBRARY_DIR}\")
|
|
"
|
|
COMPONENT Runtime
|
|
)
|
|
endif()
|
|
|
|
if(WIN32)
|
|
# these needs to be relative to CMAKE_INSTALL_PREFIX
|
|
set(plugin_dest_dir Plugins)
|
|
set(qtconf_dest_dir .)
|
|
list(APPEND libSearchDirs ${QT_LIBRARY_DIR})
|
|
|
|
install(
|
|
DIRECTORY "$<TARGET_FILE_DIR:oracle>/"
|
|
DESTINATION ./
|
|
FILES_MATCHING
|
|
PATTERN "*.dll"
|
|
PATTERN "*.pdb" EXCLUDE
|
|
PATTERN "*.dir*" EXCLUDE
|
|
PATTERN "*_autogen*" EXCLUDE
|
|
PATTERN "*.tlog*" EXCLUDE
|
|
PATTERN "CMakeFiles*" EXCLUDE
|
|
PATTERN "x64*" EXCLUDE
|
|
PATTERN ".qt*" EXCLUDE
|
|
PATTERN ".qsb*" EXCLUDE
|
|
PATTERN ".lupdate*" EXCLUDE
|
|
)
|
|
|
|
# Qt plugins: iconengines, platforms, styles, tls (Qt6)
|
|
install(
|
|
DIRECTORY "${QT_PLUGINS_DIR}/"
|
|
DESTINATION ${plugin_dest_dir}
|
|
COMPONENT Runtime
|
|
FILES_MATCHING
|
|
PATTERN "iconengines/qsvgicon.dll"
|
|
PATTERN "platforms/qdirect2d.dll"
|
|
PATTERN "platforms/qminimal.dll"
|
|
PATTERN "platforms/qoffscreen.dll"
|
|
PATTERN "platforms/qwindows.dll"
|
|
PATTERN "styles/qcertonlybackend.dll"
|
|
PATTERN "styles/qopensslbackend.dll"
|
|
PATTERN "styles/qschannelbackend.dll"
|
|
PATTERN "styles/qwindowsvistastyle.dll"
|
|
PATTERN "tls/qcertonlybackend.dll"
|
|
PATTERN "tls/qopensslbackend.dll"
|
|
PATTERN "tls/qschannelbackend.dll"
|
|
)
|
|
|
|
install(
|
|
CODE "
|
|
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"[Paths]
|
|
Plugins = Plugins
|
|
Translations = Resources/translations\")
|
|
"
|
|
COMPONENT Runtime
|
|
)
|
|
|
|
install(
|
|
CODE "
|
|
file(GLOB_RECURSE QTPLUGINS
|
|
\"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/*.dll\")
|
|
set(BU_CHMOD_BUNDLE_ITEMS ON)
|
|
include(BundleUtilities)
|
|
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/Oracle.exe\" \"\${QTPLUGINS}\" \"${libSearchDirs}\")
|
|
"
|
|
COMPONENT Runtime
|
|
)
|
|
endif()
|
|
|
|
# ------------------------
|
|
# Qt translations
|
|
# ------------------------
|
|
if(Qt6LinguistTools_FOUND)
|
|
#Qt6 Translations happen after the executable is built up
|
|
if(UPDATE_TRANSLATIONS)
|
|
qt_add_translations(
|
|
oracle
|
|
TS_FILES
|
|
${oracle_TS}
|
|
SOURCES
|
|
${translate_SRCS}
|
|
QM_FILES_OUTPUT_VARIABLE
|
|
oracle_QM
|
|
)
|
|
else()
|
|
qt_add_translations(oracle TS_FILES ${oracle_TS} QM_FILES_OUTPUT_VARIABLE oracle_QM)
|
|
endif()
|
|
|
|
if(UNIX)
|
|
if(APPLE)
|
|
install(FILES ${oracle_QM} DESTINATION ${ORACLE_MAC_QM_INSTALL_DIR})
|
|
else()
|
|
install(FILES ${oracle_QM} DESTINATION ${ORACLE_UNIX_QM_INSTALL_DIR})
|
|
endif()
|
|
elseif(WIN32)
|
|
install(FILES ${oracle_QM} DESTINATION ${ORACLE_WIN32_QM_INSTALL_DIR})
|
|
endif()
|
|
|
|
# Qt attaches the .qm files to the default build target only, so building the executable on its own
|
|
# (CLion, --target oracle) leaves it without any translations: nothing is translated and the
|
|
# language selector in the wizard stays empty.
|
|
# Depend on Qt's own lrelease target instead of attaching the .qm custom commands to a second
|
|
# target: two independent targets owning the same outputs race on MSBuild/Makefiles and are an
|
|
# error on Xcode. Older Qt versions already add this dependency themselves.
|
|
foreach(_lrelease_target Oracle_lrelease oracle_lrelease)
|
|
if(TARGET ${_lrelease_target})
|
|
add_dependencies(oracle ${_lrelease_target})
|
|
endif()
|
|
endforeach()
|
|
endif()
|
|
|
|
qt_finalize_target(oracle)
|