UI Examples
This page contains examples for creating UI for your mod using the built-in ImGui library.
ImGui.SetNextWindowPos(100, 500, ImGuiCond.FirstUseEver) -- set window position x, y
ImGui.SetNextWindowSize(300, 600, ImGuiCond.Appearing) -- set window size w, h
if ImGui.Begin("Unique Window Name") then
ImGui.Text("Hello World")
-- more window contents here
end
ImGui.End()
if ImGui.Button("Pop Button", 120, 0) then
ImGui.OpenPopup("Delete?")
end
if ImGui.BeginPopupModal("Delete?", true, ImGuiWindowFlags.AlwaysAutoResize) then
ImGui.Text("This is a popup")
if ImGui.Button("Close") then ImGui.CloseCurrentPopup() end
ImGui.EndPopup()
end
local DropdownOptions = {"1", "2", "3", "4", "5"}
local DropdownSelected = "1"
if ImGui.BeginCombo("##My Combo Box", DropdownSelected) then -- Remove the ## if you'd like for the title to display above combo box
for i, option in ipairs(DropdownSelected) do
if ImGui.Selectable(option, (option == DropdownSelected)) then
DropdownSelected = option
ImGui.SetItemDefaultFocus()
end
end
ImGui.EndCombo()
end
if ImGui.Button("Click Me!", 100, 20) then -- Label, width, height - Use -1 as width for button to span available horizontal space
-- do stuff here when button is clicked
end
registerForEvent("onUpdate", function()
if btn then
print("You pressed me!")
emd
end)
registerForEvent("onDraw", function()
btn = ImGui.Button("Click me I'm a Sexy Button", 250, 25)
end)
Last modified 1yr ago