mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-22 10:29:47 +00:00
Merge branch 'main' into dev
This commit is contained in:
commit
7994d41b19
25 changed files with 142 additions and 76 deletions
6
.github/workflows/appimage.yml
vendored
6
.github/workflows/appimage.yml
vendored
|
|
@ -50,13 +50,13 @@ jobs:
|
||||||
- name: Run engine tests
|
- name: Run engine tests
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
run: |
|
run: |
|
||||||
chmod +x build/VoxelEngine
|
chmod +x build/VoxelCore
|
||||||
chmod +x AppDir/usr/bin/vctest
|
chmod +x AppDir/usr/bin/vctest
|
||||||
AppDir/usr/bin/vctest -e build/VoxelEngine -d dev/tests -u build --memchecker valgrind
|
AppDir/usr/bin/vctest -e build/VoxelCore -d dev/tests -u build --memchecker valgrind
|
||||||
- name: Build AppImage
|
- name: Build AppImage
|
||||||
uses: AppImageCrafters/build-appimage-action@fe2205a4d6056be47051f7b1b3811106e9814910
|
uses: AppImageCrafters/build-appimage-action@fe2205a4d6056be47051f7b1b3811106e9814910
|
||||||
env:
|
env:
|
||||||
UPDATE_INFO: gh-releases-zsync|MihailRis|VoxelEngine-Cpp|latest|*x86_64.AppImage.zsync
|
UPDATE_INFO: gh-releases-zsync|MihailRis|voxelcore|latest|*x86_64.AppImage.zsync
|
||||||
with:
|
with:
|
||||||
recipe: dev/AppImageBuilder.yml
|
recipe: dev/AppImageBuilder.yml
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
|
|
|
||||||
6
.github/workflows/cmake.yml
vendored
6
.github/workflows/cmake.yml
vendored
|
|
@ -62,7 +62,7 @@ jobs:
|
||||||
# Build your program with the given configuration
|
# Build your program with the given configuration
|
||||||
run: |
|
run: |
|
||||||
cmake --build ${{github.workspace}}/build --config ${{inputs.build_type}}
|
cmake --build ${{github.workspace}}/build --config ${{inputs.build_type}}
|
||||||
mv ${{github.workspace}}/build/VoxelEngine VoxelEngine
|
mv ${{github.workspace}}/build/VoxelCore VoxelCore
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
if: ${{ inputs.run_tests }}
|
if: ${{ inputs.run_tests }}
|
||||||
run: ctest --test-dir ${{github.workspace}}/build
|
run: ctest --test-dir ${{github.workspace}}/build
|
||||||
|
|
@ -70,7 +70,7 @@ jobs:
|
||||||
if: ${{ inputs.upload_artifacts }}
|
if: ${{ inputs.upload_artifacts }}
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: VoxelEngine
|
name: VoxelCore
|
||||||
path: |
|
path: |
|
||||||
VoxelEngine
|
VoxelCore
|
||||||
res/*
|
res/*
|
||||||
|
|
|
||||||
20
.github/workflows/macos.yml
vendored
20
.github/workflows/macos.yml
vendored
|
|
@ -39,7 +39,7 @@ jobs:
|
||||||
run: chmod +x dev/fix_dylibs.sh
|
run: chmod +x dev/fix_dylibs.sh
|
||||||
|
|
||||||
- name: Fix dylibs
|
- name: Fix dylibs
|
||||||
run: ./dev/fix_dylibs.sh VoxelEngine Release build
|
run: ./dev/fix_dylibs.sh VoxelCore Release build
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: ctest --output-on-failure --test-dir build
|
run: ctest --output-on-failure --test-dir build
|
||||||
|
|
@ -47,19 +47,19 @@ jobs:
|
||||||
- name: Run engine tests
|
- name: Run engine tests
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
run: |
|
run: |
|
||||||
chmod +x build/VoxelEngine
|
chmod +x build/VoxelCore
|
||||||
chmod +x AppDir/usr/bin/vctest
|
chmod +x AppDir/usr/bin/vctest
|
||||||
AppDir/usr/bin/vctest -e build/VoxelEngine -d dev/tests -u build --output-always --debugger "lldb -batch -o 'run' -o 'thread backtrace all' -o 'quit' -- "
|
AppDir/usr/bin/vctest -e build/VoxelCore -d dev/tests -u build --output-always --debugger "lldb -batch -o 'run' -o 'thread backtrace all' -o 'quit' -- "
|
||||||
- name: Create DMG
|
- name: Create DMG
|
||||||
run: |
|
run: |
|
||||||
mkdir VoxelEngineDmgContent
|
mkdir VoxelCoreDmgContent
|
||||||
cp -r build/res VoxelEngineDmgContent/
|
cp -r build/res VoxelCoreDmgContent/
|
||||||
cp -r build/VoxelEngine VoxelEngineDmgContent/
|
cp -r build/VoxelCore VoxelCoreDmgContent/
|
||||||
cp -r build/libs VoxelEngineDmgContent/libs
|
cp -r build/libs VoxelCoreDmgContent/libs
|
||||||
hdiutil create VoxelEngineMacApp.dmg -volname "VoxelEngine" -srcfolder VoxelEngineDmgContent -ov -format UDZO
|
hdiutil create VoxelCoreMacApp.dmg -volname "VoxelCore" -srcfolder VoxelCoreDmgContent -ov -format UDZO
|
||||||
|
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: VoxelEngineMacOs
|
name: VoxelCoreMacOs
|
||||||
path: VoxelEngineMacApp.dmg
|
path: VoxelCoreMacApp.dmg
|
||||||
|
|
|
||||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
|
|
@ -48,7 +48,7 @@ jobs:
|
||||||
mkdir release
|
mkdir release
|
||||||
mv ./artifacts/AppImage/VoxelCore-latest-x86_64.AppImage \
|
mv ./artifacts/AppImage/VoxelCore-latest-x86_64.AppImage \
|
||||||
./release/voxelcore-${RELEASE_VERSION}_x86-64.AppImage
|
./release/voxelcore-${RELEASE_VERSION}_x86-64.AppImage
|
||||||
mv ./artifacts/VoxelEngineMacOs/VoxelEngineMacApp.dmg \
|
mv ./artifacts/VoxelCoreMacOs/VoxelCoreMacApp.dmg \
|
||||||
./release/voxelcore-${RELEASE_VERSION}_macos.dmg
|
./release/voxelcore-${RELEASE_VERSION}_macos.dmg
|
||||||
(cd ./artifacts/Windows-Build && zip -r ../../release/voxelcore-${RELEASE_VERSION}_win64.zip .)
|
(cd ./artifacts/Windows-Build && zip -r ../../release/voxelcore-${RELEASE_VERSION}_win64.zip .)
|
||||||
ls -la ./release
|
ls -la ./release
|
||||||
|
|
|
||||||
3
.github/workflows/windows-clang.yml
vendored
3
.github/workflows/windows-clang.yml
vendored
|
|
@ -59,11 +59,10 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
mkdir packaged
|
mkdir packaged
|
||||||
mkdir packaged/res
|
mkdir packaged/res
|
||||||
cp build/VoxelEngine.exe packaged/
|
cp build/VoxelCore.exe packaged/
|
||||||
cp build/vctest/vctest.exe packaged/
|
cp build/vctest/vctest.exe packaged/
|
||||||
cp build/*.dll packaged/
|
cp build/*.dll packaged/
|
||||||
cp -r build/res/* packaged/res/
|
cp -r build/res/* packaged/res/
|
||||||
mv packaged/VoxelEngine.exe packaged/VoxelCore.exe
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: Windows-Build
|
name: Windows-Build
|
||||||
|
|
|
||||||
3
.github/workflows/windows.yml
vendored
3
.github/workflows/windows.yml
vendored
|
|
@ -37,7 +37,7 @@ jobs:
|
||||||
run: ctest --preset default-vs-msvc-windows
|
run: ctest --preset default-vs-msvc-windows
|
||||||
- name: Run engine tests
|
- name: Run engine tests
|
||||||
run: |
|
run: |
|
||||||
build/vctest/RelWithDebInfo/vctest.exe -e build/RelWithDebInfo/VoxelEngine.exe -d dev/tests -u build
|
build/vctest/RelWithDebInfo/vctest.exe -e build/RelWithDebInfo/VoxelCore.exe -d dev/tests -u build
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
- name: Package for Windows
|
- name: Package for Windows
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -45,7 +45,6 @@ jobs:
|
||||||
cp -r build/RelWithDebInfo/* packaged/
|
cp -r build/RelWithDebInfo/* packaged/
|
||||||
cp build/vctest/RelWithDebInfo/vctest.exe packaged/
|
cp build/vctest/RelWithDebInfo/vctest.exe packaged/
|
||||||
cp C:/Windows/System32/msvcp140.dll packaged/msvcp140.dll
|
cp C:/Windows/System32/msvcp140.dll packaged/msvcp140.dll
|
||||||
mv packaged/VoxelEngine.exe packaged/VoxelCore.exe
|
|
||||||
working-directory: ${{ github.workspace }}
|
working-directory: ${{ github.workspace }}
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.5)
|
cmake_minimum_required(VERSION 3.5)
|
||||||
project(VoxelEngine)
|
project(VoxelCore)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
@ -27,23 +27,23 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
add_executable(VoxelEngine src/main.cpp)
|
add_executable(VoxelCore src/main.cpp)
|
||||||
|
|
||||||
if(VOXELENGINE_BUILD_APPDIR)
|
if(VOXELENGINE_BUILD_APPDIR)
|
||||||
include(${CMAKE_CURRENT_SOURCE_DIR}/dev/cmake/BuildAppdir.cmake)
|
include(${CMAKE_CURRENT_SOURCE_DIR}/dev/cmake/BuildAppdir.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(VoxelEngine PRIVATE VoxelEngineSrc
|
target_link_libraries(VoxelCore PRIVATE VoxelCoreSrc
|
||||||
$<$<PLATFORM_ID:Windows>:winmm>)
|
$<$<PLATFORM_ID:Windows>:winmm>)
|
||||||
|
|
||||||
target_link_options(VoxelEngine PRIVATE $<$<CXX_COMPILER_ID:GNU>:-no-pie>)
|
target_link_options(VoxelCore PRIVATE $<$<CXX_COMPILER_ID:GNU>:-no-pie>)
|
||||||
|
|
||||||
# Deploy res to build dir
|
# Deploy res to build dir
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET VoxelEngine
|
TARGET VoxelCore
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/res $<TARGET_FILE_DIR:VoxelEngine>/res)
|
${CMAKE_CURRENT_SOURCE_DIR}/res $<TARGET_FILE_DIR:VoxelCore>/res)
|
||||||
|
|
||||||
if(VOXELENGINE_BUILD_TESTS)
|
if(VOXELENGINE_BUILD_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Build docker container: docker build -t voxelcore .
|
# Build docker container: docker build -t voxelcore .
|
||||||
# Build project: docker run --rm -it -v$(pwd):/project voxelcore bash -c "cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE -Bbuild && cmake --build build"
|
# Build project: docker run --rm -it -v$(pwd):/project voxelcore bash -c "cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE -Bbuild && cmake --build build"
|
||||||
# Run project in docker: docker run --rm -it -v$(pwd):/project -v/tmp/.X11-unix:/tmp/.X11-unix -v${XAUTHORITY}:/home/user/.Xauthority:ro -eDISPLAY --network=host voxelcore ./build/VoxelEngine
|
# Run project in docker: docker run --rm -it -v$(pwd):/project -v/tmp/.X11-unix:/tmp/.X11-unix -v${XAUTHORITY}:/home/user/.Xauthority:ro -eDISPLAY --network=host voxelcore ./build/VoxelCore
|
||||||
|
|
||||||
FROM debian:bookworm-slim
|
FROM debian:bookworm-slim
|
||||||
LABEL Description="Docker container for building VoxelCore for Linux"
|
LABEL Description="Docker container for building VoxelCore for Linux"
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ docker run --rm -it \
|
||||||
-v "$XAUTHORITY:/home/user/.Xauthority:ro" \
|
-v "$XAUTHORITY:/home/user/.Xauthority:ro" \
|
||||||
-e DISPLAY="$DISPLAY" \
|
-e DISPLAY="$DISPLAY" \
|
||||||
--network=host \
|
--network=host \
|
||||||
voxel-engine ./build/VoxelEngine
|
voxel-engine ./build/VoxelCore
|
||||||
```
|
```
|
||||||
|
|
||||||
### On Windows
|
### On Windows
|
||||||
|
|
@ -218,5 +218,5 @@ docker run --rm -it -v "${PWD}:/project" voxel-engine bash -c "cmake -DCMAKE_BUI
|
||||||
#### Step 4. Run the application
|
#### Step 4. Run the application
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
docker run --rm -it -v "${PWD}:/project" -e DISPLAY=host.docker.internal:0.0 --network=host voxel-engine ./build/VoxelEngine
|
docker run --rm -it -v "${PWD}:/project" -e DISPLAY=host.docker.internal:0.0 --network=host voxel-engine ./build/VoxelCore
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ AppDir:
|
||||||
name: VoxelCore
|
name: VoxelCore
|
||||||
icon: VoxelCore
|
icon: VoxelCore
|
||||||
version: latest
|
version: latest
|
||||||
exec: usr/bin/VoxelEngine
|
exec: usr/bin/VoxelCore
|
||||||
exec_args: --dir $HOME/.config/voxelcore --res $APPDIR/usr/share/VoxelCore/res $@
|
exec_args: --dir $HOME/.config/voxelcore --res $APPDIR/usr/share/VoxelCore/res $@
|
||||||
apt:
|
apt:
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ Version=1.0
|
||||||
Type=Application
|
Type=Application
|
||||||
Name=VoxelCore
|
Name=VoxelCore
|
||||||
Comment=Minecraft-like game engine in C++ with OpenGL
|
Comment=Minecraft-like game engine in C++ with OpenGL
|
||||||
TryExec=VoxelEngine
|
TryExec=VoxelCore
|
||||||
Exec=VoxelEngine
|
Exec=VoxelCore
|
||||||
Icon=VoxelCore
|
Icon=VoxelCore
|
||||||
MimeType=image/x-foo;
|
MimeType=image/x-foo;
|
||||||
Categories=Game;
|
Categories=Game;
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,4 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelCore.desktop DESTINATION ${CMAKE_
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/lib)
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/lib)
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/lib)
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/lib)
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin)
|
||||||
install(TARGETS VoxelEngine DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin)
|
install(TARGETS VoxelCore DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
local response_received = false
|
local response_received = false
|
||||||
|
|
||||||
network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s)
|
network.get("https://api.github.com/repos/MihailRis/voxelcore/releases/latest", function (s)
|
||||||
print(json.parse(s).name)
|
print(json.parse(s).name)
|
||||||
response_received = true
|
response_received = true
|
||||||
end, function (code)
|
end, function (code)
|
||||||
|
|
|
||||||
33
dev/tests/reload_module.lua
Normal file
33
dev/tests/reload_module.lua
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
-- reload_module must run the module in its pack environment, as require does
|
||||||
|
local util = require "core:tests_util"
|
||||||
|
util.create_demo_world()
|
||||||
|
|
||||||
|
-- a pack with a module that uses pack environment (PACK_ID)
|
||||||
|
local PACK = "world:content/reload_test"
|
||||||
|
file.mkdirs(PACK .. "/modules")
|
||||||
|
file.write(PACK .. "/package.json", json.tostring({id="reload_test", title="reload_test"}))
|
||||||
|
|
||||||
|
local function write_module(version)
|
||||||
|
file.write(PACK .. "/modules/mod.lua", string.format([[
|
||||||
|
local this = {}
|
||||||
|
function this.info() return PACK_ID, %d end
|
||||||
|
return this
|
||||||
|
]], version))
|
||||||
|
end
|
||||||
|
|
||||||
|
write_module(1)
|
||||||
|
app.reconfig_packs({"reload_test"}, {})
|
||||||
|
app.tick()
|
||||||
|
|
||||||
|
local mod = require "reload_test:mod"
|
||||||
|
local packid, version = mod.info()
|
||||||
|
assert(packid == "reload_test" and version == 1)
|
||||||
|
|
||||||
|
write_module(2)
|
||||||
|
reload_module("reload_test:mod")
|
||||||
|
packid, version = mod.info()
|
||||||
|
assert(version == 2, "module is not reloaded")
|
||||||
|
assert(packid == "reload_test", "reloaded module has no pack environment")
|
||||||
|
|
||||||
|
app.close_world(true)
|
||||||
|
app.delete_world("demo")
|
||||||
|
|
@ -50,7 +50,7 @@ network.get(
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Example:
|
-- Example:
|
||||||
network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s)
|
network.get("https://api.github.com/repos/MihailRis/voxelcore/releases/latest", function (s)
|
||||||
print(json.parse(s).name) -- will output the name of the latest engine release
|
print(json.parse(s).name) -- will output the name of the latest engine release
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ network.get(
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Пример:
|
-- Пример:
|
||||||
network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s)
|
network.get("https://api.github.com/repos/MihailRis/voxelcore/releases/latest", function (s)
|
||||||
print(json.parse(s).name) -- выведет имя последнего релиза движка
|
print(json.parse(s).name) -- выведет имя последнего релиза движка
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
Format version: 1.1
|
Format version: 1.1
|
||||||
|
|
||||||
This binary data format is developed for use as binary version of JSON in [VoxelEngine-Cpp](https://github.com/MihailRis/VoxelEngine-Cpp) and not compatible with [BSON](https://bsonspec.org/spec.html) due to elements/entries syntax and type codes differences
|
This binary data format is developed for use as binary version of JSON in [voxelcore](https://github.com/MihailRis/voxelcore) and not compatible with [BSON](https://bsonspec.org/spec.html) due to elements/entries syntax and type codes differences
|
||||||
|
|
||||||
## Basic types
|
## Basic types
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cp VoxelEngine $out/bin/
|
cp VoxelCore $out/bin/
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
|
||||||
|
|
@ -183,6 +183,12 @@ function on_deprecated_call(name, alternatives)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local __pack_envs = __vc__pack_envs
|
||||||
|
function __vc_internals.get_pack_env(packid)
|
||||||
|
return __pack_envs[packid]
|
||||||
|
end
|
||||||
|
__vc__pack_envs = nil
|
||||||
|
|
||||||
function reload_module(name)
|
function reload_module(name)
|
||||||
local prefix, name = parse_path(name)
|
local prefix, name = parse_path(name)
|
||||||
local path = prefix..":modules/"..name..".lua"
|
local path = prefix..":modules/"..name..".lua"
|
||||||
|
|
@ -196,6 +202,10 @@ function reload_module(name)
|
||||||
if script == nil then
|
if script == nil then
|
||||||
error(err)
|
error(err)
|
||||||
end
|
end
|
||||||
|
local env = __pack_envs[prefix]
|
||||||
|
if env then
|
||||||
|
script = setfenv(script, env)
|
||||||
|
end
|
||||||
local result = script()
|
local result = script()
|
||||||
if not result then
|
if not result then
|
||||||
return
|
return
|
||||||
|
|
@ -270,12 +280,6 @@ function __vc_lock_internal_modules()
|
||||||
__internal_locked = true
|
__internal_locked = true
|
||||||
end
|
end
|
||||||
|
|
||||||
local __pack_envs = __vc__pack_envs
|
|
||||||
function __vc_internals.get_pack_env(packid)
|
|
||||||
return __pack_envs[packid]
|
|
||||||
end
|
|
||||||
__vc__pack_envs = nil
|
|
||||||
|
|
||||||
function require(path)
|
function require(path)
|
||||||
if not string.find(path, ':') then
|
if not string.find(path, ':') then
|
||||||
local prefix, _ = parse_path(_debug_getinfo(2).source)
|
local prefix, _ = parse_path(_debug_getinfo(2).source)
|
||||||
|
|
|
||||||
4
run.sh
4
run.sh
|
|
@ -62,5 +62,5 @@ done
|
||||||
|
|
||||||
if [[ $run ]]; then
|
if [[ $run ]]; then
|
||||||
echo "[RUN SCRIPT] Run project"
|
echo "[RUN SCRIPT] Run project"
|
||||||
./build/VoxelEngine
|
./build/VoxelCore
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
project(VoxelEngineSrc)
|
project(VoxelCoreSrc)
|
||||||
|
|
||||||
file(GLOB_RECURSE headers ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
|
file(GLOB_RECURSE headers ${CMAKE_CURRENT_SOURCE_DIR}/*.hpp)
|
||||||
file(GLOB_RECURSE sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
file(GLOB_RECURSE sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||||
list(REMOVE_ITEM sources ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
|
list(REMOVE_ITEM sources ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
|
||||||
|
|
||||||
add_library(VoxelEngineSrc STATIC ${sources} ${headers})
|
add_library(VoxelCoreSrc STATIC ${sources} ${headers})
|
||||||
|
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
find_package(GLEW REQUIRED)
|
find_package(GLEW REQUIRED)
|
||||||
|
|
@ -70,10 +70,10 @@ else()
|
||||||
add_library(luajit::luajit ALIAS PkgConfig::luajit)
|
add_library(luajit::luajit ALIAS PkgConfig::luajit)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(VoxelEngineSrc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(VoxelCoreSrc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
VoxelEngineSrc
|
VoxelCoreSrc
|
||||||
PRIVATE glfw
|
PRIVATE glfw
|
||||||
OpenGL::GL
|
OpenGL::GL
|
||||||
GLEW::GLEW
|
GLEW::GLEW
|
||||||
|
|
@ -91,7 +91,7 @@ target_link_libraries(
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_options(
|
target_compile_options(
|
||||||
VoxelEngineSrc
|
VoxelCoreSrc
|
||||||
PUBLIC $<$<CXX_COMPILER_ID:MSVC>:
|
PUBLIC $<$<CXX_COMPILER_ID:MSVC>:
|
||||||
/utf-8
|
/utf-8
|
||||||
/MP
|
/MP
|
||||||
|
|
@ -129,7 +129,7 @@ target_compile_options(
|
||||||
>)
|
>)
|
||||||
|
|
||||||
target_link_options(
|
target_link_options(
|
||||||
VoxelEngineSrc
|
VoxelCoreSrc
|
||||||
PUBLIC
|
PUBLIC
|
||||||
$<$<CXX_COMPILER_ID:GNU>:
|
$<$<CXX_COMPILER_ID:GNU>:
|
||||||
-no-pie
|
-no-pie
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,15 @@ void InlineFrame::setDocument(const std::shared_ptr<UiDocument>& document) {
|
||||||
|
|
||||||
root->setSize(size);
|
root->setSize(size);
|
||||||
|
|
||||||
gui.postRunnable([this]() {
|
gui.postRunnable([weak = weak_from_this(), document]() {
|
||||||
scripting::on_ui_open(*this->document, {});
|
auto node = weak.lock();
|
||||||
|
if (node == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (static_cast<InlineFrame&>(*node).document != document) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
scripting::on_ui_open(*document, {});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,14 +99,21 @@ template <typename T, T(tovalueFunc)(lua::State*, int)>
|
||||||
std::function<T()> create_supplier(
|
std::function<T()> create_supplier(
|
||||||
const scriptenv& env, const std::string& src, const std::string& file
|
const scriptenv& env, const std::string& src, const std::string& file
|
||||||
) {
|
) {
|
||||||
return [=]() {
|
return [=, errorLogged = false]() mutable {
|
||||||
|
lua::stackguard guard(lua::get_main_state());
|
||||||
if (auto L = process_callback(env, src, file)) {
|
if (auto L = process_callback(env, src, file)) {
|
||||||
if (lua::isfunction(L, -1)) {
|
if (lua::isfunction(L, -1) && !lua::call_nothrow(L, 0)) {
|
||||||
lua::call_nothrow(L, 0);
|
return T {};
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return tovalueFunc(L, -1);
|
||||||
|
} catch (const std::exception& err) {
|
||||||
|
if (!errorLogged) {
|
||||||
|
logger.error() << "supplier " << util::quote(src) << ": "
|
||||||
|
<< err.what();
|
||||||
|
errorLogged = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
auto str = tovalueFunc(L, -1);
|
|
||||||
lua::pop(L);
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
return T {};
|
return T {};
|
||||||
};
|
};
|
||||||
|
|
@ -158,16 +165,33 @@ int_array_consumer scripting::create_int_array_consumer(
|
||||||
vec2supplier scripting::create_vec2_supplier(
|
vec2supplier scripting::create_vec2_supplier(
|
||||||
const scriptenv& env, const std::string& src, const std::string& file
|
const scriptenv& env, const std::string& src, const std::string& file
|
||||||
) {
|
) {
|
||||||
return [=]() {
|
return [=, errorLogged = false]() mutable {
|
||||||
if (auto L = process_callback(env, src, file)) {
|
auto L = lua::get_main_state();
|
||||||
if (lua::isfunction(L, -1)) {
|
lua::stackguard guard(L);
|
||||||
lua::call_nothrow(L, 0);
|
int top = lua::gettop(L);
|
||||||
|
if (process_callback(env, src, file)) {
|
||||||
|
if (lua::isfunction(L, -1) && !lua::call_nothrow(L, 0)) {
|
||||||
|
return glm::vec2(0, 0);
|
||||||
|
}
|
||||||
|
if (lua::gettop(L) - top < 2) {
|
||||||
|
if (!errorLogged) {
|
||||||
|
logger.error() << "supplier " << util::quote(src)
|
||||||
|
<< ": two numbers expected";
|
||||||
|
errorLogged = true;
|
||||||
|
}
|
||||||
|
return glm::vec2(0, 0);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
auto y = lua::tonumber(L, -1);
|
||||||
|
auto x = lua::tonumber(L, -2);
|
||||||
|
return glm::vec2(x, y);
|
||||||
|
} catch (const std::exception& err) {
|
||||||
|
if (!errorLogged) {
|
||||||
|
logger.error() << "supplier " << util::quote(src) << ": "
|
||||||
|
<< err.what();
|
||||||
|
errorLogged = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
auto y = lua::tonumber(L, -1);
|
|
||||||
lua::pop(L);
|
|
||||||
auto x = lua::tonumber(L, -1);
|
|
||||||
lua::pop(L);
|
|
||||||
return glm::vec2(x, y);
|
|
||||||
}
|
}
|
||||||
return glm::vec2(0, 0);
|
return glm::vec2(0, 0);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
project(VoxelEngineTest)
|
project(VoxelCoreTest)
|
||||||
|
|
||||||
file(GLOB_RECURSE sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
file(GLOB_RECURSE sources ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||||
|
|
||||||
find_package(GTest)
|
find_package(GTest)
|
||||||
|
|
||||||
add_executable(VoxelEngineTest ${sources})
|
add_executable(VoxelCoreTest ${sources})
|
||||||
|
|
||||||
target_link_libraries(VoxelEngineTest PRIVATE VoxelEngineSrc GTest::gtest_main)
|
target_link_libraries(VoxelCoreTest PRIVATE VoxelCoreSrc GTest::gtest_main)
|
||||||
|
|
||||||
# HACK: copy res to test/ folder for fixing problem compatibility MultiConfig
|
# HACK: copy res to test/ folder for fixing problem compatibility MultiConfig
|
||||||
# and non MultiConfig builds. Delete in future and use only root res folder Also
|
# and non MultiConfig builds. Delete in future and use only root res folder Also
|
||||||
# this resolve problem with ctests, because it set cwd to
|
# this resolve problem with ctests, because it set cwd to
|
||||||
# ${CMAKE_CURRENT_BINARY_DIR}
|
# ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET VoxelEngineTest
|
TARGET VoxelCoreTest
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different
|
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different
|
||||||
${CMAKE_SOURCE_DIR}/res ${CMAKE_CURRENT_BINARY_DIR}/res)
|
${CMAKE_SOURCE_DIR}/res ${CMAKE_CURRENT_BINARY_DIR}/res)
|
||||||
|
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
gtest_discover_tests(VoxelEngineTest)
|
gtest_discover_tests(VoxelCoreTest)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ TEST(curltest, curltest) {
|
||||||
auto network = network::Network::create(settings);
|
auto network = network::Network::create(settings);
|
||||||
|
|
||||||
network::HttpRequest request {};
|
network::HttpRequest request {};
|
||||||
request.url = "https://raw.githubusercontent.com/MihailRis/VoxelEngine-Cpp/refs/"
|
request.url = "https://raw.githubusercontent.com/MihailRis/voxelcore/refs/"
|
||||||
"heads/curl/res/content/base/blocks/lamp.json";
|
"heads/curl/res/content/base/blocks/lamp.json";
|
||||||
request.onResponse = [](network::HttpResponse response) {
|
request.onResponse = [](network::HttpResponse response) {
|
||||||
if (response.body.empty()) {
|
if (response.body.empty()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue