From 518714344574f4b10b5287be2f8291d46d67004a Mon Sep 17 00:00:00 2001 From: omigamedev Date: Thu, 15 Jan 2026 21:43:17 +0100 Subject: [PATCH] enable lua --- .gitignore | 3 +-- CLAUDE.md | 8 +++++--- CMakeLists.txt | 8 +++++++- assets/demo.lua | 9 +++++++++ assets/demo.rml | 4 ++++ assets/phone.rcss | 27 +++++++++++++++++++++++++++ main.cpp | 2 ++ vcpkg.json | 5 +++-- 8 files changed, 58 insertions(+), 8 deletions(-) create mode 100644 assets/demo.lua diff --git a/.gitignore b/.gitignore index 6864b67..f261df5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ /build /.idea /.vs -/build -/build_test +/build* /cmake-build* /out diff --git a/CLAUDE.md b/CLAUDE.md index bafa9f6..ce65b4f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -9,8 +9,8 @@ Mosis Designer is a Windows desktop application for previewing RML/RCSS files us ## Build Commands ```bash -# Configure the build (requires vcpkg for glfw3 and freetype) -cmake -B build +# Configure the build (requires vcpkg toolchain for dependencies) +cmake -B build -DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake # Build debug cmake --build build --config Debug @@ -35,15 +35,17 @@ The application watches the parent directory of the loaded file for changes and Single-file C++23 application (`main.cpp`) that: - Uses RmlUi for rendering HTML/CSS-like markup (RML/RCSS) +- Uses RmlUi Lua bindings for scripting support in RML documents - Uses GLFW + OpenGL 3 backend from RmlUi - Windows-specific file watching via `FindFirstChangeNotification` - Automatically loads all `.ttf` fonts from the RML file's directory ## Dependencies -- **RmlUi**: Fetched via CMake FetchContent from GitHub +- **RmlUi**: Fetched via CMake FetchContent from GitHub (with Lua bindings enabled) - **GLFW3**: Via vcpkg - **FreeType**: Via vcpkg +- **Lua**: Via vcpkg (5.4.x) ## Code Style diff --git a/CMakeLists.txt b/CMakeLists.txt index b79f195..cf86f54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) # Use FetchContent for RmlUi include(FetchContent) +# Find Lua before RmlUi so it can be used +find_package(Lua REQUIRED) + +# Enable RmlUi Lua bindings before fetching +set(RMLUI_LUA_BINDINGS ON CACHE BOOL "" FORCE) + # Fetch RmlUi from GitHub FetchContent_Declare( rmlui @@ -31,7 +37,7 @@ add_executable(mosis-designer ${rmlui_SOURCE_DIR}/Backends/RmlUi_Renderer_GL3.cpp ) target_link_libraries(mosis-designer PUBLIC - RmlUi::RmlUi glfw freetype + RmlUi::RmlUi RmlUi::Lua glfw freetype ) target_include_directories(mosis-designer PUBLIC ${RMLUI_SOURCE_DIR} diff --git a/assets/demo.lua b/assets/demo.lua new file mode 100644 index 0000000..33056c0 --- /dev/null +++ b/assets/demo.lua @@ -0,0 +1,9 @@ +-- Simple button click handler +click_count = 0 + +function onButtonClick(event) + click_count = click_count + 1 + local button = event.current_element + button.inner_rml = "Clicked " .. click_count .. " times!" + print("Button clicked! Count: " .. click_count) +end diff --git a/assets/demo.rml b/assets/demo.rml index 4879b46..44964dc 100644 --- a/assets/demo.rml +++ b/assets/demo.rml @@ -2,6 +2,7 @@ + Fullscreen Mobile UI @@ -21,6 +22,9 @@

Hello omar 3 hello! and hello LEO 2 Hello!

+
+ +