factoriax.playground.editor.dialogs#
The dialogs of the level editor.
There are three dialogs. The new level dialog asks for the size and the name. The file dialog opens and saves a level. The machine inspector shows the contents of one machine, and lets the user change them.
Each dialog draws an RGBA overlay at the center of the screen, and reads its own keyboard events.
The file dialog lists the files of the levels/ directory. It is therefore
free of tkinter, and free of the file picker of the operating system.
- class factoriax.playground.editor.dialogs.FileDialog(mode: str = 'save', filename_text: str = '', files: list[str] = <factory>, selected_index: int = -1, scroll_offset: int = 0)#
Dialog that asks for a file name, to save a level or to open one.
The dialog holds a field for the name, and a list of the
.jsonfiles of thelevels/directory. W and S move through the list. Enter accepts the name, and Escape leaves the dialog.- get_path() Path | None#
Return the path of the file that the user selected.
The function adds the
.jsonsuffix to a name without one. If thelevels/directory is absent, the function makes it.- Returns:
Path in the
levels/directory. It isNonewhen the name field is empty.- Return type:
Path or None
- class factoriax.playground.editor.dialogs.MachineInspectorDialog(tile_x: int, tile_y: int, machine_type: int, inv_items: ndarray, inv_counts: ndarray, focused_slot: int = 0, editing_slot: int = -1, editing_count: bool = False, count_text: str = '', picker_scroll: int = 0)#
Dialog that shows the contents of one machine, and edits them.
The dialog holds one row for each slot. A row gives the part that the slot has in the recipe, the item, and the count. A and D move through the rows. Enter opens a picker for the item, and then takes a count.
The dialog edits its own copy of the rows. When the dialog closes,
factoriax.playground.editor.mainwrites that copy back. The dialog therefore does not reach into the editor state.- tile_x, tile_y
Tile of the machine.
- inv_items, inv_counts
Item and count of each row.
- editing_slot#
Index of the row that the picker is open for. It is -1 while the picker is closed.
- Type:
- class factoriax.playground.editor.dialogs.NewLevelDialog(width_text: str = '15', height_text: str = '15', name_text: str = 'untitled', active_field: int = 0)#
Dialog that asks for the size and the name of a new level.
handle_event()returns"ok"when the user accepts the dialog, and"cancel"when the user leaves it. It returnsNonewhile the dialog is open.- width_text, height_text
Size fields, as the text that the user typed.
- get_values() tuple[int, int, str]#
Return the size and the name that the user typed.
An empty field, or a field that holds no number, gives the default value of that field.
- class factoriax.playground.editor.dialogs.NumberInputDialog(label: str = 'Value:', text: str = '', min_value: int = 0, max_value: int = 100, default: int = 0)#
Dialog that asks for one number.
The dialog takes a digit and a backspace. Enter accepts the value, and Escape leaves the dialog.
- min_value, max_value
Lowest and highest value that
get_value()returns.
- default#
Value that
get_value()returns for an empty field.- Type:
- get_value() int#
Return the number that the user typed.
An empty field gives
default. A value outside the limits moves to the nearest limit.- Returns:
A value from
min_valuetomax_value.- Return type: