yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::InteractionContext Struct Reference

Shared context for all interaction handlers. More...

#include <interaction_context.h>

Collaboration diagram for yaze::editor::InteractionContext:

Public Member Functions

bool IsValid () const
 Check if context has required dependencies.
 
zelda3::RoomGetCurrentRoom () const
 Get pointer to current room.
 
const zelda3::RoomGetCurrentRoomConst () const
 Get const pointer to current room.
 
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::Canvascanvas = nullptr
 
Romrom = nullptr
 
std::array< zelda3::Room, dungeon_coords::kRoomCount > * rooms = nullptr
 
int current_room_id = 0
 
ObjectSelectionselection = nullptr
 
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
 
MutationDomain last_mutation_domain = MutationDomain::kUnknown
 
MutationDomain last_invalidation_domain = MutationDomain::kUnknown
 

Detailed Description

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 75 of file interaction_context.h.

Member Function Documentation

◆ IsValid()

bool yaze::editor::InteractionContext::IsValid ( ) const
inline

Check if context has required dependencies.

Definition at line 107 of file interaction_context.h.

References canvas, and rooms.

Referenced by yaze::editor::BaseEntityHandler::HasValidContext().

◆ GetCurrentRoom()

zelda3::Room * yaze::editor::InteractionContext::GetCurrentRoom ( ) const
inline

Get pointer to current room.

Returns
Pointer to room, or nullptr if invalid

Definition at line 113 of file interaction_context.h.

References current_room_id, yaze::editor::dungeon_coords::IsValidRoomId(), and rooms.

Referenced by yaze::editor::BaseEntityHandler::GetCurrentRoom().

Here is the call graph for this function:

◆ GetCurrentRoomConst()

const zelda3::Room * yaze::editor::InteractionContext::GetCurrentRoomConst ( ) const
inline

Get const pointer to current room.

Returns
Const pointer to room, or nullptr if invalid

Definition at line 124 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().

Here is the call graph for this function:

◆ NotifyMutation()

void yaze::editor::InteractionContext::NotifyMutation ( MutationDomain domain = MutationDomain::kUnknown) const
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 137 of file interaction_context.h.

References last_mutation_domain, and on_mutation.

Referenced by yaze::editor::TileObjectHandler::DeleteAllObjects(), yaze::editor::TileObjectHandler::DeleteObjects(), yaze::editor::DoorInteractionHandler::DeleteSelected(), yaze::editor::ItemInteractionHandler::DeleteSelected(), yaze::editor::SpriteInteractionHandler::DeleteSelected(), yaze::editor::TileObjectHandler::DuplicateObjects(), yaze::editor::TileObjectHandler::HandleDrag(), yaze::editor::DoorInteractionHandler::HandleRelease(), yaze::editor::ItemInteractionHandler::HandleRelease(), yaze::editor::SpriteInteractionHandler::HandleRelease(), yaze::editor::TileObjectHandler::MoveBackward(), yaze::editor::TileObjectHandler::MoveForward(), yaze::editor::TileObjectHandler::MoveObjects(), yaze::editor::TileObjectHandler::PasteFromClipboard(), yaze::editor::DoorInteractionHandler::PlaceDoorAtSnappedPosition(), yaze::editor::ItemInteractionHandler::PlaceItemAtPosition(), yaze::editor::TileObjectHandler::PlaceObjectAt(), yaze::editor::SpriteInteractionHandler::PlaceSpriteAtPosition(), yaze::editor::TileObjectHandler::ResizeObjects(), yaze::editor::TileObjectHandler::SendToBack(), yaze::editor::TileObjectHandler::SendToFront(), yaze::editor::DungeonObjectInteraction::UpdateCollisionPainting(), yaze::editor::TileObjectHandler::UpdateObjectsId(), yaze::editor::TileObjectHandler::UpdateObjectsLayer(), and yaze::editor::TileObjectHandler::UpdateObjectsSize().

◆ NotifyInvalidateCache()

◆ NotifySelectionChanged()

void yaze::editor::InteractionContext::NotifySelectionChanged ( ) const
inline

Notify that selection has changed.

Definition at line 156 of file interaction_context.h.

References on_selection_changed.

◆ NotifyEntityChanged()

Member Data Documentation

◆ canvas

◆ rom

Rom* yaze::editor::InteractionContext::rom = nullptr

◆ rooms

std::array<zelda3::Room, dungeon_coords::kRoomCount>* yaze::editor::InteractionContext::rooms = nullptr

◆ current_room_id

◆ selection

◆ current_palette_group

gfx::PaletteGroup yaze::editor::InteractionContext::current_palette_group

◆ on_mutation

std::function<void()> yaze::editor::InteractionContext::on_mutation

◆ on_invalidate_cache

std::function<void()> yaze::editor::InteractionContext::on_invalidate_cache

◆ on_selection_changed

std::function<void()> yaze::editor::InteractionContext::on_selection_changed

Definition at line 94 of file interaction_context.h.

Referenced by NotifySelectionChanged().

◆ on_entity_changed

std::function<void()> yaze::editor::InteractionContext::on_entity_changed

◆ last_mutation_domain

MutationDomain yaze::editor::InteractionContext::last_mutation_domain = MutationDomain::kUnknown
mutable

◆ last_invalidation_domain

MutationDomain yaze::editor::InteractionContext::last_invalidation_domain = MutationDomain::kUnknown
mutable

The documentation for this struct was generated from the following file: