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

#include <menu_tilemap.h>

Classes

struct  Clipboard
 
struct  Rect
 

Public Types

using ChrPixelFn
 

Public Member Functions

 MenuTilemapDocument ()=default
 
absl::Status LoadFromBytes (std::vector< uint8_t > bytes, std::string source_path="")
 
absl::Status LoadFromFile (const std::string &path)
 
absl::Status Save ()
 
absl::Status SaveAs (const std::string &path)
 
absl::Status Revert ()
 
absl::StatusOr< bool > ExternalChangeDetected () const
 
absl::Status AcknowledgeExternalChange ()
 
int rows () const
 
int cols () const
 
const std::string & path () const
 
bool dirty () const
 
bool loaded () const
 
bool has_backup () const
 
absl::Status RestoreBytes (std::vector< uint8_t > bytes)
 
const std::string & backup_path () const
 
const std::vector< uint8_t > & raw_bytes () const
 
bool InBounds (int row, int col) const
 
gfx::TileInfo GetCell (int row, int col) const
 
uint16_t GetCellWord (int row, int col) const
 
bool SetCell (int row, int col, gfx::TileInfo info)
 
bool SetCellWord (int row, int col, uint16_t word)
 
Clipboard CopyRect (Rect rect) const
 
int PasteRect (int row, int col, const Clipboard &clip)
 
int FillRect (Rect rect, gfx::TileInfo info)
 
int EraseRect (Rect rect, uint16_t erase_word=0x0000)
 
std::vector< uint8_t > RenderIndexed (const ChrPixelFn &chr) const
 
int render_width () const
 
int render_height () const
 

Static Public Member Functions

static absl::Status ValidateSize (size_t size)
 

Static Public Attributes

static constexpr int kCols = 32
 
static constexpr int kBytesPerRow = kCols * 2
 
static constexpr int kMaxRows = 32
 
static constexpr int kMaxBytes = kBytesPerRow * kMaxRows
 

Private Member Functions

void ClipRect (Rect &rect) const
 

Private Attributes

std::vector< uint8_t > bytes_
 
std::vector< uint8_t > pristine_bytes_
 
int rows_ = 0
 
std::string path_
 
bool dirty_ = false
 
bool backup_written_ = false
 
std::string backup_path_
 

Detailed Description

Definition at line 30 of file menu_tilemap.h.

Member Typedef Documentation

◆ ChrPixelFn

Initial value:
std::function<uint8_t(int tile_id, int local_x, int local_y)>

Definition at line 56 of file menu_tilemap.h.

Constructor & Destructor Documentation

◆ MenuTilemapDocument()

yaze::zelda3::MenuTilemapDocument::MenuTilemapDocument ( )
default

Member Function Documentation

◆ ValidateSize()

absl::Status yaze::zelda3::MenuTilemapDocument::ValidateSize ( size_t size)
static

Definition at line 73 of file menu_tilemap.cc.

References kBytesPerRow, and kMaxBytes.

Referenced by LoadFromBytes().

◆ LoadFromBytes()

absl::Status yaze::zelda3::MenuTilemapDocument::LoadFromBytes ( std::vector< uint8_t > bytes,
std::string source_path = "" )

Definition at line 89 of file menu_tilemap.cc.

References backup_path_, backup_written_, bytes_, dirty_, kBytesPerRow, path_, pristine_bytes_, rows_, and ValidateSize().

Referenced by LoadFromFile().

Here is the call graph for this function:

◆ LoadFromFile()

absl::Status yaze::zelda3::MenuTilemapDocument::LoadFromFile ( const std::string & path)

◆ Save()

absl::Status yaze::zelda3::MenuTilemapDocument::Save ( )

Definition at line 110 of file menu_tilemap.cc.

References path_, and SaveAs().

Referenced by yaze::editor::MenuTilemapEditorUI::SaveCurrent().

Here is the call graph for this function:

◆ SaveAs()

absl::Status yaze::zelda3::MenuTilemapDocument::SaveAs ( const std::string & path)

Definition at line 118 of file menu_tilemap.cc.

References backup_path_, backup_written_, bytes_, dirty_, path(), path_, pristine_bytes_, and RETURN_IF_ERROR.

Referenced by Save(), and yaze::editor::MenuTilemapEditorUI::SaveCurrentAs().

Here is the call graph for this function:

◆ Revert()

absl::Status yaze::zelda3::MenuTilemapDocument::Revert ( )

Definition at line 151 of file menu_tilemap.cc.

References backup_path(), backup_path_, backup_written_, LoadFromFile(), path(), path_, and RETURN_IF_ERROR.

Referenced by yaze::editor::MenuTilemapEditorUI::RevertCurrent().

Here is the call graph for this function:

◆ ExternalChangeDetected()

absl::StatusOr< bool > yaze::zelda3::MenuTilemapDocument::ExternalChangeDetected ( ) const

◆ AcknowledgeExternalChange()

absl::Status yaze::zelda3::MenuTilemapDocument::AcknowledgeExternalChange ( )

Definition at line 187 of file menu_tilemap.cc.

References ASSIGN_OR_RETURN, bytes_, dirty_, path_, and pristine_bytes_.

Referenced by yaze::editor::MenuTilemapEditorUI::Draw().

◆ rows()

int yaze::zelda3::MenuTilemapDocument::rows ( ) const
inline

Definition at line 101 of file menu_tilemap.h.

References rows_.

Referenced by yaze::cli::GfxTilemapRenderCommandHandler::Execute().

◆ cols()

int yaze::zelda3::MenuTilemapDocument::cols ( ) const
inline

Definition at line 102 of file menu_tilemap.h.

