pipeworks_mud_mapper.callbacks.room_callbacks ============================================= .. py:module:: pipeworks_mud_mapper.callbacks.room_callbacks .. autoapi-nested-parse:: 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 .. seealso:: :py:obj:`-` Functions --------- .. autoapisummary:: pipeworks_mud_mapper.callbacks.room_callbacks.add_room_to_zone pipeworks_mud_mapper.callbacks.room_callbacks.clear_form_for_new_room pipeworks_mud_mapper.callbacks.room_callbacks.populate_room_form pipeworks_mud_mapper.callbacks.room_callbacks.update_room_properties pipeworks_mud_mapper.callbacks.room_callbacks.update_delete_button_state pipeworks_mud_mapper.callbacks.room_callbacks.open_delete_confirmation pipeworks_mud_mapper.callbacks.room_callbacks.close_delete_confirmation pipeworks_mud_mapper.callbacks.room_callbacks.confirm_delete_room pipeworks_mud_mapper.callbacks.room_callbacks.undo_delete_room pipeworks_mud_mapper.callbacks.room_callbacks.render_room_form_feedback Module Contents --------------- .. py:function:: add_room_to_zone(n_clicks, zone_data, room_id, room_name, room_description, coord_x, coord_y, coord_z) 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. :param n_clicks: Click count for the Add Room button. :type n_clicks: :py:class:`int` :param zone_data: Current zone data. :type zone_data: :py:class:`dict | None` :param room_id: Room ID input value. :type room_id: :py:class:`str` :param room_name: Room name input value. :type room_name: :py:class:`str` :param room_description: Room description input value. :type room_description: :py:class:`str` :param coord_x: Coordinate input values. :type coord_x: :py:class:`int` :param coord_y: Coordinate input values. :type coord_y: :py:class:`int` :param coord_z: Coordinate input values. :type coord_z: :py:class:`int` :returns: Updated zone data, feedback, cleared form values, unsaved flag. :rtype: :py:class:`tuple` .. admonition:: 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 .. py:function:: clear_form_for_new_room(n_clicks) 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 :param n_clicks: Click count for the New Room button. :type n_clicks: :py:class:`int` :returns: Reset values for all form components. :rtype: :py:class:`tuple` .. py:function:: populate_room_form(selected_room, zone_data) 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 :param selected_room: Selected room ID, or None. :type selected_room: :py:class:`str | None` :param zone_data: Current zone data. :type zone_data: :py:class:`dict | None` :returns: Form field values, checkbox values, button states. :rtype: :py:class:`tuple` .. admonition:: 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 .. py:function:: update_room_properties(n_clicks, selected_room, zone_data, room_name, room_description, coord_x, coord_y, coord_z) Update an existing room's properties. Modifies the selected room's name, description, and coordinates. Room ID cannot be changed. :param n_clicks: Click count for the Update button. :type n_clicks: :py:class:`int` :param selected_room: Selected room ID. :type selected_room: :py:class:`str | None` :param zone_data: Current zone data. :type zone_data: :py:class:`dict | None` :param room_name: New room name value. :type room_name: :py:class:`str` :param room_description: New room description value. :type room_description: :py:class:`str` :param coord_x: New coordinate values. :type coord_x: :py:class:`int` :param coord_y: New coordinate values. :type coord_y: :py:class:`int` :param coord_z: New coordinate values. :type coord_z: :py:class:`int` :returns: Updated zone data, feedback alert, unsaved flag. :rtype: :py:class:`tuple` .. py:function:: update_delete_button_state(selected_room, zone_data) Enable/disable delete button based on selection. Delete is disabled when: - No room is selected - Selected room is the spawn room :param selected_room: Currently selected room ID. :type selected_room: :py:class:`str | None` :param zone_data: Current zone data. :type zone_data: :py:class:`dict | None` :returns: True if delete should be disabled. :rtype: :py:class:`bool` .. py:function:: open_delete_confirmation(n_clicks, selected_room, zone_data) Open delete confirmation dialog with details. Shows the room name and how many exits from other rooms will be removed. :param n_clicks: Click count for delete button. :type n_clicks: :py:class:`int` :param selected_room: Room to delete. :type selected_room: :py:class:`str | None` :param zone_data: Current zone data. :type zone_data: :py:class:`dict | None` :returns: (modal_open, body_content). :rtype: :py:class:`tuple` .. py:function:: close_delete_confirmation(n_clicks) Close delete confirmation modal on cancel. .. py:function:: confirm_delete_room(n_clicks, selected_room, zone_data) Delete the room and store undo data. :param n_clicks: Click count for confirm button. :type n_clicks: :py:class:`int` :param selected_room: Room to delete. :type selected_room: :py:class:`str | None` :param zone_data: Current zone data. :type zone_data: :py:class:`dict | None` :returns: Updated zone, cleared selection, modal closed, undo data, undo container style, unsaved flag, feedback. :rtype: :py:class:`tuple` .. py:function:: undo_delete_room(n_clicks, undo_data, zone_data) Restore a deleted room from undo data. :param n_clicks: Click count for undo button. :type n_clicks: :py:class:`int` :param undo_data: Stored undo data with room and exit info. :type undo_data: :py:class:`dict | None` :param zone_data: Current zone data. :type zone_data: :py:class:`dict | None` :returns: Updated zone, cleared undo data, hidden undo container, feedback. :rtype: :py:class:`tuple` .. py:function:: render_room_form_feedback(*payloads) Render the latest room feedback payload from any source.