earwax.mapping.map_editor module

Provides the MapEditor class.

class earwax.mapping.map_editor.AnchorPoints

Bases: enum.Enum

The corners of a box points can be anchored to.

bottom_back_left = 0
bottom_back_right = 4
bottom_front_left = 2
bottom_front_right = 3
top_back_left = 5
top_back_right = 7
top_front_left = 6
top_front_right = 1
class earwax.mapping.map_editor.BoxPoint(box_id: Optional[str] = None, corner: Optional[earwax.mapping.map_editor.AnchorPoints] = None, x: int = 0, y: int = 0, z: int = 0)

Bases: earwax.mixins.DumpLoadMixin

Anchor a point to another box.

class earwax.mapping.map_editor.BoxTemplate(start: earwax.mapping.map_editor.BoxPoint = NOTHING, end: earwax.mapping.map_editor.BoxPoint = NOTHING, name: str = 'Untitled Box', surface_sound: Optional[str] = None, wall_sound: Optional[str] = None, type: earwax.mapping.box.BoxTypes = NOTHING, id: str = NOTHING, label: str = NOTHING)

Bases: earwax.mixins.DumpLoadMixin

A template for creating a box.

Instances of this class will be dumped to the map file.

get_default_label() → str

Get a unique ID.

exception earwax.mapping.map_editor.InvalidLabel

Bases: Exception

An invalid ID or label was given.

class earwax.mapping.map_editor.LevelMap(box_templates: List[earwax.mapping.map_editor.BoxTemplate] = NOTHING, coordinates: earwax.mapping.map_editor.BoxPoint = NOTHING, bearing: int = 0, name: str = 'Untitled Map', notes: str = NOTHING)

Bases: earwax.mixins.DumpLoadMixin

A representation of a earwax.BoxLevel instance.

class earwax.mapping.map_editor.MapEditor(game: Game, boxes: List[earwax.mapping.box.Box[typing.Any][Any]] = NOTHING, coordinates: earwax.point.Point = NOTHING, bearing: int = 0, current_box: Optional[earwax.mapping.box_level.CurrentBox] = None, filename: Optional[pathlib.Path] = None, context: earwax.mapping.map_editor.MapEditorContext = NOTHING)

Bases: earwax.mapping.box_level.BoxLevel

A level which can be used for editing maps.

When this level talks about a map, it talks about a earwax.mapping.map_editor.LevelMap instance.

box_menu(box: earwax.mapping.map_editor.MapEditorBox) → None

Push a menu to configure the provided box.

box_sound(template: earwax.mapping.map_editor.BoxTemplate, name: str) → Callable[[], Generator[None, None, None]]

Push an editor for setting the given sound.

Parameters:
  • template – The template to modify.
  • name – The name of the sound to modify.
box_sounds() → None

Push a menu for configuring sounds.

boxes_menu() → None

Push a menu to select a box to configure.

If there is only 1 box, it will not be shown.

complain_box() → None

Complain about there being no box.

create_box() → None

Create a box, then call box_menu().

get_default_context() → earwax.mapping.map_editor.MapEditorContext

Return a suitable context.

id_box() → Generator[None, None, None]

Change the ID for the current box.

label_box() → Generator[None, None, None]

Rename the current box.

on_move_fail(distance: float, vertical: Optional[float], bearing: int, coordinates: earwax.point.Point) → None

Tell the user their move failed.

point_menu(template: earwax.mapping.map_editor.BoxTemplate, point: earwax.mapping.map_editor.BoxPoint) → Callable[[], None]

Push a menu for configuring individual points.

points_menu() → None

Push a menu for moving the current box.

rename_box() → Generator[None, None, None]

Rename the current box.

save() → None

Save the map level.

class earwax.mapping.map_editor.MapEditorBox(game: Game, start: earwax.point.Point, end: earwax.point.Point, name: Optional[str] = None, surface_sound: Optional[pathlib.Path] = None, wall_sound: Optional[pathlib.Path] = None, type: earwax.mapping.box.BoxTypes = NOTHING, data: Optional[T] = None, stationary: bool = NOTHING, reverb: Optional[object] = NOTHING, box_level: Optional[BoxLevel] = None, id: str = NOTHING)

Bases: earwax.mapping.box.Box

A box with an ID.

get_default_id() → str

Raise an error if the id is not provided.

class earwax.mapping.map_editor.MapEditorContext(level: MapEditor, level_map: earwax.mapping.map_editor.LevelMap, template_ids: Dict[str, earwax.mapping.map_editor.BoxTemplate] = NOTHING, box_ids: Dict[str, earwax.mapping.box.Box[str][str]] = NOTHING)

Bases: object

A context to hold map information.

This class acts as an interface between a LevelMap instance, and a MapEditor instance.

add_template(template: earwax.mapping.map_editor.BoxTemplate, box: Optional[earwax.mapping.map_editor.MapEditorBox] = None) → None

Add a template to this context.

This method will add the given template to its box_template_ids dictionary.

Parameters:template – The template to add.
reload_template(template: earwax.mapping.map_editor.BoxTemplate) → None

Reload the given template.

This method recreates the box associated with the given template.

Parameters:template – The template to reload.
to_box(template: earwax.mapping.map_editor.BoxTemplate) → earwax.mapping.map_editor.MapEditorBox

Return a box from a template.

Parameters:template – The template to convert.
to_point(data: earwax.mapping.map_editor.BoxPoint) → earwax.point.Point

Return a point from the given data.

Parameters:data – The BoxPoint to load the point from.
earwax.mapping.map_editor.iskeyword()

x.__contains__(y) <==> y in x.

earwax.mapping.map_editor.valid_label(text: str) → None

Ensure the given label or ID is valid.

If it could not be used as a Python identifier for any reason, earwax.mapping.map_editor.InvalidLabel will be raised.

Parameters:text – The text to check.