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. | |
| void | NotifyMutation () const |
| Notify that a mutation is about to happen. | |
| void | NotifyInvalidateCache () 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 |
| std::array< zelda3::Room, dungeon_coords::kRoomCount > * | rooms = nullptr |
| int | current_room_id = 0 |
| gfx::PaletteGroup | current_palette_group |
| std::function< void()> | on_mutation |
| std::function< void()> | on_invalidate_cache |
| std::function< void()> | on_selection_changed |
| std::function< void()> | on_entity_changed |
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 32 of file interaction_context.h.
|
inline |
Check if context has required dependencies.
Definition at line 58 of file interaction_context.h.
Referenced by yaze::editor::BaseEntityHandler::HasValidContext().
|
inline |
Get pointer to current room.
Definition at line 64 of file interaction_context.h.
References current_room_id, yaze::editor::dungeon_coords::IsValidRoomId(), and rooms.
Referenced by yaze::editor::BaseEntityHandler::GetCurrentRoom().

|
inline |
Get const pointer to current room.
Definition at line 75 of file interaction_context.h.
References current_room_id, yaze::editor::dungeon_coords::IsValidRoomId(), and rooms.
Referenced by yaze::editor::DoorInteractionHandler::GetEntityAtPosition(), yaze::editor::ItemInteractionHandler::GetEntityAtPosition(), and yaze::editor::SpriteInteractionHandler::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 88 of file interaction_context.h.
References on_mutation.
Referenced by yaze::editor::DungeonObjectInteraction::BringSelectedForward(), yaze::editor::DoorInteractionHandler::DeleteSelected(), yaze::editor::ItemInteractionHandler::DeleteSelected(), yaze::editor::SpriteInteractionHandler::DeleteSelected(), yaze::editor::DungeonObjectInteraction::HandleCanvasMouseInput(), yaze::editor::DungeonObjectInteraction::HandleDeleteSelected(), yaze::editor::DungeonObjectInteraction::HandleEntityDrag(), yaze::editor::DungeonObjectInteraction::HandlePasteObjects(), yaze::editor::DoorInteractionHandler::HandleRelease(), yaze::editor::ItemInteractionHandler::HandleRelease(), yaze::editor::SpriteInteractionHandler::HandleRelease(), yaze::editor::DungeonObjectInteraction::HandleScrollWheelResize(), yaze::editor::DungeonObjectInteraction::PlaceDoorAtPosition(), yaze::editor::DoorInteractionHandler::PlaceDoorAtSnappedPosition(), yaze::editor::DungeonObjectInteraction::PlaceItemAtPosition(), yaze::editor::ItemInteractionHandler::PlaceItemAtPosition(), yaze::editor::DungeonObjectInteraction::PlaceObjectAtPosition(), yaze::editor::DungeonObjectInteraction::PlaceSpriteAtPosition(), yaze::editor::SpriteInteractionHandler::PlaceSpriteAtPosition(), yaze::editor::DungeonObjectInteraction::SendSelectedBackward(), yaze::editor::DungeonObjectInteraction::SendSelectedToBack(), yaze::editor::DungeonObjectInteraction::SendSelectedToFront(), and yaze::editor::DungeonObjectInteraction::SendSelectedToLayer().
|
inline |
Notify that cache invalidation is needed.
Call this after changes that require re-rendering.
Definition at line 97 of file interaction_context.h.
References on_invalidate_cache.
Referenced by yaze::editor::DungeonObjectInteraction::BringSelectedForward(), yaze::editor::DoorInteractionHandler::DeleteSelected(), yaze::editor::ItemInteractionHandler::DeleteSelected(), yaze::editor::SpriteInteractionHandler::DeleteSelected(), yaze::editor::DungeonObjectInteraction::HandleCanvasMouseInput(), yaze::editor::DungeonObjectInteraction::HandleDeleteSelected(), yaze::editor::DungeonObjectInteraction::HandleEntityDrag(), yaze::editor::DungeonObjectInteraction::HandlePasteObjects(), yaze::editor::DoorInteractionHandler::HandleRelease(), yaze::editor::DungeonObjectInteraction::HandleScrollWheelResize(), yaze::editor::DungeonObjectInteraction::PlaceDoorAtPosition(), yaze::editor::DoorInteractionHandler::PlaceDoorAtSnappedPosition(), yaze::editor::DungeonObjectInteraction::PlaceItemAtPosition(), yaze::editor::ItemInteractionHandler::PlaceItemAtPosition(), yaze::editor::DungeonObjectInteraction::PlaceObjectAtPosition(), yaze::editor::DungeonObjectInteraction::PlaceSpriteAtPosition(), yaze::editor::SpriteInteractionHandler::PlaceSpriteAtPosition(), yaze::editor::DungeonObjectInteraction::SendSelectedBackward(), yaze::editor::DungeonObjectInteraction::SendSelectedToBack(), yaze::editor::DungeonObjectInteraction::SendSelectedToFront(), and yaze::editor::DungeonObjectInteraction::SendSelectedToLayer().
|
inline |
Notify that selection has changed.
Definition at line 104 of file interaction_context.h.
References on_selection_changed.
|
inline |
Notify that entity has changed.
Definition at line 111 of file interaction_context.h.
References on_entity_changed.
Referenced by yaze::editor::DungeonObjectInteraction::HandleEntityDrag(), yaze::editor::ItemInteractionHandler::HandleRelease(), yaze::editor::SpriteInteractionHandler::HandleRelease(), yaze::editor::DoorInteractionHandler::SelectDoor(), yaze::editor::DungeonObjectInteraction::SelectEntity(), yaze::editor::ItemInteractionHandler::SelectItem(), and yaze::editor::SpriteInteractionHandler::SelectSprite().
| gui::Canvas* yaze::editor::InteractionContext::canvas = nullptr |
Definition at line 34 of file interaction_context.h.
Referenced by yaze::editor::DoorInteractionHandler::DrawGhostPreview(), yaze::editor::ItemInteractionHandler::DrawGhostPreview(), yaze::editor::SpriteInteractionHandler::DrawGhostPreview(), yaze::editor::DungeonObjectInteraction::DungeonObjectInteraction(), yaze::editor::BaseEntityHandler::GetCanvasScale(), yaze::editor::BaseEntityHandler::GetCanvasZeroPoint(), IsValid(), and yaze::editor::DungeonObjectInteraction::SetContext().
| Rom* yaze::editor::InteractionContext::rom = nullptr |
Definition at line 35 of file interaction_context.h.
Referenced by yaze::editor::DungeonObjectInteraction::SetRom().
| std::array<zelda3::Room, dungeon_coords::kRoomCount>* yaze::editor::InteractionContext::rooms = nullptr |
Definition at line 36 of file interaction_context.h.
Referenced by GetCurrentRoom(), GetCurrentRoomConst(), IsValid(), and yaze::editor::DungeonObjectInteraction::SetCurrentRoom().
| int yaze::editor::InteractionContext::current_room_id = 0 |
Definition at line 37 of file interaction_context.h.
Referenced by GetCurrentRoom(), GetCurrentRoomConst(), and yaze::editor::DungeonObjectInteraction::SetCurrentRoom().
| gfx::PaletteGroup yaze::editor::InteractionContext::current_palette_group |
Definition at line 40 of file interaction_context.h.
Referenced by yaze::editor::DungeonObjectInteraction::SetCurrentPaletteGroup().
| std::function<void()> yaze::editor::InteractionContext::on_mutation |
Definition at line 44 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 47 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 50 of file interaction_context.h.
Referenced by NotifySelectionChanged().
| std::function<void()> yaze::editor::InteractionContext::on_entity_changed |
Definition at line 53 of file interaction_context.h.
Referenced by NotifyEntityChanged(), and yaze::editor::DungeonObjectInteraction::SetEntityChangedCallback().