github project:
https://github.com/slages/love-imgui
Pre-built binaries for Windows, Linux (Ubuntu i386) and MacOSX:
https://github.com/slages/love-imgui/releases
---------------------------
Galery of examples:
(sandsmas : viewtopic.php?f=5&t=82881)
Original post:
---------------------------
Hi guys,
Recently I've been desperately in need to switch from löveframes to a more flexible, powerful and still maintained library for all the game debug and editor tools. I directly thought about ImGui (https://github.com/ocornut/imgui) as it's clearly as far as I know the best dev oriented GUI library around. And as it's a C++ library, I took the path of directly integrating it into the löve sources instead of using ffi, as a Lua wrapping was already available. So after a bit of work and improvements to the wrapping part, I'm finally having something meeting the expectations and needs I had.
So for instance, something like that:
Code: Select all
require "imgui"
local showTestWindow = false
local showAnotherWindow = false
local floatValue = 0;
local sliderFloat = { 0.1, 0.5 }
local clearColor = { 0.2, 0.2, 0.2 }
local comboSelection = 0
local textValue = "text"
--
-- LOVE callbacks
--
function love.load(arg)
end
function love.update(dt)
imgui.NewFrame()
end
function love.draw()
local status
-- Menu
if imgui.BeginMainMenuBar() then
if imgui.BeginMenu("File") then
imgui.MenuItem("Test")
imgui.EndMenu()
end
imgui.EndMainMenuBar()
end
-- Debug window
imgui.Text("Hello, world!");
status, clearColor[1], clearColor[2], clearColor[3] = imgui.ColorEdit3("Clear color", clearColor[1], clearColor[2], clearColor[3]);
-- Sliders
status, floatValue = imgui.SliderFloat("SliderFloat", floatValue, 0.0, 1.0);
status, sliderFloat[1], sliderFloat[2] = imgui.SliderFloat2("SliderFloat2", sliderFloat[1], sliderFloat[2], 0.0, 1.0);
-- Combo
status, comboSelection = imgui.Combo("Combo", comboSelection, { "combo1", "combo2", "combo3", "combo4" }, 4);
-- Windows
if imgui.Button("Test Window") then
showTestWindow = not showTestWindow;
end
if imgui.Button("Another Window") then
showAnotherWindow = not showAnotherWindow;
end
if showAnotherWindow then
imgui.SetNextWindowPos(50, 50, ImGuiSetCond_FirstUseEver)
status, showAnotherWindow = imgui.Begin("Another Window", true, ImGuiWindowFlags_AlwaysAutoResize);
imgui.Text("Hello");
-- Input text
status, textValue = imgui.InputTextMultiline("InputText", textValue, 200, 300, 200);
imgui.End();
end
if showTestWindow then
showTestWindow = imgui.ShowTestWindow(true)
end
love.graphics.clear(clearColor[1] * 255, clearColor[2] * 255, clearColor[3] * 255, 255)
imgui.Render();
end
function love.quit()
imgui.ShutDown();
end
--
-- User inputs
--
function love.textinput(t)
imgui.TextInput(t)
if not imgui.GetWantCaptureKeyboard() then
-- Pass event to the game
end
end
function love.keypressed(key)
imgui.KeyPressed(key)
if not imgui.GetWantCaptureKeyboard() then
-- Pass event to the game
end
end
function love.keyreleased(key)
imgui.KeyReleased(key)
if not imgui.GetWantCaptureKeyboard() then
-- Pass event to the game
end
end
function love.mousemoved(x, y)
imgui.MouseMoved(x, y)
if not imgui.GetWantCaptureMouse() then
-- Pass event to the game
end
end
function love.mousepressed(x, y, button)
imgui.MousePressed(button)
if not imgui.GetWantCaptureMouse() then
-- Pass event to the game
end
end
function love.mousereleased(x, y, button)
imgui.MouseReleased(button)
if not imgui.GetWantCaptureMouse() then
-- Pass event to the game
end
end
function love.wheelmoved(x, y)
imgui.WheelMoved(y)
if not imgui.GetWantCaptureMouse() then
-- Pass event to the game
end
end
I already started integrating it into the game:
And I must admit that so far it's a life changer, it made it a lot easier to create debug and test tools. So the next step will be to migrate my whole scenario editor to it, I'll try to do it as soon as I can (probably before the end of July).
So, is it something some of you would be interested in? On my side I think that it would be well suited for löve, as it's really a dev oriented GUI library, it won't replace any fancy lib for a game GUI (and I'm not planning to use it for the in-game GUI, this part will be in pure Lua), but it can really help speed up the development of a project by making the edition and debug tools a lot more easier to create.
Anyway if you're interested, here's my current version of the module:
https://dl.dropboxusercontent.com/u/674 ... -imgui.zip
You'll find in this zip the module and the only modifications I've made to löve (by adding it to love.cpp and into the config file to enable/disable it), and the Windows CMake file. I would actually be quite interested to know if it builds without problems on the other platforms (ImGui is totally cross-platform, but my part has not been tested on something else than Windows). Don't hesitate if you want me to provide a compiled love.dll.
So I'll probably continue to improve it while I'll migrate my editor to it, meanwhile don't hesitate to let me know if it's something you would be interested seeing added to löve!