References kCols.

Referenced by yaze::cli::GfxTilemapRenderCommandHandler::Execute().

◆ path()

◆ dirty()

bool yaze::zelda3::MenuTilemapDocument::dirty ( ) const
inline

◆ loaded()

bool yaze::zelda3::MenuTilemapDocument::loaded ( ) const
inline

Definition at line 105 of file menu_tilemap.h.

References rows_.

Referenced by RestoreBytes().

◆ has_backup()

bool yaze::zelda3::MenuTilemapDocument::has_backup ( ) const
inline

Definition at line 106 of file menu_tilemap.h.

References backup_written_.

Referenced by yaze::editor::MenuTilemapEditorUI::DrawStatusBar().

◆ RestoreBytes()

absl::Status yaze::zelda3::MenuTilemapDocument::RestoreBytes ( std::vector< uint8_t > bytes)

Definition at line 198 of file menu_tilemap.cc.

References bytes_, dirty_, loaded(), and pristine_bytes_.

Referenced by yaze::editor::MenuTilemapEditorUI::RestoreSnapshot().

Here is the call graph for this function:

◆ backup_path()

const std::string & yaze::zelda3::MenuTilemapDocument::backup_path ( ) const
inline

Definition at line 112 of file menu_tilemap.h.

References backup_path_.

Referenced by yaze::editor::MenuTilemapEditorUI::DrawStatusBar(), and Revert().

◆ raw_bytes()

const std::vector< uint8_t > & yaze::zelda3::MenuTilemapDocument::raw_bytes ( ) const
inline

◆ InBounds()

bool yaze::zelda3::MenuTilemapDocument::InBounds ( int row,
int col ) const
inline

◆ GetCell()

gfx::TileInfo yaze::zelda3::MenuTilemapDocument::GetCell ( int row,
int col ) const

◆ GetCellWord()

uint16_t yaze::zelda3::MenuTilemapDocument::GetCellWord ( int row,
int col ) const

Definition at line 230 of file menu_tilemap.cc.

References bytes_, InBounds(), and kBytesPerRow.

Referenced by yaze::editor::MenuTilemapEditorUI::DrawHoverReadout(), and GetCell().

Here is the call graph for this function:

◆ SetCell()

bool yaze::zelda3::MenuTilemapDocument::SetCell ( int row,
int col,
gfx::TileInfo info )

Definition at line 237 of file menu_tilemap.cc.

References SetCellWord(), and yaze::gfx::TileInfoToWord().

Referenced by FillRect(), yaze::editor::MenuTilemapEditorUI::PaintCellAt(), and PasteRect().

Here is the call graph for this function:

◆ SetCellWord()

bool yaze::zelda3::MenuTilemapDocument::SetCellWord ( int row,
int col,
uint16_t word )

Definition at line 241 of file menu_tilemap.cc.

References bytes_, dirty_, InBounds(), and kBytesPerRow.

Referenced by EraseRect(), and SetCell().

Here is the call graph for this function:

◆ CopyRect()

◆ PasteRect()

int yaze::zelda3::MenuTilemapDocument::PasteRect ( int row,
int col,
const Clipboard & clip )

◆ FillRect()

◆ EraseRect()

int yaze::zelda3::MenuTilemapDocument::EraseRect ( Rect rect,
uint16_t erase_word = 0x0000 )

◆ RenderIndexed()

◆ render_width()

◆ render_height()

◆ ClipRect()

Member Data Documentation

◆ kCols

constexpr int yaze::zelda3::MenuTilemapDocument::kCols = 32
staticconstexpr

Definition at line 32 of file menu_tilemap.h.

Referenced by ClipRect(), cols(), InBounds(), render_width(), and RenderIndexed().

◆ kBytesPerRow

constexpr int yaze::zelda3::MenuTilemapDocument::kBytesPerRow = kCols * 2
staticconstexpr

Definition at line 33 of file menu_tilemap.h.

Referenced by GetCellWord(), LoadFromBytes(), SetCellWord(), and ValidateSize().

◆ kMaxRows

constexpr int yaze::zelda3::MenuTilemapDocument::kMaxRows = 32
staticconstexpr

Definition at line 34 of file menu_tilemap.h.

◆ kMaxBytes

constexpr int yaze::zelda3::MenuTilemapDocument::kMaxBytes = kBytesPerRow * kMaxRows
staticconstexpr

Definition at line 35 of file menu_tilemap.h.

Referenced by ValidateSize().

◆ bytes_

std::vector<uint8_t> yaze::zelda3::MenuTilemapDocument::bytes_
private

◆ pristine_bytes_

std::vector<uint8_t> yaze::zelda3::MenuTilemapDocument::pristine_bytes_
private

◆ rows_

int yaze::zelda3::MenuTilemapDocument::rows_ = 0
private

Definition at line 152 of file menu_tilemap.h.

Referenced by ClipRect(), loaded(), LoadFromBytes(), render_height(), RenderIndexed(), and rows().

◆ path_

std::string yaze::zelda3::MenuTilemapDocument::path_
private

◆ dirty_

bool yaze::zelda3::MenuTilemapDocument::dirty_ = false
private

◆ backup_written_

bool yaze::zelda3::MenuTilemapDocument::backup_written_ = false
private

Definition at line 155 of file menu_tilemap.h.

Referenced by has_backup(), LoadFromBytes(), Revert(), and SaveAs().

◆ backup_path_

std::string yaze::zelda3::MenuTilemapDocument::backup_path_
private

Definition at line 156 of file menu_tilemap.h.

Referenced by backup_path(), LoadFromBytes(), Revert(), and SaveAs().


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