#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_ |
Definition at line 30 of file menu_tilemap.h.
Definition at line 56 of file menu_tilemap.h.
|
default |
|
static |
Definition at line 73 of file menu_tilemap.cc.
References kBytesPerRow, and kMaxBytes.
Referenced by 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().

| absl::Status yaze::zelda3::MenuTilemapDocument::LoadFromFile | ( | const std::string & | path | ) |
Definition at line 105 of file menu_tilemap.cc.
References ASSIGN_OR_RETURN, LoadFromBytes(), and path().
Referenced by yaze::editor::MenuTilemapEditorUI::DrawOverlayControls(), yaze::cli::GfxTilemapRenderCommandHandler::Execute(), yaze::editor::MenuTilemapEditorUI::LoadFile(), and Revert().

| 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().

| 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().

| 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().

| absl::StatusOr< bool > yaze::zelda3::MenuTilemapDocument::ExternalChangeDetected | ( | ) | const |
Definition at line 168 of file menu_tilemap.cc.
References ASSIGN_OR_RETURN, path_, and pristine_bytes_.
Referenced by yaze::editor::MenuTilemapEditorUI::CheckExternalChange().
| 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().
|
inline |
Definition at line 101 of file menu_tilemap.h.
References rows_.
Referenced by yaze::cli::GfxTilemapRenderCommandHandler::Execute().
|
inline |
Definition at line 102 of file menu_tilemap.h.
References kCols.
Referenced by yaze::cli::GfxTilemapRenderCommandHandler::Execute().
|
inline |
Definition at line 103 of file menu_tilemap.h.
References path_.
Referenced by yaze::editor::MenuTilemapEditorUI::CommitStroke(), yaze::editor::MenuTilemapEditorUI::current_path(), yaze::editor::MenuTilemapEditorUI::DrawFileBar(), LoadFromFile(), yaze::editor::MenuTilemapEditorUI::RestoreSnapshot(), Revert(), SaveAs(), and yaze::editor::MenuTilemapEditorUI::SaveCurrentAs().
|
inline |
Definition at line 104 of file menu_tilemap.h.
References dirty_.
Referenced by yaze::editor::MenuTilemapEditorUI::dirty(), yaze::editor::MenuTilemapEditorUI::DrawFileBar(), and yaze::editor::MenuTilemapEditorUI::DrawStatusBar().
|
inline |
|
inline |
Definition at line 106 of file menu_tilemap.h.
References backup_written_.
Referenced by yaze::editor::MenuTilemapEditorUI::DrawStatusBar().
| 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().

|
inline |
Definition at line 112 of file menu_tilemap.h.
References backup_path_.
Referenced by yaze::editor::MenuTilemapEditorUI::DrawStatusBar(), and Revert().
|
inline |
Definition at line 113 of file menu_tilemap.h.
References bytes_.
Referenced by yaze::editor::MenuTilemapEditorUI::BeginStroke(), and yaze::editor::MenuTilemapEditorUI::CommitStroke().
|
inline |
Definition at line 115 of file menu_tilemap.h.
References kCols.
Referenced by yaze::editor::MenuTilemapEditorUI::DrawHoverReadout(), yaze::editor::MenuTilemapEditorUI::DrawMainCanvas(), GetCellWord(), PasteRect(), and SetCellWord().
| gfx::TileInfo yaze::zelda3::MenuTilemapDocument::GetCell | ( | int | row, |
| int | col ) const |
Definition at line 226 of file menu_tilemap.cc.
References GetCellWord(), and yaze::gfx::WordToTileInfo().
Referenced by CopyRect(), yaze::editor::MenuTilemapEditorUI::DrawHoverReadout(), yaze::editor::MenuTilemapEditorUI::EyedropAt(), and RenderIndexed().

| 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().

| 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().

| 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().

| MenuTilemapDocument::Clipboard yaze::zelda3::MenuTilemapDocument::CopyRect | ( | Rect | rect | ) | const |
Definition at line 256 of file menu_tilemap.cc.
References yaze::zelda3::MenuTilemapDocument::Clipboard::cells, ClipRect(), yaze::zelda3::MenuTilemapDocument::Rect::col, yaze::zelda3::MenuTilemapDocument::Rect::cols, yaze::zelda3::MenuTilemapDocument::Clipboard::cols, GetCell(), yaze::zelda3::MenuTilemapDocument::Rect::row, yaze::zelda3::MenuTilemapDocument::Rect::rows, and yaze::zelda3::MenuTilemapDocument::Clipboard::rows.
Referenced by yaze::editor::MenuTilemapEditorUI::DrawToolbar().

| int yaze::zelda3::MenuTilemapDocument::PasteRect | ( | int | row, |
| int | col, | ||
| const Clipboard & | clip ) |
Definition at line 270 of file menu_tilemap.cc.
References yaze::zelda3::MenuTilemapDocument::Clipboard::cells, yaze::zelda3::MenuTilemapDocument::Clipboard::cols, InBounds(), yaze::zelda3::MenuTilemapDocument::Clipboard::rows, and SetCell().
Referenced by yaze::editor::MenuTilemapEditorUI::DrawToolbar().

