enable lua
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,7 +1,6 @@
|
||||
/build
|
||||
/.idea
|
||||
/.vs
|
||||
/build
|
||||
/build_test
|
||||
/build*
|
||||
/cmake-build*
|
||||
/out
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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}
|
||||
|
||||
9
assets/demo.lua
Normal file
9
assets/demo.lua
Normal file
@@ -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
|
||||
@@ -2,6 +2,7 @@
|
||||
<head>
|
||||
<link type="text/rcss" href="html.rcss"/>
|
||||
<link type="text/rcss" href="phone.rcss"/>
|
||||
<script src="demo.lua"></script>
|
||||
<title>Fullscreen Mobile UI</title>
|
||||
</head>
|
||||
<body>
|
||||
@@ -21,6 +22,9 @@
|
||||
<div class="header-section">
|
||||
<h1>Hello omar 3 hello! and hello LEO 2 Hello!</h1>
|
||||
</div>
|
||||
<div class="button-container">
|
||||
<button id="main-button" onclick="onButtonClick(event)">Click Me!</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="nav-bar">
|
||||
|
||||
@@ -107,4 +107,31 @@ h1 {
|
||||
.nav-item:hover {
|
||||
color: #3498db;
|
||||
background-color: blue;
|
||||
}
|
||||
|
||||
/* Button container for centering */
|
||||
.button-container {
|
||||
display: block;
|
||||
text-align: center;
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
/* Styled button */
|
||||
button {
|
||||
padding: 20px 60px;
|
||||
font-size: 1.5em;
|
||||
font-family: LatoLatin;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
background-color: #3498db;
|
||||
border-radius: 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #2980b9;
|
||||
}
|
||||
|
||||
button:active {
|
||||
background-color: #1c5a85;
|
||||
}
|
||||
2
main.cpp
2
main.cpp
@@ -5,6 +5,7 @@
|
||||
#include <iostream>
|
||||
#include <RmlUi/Core.h>
|
||||
#include <RmlUi/Debugger.h>
|
||||
#include <RmlUi/Lua.h>
|
||||
#include <RmlUi_Backend.h>
|
||||
#include <RmlUi_Include_Windows.h>
|
||||
|
||||
@@ -45,6 +46,7 @@ int main(const int argc, const char* argv[])
|
||||
Rml::SetSystemInterface(Backend::GetSystemInterface());
|
||||
Rml::SetRenderInterface(Backend::GetRenderInterface());
|
||||
Rml::Initialise();
|
||||
Rml::Lua::Initialise();
|
||||
|
||||
Rml::Context* context = Rml::CreateContext("main", Rml::Vector2i(window_width, window_height));
|
||||
if (!context)
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
"name": "mosis-designer",
|
||||
"version-string": "0.1.0",
|
||||
"dependencies": [
|
||||
"rmlui",
|
||||
"glfw3"
|
||||
"glfw3",
|
||||
"freetype",
|
||||
"lua"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user