pipeworks_mud_mapper.callbacks.room_callbacks

Room editing callbacks.

This module handles:

  • Adding new rooms to the zone

  • Clearing the form for new room entry

  • Populating the form when a room is selected

  • Updating existing room properties

Component Dependencies

Inputs: - add-room-btn: Add new room button - new-room-btn: Clear form for new room - selected-room: Room selection trigger - update-room-btn: Update existing room

States: - current-zone-data: Current zone data - room-id, room-name, room-description: Form fields - room-coord-x, room-coord-y, room-coord-z: Coordinates

Outputs: - current-zone-data: Updated zone data - room-form-feedback: Validation messages - Form fields: Populated or cleared values - has-unsaved-changes: Unsaved flag - exit-checkboxes: Exit state - exit-feedback: Exit display

See also

-

Functions

add_room_to_zone(n_clicks, zone_data, room_id, ...)

Add a new room to the current zone.

clear_form_for_new_room(n_clicks)

Clear the form and deselect room when New Room button is clicked.

populate_room_form(selected_room, zone_data)

Populate the room form when a room is selected.

update_room_properties(n_clicks, selected_room, ...)

Update an existing room's properties.

update_delete_button_state(selected_room, zone_data)

Enable/disable delete button based on selection.

open_delete_confirmation(n_clicks, selected_room, ...)

Open delete confirmation dialog with details.

close_delete_confirmation(n_clicks)

Close delete confirmation modal on cancel.

confirm_delete_room(n_clicks, selected_room, zone_data)

Delete the room and store undo data.

undo_delete_room(n_clicks, undo_data, zone_data)

Restore a deleted room from undo data.

render_room_form_feedback(*payloads)

Render the latest room feedback payload from any source.

Module Contents

pipeworks_mud_mapper.callbacks.room_callbacks.add_room_to_zone(n_clicks, zone_data, room_id, room_name, room_description, coord_x, coord_y, coord_z)[source]

Add a new room to the current zone.

Validates input, creates the room data structure, and adds it to the zone. Clears the form on success.

Parameters:
  • n_clicks (int) – Click count for the Add Room button.

  • zone_data (dict | None) – Current zone data.

  • room_id (str) – Room ID input value.

  • room_name (str) – Room name input value.

  • room_description (str) – Room description input value.

  • coord_x (int) – Coordinate input values.

  • coord_y (int) – Coordinate input values.

  • coord_z (int) – Coordinate input values.

Returns:

Updated zone data, feedback, cleared form values, unsaved flag.

Return type:

tuple

Notes

  • Room ID must be unique within the zone

  • Room ID format: start with letter, alphanumeric + underscore

  • Coordinates must be valid integers

  • Name defaults to room_id if not provided

pipeworks_mud_mapper.callbacks.room_callbacks.clear_form_for_new_room(n_clicks)[source]

Clear the form and deselect room when New Room button is clicked.

Resets the properties panel to create a new room:

  • Clears all form fields

  • Deselects any selected room

  • Disables Update button

  • Enables Room ID field

  • Clears exit checkboxes

Parameters:

n_clicks (int) – Click count for the New Room button.

Returns:

Reset values for all form components.

Return type:

tuple

pipeworks_mud_mapper.callbacks.room_callbacks.populate_room_form(selected_room, zone_data)[source]

Populate the room form when a room is selected.

Fills all form fields with the selected room’s data:

  • Room ID, name, description

  • Coordinates

  • Exit checkboxes reflecting current exits

  • Exit feedback showing exit targets

Parameters:
  • selected_room (str | None) – Selected room ID, or None.

  • zone_data (dict | None) – Current zone data.

Returns:

Form field values, checkbox values, button states.

Return type:

tuple

Notes

  • When a room is selected, Room ID is disabled (can’t change ID)

  • Update button is enabled when a room is selected

  • Exit checkboxes show which directions have exits

  • Exit feedback shows “direction→target” for each exit

pipeworks_mud_mapper.callbacks.room_callbacks.update_room_properties(n_clicks, selected_room, zone_data, room_name, room_description, coord_x, coord_y, coord_z)[source]

Update an existing room’s properties.

Modifies the selected room’s name, description, and coordinates. Room ID cannot be changed.

Parameters:
  • n_clicks (int) – Click count for the Update button.

  • selected_room (str | None) – Selected room ID.

  • zone_data (dict | None) – Current zone data.

  • room_name (str) – New room name value.

  • room_description (str) – New room description value.

  • coord_x (int) – New coordinate values.

  • coord_y (int) – New coordinate values.

  • coord_z (int) – New coordinate values.

Returns:

Updated zone data, feedback alert, unsaved flag.

Return type:

tuple

pipeworks_mud_mapper.callbacks.room_callbacks.update_delete_button_state(selected_room, zone_data)[source]

Enable/disable delete button based on selection.

Delete is disabled when: - No room is selected - Selected room is the spawn room

Parameters:
  • selected_room (str | None) – Currently selected room ID.

  • zone_data (dict | None) – Current zone data.

Returns:

True if delete should be disabled.

Return type:

bool

pipeworks_mud_mapper.callbacks.room_callbacks.open_delete_confirmation(n_clicks, selected_room, zone_data)[source]

Open delete confirmation dialog with details.

Shows the room name and how many exits from other rooms will be removed.

Parameters:
  • n_clicks (int) – Click count for delete button.

  • selected_room (str | None) – Room to delete.

  • zone_data (dict | None) – Current zone data.

Returns:

(modal_open, body_content).

Return type:

tuple

pipeworks_mud_mapper.callbacks.room_callbacks.close_delete_confirmation(n_clicks)[source]

Close delete confirmation modal on cancel.

pipeworks_mud_mapper.callbacks.room_callbacks.confirm_delete_room(n_clicks, selected_room, zone_data)[source]

Delete the room and store undo data.

Parameters:
  • n_clicks (int) – Click count for confirm button.

  • selected_room (str | None) – Room to delete.

  • zone_data (dict | None) – Current zone data.

Returns:

Updated zone, cleared selection, modal closed, undo data, undo container style, unsaved flag, feedback.

Return type:

tuple

pipeworks_mud_mapper.callbacks.room_callbacks.undo_delete_room(n_clicks, undo_data, zone_data)[source]

Restore a deleted room from undo data.

Parameters:
  • n_clicks (int) – Click count for undo button.

  • undo_data (dict | None) – Stored undo data with room and exit info.

  • zone_data (dict | None) – Current zone data.

Returns:

Updated zone, cleared undo data, hidden undo container, feedback.

Return type:

tuple

pipeworks_mud_mapper.callbacks.room_callbacks.render_room_form_feedback(*payloads)[source]

Render the latest room feedback payload from any source.