| int yaze::zelda3::MenuTilemapDocument::FillRect | ( | Rect | rect, |
| gfx::TileInfo | info ) |
Definition at line 283 of file menu_tilemap.cc.
References ClipRect(), yaze::zelda3::MenuTilemapDocument::Rect::col, yaze::zelda3::MenuTilemapDocument::Rect::cols, yaze::zelda3::MenuTilemapDocument::Rect::row, yaze::zelda3::MenuTilemapDocument::Rect::rows, and SetCell().
Referenced by yaze::editor::MenuTilemapEditorUI::DrawToolbar().

| int yaze::zelda3::MenuTilemapDocument::EraseRect | ( | Rect | rect, |
| uint16_t | erase_word = 0x0000 ) |
Definition at line 295 of file menu_tilemap.cc.
References ClipRect(), yaze::zelda3::MenuTilemapDocument::Rect::col, yaze::zelda3::MenuTilemapDocument::Rect::cols, yaze::zelda3::MenuTilemapDocument::Rect::row, yaze::zelda3::MenuTilemapDocument::Rect::rows, and SetCellWord().
Referenced by yaze::editor::MenuTilemapEditorUI::DrawToolbar().

| std::vector< uint8_t > yaze::zelda3::MenuTilemapDocument::RenderIndexed | ( | const ChrPixelFn & | chr | ) | const |
Definition at line 307 of file menu_tilemap.cc.
References GetCell(), yaze::gfx::TileInfo::horizontal_mirror_, yaze::gfx::TileInfo::id_, kCols, yaze::gfx::TileInfo::palette_, render_height(), render_width(), rows_, and yaze::gfx::TileInfo::vertical_mirror_.
Referenced by yaze::editor::MenuTilemapEditorUI::DrawOverlayControls(), yaze::cli::GfxTilemapRenderCommandHandler::Execute(), and yaze::editor::MenuTilemapEditorUI::RebuildRenderTextures().

|
inline |
Definition at line 141 of file menu_tilemap.h.
References kCols.
Referenced by yaze::editor::MenuTilemapEditorUI::DrawMainCanvas(), yaze::editor::MenuTilemapEditorUI::DrawOverlayControls(), yaze::cli::GfxTilemapRenderCommandHandler::Execute(), yaze::editor::MenuTilemapEditorUI::RebuildRenderTextures(), and RenderIndexed().
|
inline |
Definition at line 142 of file menu_tilemap.h.
References rows_.
Referenced by yaze::editor::MenuTilemapEditorUI::DrawMainCanvas(), yaze::editor::MenuTilemapEditorUI::DrawOverlayControls(), yaze::cli::GfxTilemapRenderCommandHandler::Execute(), yaze::editor::MenuTilemapEditorUI::RebuildRenderTextures(), and RenderIndexed().
|
private |
Definition at line 215 of file menu_tilemap.cc.
References yaze::zelda3::MenuTilemapDocument::Rect::col, yaze::zelda3::MenuTilemapDocument::Rect::cols, kCols, yaze::zelda3::MenuTilemapDocument::Rect::row, yaze::zelda3::MenuTilemapDocument::Rect::rows, and rows_.
Referenced by CopyRect(), EraseRect(), and FillRect().
|
staticconstexpr |
Definition at line 32 of file menu_tilemap.h.
Referenced by ClipRect(), cols(), InBounds(), render_width(), and RenderIndexed().
|
staticconstexpr |
Definition at line 33 of file menu_tilemap.h.
Referenced by GetCellWord(), LoadFromBytes(), SetCellWord(), and ValidateSize().
|
staticconstexpr |
Definition at line 34 of file menu_tilemap.h.
|
staticconstexpr |
Definition at line 35 of file menu_tilemap.h.
Referenced by ValidateSize().
|
private |
Definition at line 147 of file menu_tilemap.h.
Referenced by AcknowledgeExternalChange(), GetCellWord(), LoadFromBytes(), raw_bytes(), RestoreBytes(), SaveAs(), and SetCellWord().
|
private |
Definition at line 151 of file menu_tilemap.h.
Referenced by AcknowledgeExternalChange(), ExternalChangeDetected(), LoadFromBytes(), RestoreBytes(), and SaveAs().
|
private |
Definition at line 152 of file menu_tilemap.h.
Referenced by ClipRect(), loaded(), LoadFromBytes(), render_height(), RenderIndexed(), and rows().
|
private |
Definition at line 153 of file menu_tilemap.h.
Referenced by AcknowledgeExternalChange(), ExternalChangeDetected(), LoadFromBytes(), path(), Revert(), Save(), and SaveAs().
|
private |
Definition at line 154 of file menu_tilemap.h.
Referenced by AcknowledgeExternalChange(), dirty(), LoadFromBytes(), RestoreBytes(), SaveAs(), and SetCellWord().
|
private |
Definition at line 155 of file menu_tilemap.h.
Referenced by has_backup(), LoadFromBytes(), Revert(), and SaveAs().
|
private |
Definition at line 156 of file menu_tilemap.h.
Referenced by backup_path(), LoadFromBytes(), Revert(), and SaveAs().