Shared context for all interaction handlers. More...
#include <interaction_context.h>
Public Member Functions | |
| bool | IsValid () const |
| Check if context has required dependencies. | |
| zelda3::Room * | GetCurrentRoom () const |
| Get pointer to current room. | |
| const zelda3::Room * | GetCurrentRoomConst () const |
| Get const pointer to current room. | |
| bool | IsObjectVisibleForSelection (const zelda3::RoomObject &object) const |
| void | NotifyMutation (MutationDomain domain=MutationDomain::kUnknown) const |
| Notify that a mutation is about to happen. | |
| void | NotifyInvalidateCache (MutationDomain domain=MutationDomain::kUnknown) const |
| Notify that cache invalidation is needed. | |
| void | NotifySelectionChanged () const |
| Notify that selection has changed. | |
| void | NotifyEntityChanged () const |
| Notify that entity has changed. | |
Public Attributes | |
| gui::Canvas * | canvas = nullptr |
| Rom * | rom = nullptr |
| DungeonRoomStore * | rooms = nullptr |
| int | current_room_id = 0 |
| ObjectSelection * | selection = nullptr |
| gfx::PaletteGroup | current_palette_group |
| std::function< absl::Status(const DungeonSelectionEditPlan &, bool continuous) | on_selection_edit ) |
| std::function< void()> | on_selection_edit_finished |
| std::function< void(const absl::Status &) | on_selection_edit_error ) |
| std::function< void()> | on_mutation |
| std::function< void()> | on_invalidate_cache |
| std::function< void()> | on_selection_changed |
| std::function< void()> | on_entity_changed |
| std::function< bool(int, const zelda3::RoomObject &) | is_object_visible_for_selection ) |
| std::function< void(int target_room_id, std::optional< size_t > target_door_index, int target_tile_x, int target_tile_y)> | on_door_pair_navigation |
| MutationDomain | last_mutation_domain = MutationDomain::kUnknown |
| MutationDomain | last_invalidation_domain = MutationDomain::kUnknown |
Shared context for all interaction handlers.
This struct provides a unified way to pass dependencies and callbacks to all interaction handlers, replacing the previous pattern of multiple individual setter methods.
Usage: InteractionContext ctx; ctx.canvas = &canvas_; ctx.rom = rom_; ctx.rooms = &rooms_; ctx.current_room_id = room_id; ctx.on_mutation = [this]() { PushUndoSnapshot(); }; handler.SetContext(&ctx);
Definition at line 79 of file interaction_context.h.
|
inline |
Check if context has required dependencies.
Definition at line 132 of file interaction_context.h.
Referenced by yaze::editor::BaseEntityHandler::HasValidContext().
|
inline |
Get pointer to current room.
Definition at line 138 of file interaction_context.h.
References current_room_id, yaze::editor::dungeon_coords::IsValidRoomId(), and rooms.
Referenced by yaze::editor::InteractionCoordinator::CommitSelectionEdit(), and yaze::editor::BaseEntityHandler::GetCurrentRoom().

|
inline |
Get const pointer to current room.
Definition at line 149 of file interaction_context.h.
References current_room_id, yaze::editor::dungeon_coords::IsValidRoomId(), and rooms.
Referenced by yaze::editor::InteractionCoordinator::DescribeEntity(), yaze::editor::InteractionCoordinator::DrawMultiEntitySelectionHighlights(), yaze::editor::DoorInteractionHandler::GetEntityAtPosition(), yaze::editor::ItemInteractionHandler::GetEntityAtPosition(), yaze::editor::SpriteInteractionHandler::GetEntityAtPosition(), yaze::editor::DoorInteractionHandler::HandleClick(), yaze::editor::InteractionCoordinator::NudgeSelected(), and yaze::editor::InteractionCoordinator::SelectEntitiesInRect().

