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

#include <lyra_terrain_canvas.h>

Collaboration diagram for yaze::editor::LyraTerrainCanvas:

Classes

struct  MapAssets
 
struct  PropertyDraft
 

Public Member Functions

 LyraTerrainCanvas ()=default
 
 ~LyraTerrainCanvas ()
 
 LyraTerrainCanvas (const LyraTerrainCanvas &)=delete
 
LyraTerrainCanvas & operator= (const LyraTerrainCanvas &)=delete
 
absl::Status Load (project::YazeProject *project, zelda3::Overworld &overworld)
 
absl::Status Open (project::YazeProject *project, const std::string &path, zelda3::Overworld &overworld)
 
absl::Status Create (project::YazeProject *project, zelda3::Overworld &overworld)
 
absl::Status Save (project::YazeProject *project, zelda3::Overworld &overworld)
 
absl::Status SaveAs (project::YazeProject *project, const std::string &project_path, zelda3::Overworld &overworld)
 
absl::Status ValidateSave (project::YazeProject *project, zelda3::Overworld &overworld)
 
bool dirty () const
 
void ProjectSaveCommitted ()
 
bool loaded () const
 
void DrawSpecialWorld (const gui::CanvasRuntime &canvas)
 
absl::Status PaintPattern (const TileBrush &brush, int x, int y, int width, int height, bool finalize, UndoManager &history)
 
void FinishStroke (UndoManager &history)
 
void Reset ()
 
const core::LyraTerrainDocument * document () const
 
const gfx::Bitmap & atlas () const
 
gfx::Bitmap & atlas ()
 
bool stroke_active () const
 
absl::Status EditAuthoring (core::LyraAuthoringState after, zelda3::Overworld &overworld, UndoManager &history)
 
absl::Status SetGameplayArea (int map_id, std::optional< core::LyraGameplayAreaSize > size, zelda3::Overworld &overworld, UndoManager &history)
 
absl::Status PrepareMapAssets (zelda3::Overworld &overworld, int state)
 
gfx::Bitmap & MapAtlas (int map_id)
 
gfx::Bitmap * MapGraphics (int map_id)
 
void DrawProperties (int map_id, int &state, zelda3::Overworld &overworld, UndoManager &history)
 
bool entity_placement_active () const
 
void DrawSpritePreview (const gui::CanvasRuntime &canvas, int map_id, const core::LyraSpritePlacement &sprite)
 
void DrawEntities (const gui::CanvasRuntime &canvas, int world, int state)
 
void HandleEntityInput (const gui::CanvasRuntime &canvas, int world, zelda3::Overworld &overworld, UndoManager &history)
 

Private Member Functions

core::LyraMapProperties & PropertyDraftFor (int map_index)
 
bool PropertyPending (int map_index) const
 
bool PropertyConflict (int map_index) const
 
std::vector< int > PendingPropertyMaps () const
 
absl::Status ApplyPropertyDraft (int map_index, zelda3::Overworld &overworld, UndoManager &history)
 
void RevertPropertyDraft (int map_index)
 
void DrawEdgeConnections (int map_id, zelda3::Overworld &overworld, UndoManager &history)
 
void DrawGameplayArea (int map_id, zelda3::Overworld &overworld, UndoManager &history)
 
absl::Status ApplyAuthoring (core::LyraAuthoringState after, zelda3::Overworld &overworld, UndoManager &history)
 
absl::StatusOr< std::unique_ptr< MapAssets > > ResolveMapAssets (zelda3::Overworld &overworld, const core::LyraMapProperties &properties, int state, bool textures)
 
absl::StatusOr< core::LyraMapProperties > CopyNativeGraphicsSettings (zelda3::Overworld &overworld, int source_map, core::LyraMapProperties candidate)
 
absl::Status CheckAssetSources (zelda3::Overworld &overworld)
 
absl::Status ValidateMapAssets (zelda3::Overworld &overworld, const core::LyraAuthoringState &authoring)
 
absl::Status BindSource (zelda3::Overworld &overworld, core::LyraTerrainProfile *profile, gfx::Bitmap *atlas=nullptr)
 
