Skip to content

hkb_editor.gui.dialogs.state_graph_viewer_dialog

CachedLayout dataclass

Bases: HorizontalGraphLayout

A layout that simply replays pre-computed node positions.

state_graph_viewer_dialog

Bases: DpgItem

Draw a state machine's transitions as a graph.

Transitions are derived from event names of the form <source>_to_<target>. The node layout is computed with networkx and then handed to the graph widget through a :class:CachedLayout.

Parameters:

Name Type Description Default
behavior HavokBehavior

Behavior to read state machines from.

required
statemachine_id str or None

Object ID of the state machine to show first; falls back to any.

required
jump_callback callable

Called as callback(tag, record, user_data) from the context menu.

None
title str

Window title bar label.

'State Graph Viewer'
tag int or str

Explicit tag; auto-generated if None.

None
user_data any

Passed through to jump_callback.

None

statemachine property

statemachine

The state machine currently on display.

refresh

refresh() -> None

Rebuild and re-layout the graph from the current selection.

build_state_graph

build_state_graph(
    behavior: HavokBehavior, statemachine: HkbRecord
) -> nx.DiGraph

Build the state transition graph of a state machine.

Nodes are state names carrying record and state_id; edges come from events named <source>_to_<target> and carry event and the event's idx.

get_statemachines

get_statemachines(
    behavior: HavokBehavior,
) -> dict[str, HkbRecord]

All hkbStateMachine records, keyed by object ID.

Ko-fi donations