trigger_editor package
Submodules
trigger_editor.editor_dialog module
- class ui.dialogs.trigger_editor.editor_dialog.TriggerEditorDialog(tile_data_or_entity, *args, **kwargs)
Bases:
QDialog
Dialog window for editing triggers associated with a tile or entity. This dialog provides a user interface for viewing, creating, and editing triggers. It contains a stack widget for trigger editing and a button to add new triggers. :param tile_data_or_entity: The tile data or entity to associate with the trigger editor context. :type tile_data_or_entity: object :param *args: Additional positional arguments passed to the QDialog constructor. :type *args: tuple :param **kwargs: Additional keyword arguments passed to the QDialog constructor. :type **kwargs: dict
- editor_stack
The stack widget managing the trigger list and property editor views.
- Type:
- add_trigger_btn
Button to create a new trigger.
- Type:
QPushButton
- create_new_trigger()
Clears the property editor and switches to the trigger creation view.
- create_new_trigger()
trigger_editor.editor_stack module
- class ui.dialogs.trigger_editor.editor_stack.TriggerEditorStack(parent=None)
Bases:
QStackedWidget
A stacked widget that manages different views for editing triggers.
This widget allows switching between a list view, a property editor, and a graph view for editing triggers associated with a tile or game entity.
- set_context(obj)
Set the currently selected tile or entity whose triggers are being edited.
- Parameters:
obj (object) – The context object (TileData or GameEntity).
- show_graph_view()
Show the trigger graph view.
- show_list_view()
Show the trigger list view.
- show_property_view(trigger=None)
Show the trigger property editor view.
- Parameters:
trigger (object or None) – The trigger to edit, or None to clear selection.
trigger_editor.graph_view module
- class ui.dialogs.trigger_editor.graph_view.TriggerGraphView(context=None)
Bases:
QWidget
A QWidget that displays a graph of trigger nodes using QGraphicsView and QGraphicsScene. Nodes are laid out horizontally and arrows are drawn to represent trigger connections.
- add_trigger_node(trigger, x, y)
Add a trigger node to the scene at the specified position.
- Parameters:
trigger – The trigger object to represent.
x – The x-coordinate for the node.
y – The y-coordinate for the node.
- build_graph(context)
Build the graph layout from the context’s triggers.
- Parameters:
context – The context object containing triggers.
- draw_arrow(start_item, end_item)
Draw an arrow (line) from the output anchor of one node to the input anchor of another.
- Parameters:
start_item – The starting TriggerNodeItem.
end_item – The ending TriggerNodeItem.
- manage_graph_building_and_arrows(context)
Draw arrows between trigger nodes based on their connections.
- Parameters:
context – The context object containing triggers.
- set_context(context)
Set a new context and rebuild the graph.
- Parameters:
context – The new context object containing triggers.
trigger_editor.list_view module
- class ui.dialogs.trigger_editor.list_view.TriggerListView
Bases:
QWidget
A QWidget subclass that displays a list of triggers associated with a given object.
This view provides a label and a QListWidget to show the triggers attached to a tile or entity. The context (object) can be set via
set_context()
, which will populate the list with trigger labels.- set_context(obj)
Set the context object and update the trigger list.
- Parameters:
obj (object) – The object whose
triggers
attribute (an iterable of objects with alabel
attribute) will be displayed in the list widget.
trigger_editor.property_editor module
- class ui.dialogs.trigger_editor.property_editor.TriggerPropertyEditor
Bases:
QWidget
Widget for editing the properties of a Trigger object.
Allows selection and configuration of event type, condition, reaction, and next trigger, as well as saving changes to the context.
- build_condition_fields(condition_cls)
Build and display input fields for the parameters of the given condition class.
- Parameters:
condition_cls (type) – The condition class to inspect.
- build_reaction_fields(reaction_cls)
Build and display input fields for the parameters of the given reaction class.
- Parameters:
reaction_cls (type) – The reaction class to inspect.
- clear_inputs()
Clear all input fields and reset to defaults.
- on_reaction_changed(reaction_name)
Update the reaction parameter fields based on the selected reaction.
- Parameters:
reaction_name (str) – Name of the selected reaction class.
- refresh_next_trigger_choices()
Refresh the list of available next triggers in the dropdown.
- save_trigger()
Save the current trigger configuration to the context.
- set_context(context)
Set the context object that contains triggers.
- Parameters:
context (object) – The context object (should have a ‘triggers’ attribute).
- set_defaults()
Reset the editor to default state, clearing all fields and rebuilding parameter inputs.
- set_trigger(trigger=None)
Set the trigger to be edited.
- Parameters:
trigger (Trigger or None) – The Trigger object to edit, or None to clear.
- update_condition_fields(name)
Update the condition parameter fields based on the selected condition.
- Parameters:
name (str) – Name of the selected condition class.
trigger_editor.trigger_node module
- class ui.dialogs.trigger_editor.trigger_node.TriggerNodeItem(trigger, x, y, width=180, height=100)
Bases:
QGraphicsItemGroup
A QGraphicsItemGroup representing a trigger node in the editor.
Displays a colored box with the trigger’s event type, condition, and reaction.
- Parameters:
trigger (object) – The trigger object to represent.
x (float) – The x position of the node.
y (float) – The y position of the node.
width (float) – The width of the node box.
height (float) – The height of the node box.
- get_input_anchor() QPointF
Get the input anchor point in scene coordinates.
- Returns:
The input anchor point (left middle of the node).
- Return type:
QPointF
- get_output_anchor() QPointF
Get the output anchor point in scene coordinates.
- Returns:
The output anchor point (right middle of the node).
- Return type:
QPointF
- update_label()
Update the label text to reflect the current trigger’s event, condition, and reaction.