void InstallDocument (std::shared_ptr< core::LyraTerrainDocument > document, gfx::Bitmap atlas, std::string source_path, std::optional< std::string > source_bytes, bool unpublished)
 
void DrawTile (ImDrawList *draw, const gfx::Bitmap &atlas, int tile, ImVec2 min, float size) const
 
void PaintStamp (int x, int y)
 
void PaintLine (int x, int y)
 

Static Private Member Functions

static std::string FormatMapIds (const std::vector< int > &map_ids)
 

Private Attributes

std::shared_ptr< core::LyraTerrainDocument > document_
 
gfx::Bitmap atlas_
 
std::string source_path_
 
std::optional< std::string > source_bytes_
 
bool unpublished_ = false
 
bool pending_project_commit_ = false
 
bool stroke_active_ = false
 
std::optional< ImVec2 > last_cell_
 
TileBrush brush_
 
int pattern_width_ = 0
 
int pattern_height_ = 0
 
absl::Status status_
 
std::unordered_map< std::string, std::unique_ptr< MapAssets > > map_assets_
 
std::array< MapAssets *, 32 > displayed_assets_ {}
 
int asset_state_ = 0
 
gfx::Bitmap unavailable_atlas_
 
std::vector< uint8_t > source_rom_
 
std::vector< uint8_t > source_graphics_
 
std::string source_metadata_
 
absl::Status source_status_
 
absl::Status authoring_assets_status_
 
std::optional< core::LyraAuthoringState > validated_authoring_
 
bool assets_valid_ = false
 
int property_map_ = -1
 
std::array< std::optional< PropertyDraft >, core::LyraTerrainDocument::kMapCount > property_drafts_ {}
 
int copy_source_map_ = 0x3A
 
std::string copy_message_
 
bool copy_failed_ = false
 
int placement_kind_ = 0
 
int placement_type_ = 0
 
int placement_state_ = 0
 
int new_sprite_type_ = 0
 
std::array< char, 64 > sprite_filter_ {}
 
uint32_t selected_entity_ = 0
 
int selected_kind_ = 0
 
std::optional< core::LyraAuthoringState > drag_before_
 
int drag_map_ = -1
 

Friends

class LyraTerrainCanvasTestPeer
 

Detailed Description

Definition at line 31 of file lyra_terrain_canvas.h.

Constructor & Destructor Documentation

◆ LyraTerrainCanvas() [1/2]

yaze::editor::LyraTerrainCanvas::LyraTerrainCanvas ( )
default

◆ ~LyraTerrainCanvas()

yaze::editor::LyraTerrainCanvas::~LyraTerrainCanvas ( )

Definition at line 167 of file lyra_terrain_canvas.cc.

References Reset().

Here is the call graph for this function:

◆ LyraTerrainCanvas() [2/2]

yaze::editor::LyraTerrainCanvas::LyraTerrainCanvas ( const LyraTerrainCanvas & )
delete

Member Function Documentation

◆ operator=()

LyraTerrainCanvas & yaze::editor::LyraTerrainCanvas::operator= ( const LyraTerrainCanvas & )
delete

◆ Load()

◆ Open()

absl::Status yaze::editor::LyraTerrainCanvas::Open ( project::YazeProject * project,
const std::string & path,
zelda3::Overworld & overworld )

◆ Create()

◆ Save()

absl::Status yaze::editor::LyraTerrainCanvas::Save ( project::YazeProject * project,
zelda3::Overworld & overworld )

◆ SaveAs()

absl::Status yaze::editor::LyraTerrainCanvas::SaveAs ( project::YazeProject * project,
const std::string & project_path,
zelda3::Overworld & overworld )

◆ ValidateSave()

◆ dirty()

bool yaze::editor::LyraTerrainCanvas::dirty ( ) const

◆ ProjectSaveCommitted()

void yaze::editor::LyraTerrainCanvas::ProjectSaveCommitted ( )
inline

◆ loaded()

◆ DrawSpecialWorld()

void yaze::editor::LyraTerrainCanvas::DrawSpecialWorld ( const gui::CanvasRuntime & canvas)

◆ PaintPattern()

