ImGui
Bindings for ImGui directly inside lua.
ImGui.Begin(id)
ImGui.Begin(id)id- The id of the window
Begins a new ImGui Window with the given id.
Example:
function render()
ImGui.Begin("mymenu")
ImGui.Text("some text")
ImGui.End()
end
engine.addEventListener("render", render)ImGui.Begin(id, windowFlags)
ImGui.Begin(id, windowFlags)id- The id of the windowwindowFlags- The flags for the window
Begins a new ImGui Window with the given id and additional window flags. For a list of available windowflags, check here.
Example:
ImGui.End()
ImGui.End()Ends a ImGui Window.
Example:
ImGui.PushStyleColor(colorIndex, color)
ImGui.PushStyleColor(colorIndex, color)Pushes a style color identified by the colorIndex. For available indices check here. All following rendered elements targeted by the index will have this color applied to them.
For each time you push a style color, you WILL have to use ImGui.PopStyleColor after you're doing using the given color for elements.
Example:
ImGui.PopStyleColor(count)
ImGui.PopStyleColor(count)count- How many style colors to pop of the color stack
Pops a number of style colors of the color stack.
Example:
ImGui.PushStyleVarFloat(varIndex, floatValue)
ImGui.PushStyleVarFloat(varIndex, floatValue)varIndex- The variable index as a ImGuiStyleVarfloatValue- The value to set the var to
Pushes a style var identified by the varIndex. For available indices check here. All following rendered elements targeted by the index will have this style variable applied to them.
For each time you push a style variable, you WILL have to use ImGui.PopStyleVar after you're doing using the given style variable for elements.
Example:
ImGui.PushStyleVarVec2(varIndex, vec2Value)
ImGui.PushStyleVarVec2(varIndex, vec2Value)varIndex- The variable index as a ImGuiStyleVarvec2Value- The Vec2 value to set the var to
Pushes a style var identified by the varIndex. For available indices check here. All following rendered elements targeted by the index will have this style variable applied to them.
For each time you push a style variable, you WILL have to use ImGui.PopStyleVar after you're doing using the given style variable for elements.
Example:
ImGui.PopStyleVar(count)
ImGui.PopStyleVar(count)count- How many style variables to pop of the style variable stack
Pops a number of style variable of the style variable stack.
Example:
ImGui.PushFont(name, size)
ImGui.PushFont(name, size)name- The name of the fontsize- The size in pixels of the font
Available Fonts:
Verdana
VerdanaBold
Impact
Beyblade
Dameron
RobotoMono-Light
Available Font sizes:
12, 14, 16, 18, 24, 32, 36, 48, 60
Pushes a font. All following elements containing text will have this font applied until it is popped with ImGui.PopFont
Make sure to use ImGui.PopFont after you're done using the font. For one PushFont you want one PopFont.
Example:
ImGui.PopFont()
ImGui.PopFont()Pops a font.
Example:
ImGui.GetTexture(name)
ImGui.GetTexture(name)name- The name of the texture.
Returns a pointer to a IDirect3DTexture9. This can be directly used wherever the ImGui lua bindings expect a texture. For example ImGui.Image
Custom Textures
Custom Textures can be loaded the following way:
Locate the directory C:\Users\
your user\AnvilCreate a new directory called texture_assets
You can store any images of format
.png,.jpgor.jpegin this folderThe name of each file will be the key which you pass to ImGui.GetTexture
Custom Textures Example Scenario
Suppose you put a file called icon.png into the texture_assets directory. To get access to this image as a texture that you can pass to other ImGui functions, do the following:
Full Example:
ImGui.BeginMenuBar()
ImGui.BeginMenuBar()Begin a menu bar.
You will have to pass the ImGuiWindowFlags.MenuBar flag to the ImGui.Begin
in order to see the menubar!
ImGui.EndMenuBar()
ImGui.EndMenuBar()Ends a menu bar.
ImGui.BeginMenu(menuName)
ImGui.BeginMenu(menuName)menuName- The name of the menu.
Begin a menu.
ImGui.EndMenu()
ImGui.EndMenu()End a menu bar.
ImGui.MenuItem(label, shortCut, selected)
ImGui.MenuItem(label, shortCut, selected)label- The label of the menu itemshortCut- Shortcut.selected- If the menu item is selected.
Example:
ImGui.SameLine(offsetFromStart, spacing)
ImGui.SameLine(offsetFromStart, spacing)Use this to have the next ImGui Element on the same "line" meaning vertical position.
offsetFromStart- align to specified x positionspacing- horizontal spacing amount in pixels
Example:
ImGui.Image(texture, size)
ImGui.Image(texture, size)Renders a texture with the given size.
texture- The texture to use. Use ImGui.GetTexture to obtain a texture.size- The size of the image as a Vec2
Example:
ImGui.Text(text)
ImGui.Text(text)Renders the given text.
text- The text to render
Example:
ImGui.calcTextSize(text)
ImGui.calcTextSize(text)Returns the size of the given text in the context of the currently used font as a Vec2.
text- The text
Example:
ImGui.Checkbox(text, state)
ImGui.Checkbox(text, state)Renders a checkbox with the given text as label. Returns a tuple of two boolean values.
The first boolean indicates if the checkbox was clicked this frame. The second boolean indicates the current state of the checkbox.
text- The labelstate- The current state of the checkbox
Example:
ImGui.Button(text, [size])
ImGui.Button(text, [size])Renders a checkbox with the given text as label. Returns a tuple of two boolean values.
The first boolean indicates if the checkbox was clicked this frame. The second boolean indicates the current state of the checkbox.
label- The labelsize- The size of the button. Optional.
Example:
ImGui.GetRandomColor([alphaFloat])
ImGui.GetRandomColor([alphaFloat])Returns a random color.
alphaFloat- The alpha value of the color, expects 0 - 1. Optional.
Example:
Last updated