Module Gui
Description
Module Status: Work in progress.
Usage:
local Gui = require('__eradicators-library__/erlib/factorio/Gui')()
Generic
destroy([elm]) | Destroys a gui element or does nothing. |
find_child(parent, name) | Recursively find a named element. |
get_ancestors(elm) | Gets all elements above an element. |
Screen
move(elm, w, h[, x=0.5[, y=0.5]]) | Moves a LuaGuiElement inside LuaGui.screen. |
create_title_bar(opts) | Creates a draggable title-bar with close button. |
set_minimize_button_sprite(elm, state) | Updates the sprite on a min-max button. |
AutoStyler
set_slider_auto_tooltip(elm, postfix) | Automatically updates this sliders tooltip when it's value changes. |
Constructor
constructioneer([theme], layout, root, return_last_first) | Makes Guis. |
RuntimeTheme | Constructioneer theme. |
GuiLayout | Constructioneer layout. |
ElementSpec | Constructioneer Element. |
RuntimeStyle | Constructioneer style. |
Generic
- destroy([elm])
-
Destroys a gui element or does nothing.
Parameters:
- elm LuaGuiElement (optional)
- find_child(parent, name)
-
Recursively find a named element. Depth-first search.
Parameters:
- parent LuaGuiElement The element to start searching at.
- name string
Returns:
-
nil or LuaGuiElement
The first element with a matching name, if any.
- get_ancestors(elm)
-
Gets all elements above an element.
Most useful to get the anchor element or the name of the root.
Parameters:
- elm LuaGuiElement
Returns:
-
DenseArray
Starts at the root element (screen, relative, etc.) and
ends at the input element.
Screen
- move(elm, w, h[, x=0.5[, y=0.5]])
-
Moves a LuaGuiElement inside LuaGui.screen.
Parameters:
- elm LuaGuiElement
- w NaturalNumber Width
- h NaturalNumber Height
- x UnitInterval Relative center position on the x axis. (default 0.5)
- y UnitInterval (default 0.5)
Returns:
-
LuaGuiElement
The given element.
- create_title_bar(opts)
-
Creates a draggable title-bar with close button.
Mimics vanilla style in accordance with
Raiguards Style Guide
Parameters:
- opts
- anchor LuaGuiElement The LuaGuiElement that the title bar will be created in.
- caption LocalisedString or string
- drag_target LuaGuiElement (optional)
- close_button_name string (optional)
- minimize_button_name string (optional)
Returns:
-
table
A table containing the created LuaGuiElements.
{title_flow=, title_label=, drag_widget=, minimize_button=, close_button=}
- opts
- set_minimize_button_sprite(elm, state)
-
Updates the sprite on a min-max button.
Parameters:
- elm
LuaGuiElement
This must be a
sprite-button
! - state boolean True is a downwards arrow, false is a rightwards arrow.
- elm
LuaGuiElement
This must be a
AutoStyler
These functions will silently do nothing unless activated.
Usage:
-- settings.lua erlib_enable_plugin('gui-auto-styler')
- set_slider_auto_tooltip(elm, postfix)
-
Automatically updates this sliders tooltip when it's value changes.
Parameters:
- elm LuaGuiElement
- postfix LocalisedString or string
Returns:
-
LuaGuiElement
The given element.
Constructor
- constructioneer([theme], layout, root, return_last_first)
-
Makes Guis.
Curried function. Unsupported draft.
Parameters:
- theme RuntimeTheme (optional)
- layout GuiLayout
- root LuaGuiElement
- return_last_first boolean
Returns:
Usage:
Gui.constructioneer(theme)(layout)(root, return_last_first)
- RuntimeTheme
-
Constructioneer theme.
Fields:
- type string A LuaGuiElement type.
- ... Additional LuaGuiElement.add arguments. (optional)
- GuiLayout
-
Constructioneer layout.
Recursively specifies a Guis layout. Each ElementSpec creates a new
relative root element for the subsequent GuiLayouts.
Fields:
- ... DenseArray An array of ElementSpec or GuiLayout.
- ElementSpec
-
Constructioneer Element.
Fields:
- RuntimeStyle
- Constructioneer style. A table of LuaStyle (key -> value) pairs.