absl::Status yaze::editor::LyraTerrainCanvas::PaintPattern ( const TileBrush & brush,
int x,
int y,
int width,
int height,
bool finalize,
UndoManager & history )

◆ FinishStroke()

◆ Reset()

◆ document()

◆ atlas() [1/2]

const gfx::Bitmap & yaze::editor::LyraTerrainCanvas::atlas ( ) const
inline

Definition at line 66 of file lyra_terrain_canvas.h.

References atlas_.

Referenced by BindSource(), Create(), DrawSpecialWorld(), DrawTile(), InstallDocument(), and Load().

◆ atlas() [2/2]

gfx::Bitmap & yaze::editor::LyraTerrainCanvas::atlas ( )
inline

Definition at line 67 of file lyra_terrain_canvas.h.

References atlas_.

◆ stroke_active()

bool yaze::editor::LyraTerrainCanvas::stroke_active ( ) const
inline

Definition at line 68 of file lyra_terrain_canvas.h.

References stroke_active_.

◆ EditAuthoring()

absl::Status yaze::editor::LyraTerrainCanvas::EditAuthoring ( core::LyraAuthoringState after,
zelda3::Overworld & overworld,
UndoManager & history )

◆ SetGameplayArea()

absl::Status yaze::editor::LyraTerrainCanvas::SetGameplayArea ( int map_id,
std::optional< core::LyraGameplayAreaSize > size,
zelda3::Overworld & overworld,
UndoManager & history )

Definition at line 502 of file lyra_terrain_canvas.cc.

References ASSIGN_OR_RETURN, document_, EditAuthoring(), and yaze::core::LyraGameplayAreaFootprint().

Referenced by DrawGameplayArea().

Here is the call graph for this function:

◆ PrepareMapAssets()

absl::Status yaze::editor::LyraTerrainCanvas::PrepareMapAssets ( zelda3::Overworld & overworld,
int state )

◆ MapAtlas()

gfx::Bitmap & yaze::editor::LyraTerrainCanvas::MapAtlas ( int map_id)

◆ MapGraphics()

gfx::Bitmap * yaze::editor::LyraTerrainCanvas::MapGraphics ( int map_id)

Definition at line 451 of file lyra_terrain_canvas.cc.

References assets_valid_, and displayed_assets_.

◆ DrawProperties()

◆ entity_placement_active()

bool yaze::editor::LyraTerrainCanvas::entity_placement_active ( ) const
inline

Definition at line 84 of file lyra_terrain_canvas.h.

References document_, and placement_kind_.

Referenced by yaze::editor::OverworldEditor::Initialize().

◆ DrawSpritePreview()

◆ DrawEntities()

void yaze::editor::LyraTerrainCanvas::DrawEntities ( const gui::CanvasRuntime & canvas,
int world,
int state )

◆ HandleEntityInput()

◆ PropertyDraftFor()

core::LyraMapProperties & yaze::editor::LyraTerrainCanvas::PropertyDraftFor ( int map_index)
private

◆ PropertyPending()

bool yaze::editor::LyraTerrainCanvas::PropertyPending ( int map_index) const
private

Definition at line 690 of file lyra_terrain_canvas.cc.

References document_, and property_drafts_.

Referenced by DrawProperties(), PendingPropertyMaps(), and PropertyConflict().

◆ PropertyConflict()

bool yaze::editor::LyraTerrainCanvas::PropertyConflict ( int map_index) const
private

Definition at line 696 of file lyra_terrain_canvas.cc.

References document_, property_drafts_, and PropertyPending().

Referenced by ApplyPropertyDraft(), and DrawProperties().

Here is the call graph for this function:

◆ PendingPropertyMaps()

std::vector< int > yaze::editor::LyraTerrainCanvas::PendingPropertyMaps ( ) const
private

Definition at line 702 of file lyra_terrain_canvas.cc.

References PropertyPending().

Referenced by dirty(), DrawProperties(), and ValidateSave().

Here is the call graph for this function:

◆ FormatMapIds()

std::string yaze::editor::LyraTerrainCanvas::FormatMapIds ( const std::vector< int > & map_ids)
staticprivate

Definition at line 711 of file lyra_terrain_canvas.cc.