|
inline |
Definition at line 156 of file interaction_context.h.
References current_room_id, and is_object_visible_for_selection.
Referenced by yaze::editor::TileObjectHandler::GetEntityAtPosition().
|
inline |
Notify that a mutation is about to happen.
Call this before making any changes to room data. This allows the editor to capture undo snapshots.
Definition at line 167 of file interaction_context.h.
References last_mutation_domain, and on_mutation.
Referenced by yaze::editor::TileObjectHandler::CommitCandidate(), yaze::editor::InteractionCoordinator::CommitSelectionEdit(), yaze::editor::DoorInteractionHandler::DeleteAll(), yaze::editor::ItemInteractionHandler::DeleteAll(), yaze::editor::SpriteInteractionHandler::DeleteAll(), yaze::editor::DoorInteractionHandler::DeleteSelected(), yaze::editor::ItemInteractionHandler::DeleteSelected(), yaze::editor::SpriteInteractionHandler::DeleteSelected(), yaze::editor::DoorInteractionHandler::HandleRelease(), yaze::editor::ItemInteractionHandler::HandleRelease(), yaze::editor::TileObjectHandler::MoveObjects(), yaze::editor::ItemInteractionHandler::MutateItemType(), yaze::editor::ItemInteractionHandler::NudgeSelected(), yaze::editor::DoorInteractionHandler::NudgeSelected(), yaze::editor::DoorInteractionHandler::PlaceDoorAtSnappedPosition(), yaze::editor::ItemInteractionHandler::PlaceItemAtPosition(), yaze::editor::SpriteInteractionHandler::PlaceSpriteAtPosition(), yaze::editor::DungeonObjectInteraction::UpdateCollisionPainting(), yaze::editor::DoorInteractionHandler::UpdateDoor(), yaze::editor::ItemInteractionHandler::UpdateItem(), and yaze::editor::SpriteInteractionHandler::UpdateSprite().
|
inline |
Notify that cache invalidation is needed.
Call this after changes that require re-rendering.
Definition at line 178 of file interaction_context.h.
References last_invalidation_domain, and on_invalidate_cache.
Referenced by yaze::editor::InteractionCoordinator::CommitSelectionEdit(), yaze::editor::DoorInteractionHandler::DeleteAll(), yaze::editor::ItemInteractionHandler::DeleteAll(), yaze::editor::SpriteInteractionHandler::DeleteAll(), yaze::editor::DoorInteractionHandler::DeleteSelected(), yaze::editor::ItemInteractionHandler::DeleteSelected(), yaze::editor::SpriteInteractionHandler::DeleteSelected(), yaze::editor::DoorInteractionHandler::HandleRelease(), yaze::editor::ItemInteractionHandler::HandleRelease(), yaze::editor::TileObjectHandler::HandleRelease(), yaze::editor::ItemInteractionHandler::MutateItemType(), yaze::editor::TileObjectHandler::NotifyChange(), yaze::editor::ItemInteractionHandler::NudgeSelected(), yaze::editor::DoorInteractionHandler::NudgeSelected(), yaze::editor::DoorInteractionHandler::PlaceDoorAtSnappedPosition(), yaze::editor::ItemInteractionHandler::PlaceItemAtPosition(), yaze::editor::SpriteInteractionHandler::PlaceSpriteAtPosition(), yaze::editor::DungeonObjectInteraction::UpdateCollisionPainting(), yaze::editor::DoorInteractionHandler::UpdateDoor(), yaze::editor::ItemInteractionHandler::UpdateItem(), and yaze::editor::SpriteInteractionHandler::UpdateSprite().
|
inline |
Notify that selection has changed.
Definition at line 188 of file interaction_context.h.
References on_selection_changed.
|
inline |
Notify that entity has changed.
Definition at line 196 of file interaction_context.h.
References on_entity_changed.
Referenced by yaze::editor::InteractionCoordinator::ClearEntitySelection(), yaze::editor::InteractionCoordinator::CommitSelectionEdit(), yaze::editor::DoorInteractionHandler::DeleteAll(), yaze::editor::ItemInteractionHandler::DeleteAll(), yaze::editor::SpriteInteractionHandler::DeleteAll(), yaze::editor::DoorInteractionHandler::DeleteSelected(), yaze::editor::ItemInteractionHandler::DeleteSelected(), yaze::editor::SpriteInteractionHandler::DeleteSelected(), yaze::editor::InteractionCoordinator::HandleClick(), yaze::editor::ItemInteractionHandler::HandleRelease(), yaze::editor::ItemInteractionHandler::MutateItemType(), yaze::editor::ItemInteractionHandler::NudgeSelected(), yaze::editor::DoorInteractionHandler::NudgeSelected(), yaze::editor::DoorInteractionHandler::SelectDoor(), yaze::editor::InteractionCoordinator::SelectEntitiesInRect(), yaze::editor::ItemInteractionHandler::SelectItem(), yaze::editor::SpriteInteractionHandler::SelectSprite(), yaze::editor::InteractionCoordinator::SetSelectedEntities(), yaze::editor::DoorInteractionHandler::UpdateDoor(), yaze::editor::InteractionCoordinator::UpdateEntitySelection(), yaze::editor::ItemInteractionHandler::UpdateItem(), and yaze::editor::SpriteInteractionHandler::UpdateSprite().
| gui::Canvas* yaze::editor::InteractionContext::canvas = nullptr |
Definition at line 81 of file interaction_context.h.
Referenced by yaze::editor::ItemInteractionHandler::DrawGhostPreview(), yaze::editor::SpriteInteractionHandler::DrawGhostPreview(), yaze::editor::InteractionCoordinator::DrawMultiEntitySelectionHighlights(), yaze::editor::TileObjectHandler::DrawSelectionHighlight(), yaze::editor::TileObjectHandler::DrawSmartGuides(), yaze::editor::DungeonObjectInteraction::DungeonObjectInteraction(), yaze::editor::BaseEntityHandler::GetCanvasTransform(), yaze::editor::BaseEntityHandler::GetCanvasZeroPoint(), yaze::editor::BaseEntityHandler::GetPointerScreenPosition(), yaze::editor::TileObjectHandler::HandleMarqueeSelection(), IsValid(), yaze::editor::DungeonObjectInteraction::SetContext(), and yaze::editor::InteractionCoordinator::UpdateSelectionCycleHudPreview().
| Rom* yaze::editor::InteractionContext::rom = nullptr |
Definition at line 82 of file interaction_context.h.
Referenced by yaze::editor::DungeonObjectInteraction::SetRom().
| DungeonRoomStore* yaze::editor::InteractionContext::rooms = nullptr |
Definition at line 83 of file interaction_context.h.
Referenced by yaze::editor::DoorInteractionHandler::BuildPairBadgeOverlay(), GetCurrentRoom(), GetCurrentRoomConst(), yaze::editor::TileObjectHandler::GetRoom(), and IsValid().
| int yaze::editor::InteractionContext::current_room_id = 0 |
Definition at line 84 of file interaction_context.h.
Referenced by yaze::editor::DoorInteractionHandler::BuildPairBadgeOverlay(), yaze::editor::TileObjectHandler::CommitCandidate(), yaze::editor::DungeonEditorV2::ConfigureViewerUndoHooks(), yaze::editor::TileObjectHandler::DrawGhostPreview(), GetCurrentRoom(), GetCurrentRoomConst(), yaze::editor::TileObjectHandler::GetEntityAtPosition(), yaze::editor::TileObjectHandler::GetPlacementGhostCapacityState(), yaze::editor::TileObjectHandler::HandleClick(), yaze::editor::TileObjectHandler::HandleDrag(), yaze::editor::TileObjectHandler::HandleMarqueeSelection(), yaze::editor::TileObjectHandler::HandleMouseWheel(), yaze::editor::DoorEditorContent::HasMatchingViewer(), yaze::editor::ItemEditorPanel::HasMatchingViewer(), IsObjectVisibleForSelection(), yaze::editor::TileObjectHandler::MoveObjects(), yaze::editor::DoorInteractionHandler::PreflightDoors(), yaze::editor::ItemInteractionHandler::PreflightPlacement(), and yaze::editor::SpriteInteractionHandler::PreflightSprites().
| ObjectSelection* yaze::editor::InteractionContext::selection = nullptr |
Definition at line 85 of file interaction_context.h.
Referenced by yaze::editor::InteractionCoordinator::ApplySelection(), yaze::editor::TileObjectHandler::BeginMarqueeSelection(), yaze::editor::TileObjectHandler::CommitCandidate(), yaze::editor::InteractionCoordinator::CommitSelectionEdit(), yaze::editor::TileObjectHandler::DrawSelectionHighlight(), yaze::editor::TileObjectHandler::DrawSmartGuides(), yaze::editor::DungeonObjectInteraction::DungeonObjectInteraction(), yaze::editor::InteractionCoordinator::FindSelectedCycleIndex(), yaze::editor::TileObjectHandler::GetEntityAtPosition(), yaze::editor::InteractionCoordinator::HandleClick(), yaze::editor::TileObjectHandler::HandleClick(), yaze::editor::InteractionCoordinator::HandleDrag(), yaze::editor::TileObjectHandler::HandleDrag(), yaze::editor::InteractionCoordinator::HandleEntityGroupDrag(), yaze::editor::TileObjectHandler::HandleMarqueeSelection(), yaze::editor::TileObjectHandler::HandleMouseWheel(), yaze::editor::InteractionCoordinator::HasGroupDragSelection(), yaze::editor::InteractionCoordinator::IsSelectionHitSelected(), yaze::editor::InteractionCoordinator::NudgeSelected(), yaze::editor::InteractionCoordinator::SelectEntity(), and yaze::editor::DungeonObjectInteraction::SetContext().
| gfx::PaletteGroup yaze::editor::InteractionContext::current_palette_group |
Definition at line 88 of file interaction_context.h.
Referenced by yaze::editor::DungeonObjectInteraction::SetCurrentPaletteGroup().
| std::function<absl::Status(const DungeonSelectionEditPlan&, bool continuous) yaze::editor::InteractionContext::on_selection_edit) |
Definition at line 94 of file interaction_context.h.
Referenced by yaze::editor::InteractionCoordinator::CommitSelectionEdit().
| std::function<void()> yaze::editor::InteractionContext::on_selection_edit_finished |
Definition at line 95 of file interaction_context.h.
Referenced by yaze::editor::InteractionCoordinator::FinishEntityGroupDrag().
| std::function<void(const absl::Status&) yaze::editor::InteractionContext::on_selection_edit_error) |
Definition at line 96 of file interaction_context.h.
Referenced by yaze::editor::InteractionCoordinator::ReportSelectionEditStatus().
| std::function<void()> yaze::editor::InteractionContext::on_mutation |
Definition at line 99 of file interaction_context.h.
Referenced by NotifyMutation(), and yaze::editor::DungeonObjectInteraction::SetMutationCallback().
| std::function<void()> yaze::editor::InteractionContext::on_invalidate_cache |
Definition at line 102 of file interaction_context.h.
Referenced by NotifyInvalidateCache(), and yaze::editor::DungeonObjectInteraction::SetCacheInvalidationCallback().
| std::function<void()> yaze::editor::InteractionContext::on_selection_changed |
Definition at line 105 of file interaction_context.h.
Referenced by NotifySelectionChanged().
| std::function<void()> yaze::editor::InteractionContext::on_entity_changed |
Definition at line 108 of file interaction_context.h.
Referenced by NotifyEntityChanged(), and yaze::editor::DungeonObjectInteraction::SetEntityChangedCallback().
| std::function<bool(int, const zelda3::RoomObject&) yaze::editor::InteractionContext::is_object_visible_for_selection) |
Definition at line 115 of file interaction_context.h.
Referenced by IsObjectVisibleForSelection(), and yaze::editor::DungeonObjectInteraction::SetObjectSelectionVisibilityPredicate().
| std::function<void(int target_room_id, std::optional<size_t> target_door_index, int target_tile_x, int target_tile_y)> yaze::editor::InteractionContext::on_door_pair_navigation |
|
mutable |
Definition at line 126 of file interaction_context.h.
Referenced by yaze::editor::DungeonObjectInteraction::last_mutation_domain(), and NotifyMutation().
|
mutable |
Definition at line 127 of file interaction_context.h.
Referenced by yaze::editor::DungeonObjectInteraction::last_invalidation_domain(), and NotifyInvalidateCache().