enable lua
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,7 +1,6 @@
|
|||||||
/build
|
/build
|
||||||
/.idea
|
/.idea
|
||||||
/.vs
|
/.vs
|
||||||
/build
|
/build*
|
||||||
/build_test
|
|
||||||
/cmake-build*
|
/cmake-build*
|
||||||
/out
|
/out
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ Mosis Designer is a Windows desktop application for previewing RML/RCSS files us
|
|||||||
## Build Commands
|
## Build Commands
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Configure the build (requires vcpkg for glfw3 and freetype)
|
# Configure the build (requires vcpkg toolchain for dependencies)
|
||||||
cmake -B build
|
cmake -B build -DCMAKE_TOOLCHAIN_FILE=D:/vcpkg/scripts/buildsystems/vcpkg.cmake
|
||||||
|
|
||||||
# Build debug
|
# Build debug
|
||||||
cmake --build build --config 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:
|
Single-file C++23 application (`main.cpp`) that:
|
||||||
- Uses RmlUi for rendering HTML/CSS-like markup (RML/RCSS)
|
- 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
|
- Uses GLFW + OpenGL 3 backend from RmlUi
|
||||||
- Windows-specific file watching via `FindFirstChangeNotification`
|
- Windows-specific file watching via `FindFirstChangeNotification`
|
||||||
- Automatically loads all `.ttf` fonts from the RML file's directory
|
- Automatically loads all `.ttf` fonts from the RML file's directory
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
- **RmlUi**: Fetched via CMake FetchContent from GitHub
|
- **RmlUi**: Fetched via CMake FetchContent from GitHub (with Lua bindings enabled)
|
||||||
- **GLFW3**: Via vcpkg
|
- **GLFW3**: Via vcpkg
|
||||||
- **FreeType**: Via vcpkg
|
- **FreeType**: Via vcpkg
|
||||||
|
- **Lua**: Via vcpkg (5.4.x)
|
||||||
|
|
||||||
## Code Style
|
## Code Style
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|||||||
# Use FetchContent for RmlUi
|
# Use FetchContent for RmlUi
|
||||||
include(FetchContent)
|
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
|
# Fetch RmlUi from GitHub
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
rmlui
|
rmlui
|
||||||
@@ -31,7 +37,7 @@ add_executable(mosis-designer
|
|||||||
${rmlui_SOURCE_DIR}/Backends/RmlUi_Renderer_GL3.cpp
|
${rmlui_SOURCE_DIR}/Backends/RmlUi_Renderer_GL3.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(mosis-designer PUBLIC
|
target_link_libraries(mosis-designer PUBLIC
|
||||||
RmlUi::RmlUi glfw freetype
|
RmlUi::RmlUi RmlUi::Lua glfw freetype
|
||||||
)
|
)
|
||||||
target_include_directories(mosis-designer PUBLIC
|
target_include_directories(mosis-designer PUBLIC
|
||||||
${RMLUI_SOURCE_DIR}
|
${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>
|
<head>
|
||||||
<link type="text/rcss" href="html.rcss"/>
|
<link type="text/rcss" href="html.rcss"/>
|
||||||
<link type="text/rcss" href="phone.rcss"/>
|
<link type="text/rcss" href="phone.rcss"/>
|
||||||
|
<script src="demo.lua"></script>
|
||||||
<title>Fullscreen Mobile UI</title>
|
<title>Fullscreen Mobile UI</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -21,6 +22,9 @@
|
|||||||
<div class="header-section">
|
<div class="header-section">
|
||||||
<h1>Hello omar 3 hello! and hello LEO 2 Hello!</h1>
|
<h1>Hello omar 3 hello! and hello LEO 2 Hello!</h1>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="button-container">
|
||||||
|
<button id="main-button" onclick="onButtonClick(event)">Click Me!</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="nav-bar">
|
<div id="nav-bar">
|
||||||
|
|||||||
@@ -108,3 +108,30 @@ h1 {
|
|||||||
color: #3498db;
|
color: #3498db;
|
||||||
background-color: blue;
|
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 <iostream>
|
||||||
#include <RmlUi/Core.h>
|
#include <RmlUi/Core.h>
|
||||||
#include <RmlUi/Debugger.h>
|
#include <RmlUi/Debugger.h>
|
||||||
|
#include <RmlUi/Lua.h>
|
||||||
#include <RmlUi_Backend.h>
|
#include <RmlUi_Backend.h>
|
||||||
#include <RmlUi_Include_Windows.h>
|
#include <RmlUi_Include_Windows.h>
|
||||||
|
|
||||||
@@ -45,6 +46,7 @@ int main(const int argc, const char* argv[])
|
|||||||
Rml::SetSystemInterface(Backend::GetSystemInterface());
|
Rml::SetSystemInterface(Backend::GetSystemInterface());
|
||||||
Rml::SetRenderInterface(Backend::GetRenderInterface());
|
Rml::SetRenderInterface(Backend::GetRenderInterface());
|
||||||
Rml::Initialise();
|
Rml::Initialise();
|
||||||
|
Rml::Lua::Initialise();
|
||||||
|
|
||||||
Rml::Context* context = Rml::CreateContext("main", Rml::Vector2i(window_width, window_height));
|
Rml::Context* context = Rml::CreateContext("main", Rml::Vector2i(window_width, window_height));
|
||||||
if (!context)
|
if (!context)
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
"name": "mosis-designer",
|
"name": "mosis-designer",
|
||||||
"version-string": "0.1.0",
|
"version-string": "0.1.0",
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"rmlui",
|
"glfw3",
|
||||||
"glfw3"
|
"freetype",
|
||||||
|
"lua"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user