factoriax.playground.editor.toolbar#
Sidebar toolbar, menu bar, and status bar for the level editor.
Renders all chrome around the canvas: tool palette, block selector,
resource brush panel, machine palette, entity palette, top menu bar,
and bottom status bar. Each render function returns an RGB or RGBA image and a list of
ClickRegion objects for hit-testing.
- factoriax.playground.editor.toolbar.get_palette_items_for_machine_slot(machine_type: int, slot_idx: int) list[tuple[int, str]]#
Return every item that one slot of a machine can hold.
The part that the slot has in the recipe sets the list. A slot with the
NONEpart holds nothing, and gives an empty list. AFUELslot holds coal only. Every other part gives each item exceptEMPTY, so the editor can put any value in the slot.
- factoriax.playground.editor.toolbar.get_palette_items_for_player() list[tuple[int, str]]#
Return every item that a player inventory slot can hold.
- factoriax.playground.editor.toolbar.render_item_palette(items: list[tuple[int, str]], height: int, scroll_offset: int = 0) tuple[ndarray, list[ClickRegion]]#
Draw the item palette of the inventory view.
The palette holds an
"Items"header, and then one row for each item. A row holds the icon of the item and the name. The function draws the part of a row that falls inside the height.- Parameters:
items –
(item, name)pairs to show, in the order to draw them.height – Palette height in pixels. It is the height of the toolbar content.
scroll_offset – Number of pixels to move the list up. If the list is taller than
height, this offset selects the part to show.
- Returns:
The RGB palette, and one click region for each row that it drew. Each region holds the action
"inv_item"and the item as the parameter.- Return type:
Render the top menu bar with New / Load / Save / Play buttons.
- Parameters:
width (int :) – Full window width in pixels.
width
- Returns:
(image, regions)where image is RGB shape(MENU_BAR_HEIGHT, width, 3)and regions containsclick regions for each button.
- factoriax.playground.editor.toolbar.render_status_bar(tool: str, brush_name: str, cursor_tile: tuple[int, int] | None, level_name: str, dirty: bool, resource_info: str, width: int, layer: str = 'terrain') ndarray#
Render the bottom status bar.
- Parameters:
tool (str :) – Active tool name.
brush_name (str :) – Name of the selected block or machine.
cursor_tile (tuple[int :) –
(x, y)tile under the cursor, orNone.level_name (str :) – Current level name.
dirty (bool :) – Whether unsaved changes exist.
resource_info (str :) – Resource brush summary, for example
"Res:100".width (int :) – Full window width in pixels.
layer (str :) – Active editing layer (
"terrain","machine", or"entity").tool
brush_name
cursor_tile
None (int] |)
level_name
dirty
resource_info
width
layer – (Default value = “terrain”)
- Return type:
RGB uint8 array of shape
(STATUS_BAR_HEIGHT, width, 3).
- factoriax.playground.editor.toolbar.render_toolbar(selected_tool: str, selected_block: int, selected_machine: int, direction: int, resource_brush: object, height: int, show_resources: bool = False, selected_entity: tuple[str, int] | None = None) tuple[ndarray, list[ClickRegion]]#
Render the sidebar toolbar with all palette sections.
- Parameters:
selected_tool (str :) – Active tool name (
"paint","fill","erase").selected_block (int :) – Active
BlockTypevalue.selected_machine (int :) – Active
Machinevalue, or 0 for none.direction (int :) – Current machine placement direction.
resource_brush (object :) –
ResourceBrush.height (int :) – Available height for the toolbar in pixels.
show_resources (bool :) – Whether the resource overlay is active.
selected_entity (tuple[str :) – Active entity selection as
(kind, index)where kind is"player", orNone.selected_tool
selected_block
selected_machine
direction
resource_brush
height
show_resources – (Default value = False)
selected_entity
None (int] |) – (Default value = None)
- Returns:
(image, regions)where image is RGB shape(height, TOOLBAR_WIDTH, 3).