cp2077_extractor.radio_dj

Helpers for handling radio DJ logic and audio files.

Classes:

DJData(audio_filename_prefix, scene_file, ...)

Data for a radio DJ's sound files.

EventData(event_id, screenplay_line_id, ...)

Metadata for an event triggered by a node in a scene.

Functions:

find_graph_entry_points(graph)

Find entry points into the radio logic graph.

get_link_paths(graph)

Returns an iterator over possible paths through the various link segments.

load_events_dict(events_dict)

Load a JSON serialised mapping of node numbers to EventData.

parse_radio_scene_graph(data)

Partial parsing of scene graph.

parse_subtitles(data)

Parse subtitle data.

plot_graph(graph)

Plot the graph, in a hierarchy from start nodes down to finish nodes.

remove_intermediate_nodes(graph, audio_nodes)

Remove non-audio nodes from a networkx graph, and reconnect edges.

namedtuple DJData(audio_filename_prefix, scene_file, station_name, general_audio=False)[source]

Bases: NamedTuple

Data for a radio DJ’s sound files.

Fields
  1.  audio_filename_prefix (str) – The filenames in the game files (in base/localization/en-us/vo or base\localization\common\vo) for this advert all start with this string.

  2.  scene_file (str) – The name of the scene file in base/media/animated_billboards/scenes in the game files (with the suffix .scene.)

  3.  station_name (str) – The name of the radio station etc.

  4.  general_audio (bool) – Whether the audio is common too all game languages. False for localised audio, True for files in audio_1_general.archive.

__repr__()

Return a nicely formatted representation string

namedtuple EventData(event_id, screenplay_line_id, audio_file_suffix, subtitle_ruid)[source]

Bases: NamedTuple

Metadata for an event triggered by a node in a scene.

Fields
  1.  event_id (str) – Alias for field number 0

  2.  screenplay_line_id (int) – Identifier of the scnscreenplayDialogLine for this event (which indicates the file to play and the subtitle line).

  3.  audio_file_suffix (str) – The suffix of the audio file, to give the file to play. e.g. f_1BAAA2A79044D000.

  4.  subtitle_ruid (str) – Identifier of the subtitles for the event.

__repr__()

Return a nicely formatted representation string

find_graph_entry_points(graph)[source]

Find entry points into the radio logic graph.

That is, any lone nodes, any start nodes, and any end nodes (skipping chatter).

Parameters

graph (Graph)

Return type

tuple[list[int], list[int], list[int]]

Returns an iterator over possible paths through the various link segments.

Return type

Iterator[list[int]]

load_events_dict(events_dict)[source]

Load a JSON serialised mapping of node numbers to EventData.

Converts string keys back into integers and value tuples bacm into EventData.

Parameters

events_dict (dict[str, list[tuple[str, int, str, str]]])

Return type

dict[int, list[EventData]]

parse_radio_scene_graph(data)[source]

Partial parsing of scene graph.

Only finds dialogue events and the paths between them; no conditional logic.

Parameters

data (Union[dict[str, Any], CR2WFile]) – A REDengine .scene file, either as a JSON representation as parsed by Wolvenkit, or as a CR2WFile instance.

Return type

tuple[Graph, dict[int, list[EventData]]]

parse_subtitles(data)[source]

Parse subtitle data.

Parameters

data (Union[dict[str, Any], CR2WFile]) – A REDengine .scene file, either as a JSON representation as parsed by Wolvenkit, or as a CR2WFile instance.

Return type

dict[str, str]

plot_graph(graph)[source]

Plot the graph, in a hierarchy from start nodes down to finish nodes.

Requires matplotlib and pygraphviz.

Parameters

graph (Graph)

Return type

Figure

remove_intermediate_nodes(graph, audio_nodes)[source]

Remove non-audio nodes from a networkx graph, and reconnect edges.

Parameters