Referenced by DrawGameplayArea(), DrawProperties(), and ValidateSave().

◆ ApplyPropertyDraft()

absl::Status yaze::editor::LyraTerrainCanvas::ApplyPropertyDraft ( int map_index,
zelda3::Overworld & overworld,
UndoManager & history )
private

Definition at line 718 of file lyra_terrain_canvas.cc.

References document_, EditAuthoring(), yaze::core::LyraAuthoringState::maps, PropertyConflict(), PropertyDraftFor(), RETURN_IF_ERROR, and RevertPropertyDraft().

Referenced by DrawProperties().

Here is the call graph for this function:

◆ RevertPropertyDraft()

void yaze::editor::LyraTerrainCanvas::RevertPropertyDraft ( int map_index)
private

Definition at line 737 of file lyra_terrain_canvas.cc.

References document_, and property_drafts_.

Referenced by ApplyPropertyDraft(), and DrawProperties().

◆ DrawEdgeConnections()

void yaze::editor::LyraTerrainCanvas::DrawEdgeConnections ( int map_id,
zelda3::Overworld & overworld,
UndoManager & history )
private

◆ DrawGameplayArea()

void yaze::editor::LyraTerrainCanvas::DrawGameplayArea ( int map_id,
zelda3::Overworld & overworld,
UndoManager & history )
private

◆ ApplyAuthoring()

absl::Status yaze::editor::LyraTerrainCanvas::ApplyAuthoring ( core::LyraAuthoringState after,
zelda3::Overworld & overworld,
UndoManager & history )
private

◆ ResolveMapAssets()

◆ CopyNativeGraphicsSettings()

◆ CheckAssetSources()

◆ ValidateMapAssets()

absl::Status yaze::editor::LyraTerrainCanvas::ValidateMapAssets ( zelda3::Overworld & overworld,
const core::LyraAuthoringState & authoring )
private

Definition at line 322 of file lyra_terrain_canvas.cc.

References ASSIGN_OR_RETURN, yaze::zelda3::LyraMapAssetKey(), yaze::core::LyraAuthoringState::maps, and ResolveMapAssets().

Referenced by Create(), Load(), PrepareMapAssets(), and ValidateSave().

Here is the call graph for this function:

◆ BindSource()

absl::Status yaze::editor::LyraTerrainCanvas::BindSource ( zelda3::Overworld & overworld,
core::LyraTerrainProfile * profile,
gfx::Bitmap * atlas = nullptr )
private

Definition at line 171 of file lyra_terrain_canvas.cc.

References atlas(), and yaze::zelda3::BindLyraTerrainSource().

Referenced by CheckAssetSources(), Create(), Load(), and ValidateSave().

Here is the call graph for this function:

◆ InstallDocument()

void yaze::editor::LyraTerrainCanvas::InstallDocument ( std::shared_ptr< core::LyraTerrainDocument > document,
gfx::Bitmap atlas,
std::string source_path,
std::optional< std::string > source_bytes,
bool unpublished )
private

◆ DrawTile()

void yaze::editor::LyraTerrainCanvas::DrawTile ( ImDrawList * draw,
const gfx::Bitmap & atlas,
int tile,
ImVec2 min,
float size ) const
private

Definition at line 885 of file lyra_terrain_canvas.cc.

References atlas(), yaze::gfx::Bitmap::height(), and yaze::gfx::Bitmap::texture().

Referenced by DrawSpecialWorld().

Here is the call graph for this function:

◆ PaintStamp()

void yaze::editor::LyraTerrainCanvas::PaintStamp ( int x,
int y )
private

Definition at line 851 of file lyra_terrain_canvas.cc.

References yaze::editor::TileBrush::at(), brush_, document_, yaze::editor::TileBrush::height, pattern_height_, pattern_width_, status_, and yaze::editor::TileBrush::width.

Referenced by PaintLine().

Here is the call graph for this function:

◆ PaintLine()

void yaze::editor::LyraTerrainCanvas::PaintLine ( int x,
int y )
private

Definition at line 862 of file lyra_terrain_canvas.cc.

References last_cell_, PaintStamp(), and status_.

