dialogs package

Submodules

entity_editor_dialog module

class ui.dialogs.entity_editor_dialog.EntityEditorDialog(tile_data)

Bases: QDialog

Dialog for editing entities on a specific tile.

Allows adding, removing, importing, and editing triggers for entities.

Parameters:

tile_data (object) – The tile data object containing entities.

add_entity()

Open a dialog to add a new entity to the tile.

edit_triggers_for_selected()

Open the TriggerEditorDialog for the currently selected entity.

import_from_rulebook()

Import an entity from the rulebook using the UniversalSearchDialog.

remove_entity()

Remove the currently selected entity from the tile.

entity_preview_dialog module

class ui.dialogs.entity_preview_dialog.EntityPreviewDialog(entity: GameEntity, parent=None)

Bases: QDialog

A dialog window for previewing and editing a GameEntity’s properties.

Allows the user to view and modify the entity’s name, type, stats, and abilities. The dialog provides editable fields for each property and returns an updated GameEntity instance upon confirmation.

Parameters:
  • entity (GameEntity) – The entity to preview and edit.

  • parent (QWidget, optional) – The parent widget of the dialog (default is None).

Variables:
  • entity (GameEntity) – The entity being previewed and edited.

  • name_input (QLineEdit) – Input field for the entity’s name.

  • type_input (QComboBox) – Dropdown for selecting the entity’s type.

  • stat_inputs (dict) – Dictionary mapping stat names to their corresponding QLineEdit fields.

  • abilities_box (QTextEdit) – Text box for editing the entity’s abilities/inventory.

get_entity() GameEntity

Retrieve an updated GameEntity instance based on the current dialog inputs.

Returns:

The updated entity with values from the dialog fields.

Return type:

GameEntity

new_entity_dialog module

class ui.dialogs.new_entity_dialog.NewEntityDialog

Bases: QDialog

Dialog window for creating a new game entity.

This dialog allows the user to input a name and select a type for a new entity. Upon confirmation, a GameEntity instance is created and default triggers are attached based on the selected entity type.

entity

The created entity instance, or None if creation was cancelled.

Type:

GameEntity or None

name_input

Input field for the entity’s name.

Type:

QLineEdit

type_input

Dropdown for selecting the entity’s type.

Type:

QComboBox

accept_entity()

Accept the entity creation if the input is valid.

Creates a GameEntity with the provided name and type, attaches default triggers, and closes the dialog.

get_entity()

Get the created entity.

Returns:

The created entity instance, or None if no entity was created.

Return type:

GameEntity or None

tile_dialog module

class ui.dialogs.tile_dialog.TileDialog(tile_data, main_window=None, tile_item=None, *args, **kwargs)

Bases: QDialog

Dialog for viewing and editing the attributes of a tile.

This dialog allows users to view and modify various properties of a tile, such as terrain type, tags, user label, note, overlay color, and associated entities and triggers. It also provides undo functionality by saving the original state and pushing changes to the main window’s undo stack.

Parameters:
  • tile_data (TileData) – The TileData instance representing the tile to be edited.

  • main_window (QMainWindow, optional) – Reference to the main application window, used for undo stack integration.

  • tile_item (QGraphicsItem, optional) – The graphical item representing the tile in the scene.

  • *args – Additional positional arguments for QDialog.

  • **kwargs – Additional keyword arguments for QDialog.

tile_data

The tile data being edited.

Type:

TileData

main_window

Reference to the main window for undo stack operations.

Type:

QMainWindow or None

tile_item

The graphical item for the tile.

Type:

QGraphicsItem or None

_original_state

The original state of the tile data for undo purposes.

Type:

dict

terrain_input

Dropdown for selecting terrain type.

Type:

QComboBox

tag_checkboxes

Mapping of TileTag to QCheckBox for tag selection.

Type:

dict

label_input

Input for user label.

Type:

QLineEdit

note_input

Input for tile note.

Type:

QTextEdit

overlay_input

Input for overlay color (hex).

Type:

QLineEdit

color_button

Button to open color picker dialog.

Type:

QPushButton

entity_preview

Read-only preview of associated entities.

Type:

QLineEdit

last_updated_label

Label showing last updated timestamp.

Type:

QLabel

edit_entities()

Open the entity editor dialog for this tile.

edit_triggers()

Open the trigger editor dialog for this tile.

open_color_picker()

Open a color picker dialog to select overlay color.

save_attributes()

Save the current attributes to the tile data and push an undo command if applicable.

update_tile_overlay_preview(hex_color)

Update the overlay color preview for the tile item.

Parameters:

hex_color (str) – The hex color string to set as the overlay color.

trigger_editor_dialog module

class ui.dialogs.trigger_editor_dialog.TriggerEditorDialog(registry)

Bases: QDialog

Dialog for displaying and managing active triggers.

Allows users to view all registered triggers and remove them if desired.

remove_trigger(trigger)

Remove a trigger from the registry and unsubscribe it from the event bus.

This method also refreshes the dialog to reflect the changes.

Parameters:

trigger – The trigger object to remove.

universal_search_dialog module

class ui.dialogs.universal_search_dialog.UniversalSearchDialog(mode='monster', *args, **kwargs)

Bases: QDialog

A dialog for searching and importing entities (e.g., monsters, spells) from a rulebook.

Allows the user to select a category (such as “Monster” or “Spell”), search for entities by name, preview their details, and import them into the application.

Parameters:
  • mode (str, optional) – The initial category to search in (“monster” or “spell”). Defaults to “monster”.

  • args – Additional positional arguments passed to QDialog.

  • kwargs – Additional keyword arguments passed to QDialog.

Variables:
  • importer (RulebookImporter) – The importer used to search and import entities from the rulebook.

  • mode (str) – The current search category (“monster” or “spell”).

  • category_selector (QComboBox) – Dropdown for selecting the entity category.

  • search_input (QLineEdit) – Input field for typing search queries.

  • result_list (QListWidget) – List widget displaying search results.

  • import_btn (QPushButton) – Button to import the selected entity.

  • cancel_btn (QPushButton) – Button to cancel and close the dialog.

  • selected_object (object) – The imported and possibly converted entity selected by the user (set after successful import).

filter_list(text)

Filter the displayed list of entities based on the search input.

Parameters:

text (str) – The text to filter the list by.

get_selected_object()

Get the imported entity selected by the user.

Returns:

The imported and possibly converted entity, or None if no selection was made.

Return type:

object or None

import_selected()

Import the currently selected entity from the list.

Opens a preview dialog for the selected entity. If the user confirms, the entity is imported and stored in selected_object. Displays error dialogs if import fails or no selection is made.

load_suggestions(mode)

Load and display suggestions for the selected category.

Parameters:

mode (str) – The category to load suggestions for (“Monster” or “Spell”).

trigger_editor module