1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-24 03:47:18 +02:00

address code review comments

This commit is contained in:
Simeon Manolov 2024-08-31 18:12:00 +03:00
parent 20ccc92e6d
commit e502853227
No known key found for this signature in database
GPG Key ID: 0AAC6D4A304B5635
2 changed files with 97 additions and 95 deletions

View File

@ -20,6 +20,8 @@ extern SDL_Surface *screen; // main screen surface
extern SDL_Surface *screen2; // and hlp surface (used to store not-active interfaces layer) extern SDL_Surface *screen2; // and hlp surface (used to store not-active interfaces layer)
extern SDL_Surface *screenBuf; // points to screen (if only advmapint is present) or screen2 (else) - should be used when updating controls which are not regularly redrawed extern SDL_Surface *screenBuf; // points to screen (if only advmapint is present) or screen2 (else) - should be used when updating controls which are not regularly redrawed
// defined in clientapp EntryPoint /// Notify user about encountered fatal error and terminate the game
/// Defined in clientapp EntryPoint
/// TODO: decide on better location for this method
[[noreturn]] void handleFatalError(const std::string & message, bool terminate);
void handleQuit(bool ask = true); void handleQuit(bool ask = true);
void handleFatalError(const std::string & message, bool terminate);

View File

@ -1,137 +1,137 @@
set(clientapp_SRCS set(clientapp_SRCS
StdInc.cpp StdInc.cpp
EntryPoint.cpp EntryPoint.cpp
) )
set(clientapp_HEADERS set(clientapp_HEADERS
StdInc.h StdInc.h
) )
if(APPLE_IOS) if(APPLE_IOS)
set(clientapp_SRCS ${clientapp_SRCS} set(clientapp_SRCS ${clientapp_SRCS}
CFocusableHelper.cpp CFocusableHelper.cpp
ios/GameChatKeyboardHandler.m ios/GameChatKeyboardHandler.m
ios/main.m ios/main.m
ios/startSDL.mm ios/startSDL.mm
) )
set(clientapp_HEADERS ${clientapp_HEADERS} set(clientapp_HEADERS ${clientapp_HEADERS}
CFocusableHelper.h CFocusableHelper.h
ios/GameChatKeyboardHandler.h ios/GameChatKeyboardHandler.h
ios/startSDL.h ios/startSDL.h
) )
endif() endif()
assign_source_group(${clientapp_SRCS} ${clientapp_HEADERS}) assign_source_group(${clientapp_SRCS} ${clientapp_HEADERS})
if(ANDROID) if(ANDROID)
add_library(vcmiclient SHARED ${clientapp_SRCS} ${clientapp_HEADERS}) add_library(vcmiclient SHARED ${clientapp_SRCS} ${clientapp_HEADERS})
set_target_properties(vcmiclient PROPERTIES set_target_properties(vcmiclient PROPERTIES
OUTPUT_NAME "vcmiclient_${ANDROID_ABI}" # required by Qt OUTPUT_NAME "vcmiclient_${ANDROID_ABI}" # required by Qt
) )
else() else()
add_executable(vcmiclient ${clientapp_SRCS} ${clientapp_HEADERS}) add_executable(vcmiclient ${clientapp_SRCS} ${clientapp_HEADERS})
endif() endif()
target_link_libraries(vcmiclient PRIVATE vcmiclientcommon) target_link_libraries(vcmiclient PRIVATE vcmiclientcommon)
if(ENABLE_SINGLE_APP_BUILD AND ENABLE_LAUNCHER) if(ENABLE_SINGLE_APP_BUILD AND ENABLE_LAUNCHER)
target_link_libraries(vcmiclient PRIVATE vcmilauncher) target_link_libraries(vcmiclient PRIVATE vcmilauncher)
endif() endif()
target_include_directories(vcmiclient target_include_directories(vcmiclient
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
) )
if(WIN32) if(WIN32)
target_sources(vcmiclient PRIVATE "VCMI_client.rc") target_sources(vcmiclient PRIVATE "VCMI_client.rc")
set_target_properties(vcmiclient set_target_properties(vcmiclient
PROPERTIES PROPERTIES
OUTPUT_NAME "VCMI_client" OUTPUT_NAME "VCMI_client"
PROJECT_LABEL "VCMI_client" PROJECT_LABEL "VCMI_client"
) )
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT vcmiclient) set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT vcmiclient)
if(NOT ENABLE_DEBUG_CONSOLE) if(NOT ENABLE_DEBUG_CONSOLE)
set_target_properties(vcmiclient PROPERTIES WIN32_EXECUTABLE) set_target_properties(vcmiclient PROPERTIES WIN32_EXECUTABLE)
target_link_libraries(vcmiclient SDL2::SDL2main) target_link_libraries(vcmiclient SDL2::SDL2main)
endif() endif()
target_compile_definitions(vcmiclient PRIVATE WINDOWS_IGNORE_PACKING_MISMATCH) target_compile_definitions(vcmiclient PRIVATE WINDOWS_IGNORE_PACKING_MISMATCH)
# TODO: very hacky, find proper solution to copy AI dlls into bin dir # TODO: very hacky, find proper solution to copy AI dlls into bin dir
if(MSVC) if(MSVC)
add_custom_command(TARGET vcmiclient POST_BUILD add_custom_command(TARGET vcmiclient POST_BUILD
WORKING_DIRECTORY "$<TARGET_FILE_DIR:vcmiclient>" WORKING_DIRECTORY "$<TARGET_FILE_DIR:vcmiclient>"
COMMAND ${CMAKE_COMMAND} -E copy AI/fuzzylite.dll fuzzylite.dll COMMAND ${CMAKE_COMMAND} -E copy AI/fuzzylite.dll fuzzylite.dll
COMMAND ${CMAKE_COMMAND} -E copy AI/tbb12.dll tbb12.dll COMMAND ${CMAKE_COMMAND} -E copy AI/tbb12.dll tbb12.dll
) )
endif() endif()
elseif(APPLE_IOS) elseif(APPLE_IOS)
set_target_properties(vcmiclient PROPERTIES set_target_properties(vcmiclient PROPERTIES
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_LIST_DIR}/ios/Info.plist" MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_LIST_DIR}/ios/Info.plist"
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/Frameworks" XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/Frameworks"
XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "$(CODE_SIGNING_ALLOWED_FOR_APPS)" XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "$(CODE_SIGNING_ALLOWED_FOR_APPS)"
XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME AppIcon XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME AppIcon
) )
foreach(XCODE_RESOURCE LaunchScreen.storyboard Images.xcassets Settings.bundle vcmi_logo.png) foreach(XCODE_RESOURCE LaunchScreen.storyboard Images.xcassets Settings.bundle vcmi_logo.png)
set(XCODE_RESOURCE_PATH ios/${XCODE_RESOURCE}) set(XCODE_RESOURCE_PATH ios/${XCODE_RESOURCE})
target_sources(vcmiclient PRIVATE ${XCODE_RESOURCE_PATH}) target_sources(vcmiclient PRIVATE ${XCODE_RESOURCE_PATH})
set_source_files_properties(${XCODE_RESOURCE_PATH} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) set_source_files_properties(${XCODE_RESOURCE_PATH} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
# workaround to prevent CMAKE_SKIP_PRECOMPILE_HEADERS being added as compile flag # workaround to prevent CMAKE_SKIP_PRECOMPILE_HEADERS being added as compile flag
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.22.0" AND CMAKE_VERSION VERSION_LESS "3.25.0") if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.22.0" AND CMAKE_VERSION VERSION_LESS "3.25.0")
set_source_files_properties(${XCODE_RESOURCE_PATH} PROPERTIES LANGUAGE CXX) set_source_files_properties(${XCODE_RESOURCE_PATH} PROPERTIES LANGUAGE CXX)
endif() endif()
endforeach() endforeach()
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-e,_client_main") set(CMAKE_EXE_LINKER_FLAGS "-Wl,-e,_client_main")
endif() endif()
vcmi_set_output_dir(vcmiclient "") vcmi_set_output_dir(vcmiclient "")
enable_pch(vcmiclient) enable_pch(vcmiclient)
if(APPLE_IOS) if(APPLE_IOS)
vcmi_install_conan_deps("\${CMAKE_INSTALL_PREFIX}") vcmi_install_conan_deps("\${CMAKE_INSTALL_PREFIX}")
add_custom_command(TARGET vcmiclient POST_BUILD add_custom_command(TARGET vcmiclient POST_BUILD
COMMAND ios/set_build_version.sh "$<TARGET_BUNDLE_CONTENT_DIR:vcmiclient>" COMMAND ios/set_build_version.sh "$<TARGET_BUNDLE_CONTENT_DIR:vcmiclient>"
COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}" --component "${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}" --config "$<CONFIG>" --prefix "$<TARGET_BUNDLE_CONTENT_DIR:vcmiclient>" COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}" --component "${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME}" --config "$<CONFIG>" --prefix "$<TARGET_BUNDLE_CONTENT_DIR:vcmiclient>"
COMMAND ios/rpath_remove_symlinks.sh COMMAND ios/rpath_remove_symlinks.sh
COMMAND ios/codesign.sh COMMAND ios/codesign.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
) )
install(TARGETS vcmiclient DESTINATION Payload COMPONENT app) # for ipa generation with cpack install(TARGETS vcmiclient DESTINATION Payload COMPONENT app) # for ipa generation with cpack
elseif(ANDROID) elseif(ANDROID)
find_program(androidDeployQt androiddeployqt find_program(androidDeployQt androiddeployqt
PATHS "${qtBinDir}" PATHS "${qtBinDir}"
) )
vcmi_install_conan_deps("\${CMAKE_INSTALL_PREFIX}/${LIB_DIR}") vcmi_install_conan_deps("\${CMAKE_INSTALL_PREFIX}/${LIB_DIR}")
add_custom_target(android_deploy ALL add_custom_target(android_deploy ALL
COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}" --config "$<CONFIG>" --prefix "${androidQtBuildDir}" COMMAND ${CMAKE_COMMAND} --install "${CMAKE_BINARY_DIR}" --config "$<CONFIG>" --prefix "${androidQtBuildDir}"
COMMAND "${androidDeployQt}" --input "${CMAKE_BINARY_DIR}/androiddeployqt.json" --output "${androidQtBuildDir}" --android-platform "android-${ANDROID_TARGET_SDK_VERSION}" --verbose $<$<NOT:$<CONFIG:Debug>>:--release> ${ANDROIDDEPLOYQT_OPTIONS} COMMAND "${androidDeployQt}" --input "${CMAKE_BINARY_DIR}/androiddeployqt.json" --output "${androidQtBuildDir}" --android-platform "android-${ANDROID_TARGET_SDK_VERSION}" --verbose $<$<NOT:$<CONFIG:Debug>>:--release> ${ANDROIDDEPLOYQT_OPTIONS}
COMMAND_EXPAND_LISTS COMMAND_EXPAND_LISTS
VERBATIM VERBATIM
COMMENT "Create android package" COMMENT "Create android package"
) )
add_dependencies(android_deploy vcmiclient) add_dependencies(android_deploy vcmiclient)
else() else()
install(TARGETS vcmiclient DESTINATION ${BIN_DIR}) install(TARGETS vcmiclient DESTINATION ${BIN_DIR})
endif() endif()
#install icons and desktop file on Linux #install icons and desktop file on Linux
if(NOT WIN32 AND NOT APPLE AND NOT ANDROID) if(NOT WIN32 AND NOT APPLE AND NOT ANDROID)
#FIXME: move to client makefile? #FIXME: move to client makefile?
foreach(iconSize 16 22 32 48 64 128 256 512 1024 2048) foreach(iconSize 16 22 32 48 64 128 256 512 1024 2048)
install(FILES "icons/vcmiclient.${iconSize}x${iconSize}.png" install(FILES "icons/vcmiclient.${iconSize}x${iconSize}.png"
DESTINATION "share/icons/hicolor/${iconSize}x${iconSize}/apps" DESTINATION "share/icons/hicolor/${iconSize}x${iconSize}/apps"
RENAME vcmiclient.png RENAME vcmiclient.png
) )
endforeach() endforeach()
install(FILES icons/vcmiclient.svg install(FILES icons/vcmiclient.svg
DESTINATION share/icons/hicolor/scalable/apps DESTINATION share/icons/hicolor/scalable/apps
RENAME vcmiclient.svg RENAME vcmiclient.svg
) )
install(FILES icons/vcmiclient.desktop install(FILES icons/vcmiclient.desktop
DESTINATION share/applications DESTINATION share/applications
) )
endif() endif()