Referenced by PaintPattern().

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ LyraTerrainCanvasTestPeer

friend class LyraTerrainCanvasTestPeer
friend

Definition at line 94 of file lyra_terrain_canvas.h.

Member Data Documentation

◆ document_

◆ atlas_

gfx::Bitmap yaze::editor::LyraTerrainCanvas::atlas_
private

Definition at line 157 of file lyra_terrain_canvas.h.

Referenced by atlas(), atlas(), DrawSpecialWorld(), InstallDocument(), MapAtlas(), and Reset().

◆ source_path_

std::string yaze::editor::LyraTerrainCanvas::source_path_
private

Definition at line 158 of file lyra_terrain_canvas.h.

Referenced by Create(), InstallDocument(), Load(), Reset(), Save(), SaveAs(), and ValidateSave().

◆ source_bytes_

std::optional<std::string> yaze::editor::LyraTerrainCanvas::source_bytes_
private

Definition at line 159 of file lyra_terrain_canvas.h.

Referenced by InstallDocument(), Reset(), Save(), and SaveAs().

◆ unpublished_

bool yaze::editor::LyraTerrainCanvas::unpublished_ = false
private

Definition at line 160 of file lyra_terrain_canvas.h.

Referenced by dirty(), InstallDocument(), Reset(), Save(), and SaveAs().

◆ pending_project_commit_

bool yaze::editor::LyraTerrainCanvas::pending_project_commit_ = false
private

Definition at line 161 of file lyra_terrain_canvas.h.

Referenced by Create(), dirty(), Open(), ProjectSaveCommitted(), Reset(), Save(), and SaveAs().

◆ stroke_active_

bool yaze::editor::LyraTerrainCanvas::stroke_active_ = false
private

Definition at line 162 of file lyra_terrain_canvas.h.

Referenced by FinishStroke(), PaintPattern(), Reset(), and stroke_active().

◆ last_cell_

std::optional<ImVec2> yaze::editor::LyraTerrainCanvas::last_cell_
private

Definition at line 163 of file lyra_terrain_canvas.h.

Referenced by FinishStroke(), PaintLine(), PaintPattern(), and Reset().

◆ brush_

TileBrush yaze::editor::LyraTerrainCanvas::brush_
private

Definition at line 164 of file lyra_terrain_canvas.h.

Referenced by PaintPattern(), PaintStamp(), and Reset().

◆ pattern_width_

int yaze::editor::LyraTerrainCanvas::pattern_width_ = 0
private

Definition at line 165 of file lyra_terrain_canvas.h.

Referenced by PaintPattern(), and PaintStamp().

◆ pattern_height_

int yaze::editor::LyraTerrainCanvas::pattern_height_ = 0
private

Definition at line 166 of file lyra_terrain_canvas.h.

Referenced by PaintPattern(), and PaintStamp().

◆ status_

absl::Status yaze::editor::LyraTerrainCanvas::status_
private

◆ map_assets_

std::unordered_map<std::string, std::unique_ptr<MapAssets> > yaze::editor::LyraTerrainCanvas::map_assets_
private

Definition at line 168 of file lyra_terrain_canvas.h.

Referenced by CheckAssetSources(), PrepareMapAssets(), and Reset().

◆ displayed_assets_

std::array<MapAssets*, 32> yaze::editor::LyraTerrainCanvas::displayed_assets_ {}
private

◆ asset_state_

int yaze::editor::LyraTerrainCanvas::asset_state_ = 0
private

Definition at line 170 of file lyra_terrain_canvas.h.

Referenced by PrepareMapAssets().

◆ unavailable_atlas_

gfx::Bitmap yaze::editor::LyraTerrainCanvas::unavailable_atlas_
private

Definition at line 171 of file lyra_terrain_canvas.h.

Referenced by MapAtlas().

◆ source_rom_

std::vector<uint8_t> yaze::editor::LyraTerrainCanvas::source_rom_
private

Definition at line 172 of file lyra_terrain_canvas.h.

Referenced by CheckAssetSources(), and Reset().

◆ source_graphics_

std::vector<uint8_t> yaze::editor::LyraTerrainCanvas::source_graphics_
private

