Merge branch 'main' into update-gfx-pipeline
This commit is contained in:
commit
6927a87973
10
Dockerfile
10
Dockerfile
@ -11,6 +11,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
|
|||||||
g++ \
|
g++ \
|
||||||
make \
|
make \
|
||||||
cmake \
|
cmake \
|
||||||
|
pkg-config \
|
||||||
xauth \
|
xauth \
|
||||||
gdb \
|
gdb \
|
||||||
gdbserver \
|
gdbserver \
|
||||||
@ -25,8 +26,17 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
|
|||||||
libvorbis-dev \
|
libvorbis-dev \
|
||||||
libcurl4-openssl-dev \
|
libcurl4-openssl-dev \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
|
wget \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Установка CMake >= 3.26 вручную
|
||||||
|
ARG CMAKE_VERSION=3.27.9
|
||||||
|
RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.sh && \
|
||||||
|
chmod +x cmake-${CMAKE_VERSION}-linux-x86_64.sh && \
|
||||||
|
./cmake-${CMAKE_VERSION}-linux-x86_64.sh --skip-license --prefix=/usr/local && \
|
||||||
|
rm cmake-${CMAKE_VERSION}-linux-x86_64.sh
|
||||||
|
|
||||||
|
|
||||||
# Install EnTT
|
# Install EnTT
|
||||||
RUN git clone https://github.com/skypjack/entt.git && \
|
RUN git clone https://github.com/skypjack/entt.git && \
|
||||||
cd entt/build && \
|
cd entt/build && \
|
||||||
|
|||||||
46
README.md
46
README.md
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
## Latest release
|
## Latest release
|
||||||
|
|
||||||
- [Download](https://github.com/MihailRis/VoxelEngine-Cpp/releases/latest) | [Скачать](https://github.com/MihailRis/VoxelEngine-Cpp/releases/latest)
|
- [Download](https://github.com/MihailRis/VoxelCore/releases/latest) | [Скачать](https://github.com/MihailRis/VoxelCore/releases/latest)
|
||||||
- [Documentation](https://github.com/MihailRis/VoxelEngine-Cpp/blob/release-0.27/doc/en/main-page.md) | [Документация](https://github.com/MihailRis/VoxelEngine-Cpp/blob/release-0.27/doc/ru/main-page.md)
|
- [Documentation](https://github.com/MihailRis/VoxelCore/blob/release-0.27/doc/en/main-page.md) | [Документация](https://github.com/MihailRis/VoxelCore/blob/release-0.27/doc/ru/main-page.md)
|
||||||
|
|
||||||
## Build project in Linux
|
## Build project in Linux
|
||||||
|
|
||||||
@ -71,8 +71,8 @@ yay -S entt
|
|||||||
### Building engine with CMake
|
### Building engine with CMake
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone --recursive https://github.com/MihailRis/VoxelEngine-Cpp.git
|
git clone --recursive https://github.com/MihailRis/VoxelCore.git
|
||||||
cd VoxelEngine-Cpp
|
cd VoxelCore
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||||
@ -95,8 +95,8 @@ brew install glfw3 glew glm libpng libvorbis lua luajit libcurl openal-soft skyp
|
|||||||
### Building engine with CMake
|
### Building engine with CMake
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone --recursive https://github.com/MihailRis/VoxelEngine-Cpp.git
|
git clone --recursive https://github.com/MihailRis/VoxelCore.git
|
||||||
cd VoxelEngine-Cpp
|
cd VoxelCore
|
||||||
mkdir build
|
mkdir build
|
||||||
cd build
|
cd build
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||||
@ -128,8 +128,8 @@ $env:PATH = "$env:VCPKG_ROOT;$env:PATH"
|
|||||||
|
|
||||||
After installing **vcpkg** you can build project:
|
After installing **vcpkg** you can build project:
|
||||||
```PowerShell
|
```PowerShell
|
||||||
git clone --recursive https://github.com/MihailRis/VoxelEngine-Cpp.git
|
git clone --recursive https://github.com/MihailRis/VoxelCore.git
|
||||||
cd VoxelEngine-Cpp
|
cd VoxelCore
|
||||||
cmake --preset default-vs-msvc-windows
|
cmake --preset default-vs-msvc-windows
|
||||||
cmake --build --preset default-vs-msvc-windows
|
cmake --build --preset default-vs-msvc-windows
|
||||||
```
|
```
|
||||||
@ -140,6 +140,8 @@ cmake --build --preset default-vs-msvc-windows
|
|||||||
|
|
||||||
See <https://docs.docker.com/engine/install>
|
See <https://docs.docker.com/engine/install>
|
||||||
|
|
||||||
|
### Do you have Linux
|
||||||
|
|
||||||
### Step 1. Build docker container
|
### Step 1. Build docker container
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@ -157,3 +159,31 @@ docker run --rm -it -v$(pwd):/project voxel-engine bash -c "cmake -DCMAKE_BUILD_
|
|||||||
```sh
|
```sh
|
||||||
docker run --rm -it -v$(pwd):/project -v/tmp/.X11-unix:/tmp/.X11-unix -v${XAUTHORITY}:/home/user/.Xauthority:ro -eDISPLAY --network=host voxel-engine ./build/VoxelEngine
|
docker run --rm -it -v$(pwd):/project -v/tmp/.X11-unix:/tmp/.X11-unix -v${XAUTHORITY}:/home/user/.Xauthority:ro -eDISPLAY --network=host voxel-engine ./build/VoxelEngine
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Do you have Windows
|
||||||
|
|
||||||
|
### Step 1. You need to install VcXsrv
|
||||||
|
|
||||||
|
### Step 2. Run VcXsrv with the command
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
.\vcxsrv.exe :0 -multiwindow -ac
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 3. Build docker container
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
docker build -t voxel-engine .
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 4. Build project using the docker container
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
docker run --rm -it -v "${PWD}:/project" voxel-engine bash -c "cmake -DCMAKE_BUILD_TYPE=Release -Bbuild && cmake --build build"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 5. Run project using the docker container
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
docker run --rm -it -v "${PWD}:/project" -e DISPLAY=host.docker.internal:0.0 --network host voxel-engine ./build/VoxelEngine
|
||||||
|
```
|
||||||
|
|||||||
3
res/devtools/syntax/vcm.toml
Normal file
3
res/devtools/syntax/vcm.toml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
language = "VCM"
|
||||||
|
extensions = ["vcm"]
|
||||||
|
line-comment-start = "#"
|
||||||
@ -8,47 +8,49 @@
|
|||||||
</panel>
|
</panel>
|
||||||
</splitbox>
|
</splitbox>
|
||||||
<splitbox id="editorContainer" split-pos="0.8">
|
<splitbox id="editorContainer" split-pos="0.8">
|
||||||
<container color="#00000080"
|
<splitbox id="codePanel" orientation="horizontal">
|
||||||
onclick="document.editor.focused = true document.editor.caret = -1">
|
<container color="#00000080" cursor="text"
|
||||||
<container size-func="-1,30" color="#00000020">
|
onclick="document.editor.focused = true document.editor.caret = -1">
|
||||||
<image id="lockIcon" src="gui/lock" tooltip="@Read only"
|
<container size-func="-1,30" color="#00000020">
|
||||||
interactive="true" onclick="unlock_access()"
|
<image id="lockIcon" src="gui/lock" tooltip="@Read only"
|
||||||
color="#FFFFFF80" size="16" pos="4,6"
|
interactive="true" onclick="unlock_access()"
|
||||||
hover-color="#1080FF"></image>
|
color="#FFFFFF80" size="16" pos="4,6"
|
||||||
<panel orientation="horizontal" gravity="top-right"
|
hover-color="#1080FF"></image>
|
||||||
size="60,16" padding="8" interval="8" color="0">
|
<panel orientation="horizontal" gravity="top-right"
|
||||||
<image id="saveIcon" src="gui/save" tooltip="@Save"
|
size="60,16" padding="8" interval="8" color="0">
|
||||||
enabled="false" interactive="true"
|
<image id="saveIcon" src="gui/save" tooltip="@Save"
|
||||||
hover-color="#1080FF"
|
enabled="false" interactive="true"
|
||||||
onclick="save_current_file()"
|
hover-color="#1080FF"
|
||||||
color="#FFFFFF80" size="16"></image>
|
onclick="save_current_file()"
|
||||||
<image id="infoIcon" src="gui/info" tooltip="@editor.info.tooltip"
|
color="#FFFFFF80" size="16"></image>
|
||||||
enabled="true" interactive="true"
|
<image id="infoIcon" src="gui/info" tooltip="@editor.info.tooltip"
|
||||||
color="#FFFFFF80" size="16"></image>
|
enabled="true" interactive="true"
|
||||||
<image id="syncIcon" src="gui/play" tooltip="@Run"
|
color="#FFFFFF80" size="16"></image>
|
||||||
enabled="true" interactive="true"
|
<image id="syncIcon" src="gui/play" tooltip="@Run"
|
||||||
hover-color="#1080FF"
|
enabled="true" interactive="true"
|
||||||
onclick="run_current_file()"
|
hover-color="#1080FF"
|
||||||
color="#FFFFFF80" size="16"></image>
|
onclick="run_current_file()"
|
||||||
</panel>
|
color="#FFFFFF80" size="16"></image>
|
||||||
<label id="title" pos="26,8"></label>
|
</panel>
|
||||||
|
<label id="title" pos="26,8"></label>
|
||||||
|
</container>
|
||||||
|
<textbox
|
||||||
|
id='editor'
|
||||||
|
pos='0,30'
|
||||||
|
color='0'
|
||||||
|
autoresize='true'
|
||||||
|
margin='0'
|
||||||
|
padding='5'
|
||||||
|
multiline='true'
|
||||||
|
line-numbers='true'
|
||||||
|
oncontrolkey='on_control_combination'
|
||||||
|
size-func="-1,40"
|
||||||
|
text-wrap='false'
|
||||||
|
scroll-step='50'
|
||||||
|
></textbox>
|
||||||
</container>
|
</container>
|
||||||
<textbox
|
<modelviewer id="modelviewer" visible="false" center="0.5,0.5,0.5" cam-rotation="45,-45,0"/>
|
||||||
id='editor'
|
</splitbox>
|
||||||
pos='0,30'
|
|
||||||
color='0'
|
|
||||||
autoresize='true'
|
|
||||||
margin='0'
|
|
||||||
padding='5'
|
|
||||||
multiline='true'
|
|
||||||
line-numbers='true'
|
|
||||||
oncontrolkey='on_control_combination'
|
|
||||||
size-func="-1,40"
|
|
||||||
text-wrap='false'
|
|
||||||
scroll-step='50'
|
|
||||||
></textbox>
|
|
||||||
<modelviewer size="480" model="stairs" center="0.5,0.5,0.5" cam-rotation="45,-45,0" gravity="top-right"/>
|
|
||||||
</container>
|
|
||||||
<splitbox orientation="horizontal" split-pos="0.4">
|
<splitbox orientation="horizontal" split-pos="0.4">
|
||||||
<panel id="traceback" padding="4" color="#000000A0">
|
<panel id="traceback" padding="4" color="#000000A0">
|
||||||
</panel>
|
</panel>
|
||||||
|
|||||||
@ -104,10 +104,29 @@ function unlock_access()
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function reload_model(filename, name)
|
||||||
|
assets.parse_model("xml", document.editor.text, name)
|
||||||
|
end
|
||||||
|
|
||||||
function run_current_file()
|
function run_current_file()
|
||||||
if not current_file.filename then
|
if not current_file.filename then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local info = registry.get_info(current_file.filename)
|
||||||
|
local script_type = info and info.type or "file"
|
||||||
|
local unit = info and info.unit
|
||||||
|
|
||||||
|
if script_type == "model" then
|
||||||
|
print(current_file.filename)
|
||||||
|
clear_output()
|
||||||
|
local _, err = pcall(reload_model, current_file.filename, unit)
|
||||||
|
if err then
|
||||||
|
document.output:paste(string.format("\n[#FF0000]%s[#FFFFFF]", err))
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local chunk, err = loadstring(document.editor.text, current_file.filename)
|
local chunk, err = loadstring(document.editor.text, current_file.filename)
|
||||||
clear_output()
|
clear_output()
|
||||||
if not chunk then
|
if not chunk then
|
||||||
@ -119,9 +138,7 @@ function run_current_file()
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local info = registry.get_info(current_file.filename)
|
|
||||||
local script_type = info and info.type or "file"
|
|
||||||
local unit = info and info.unit
|
|
||||||
save_current_file()
|
save_current_file()
|
||||||
|
|
||||||
local func = function()
|
local func = function()
|
||||||
@ -191,6 +208,7 @@ events.on("core:open_traceback", function(traceback_b64)
|
|||||||
tb_list.size = srcsize
|
tb_list.size = srcsize
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
--- Save the current file in the code editor if has writeable path.
|
||||||
function save_current_file()
|
function save_current_file()
|
||||||
if not current_file.mutable then
|
if not current_file.mutable then
|
||||||
return
|
return
|
||||||
@ -202,7 +220,22 @@ function save_current_file()
|
|||||||
document.editor.edited = false
|
document.editor.edited = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Open a file in the code editor.
|
||||||
|
--- @param filename string - the path to the file to open.
|
||||||
|
--- @param line integer - the line number to focus on (optional).
|
||||||
|
--- @param mutable string - writeable file path (optional).
|
||||||
function open_file_in_editor(filename, line, mutable)
|
function open_file_in_editor(filename, line, mutable)
|
||||||
|
debug.log("opening file " .. string.escape(filename) .. " in editor")
|
||||||
|
|
||||||
|
local ext = file.ext(filename)
|
||||||
|
if ext == "xml" or ext == "vcm" then
|
||||||
|
document.modelviewer.src = file.stem(filename)
|
||||||
|
document.modelviewer.visible = true
|
||||||
|
else
|
||||||
|
document.modelviewer.visible = false
|
||||||
|
end
|
||||||
|
document.codePanel:refresh()
|
||||||
|
|
||||||
local editor = document.editor
|
local editor = document.editor
|
||||||
local source = file.read(filename):gsub('\t', ' ')
|
local source = file.read(filename):gsub('\t', ' ')
|
||||||
editor.scroll = 0
|
editor.scroll = 0
|
||||||
@ -225,7 +258,7 @@ end
|
|||||||
function on_open(mode)
|
function on_open(mode)
|
||||||
registry = require "core:internal/scripts_registry"
|
registry = require "core:internal/scripts_registry"
|
||||||
|
|
||||||
document.editorContainer:setInterval(200, refresh_file_title)
|
document.codePanel:setInterval(200, refresh_file_title)
|
||||||
|
|
||||||
clear_traceback()
|
clear_traceback()
|
||||||
clear_output()
|
clear_output()
|
||||||
|
|||||||
@ -22,8 +22,7 @@
|
|||||||
markup="md"
|
markup="md"
|
||||||
></textbox>
|
></textbox>
|
||||||
</container>
|
</container>
|
||||||
<iframe id="editorRoot" pos="0,30" size-func="-1,gui.get_viewport()[2]-30"
|
<iframe id="editorRoot" pos="0,30" size-func="-1,gui.get_viewport()[2]-30">
|
||||||
src="core:code_editor">
|
|
||||||
</iframe>
|
</iframe>
|
||||||
<textbox id='prompt'
|
<textbox id='prompt'
|
||||||
consumer='submit'
|
consumer='submit'
|
||||||
|
|||||||
@ -104,8 +104,10 @@ function set_mode(mode)
|
|||||||
|
|
||||||
if mode == 'debug' then
|
if mode == 'debug' then
|
||||||
document.root.color = {16, 18, 20, 220}
|
document.root.color = {16, 18, 20, 220}
|
||||||
|
document.editorRoot.src = "core:code_editor"
|
||||||
else
|
else
|
||||||
document.root.color = {0, 0, 0, 128}
|
document.root.color = {0, 0, 0, 128}
|
||||||
|
document.editorRoot.src = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
document.prompt.visible = show_prompt
|
document.prompt.visible = show_prompt
|
||||||
|
|||||||
4
res/models/stairs.vcm
Normal file
4
res/models/stairs.vcm
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
@box from (0,0,0) to (1,0.5,1) delete (top,south)
|
||||||
|
@box from (0,0.5,0) to (1,1,0.5) delete (bottom,south)
|
||||||
|
@rect from (0,0.5,0.5) right (1,0,0) up (0,0,0.5) texture "$2"
|
||||||
|
@rect from (0,0,0) right (1,0,0) up (0,1,0) texture "$1"
|
||||||
@ -1,6 +0,0 @@
|
|||||||
<model>
|
|
||||||
<box from="0,0,0" to="1,0.5,1" delete="top,south"/>
|
|
||||||
<box from="0,0.5,0" to="1,1,0.5" delete="bottom,south"/>
|
|
||||||
<rect from="0,0.5,0.5" right="1,0,0" up="0,0,0.5" texture="$2"/>
|
|
||||||
<rect from="0,0,0" right="1,0,0" up="0,1,0" texture="$1"/>
|
|
||||||
</model>
|
|
||||||
@ -55,7 +55,7 @@ local function load_models_list(packs)
|
|||||||
local registry = export.registry
|
local registry = export.registry
|
||||||
for _, filename in ipairs(file.list("models")) do
|
for _, filename in ipairs(file.list("models")) do
|
||||||
local ext = file.ext(filename)
|
local ext = file.ext(filename)
|
||||||
if ext == "xml" then
|
if ext == "xml" or ext == "vcm" then
|
||||||
registry[filename] = {type="model", unit=file.stem(filename)}
|
registry[filename] = {type="model", unit=file.stem(filename)}
|
||||||
table.insert(export.filenames, filename)
|
table.insert(export.filenames, filename)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -291,6 +291,19 @@ console.add_command(
|
|||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
|
console.add_command(
|
||||||
|
"weather.list",
|
||||||
|
"Show available weather presets list",
|
||||||
|
function(args, kwargs)
|
||||||
|
local filenames = file.list_all_res("presets/weather/")
|
||||||
|
local presets = " "
|
||||||
|
for index, filename in pairs(filenames) do
|
||||||
|
presets = presets .. "\n" .. file.stem(filename)
|
||||||
|
end
|
||||||
|
return "available presets:" .. presets
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
console.cheats = {
|
console.cheats = {
|
||||||
"blocks.fill",
|
"blocks.fill",
|
||||||
"tp",
|
"tp",
|
||||||
|
|||||||
@ -19,8 +19,17 @@ Problems=Праблемы
|
|||||||
Monitor=Маніторынг
|
Monitor=Маніторынг
|
||||||
Debug=Адладка
|
Debug=Адладка
|
||||||
File=Файл
|
File=Файл
|
||||||
|
Read only=Толькі для чытання
|
||||||
|
Save=Захаваць
|
||||||
|
Grant %{0} pack modification permission?=Выдаць дазвол на мадыфікацыю пака %{0}?
|
||||||
|
Error at line %{0}=Памылка ў радку %{0}
|
||||||
|
Run=Запусціць
|
||||||
|
Filter=Фільтр
|
||||||
|
|
||||||
|
editor.info.tooltip=CTRL+S - Захаваць\nCTRL+R - Запусціць\nCTRL+Z - Скасаваць\nCTRL+Y - Паўтарыць
|
||||||
devtools.traceback=Стэк выклікаў (ад апошняга)
|
devtools.traceback=Стэк выклікаў (ад апошняга)
|
||||||
|
devtools.output=Вывод
|
||||||
|
|
||||||
error.pack-not-found=Не ўдалося знайсці пакет
|
error.pack-not-found=Не ўдалося знайсці пакет
|
||||||
error.dependency-not-found=Выкарыстоўваная залежнасць не знойдзена
|
error.dependency-not-found=Выкарыстоўваная залежнасць не знойдзена
|
||||||
pack.remove-confirm=Выдаліць увесь кантэнт, які пастаўляецца пакетам/пакетамі, са свету (беззваротна)?
|
pack.remove-confirm=Выдаліць увесь кантэнт, які пастаўляецца пакетам/пакетамі, са свету (беззваротна)?
|
||||||
@ -43,7 +52,7 @@ menu.Display=Дысплей
|
|||||||
menu.Graphics=Графіка
|
menu.Graphics=Графіка
|
||||||
menu.missing-content=Адсутнічае Кантэнт!
|
menu.missing-content=Адсутнічае Кантэнт!
|
||||||
menu.New World=Новы Свет
|
menu.New World=Новы Свет
|
||||||
menu.Open worlds folder=Адкрыць папку з сусветамі
|
menu.Open worlds folder=Адкрыць тэчку са сусветамі
|
||||||
menu.Worlds=Сусветы
|
menu.Worlds=Сусветы
|
||||||
menu.Page not found=Старонка не знойдзена
|
menu.Page not found=Старонка не знойдзена
|
||||||
menu.Quit=Выхад
|
menu.Quit=Выхад
|
||||||
@ -51,8 +60,8 @@ menu.Save and Quit to Menu=Захаваць і Выйсці ў Меню
|
|||||||
menu.Settings=Налады
|
menu.Settings=Налады
|
||||||
menu.Reset settings=Скінуць налады
|
menu.Reset settings=Скінуць налады
|
||||||
menu.Contents Menu=Меню кантэнт-пакаў
|
menu.Contents Menu=Меню кантэнт-пакаў
|
||||||
menu.Open data folder=Адкрыць папку з дадзенымі
|
menu.Open data folder=Адкрыць тэчку з дадзенымі
|
||||||
menu.Open content folder=Адкрыць папку [content]
|
menu.Open content folder=Адкрыць тэчку [content]
|
||||||
|
|
||||||
world.Seed=Зерне
|
world.Seed=Зерне
|
||||||
world.Name=Назва
|
world.Name=Назва
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#include "assetload_funcs.hpp"
|
#include "assetload_funcs.hpp"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@ -352,21 +353,35 @@ assetload::postfunc assetload::model(
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
path = paths.find(file + ".xml");
|
|
||||||
if (io::exists(path)) {
|
std::array<std::string, 2> extensions {
|
||||||
auto text = io::read_string(path);
|
".xml",
|
||||||
try {
|
".vcm"
|
||||||
auto model = vcm::parse(path.string(), text).release();
|
};
|
||||||
return [=](Assets* assets) {
|
|
||||||
request_textures(loader, *model);
|
path = "";
|
||||||
assets->store(std::unique_ptr<model::Model>(model), name);
|
for (const auto& ext : extensions) {
|
||||||
};
|
auto newPath = paths.find(file + ext);
|
||||||
} catch (const parsing_error& err) {
|
if (io::exists(newPath)) {
|
||||||
std::cerr << err.errorLog() << std::endl;
|
path = std::move(newPath);
|
||||||
throw;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw std::runtime_error("could not to find model " + util::quote(file));
|
if (path.empty()) {
|
||||||
|
throw std::runtime_error("could not to find model " + util::quote(file));
|
||||||
|
}
|
||||||
|
|
||||||
|
auto text = io::read_string(path);
|
||||||
|
try {
|
||||||
|
auto model = vcm::parse(path.string(), text).release();
|
||||||
|
return [=](Assets* assets) {
|
||||||
|
request_textures(loader, *model);
|
||||||
|
assets->store(std::unique_ptr<model::Model>(model), name);
|
||||||
|
};
|
||||||
|
} catch (const parsing_error& err) {
|
||||||
|
std::cerr << err.errorLog() << std::endl;
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void read_anim_file(
|
static void read_anim_file(
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
#include "xml.hpp"
|
#include "xml.hpp"
|
||||||
#include "util/stringutil.hpp"
|
#include "util/stringutil.hpp"
|
||||||
#include "graphics/commons/Model.hpp"
|
#include "graphics/commons/Model.hpp"
|
||||||
|
#include "io/io.hpp"
|
||||||
|
|
||||||
using namespace vcm;
|
using namespace vcm;
|
||||||
using namespace xml;
|
using namespace xml;
|
||||||
@ -143,12 +144,18 @@ static std::unique_ptr<model::Model> load_model(const xmlelement& root) {
|
|||||||
std::unique_ptr<model::Model> vcm::parse(
|
std::unique_ptr<model::Model> vcm::parse(
|
||||||
std::string_view file, std::string_view src
|
std::string_view file, std::string_view src
|
||||||
) {
|
) {
|
||||||
auto doc = xml::parse(file, src);
|
try {
|
||||||
const auto& root = *doc->getRoot();
|
auto doc = io::path(std::string(file)).extension() == ".xml"
|
||||||
if (root.getTag() != "model") {
|
? xml::parse(file, src) : xml::parse_vcm(file, src, "model");
|
||||||
throw std::runtime_error(
|
const auto& root = *doc->getRoot();
|
||||||
"'model' tag expected as root, got '" + root.getTag() + "'"
|
if (root.getTag() != "model") {
|
||||||
);
|
throw std::runtime_error(
|
||||||
|
"'model' tag expected as root, got '" + root.getTag() + "'"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
std::cout << xml::stringify(*doc) << std::endl;
|
||||||
|
return load_model(root);
|
||||||
|
} catch (const parsing_error& err) {
|
||||||
|
throw std::runtime_error(err.errorLog());
|
||||||
}
|
}
|
||||||
return load_model(root);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -355,6 +355,83 @@ std::unique_ptr<Document> xml::parse(
|
|||||||
return parser.parse();
|
return parser.parse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
class VcmParser : public BasicParser<char> {
|
||||||
|
public:
|
||||||
|
VcmParser(std::string_view filename, std::string_view source)
|
||||||
|
: BasicParser(filename, source) {
|
||||||
|
document = std::make_unique<Document>("1.0", "UTF-8");
|
||||||
|
hashComment = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string parseValue() {
|
||||||
|
char c = peek();
|
||||||
|
if (c == '"' || c == '\'') {
|
||||||
|
nextChar();
|
||||||
|
return parseString(c);
|
||||||
|
}
|
||||||
|
if (c == '(') {
|
||||||
|
nextChar();
|
||||||
|
// TODO: replace with array parsing after moving to dv::value's
|
||||||
|
std::string value = std::string(readUntil(')'));
|
||||||
|
expect(')');
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return std::string(readUntilWhitespace());
|
||||||
|
}
|
||||||
|
|
||||||
|
void parseSubElements(Node& node) {
|
||||||
|
skipWhitespace();
|
||||||
|
while (hasNext()) {
|
||||||
|
if (peek() != '@') {
|
||||||
|
throw error("unexpected character in element");
|
||||||
|
}
|
||||||
|
nextChar();
|
||||||
|
auto subnodePtr = std::make_unique<Node>(parseName());
|
||||||
|
auto subnode = subnodePtr.get();
|
||||||
|
node.add(std::move(subnodePtr));
|
||||||
|
|
||||||
|
skipWhitespace();
|
||||||
|
while (hasNext() && peek() != '@' && peek() != '{' && peek() != '}') {
|
||||||
|
std::string attrname = parseName();
|
||||||
|
skipWhitespace();
|
||||||
|
std::string value = parseValue();
|
||||||
|
subnode->set(attrname, value);
|
||||||
|
skipWhitespace();
|
||||||
|
}
|
||||||
|
if (!hasNext()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
char c = peek();
|
||||||
|
if (c == '{') {
|
||||||
|
nextChar();
|
||||||
|
parseSubElements(*subnode);
|
||||||
|
expect('}');
|
||||||
|
skipWhitespace();
|
||||||
|
} else if (c == '}') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<Document> parse(const std::string& rootTag) {
|
||||||
|
auto root = std::make_unique<Node>(rootTag);
|
||||||
|
parseSubElements(*root);
|
||||||
|
document->setRoot(std::move(root));
|
||||||
|
return std::move(document);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::unique_ptr<Document> document;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<Document> xml::parse_vcm(
|
||||||
|
std::string_view filename, std::string_view source, std::string_view tag
|
||||||
|
) {
|
||||||
|
VcmParser parser(filename, source);
|
||||||
|
return parser.parse(std::string(tag));
|
||||||
|
}
|
||||||
|
|
||||||
inline void newline(
|
inline void newline(
|
||||||
std::stringstream& ss, bool nice, const std::string& indentStr, int indent
|
std::stringstream& ss, bool nice, const std::string& indentStr, int indent
|
||||||
) {
|
) {
|
||||||
|
|||||||
@ -126,5 +126,9 @@ namespace xml {
|
|||||||
std::string_view filename, std::string_view source
|
std::string_view filename, std::string_view source
|
||||||
);
|
);
|
||||||
|
|
||||||
|
std::unique_ptr<Document> parse_vcm(
|
||||||
|
std::string_view filename, std::string_view source, std::string_view tag
|
||||||
|
);
|
||||||
|
|
||||||
using xmlelement = Node;
|
using xmlelement = Node;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#include <array>
|
||||||
#include <glm/ext.hpp>
|
#include <glm/ext.hpp>
|
||||||
#include "ModelViewer.hpp"
|
#include "ModelViewer.hpp"
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
#include "SplitBox.hpp"
|
#include "SplitBox.hpp"
|
||||||
|
|
||||||
|
#include "util/stack_vector.hpp"
|
||||||
|
|
||||||
using namespace gui;
|
using namespace gui;
|
||||||
|
|
||||||
SplitBox::SplitBox(GUI& gui, const glm::vec2& size, float splitPos, Orientation orientation)
|
SplitBox::SplitBox(GUI& gui, const glm::vec2& size, float splitPos, Orientation orientation)
|
||||||
@ -28,18 +30,31 @@ void SplitBox::mouseMove(int x, int y) {
|
|||||||
void SplitBox::refresh() {
|
void SplitBox::refresh() {
|
||||||
Container::refresh();
|
Container::refresh();
|
||||||
|
|
||||||
if (nodes.empty()) {
|
util::stack_vector<UINode*, 2> visibleNodes;
|
||||||
|
|
||||||
|
for (const auto& node : nodes) {
|
||||||
|
if (!node->isVisible()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
visibleNodes.push_back(node.get());
|
||||||
|
if (visibleNodes.full()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (visibleNodes.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 size = getSize();
|
glm::vec2 size = getSize();
|
||||||
if (nodes.size() == 1) {
|
if (visibleNodes.size() == 1) {
|
||||||
auto node = nodes.at(0);
|
auto node = visibleNodes.at(0);
|
||||||
node->setPos(glm::vec2());
|
node->setPos(glm::vec2());
|
||||||
node->setSize(size);
|
node->setSize(size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto nodeA = nodes.at(0);
|
auto nodeA = visibleNodes.at(0);
|
||||||
auto nodeB = nodes.at(1);
|
auto nodeB = visibleNodes.at(1);
|
||||||
|
|
||||||
float sepRadius = interval / 2.0f;
|
float sepRadius = interval / 2.0f;
|
||||||
|
|
||||||
|
|||||||
@ -372,7 +372,7 @@ static std::shared_ptr<UINode> read_split_box(
|
|||||||
static std::shared_ptr<UINode> read_model_viewer(
|
static std::shared_ptr<UINode> read_model_viewer(
|
||||||
UiXmlReader& reader, const xml::xmlelement& element
|
UiXmlReader& reader, const xml::xmlelement& element
|
||||||
) {
|
) {
|
||||||
auto model = element.attr("model", "").getText();
|
auto model = element.attr("src", "").getText();
|
||||||
auto viewer = std::make_shared<ModelViewer>(
|
auto viewer = std::make_shared<ModelViewer>(
|
||||||
reader.getGUI(), glm::vec2(), model
|
reader.getGUI(), glm::vec2(), model
|
||||||
);
|
);
|
||||||
|
|||||||
@ -192,6 +192,9 @@ std::string EnginePaths::createWriteableDevice(const std::string& name) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (name == "core") {
|
||||||
|
folder = "res:";
|
||||||
|
}
|
||||||
if (folder.emptyOrInvalid()) {
|
if (folder.emptyOrInvalid()) {
|
||||||
throw std::runtime_error("pack not found");
|
throw std::runtime_error("pack not found");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,7 +51,7 @@ static int l_parse_model(lua::State* L) {
|
|||||||
auto string = lua::require_lstring(L, 2);
|
auto string = lua::require_lstring(L, 2);
|
||||||
auto name = lua::require_string(L, 3);
|
auto name = lua::require_string(L, 3);
|
||||||
|
|
||||||
if (format == "xml") {
|
if (format == "xml" || format == "vcm") {
|
||||||
engine->getAssets()->store(vcm::parse(name, string), name);
|
engine->getAssets()->store(vcm::parse(name, string), name);
|
||||||
} else {
|
} else {
|
||||||
throw std::runtime_error("unknown format " + util::quote(std::string(format)));
|
throw std::runtime_error("unknown format " + util::quote(std::string(format)));
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
#include "api_lua.hpp"
|
#include "api_lua.hpp"
|
||||||
#include "constants.hpp"
|
#include "constants.hpp"
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
#include <filesystem>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
@ -156,7 +155,8 @@ static int l_write_bytes(lua::State* L) {
|
|||||||
return lua::pushboolean(L, res);
|
return lua::pushboolean(L, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_list_all_res(lua::State* L, const std::string& path) {
|
static int l_list_all_res(lua::State* L) {
|
||||||
|
std::string path = lua::require_string(L, 1);
|
||||||
auto files = engine->getResPaths().listdirRaw(path);
|
auto files = engine->getResPaths().listdirRaw(path);
|
||||||
lua::createtable(L, files.size(), 0);
|
lua::createtable(L, files.size(), 0);
|
||||||
for (size_t i = 0; i < files.size(); i++) {
|
for (size_t i = 0; i < files.size(); i++) {
|
||||||
@ -169,7 +169,7 @@ static int l_list_all_res(lua::State* L, const std::string& path) {
|
|||||||
static int l_list(lua::State* L) {
|
static int l_list(lua::State* L) {
|
||||||
std::string dirname = lua::require_string(L, 1);
|
std::string dirname = lua::require_string(L, 1);
|
||||||
if (dirname.find(':') == std::string::npos) {
|
if (dirname.find(':') == std::string::npos) {
|
||||||
return l_list_all_res(L, dirname);
|
return l_list_all_res(L);
|
||||||
}
|
}
|
||||||
io::path path = dirname;
|
io::path path = dirname;
|
||||||
if (!io::is_directory(path)) {
|
if (!io::is_directory(path)) {
|
||||||
@ -265,6 +265,7 @@ const luaL_Reg filelib[] = {
|
|||||||
{"isfile", lua::wrap<l_isfile>},
|
{"isfile", lua::wrap<l_isfile>},
|
||||||
{"length", lua::wrap<l_length>},
|
{"length", lua::wrap<l_length>},
|
||||||
{"list", lua::wrap<l_list>},
|
{"list", lua::wrap<l_list>},
|
||||||
|
{"list_all_res", lua::wrap<l_list_all_res>},
|
||||||
{"mkdir", lua::wrap<l_mkdir>},
|
{"mkdir", lua::wrap<l_mkdir>},
|
||||||
{"mkdirs", lua::wrap<l_mkdirs>},
|
{"mkdirs", lua::wrap<l_mkdirs>},
|
||||||
{"read_bytes", lua::wrap<l_read_bytes>},
|
{"read_bytes", lua::wrap<l_read_bytes>},
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
#include "graphics/ui/elements/TextBox.hpp"
|
#include "graphics/ui/elements/TextBox.hpp"
|
||||||
#include "graphics/ui/elements/TrackBar.hpp"
|
#include "graphics/ui/elements/TrackBar.hpp"
|
||||||
#include "graphics/ui/elements/InlineFrame.hpp"
|
#include "graphics/ui/elements/InlineFrame.hpp"
|
||||||
|
#include "graphics/ui/elements/ModelViewer.hpp"
|
||||||
#include "graphics/ui/gui_util.hpp"
|
#include "graphics/ui/gui_util.hpp"
|
||||||
#include "graphics/ui/markdown.hpp"
|
#include "graphics/ui/markdown.hpp"
|
||||||
#include "graphics/core/Font.hpp"
|
#include "graphics/core/Font.hpp"
|
||||||
@ -114,6 +115,16 @@ static int l_node_destruct(lua::State* L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_container_refresh(lua::State* L) {
|
||||||
|
auto docnode = get_document_node(L);
|
||||||
|
auto node = dynamic_cast<Container*>(docnode.node.get());
|
||||||
|
if (node == nullptr) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
node->refresh();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int l_node_reposition(lua::State* L) {
|
static int l_node_reposition(lua::State* L) {
|
||||||
auto docnode = get_document_node(L);
|
auto docnode = get_document_node(L);
|
||||||
docnode.node->reposition();
|
docnode.node->reposition();
|
||||||
@ -341,6 +352,8 @@ static int p_get_src(UINode* node, lua::State* L) {
|
|||||||
return lua::pushstring(L, image->getTexture());
|
return lua::pushstring(L, image->getTexture());
|
||||||
} else if (auto iframe = dynamic_cast<InlineFrame*>(node)) {
|
} else if (auto iframe = dynamic_cast<InlineFrame*>(node)) {
|
||||||
return lua::pushstring(L, iframe->getSrc());
|
return lua::pushstring(L, iframe->getSrc());
|
||||||
|
} else if (auto modelviewer = dynamic_cast<ModelViewer*>(node)) {
|
||||||
|
return lua::pushstring(L, modelviewer->getModel());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -408,6 +421,13 @@ static int p_get_destruct(UINode*, lua::State* L) {
|
|||||||
return lua::pushcfunction(L, lua::wrap<l_node_destruct>);
|
return lua::pushcfunction(L, lua::wrap<l_node_destruct>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int p_refresh(UINode* node, lua::State* L) {
|
||||||
|
if (dynamic_cast<Container*>(node)) {
|
||||||
|
return lua::pushcfunction(L, lua::wrap<l_container_refresh>);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int p_get_reposition(UINode*, lua::State* L) {
|
static int p_get_reposition(UINode*, lua::State* L) {
|
||||||
return lua::pushcfunction(L, lua::wrap<l_node_reposition>);
|
return lua::pushcfunction(L, lua::wrap<l_node_reposition>);
|
||||||
}
|
}
|
||||||
@ -539,6 +559,7 @@ static int l_gui_getattr(lua::State* L) {
|
|||||||
{"moveInto", p_move_into},
|
{"moveInto", p_move_into},
|
||||||
{"add", p_get_add},
|
{"add", p_get_add},
|
||||||
{"destruct", p_get_destruct},
|
{"destruct", p_get_destruct},
|
||||||
|
{"refresh", p_refresh},
|
||||||
{"reposition", p_get_reposition},
|
{"reposition", p_get_reposition},
|
||||||
{"clear", p_get_clear},
|
{"clear", p_get_clear},
|
||||||
{"setInterval", p_set_interval},
|
{"setInterval", p_set_interval},
|
||||||
@ -675,6 +696,8 @@ static void p_set_src(UINode* node, lua::State* L, int idx) {
|
|||||||
image->setTexture(lua::require_string(L, idx));
|
image->setTexture(lua::require_string(L, idx));
|
||||||
} else if (auto iframe = dynamic_cast<InlineFrame*>(node)) {
|
} else if (auto iframe = dynamic_cast<InlineFrame*>(node)) {
|
||||||
iframe->setSrc(lua::require_string(L, idx));
|
iframe->setSrc(lua::require_string(L, idx));
|
||||||
|
} else if (auto modelviewer = dynamic_cast<ModelViewer*>(node)) {
|
||||||
|
modelviewer->setModel(lua::require_string(L, idx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void p_set_region(UINode* node, lua::State* L, int idx) {
|
static void p_set_region(UINode* node, lua::State* L, int idx) {
|
||||||
|
|||||||
99
src/util/stack_vector.hpp
Normal file
99
src/util/stack_vector.hpp
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace util {
|
||||||
|
template<typename T, int capacity>
|
||||||
|
class stack_vector {
|
||||||
|
public:
|
||||||
|
stack_vector() : size_(0) {}
|
||||||
|
|
||||||
|
stack_vector(const stack_vector<T, capacity>& other)
|
||||||
|
: size_(other.size_) {
|
||||||
|
for (int i = 0; i < size_; ++i) {
|
||||||
|
new (&data_[i]) T(data_[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stack_vector(stack_vector<T, capacity>&& other) noexcept
|
||||||
|
: size_(other.size_) {
|
||||||
|
for (int i = 0; i < size_; ++i) {
|
||||||
|
new (&data_[i]) T(std::move(other.data_[i]));
|
||||||
|
}
|
||||||
|
other.size_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
stack_vector(const std::initializer_list<T>& init) : size_(0) {
|
||||||
|
static_assert(
|
||||||
|
init.size() <= capacity,
|
||||||
|
"initializer list exceeds stack vector capacity"
|
||||||
|
);
|
||||||
|
for (const auto& value : init) {
|
||||||
|
new (&data_[size_++]) T(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~stack_vector() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void push_back(const T& value) {
|
||||||
|
if (size_ < capacity) {
|
||||||
|
data_[size_++] = value;
|
||||||
|
} else {
|
||||||
|
throw std::overflow_error("stack vector capacity exceeded");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void pop_back() {
|
||||||
|
if (size_ > 0) {
|
||||||
|
data_[size_ - 1].~T();
|
||||||
|
--size_;
|
||||||
|
} else {
|
||||||
|
throw std::underflow_error("stack vector is empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear() {
|
||||||
|
for (int i = 0; i < size_; ++i) {
|
||||||
|
data_[i].~T();
|
||||||
|
}
|
||||||
|
size_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
T& operator[](int index) {
|
||||||
|
return data_[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
const T& operator[](int index) const {
|
||||||
|
return data_[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
T& at(int index) {
|
||||||
|
if (index < 0 || index >= size_) {
|
||||||
|
throw std::out_of_range("index out of range");
|
||||||
|
}
|
||||||
|
return data_[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
const T& at(int index) const {
|
||||||
|
if (index < 0 || index >= size_) {
|
||||||
|
throw std::out_of_range("index out of range");
|
||||||
|
}
|
||||||
|
return data_[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
int size() const {
|
||||||
|
return size_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool empty() const {
|
||||||
|
return size_ == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool full() const {
|
||||||
|
return size_ == capacity;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
T data_[capacity];
|
||||||
|
int size_;
|
||||||
|
};
|
||||||
|
}
|
||||||
24
test/coders/xml.cpp
Normal file
24
test/coders/xml.cpp
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "coders/xml.hpp"
|
||||||
|
#include "coders/commons.hpp"
|
||||||
|
|
||||||
|
TEST(XML, VCM) {
|
||||||
|
std::string code = ""
|
||||||
|
"@line x1 y1 z1\n"
|
||||||
|
"# @tst ysfdrg\n"
|
||||||
|
"@box {\n"
|
||||||
|
" @rect texture \"$2\"\n"
|
||||||
|
" @utro a 53.1\n"
|
||||||
|
"}\n"
|
||||||
|
;
|
||||||
|
std::cout << code << std::endl;
|
||||||
|
|
||||||
|
try {
|
||||||
|
auto document = xml::parse_vcm("<test>", code, "test");
|
||||||
|
std::cout << xml::stringify(*document);
|
||||||
|
} catch (const parsing_error& err) {
|
||||||
|
std::cerr << err.errorLog() << std::endl;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user