mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 09:47:01 +08:00
* build: replace FetchContent with direct includes for glm * build(deps): replace SOIL2 with stb for image and vorbis decoding * build: replace FetchContent with direct includes for toml++ * refactor(texture): bump block texture size to 512 and disable items tab * feat: add hotbar system with ItemStack and RowLayout * fix(ui): restrict Ctrl key handling to typing mode * feat(ui): add widget border support and highlight selected hotbar slot * fix(ui): update borders on scale change and correct Image width - Added update_border() calls in set_scale() for Button, ChatBox, Image, Label, and TextField. - Fixed Image::width() to multiply by width instead of height. - Added early return in Widget::update_border() if border is not supported. * feat(ui): add border visual feedback on slider drag * feat(ui): add ItemSlot widget and refactor hotbar to use it * feat(world_scene): add inventory UI and pause type enum * feat(ui): add item slot tooltip and make window size static * fix(ui label): account for background offset in width/height * refactor(ui): centralize item info label in inventory and add update * feat(ui): add hotbar interaction in inventory UI * fix(inventory-ui): correct row creation logic for first item The loop starting at index 0 created a new row on the first iteration (i % 10 == 0). Shift the loop to start at 1 and adjust modulus condition to create rows correctly every 10 items. * feat(block): add name_key for localized block names Add `name_key` field to all block TOML definitions, enabling per-block localization. Update `BlockData` struct and `BlockManager` with `local_name()` method that returns a localized string via the translation system. Add corresponding entries to `en_US.json` and `zh_CN.json`. Modify inventory UI to use the localized name when displaying block info, and fix a bug where emptying a hotbar slot did not clear the item locally. * fix(ui): change inventory item slot color from white to gray * fix(ui): add missing include for std::array
164 lines
3.8 KiB
CMake
164 lines
3.8 KiB
CMake
cmake_minimum_required(VERSION 3.21)
|
|
|
|
if(APPLE)
|
|
message(FATAL_ERROR "This game does not support macOS")
|
|
endif()
|
|
|
|
project(Cubed LANGUAGES C CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
if(NOT CMAKE_CONFIGURATION_TYPES
|
|
AND NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
|
|
|
|
endif()
|
|
|
|
if(NOT DEFINED CUBED_VERSION)
|
|
set(CUBED_VERSION "dev")
|
|
endif()
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_NAME})
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_NAME})
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
|
|
list(APPEND CMAKE_MODULE_PATH
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
|
|
)
|
|
|
|
include(Dependencies)
|
|
|
|
add_subdirectory(third_party/glad)
|
|
|
|
add_subdirectory(third_party/imgui)
|
|
|
|
add_subdirectory(third_party/dr_libs)
|
|
|
|
add_subdirectory(third_party/stb)
|
|
|
|
add_executable(${PROJECT_NAME})
|
|
|
|
add_subdirectory(src)
|
|
|
|
file(GLOB_RECURSE PROTO_FILES
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/proto/*.proto
|
|
)
|
|
|
|
protobuf_generate(
|
|
TARGET ${PROJECT_NAME}
|
|
LANGUAGE cpp
|
|
PROTOS ${PROTO_FILES}
|
|
IMPORT_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/proto
|
|
)
|
|
|
|
configure_file(
|
|
src/version.hpp.in
|
|
${CMAKE_BINARY_DIR}/generated/version.hpp
|
|
@ONLY
|
|
)
|
|
|
|
target_compile_options(${PROJECT_NAME}
|
|
PRIVATE
|
|
$<$<CONFIG:Debug>:-fno-omit-frame-pointer>
|
|
$<$<CONFIG:Debug>:-g>
|
|
#$<$<CONFIG:Debug>:-fsanitize=address>
|
|
#$<$<CONFIG:Debug>:-fsanitize=thread>
|
|
|
|
$<$<CXX_COMPILER_ID:GNU,Clang>:-Wall>
|
|
$<$<CXX_COMPILER_ID:GNU,Clang>:-Wextra>
|
|
$<$<CXX_COMPILER_ID:GNU,Clang>:-Wpedantic>
|
|
|
|
$<$<CXX_COMPILER_ID:MSVC>:/utf-8>
|
|
$<$<CXX_COMPILER_ID:MSVC>:/W4>
|
|
)
|
|
|
|
target_link_options(${PROJECT_NAME}
|
|
PRIVATE
|
|
#$<$<CONFIG:Debug>:-fsanitize=address>
|
|
#$<$<CONFIG:Debug>:-fsanitize=thread>
|
|
)
|
|
|
|
target_compile_definitions(${PROJECT_NAME}
|
|
PRIVATE
|
|
ASIO_STANDALONE
|
|
ASIO_NO_DEPRECATED
|
|
$<$<CONFIG:Debug>:DEBUG_MODE>
|
|
$<$<CXX_COMPILER_ID:MSVC>:
|
|
WIN32_LEAN_AND_MEAN
|
|
NOMINMAX
|
|
_CRT_SECURE_NO_WARNINGS
|
|
>
|
|
)
|
|
|
|
if(CMAKE_CONFIGURATION_TYPES)
|
|
# Visual Studio / Xcode multi-configuration generator
|
|
target_compile_definitions(${PROJECT_NAME}
|
|
PRIVATE
|
|
ASSETS_PATH="$<$<CONFIG:Debug>:${PROJECT_SOURCE_DIR}/assets/>$<$<NOT:$<CONFIG:Debug>>:./assets/>"
|
|
)
|
|
else()
|
|
# Ninja / Makefiles single-configuration generator
|
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
target_compile_definitions(${PROJECT_NAME}
|
|
PRIVATE
|
|
ASSETS_PATH="${PROJECT_SOURCE_DIR}/assets/"
|
|
)
|
|
else()
|
|
target_compile_definitions(${PROJECT_NAME}
|
|
PRIVATE
|
|
ASSETS_PATH="./assets/"
|
|
)
|
|
endif()
|
|
endif()
|
|
|
|
|
|
target_include_directories(${PROJECT_NAME}
|
|
PRIVATE
|
|
${PROJECT_SOURCE_DIR}/include
|
|
${PROJECT_SOURCE_DIR}/third_party/asio/include
|
|
${CMAKE_BINARY_DIR}/generated
|
|
${PROJECT_BINARY_DIR}
|
|
${PROJECT_BINARY_DIR}/src
|
|
|
|
)
|
|
|
|
|
|
target_link_libraries(${PROJECT_NAME}
|
|
PRIVATE
|
|
SDL3::SDL3
|
|
glad
|
|
OpenGL::GL
|
|
Freetype::Freetype
|
|
imgui
|
|
dr_libs
|
|
tbb
|
|
stb
|
|
protobuf::libprotobuf
|
|
absl::log
|
|
absl::check
|
|
absl::base
|
|
absl::strings
|
|
absl::flat_hash_map
|
|
zstd::zstd
|
|
OpenAL::OpenAL
|
|
harfbuzz::harfbuzz
|
|
Opus::Opus
|
|
$<$<PLATFORM_ID:Windows>:ws2_32>
|
|
|
|
)
|
|
|
|
if(WIN32)
|
|
add_custom_command(
|
|
TARGET ${PROJECT_NAME}
|
|
POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
$<TARGET_RUNTIME_DLLS:${PROJECT_NAME}>
|
|
$<TARGET_FILE_DIR:${PROJECT_NAME}>
|
|
COMMAND_EXPAND_LISTS
|
|
)
|
|
endif() |