Definition at line 172 of file lyra_terrain_canvas.h.

Referenced by CheckAssetSources(), and Reset().

◆ source_metadata_

std::string yaze::editor::LyraTerrainCanvas::source_metadata_
private

Definition at line 173 of file lyra_terrain_canvas.h.

Referenced by CheckAssetSources(), and Reset().

◆ source_status_

absl::Status yaze::editor::LyraTerrainCanvas::source_status_
private

Definition at line 174 of file lyra_terrain_canvas.h.

Referenced by CheckAssetSources(), and Reset().

◆ authoring_assets_status_

absl::Status yaze::editor::LyraTerrainCanvas::authoring_assets_status_
private

Definition at line 175 of file lyra_terrain_canvas.h.

Referenced by PrepareMapAssets(), and Reset().

◆ validated_authoring_

std::optional<core::LyraAuthoringState> yaze::editor::LyraTerrainCanvas::validated_authoring_
private

Definition at line 176 of file lyra_terrain_canvas.h.

Referenced by CheckAssetSources(), PrepareMapAssets(), and Reset().

◆ assets_valid_

bool yaze::editor::LyraTerrainCanvas::assets_valid_ = false
private

◆ property_map_

int yaze::editor::LyraTerrainCanvas::property_map_ = -1
private

Definition at line 179 of file lyra_terrain_canvas.h.

Referenced by DrawProperties(), and Reset().

◆ property_drafts_

std::array<std::optional<PropertyDraft>, core::LyraTerrainDocument::kMapCount> yaze::editor::LyraTerrainCanvas::property_drafts_ {}
private

◆ copy_source_map_

int yaze::editor::LyraTerrainCanvas::copy_source_map_ = 0x3A
private

Definition at line 182 of file lyra_terrain_canvas.h.

Referenced by DrawProperties(), and Reset().

◆ copy_message_

std::string yaze::editor::LyraTerrainCanvas::copy_message_
private

Definition at line 184 of file lyra_terrain_canvas.h.

Referenced by DrawProperties(), and Reset().

◆ copy_failed_

bool yaze::editor::LyraTerrainCanvas::copy_failed_ = false
private

Definition at line 185 of file lyra_terrain_canvas.h.

Referenced by DrawProperties(), and Reset().

◆ placement_kind_

int yaze::editor::LyraTerrainCanvas::placement_kind_ = 0
private

◆ placement_type_

int yaze::editor::LyraTerrainCanvas::placement_type_ = 0
private

Definition at line 187 of file lyra_terrain_canvas.h.

Referenced by DrawProperties(), HandleEntityInput(), and Reset().

◆ placement_state_

int yaze::editor::LyraTerrainCanvas::placement_state_ = 0
private

Definition at line 188 of file lyra_terrain_canvas.h.

Referenced by DrawProperties(), HandleEntityInput(), and Reset().

◆ new_sprite_type_

int yaze::editor::LyraTerrainCanvas::new_sprite_type_ = 0
private

Definition at line 190 of file lyra_terrain_canvas.h.

Referenced by DrawProperties(), and Reset().

◆ sprite_filter_

std::array<char, 64> yaze::editor::LyraTerrainCanvas::sprite_filter_ {}
private

Definition at line 191 of file lyra_terrain_canvas.h.

Referenced by DrawProperties(), and Reset().

◆ selected_entity_

uint32_t yaze::editor::LyraTerrainCanvas::selected_entity_ = 0
private

Definition at line 192 of file lyra_terrain_canvas.h.

Referenced by Reset().

◆ selected_kind_

int yaze::editor::LyraTerrainCanvas::selected_kind_ = 0
private

Definition at line 193 of file lyra_terrain_canvas.h.

Referenced by Reset().

◆ drag_before_

std::optional<core::LyraAuthoringState> yaze::editor::LyraTerrainCanvas::drag_before_
private

Definition at line 194 of file lyra_terrain_canvas.h.

Referenced by Reset().

◆ drag_map_

int yaze::editor::LyraTerrainCanvas::drag_map_ = -1
private

Definition at line 195 of file lyra_terrain_canvas.h.

Referenced by Reset().


The documentation for this class was generated from the following files: