Nuklear module for the LÖVE game engine.
Provides a lightweight immediate mode GUI for LÖVE games.
-- Simple UI example.
local nuklear = require 'nuklear'
local ui
function love.load()
ui = nuklear.newUI()
end
local combo = {value = 1, items = {'A', 'B', 'C'}}
function love.update(dt)
ui:frameBegin()
if ui:windowBegin('Simple Example', 100, 100, 200, 160,
'border', 'title', 'movable') then
ui:layoutRow('dynamic', 30, 1)
ui:label('Hello, world!')
ui:layoutRow('dynamic', 30, 2)
ui:label('Combo box:')
if ui:combobox(combo, combo.items) then
print('Combo!', combo.items[combo.value])
end
ui:layoutRow('dynamic', 30, 3)
ui:label('Buttons:')
if ui:button('Sample') then
print('Sample!')
end
if ui:button('Button') then
print('Button!')
end
end
ui:windowEnd()
ui:frameEnd()
end
function love.draw()
ui:draw()
end
function love.keypressed(key, scancode, isrepeat)
ui:keypressed(key, scancode, isrepeat)
end
function love.keyreleased(key, scancode)
ui:keyreleased(key, scancode)
end
function love.mousepressed(x, y, button, istouch, presses)
ui:mousepressed(x, y, button, istouch, presses)
end
function love.mousereleased(x, y, button, istouch, presses)
ui:mousereleased(x, y, button, istouch, presses)
end
function love.mousemoved(x, y, dx, dy, istouch)
ui:mousemoved(x, y, dx, dy, istouch)
end
function love.textinput(text)
ui:textinput(text)
end
function love.wheelmoved(x, y)
ui:wheelmoved(x, y)
end
Windows binaries are available for each release.
To build the library yourself, grab the code with:
$ git clone --recursive https://github.com/keharriso/love-nuklear.git
Next, you need to compile the code to a native Lua module.
- First, ensure you have a C compiler and the
cmake
andluajit
orlua51-luajit
(for openSUSE) packages installed, as well aslibluajit-5.1-dev
(for Ubuntu/Debian),luajit-devel
(for Fedora), orlua51-luajit-devel
(for openSUSE) if your distro has one of these packages. - Create a new folder next to
love-nuklear
calledlove-nuklear-build
. - Open a terminal inside
love-nuklear-build
. - Compile the library with
$ cmake -DCMAKE_BUILD_TYPE=Release ../love-nuklear
$ make
- Locate
nuklear.so
in the build folder.
LÖVE-Nuklear is also available as a Guix package, and can thus be directly downloaded and built via:
$ guix package --install love-nuklear
- Install CMake and MinGW or MinGW-w64.
- Download the source code for LuaJIT.
- Open a command window inside the LuaJIT folder (the one that contains "README").
- Compile LuaJIT with
$ mingw32-make
- Remember the path to
lua51.dll
inside the LuaJITsrc
folder. - Run the CMake GUI.
- Click "Browse Source" at the top right, then select the
love-nuklear
folder. - Enter a path for the build folder. It should be separate from the source folder.
- Press "Configure" at the bottom.
- Select "MinGW Makefiles" from the generator drop list, then click "Finish".
- You should receive an error. This is normal.
- Open the LUA tree by clicking the triangle on the left.
- Replace "LUA_INCLUDE_DIR-NOTFOUND" with the path to the LuaJIT
src
folder. - Replace "LUA_LIBRARY-NOTFOUND" with the path to
lua51.dll
inside the LuaJITsrc
folder. - Click "Generate" at the bottom.
- Open a command window inside the build folder.
- Compile with
$ mingw32-make
- Locate
nuklear.dll
inside the build folder.
- Install CMake and Visual Studio. Community or Express edition is sufficient.
- Download the source code for LuaJIT.
- Open a Visual Studio Command Prompt (x86 or x64 depending on what architecture you need) and set the current directory to the LuaJIT folder (the one that contains "README"). Also remember this path.
- At the VS Command Prompt, set your current directory to
src
then executemsvcbuild.bat
. This will create lua51.dll, lua51.lib, and luajit.exe - Now open new command prompt window inside the
love-nuklear
folder. - Type
set "LUA_DIR=<path to directory at step 3>"
- Then type
cmake -Bbuild -H. -A Win32 -DLUA_INCLUDE_DIR=%LUA_DIR%\src -DLUA_LIBRARY=%LUA_DIR%\src\lua51.lib -DCMAKE_INSTALL_PREFIX=%CD%\install
. If you previously compile LuaJIT using x64 VS command prompt, replaceWin32
withx64
at above command. - Then type
cmake --build build --config Release --target install
and you'll foundnuklear.dll
inside "install" folder.
A complete description of all functions and style properties, alongside additional examples, is available at the LÖVE-Nuklear wiki.
Copyright (c) 2016 Kevin Harrison, released under the MIT License (see LICENSE for details).