yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::util Namespace Reference

Namespaces

namespace  anonymous_namespace{bps.cc}
 
namespace  anonymous_namespace{hex.cc}
 
namespace  anonymous_namespace{indexed_png.cc}
 
namespace  anonymous_namespace{rom_hash.cc}
 
namespace  detail
 

Classes

class  CrashHandler
 Manages crash logging for release builds. More...
 
struct  FileDialogFilter
 
struct  FileDialogOptions
 
class  FileDialogWrapper
 
class  Flag
 
class  FlagParser
 
class  FlagRegistry
 
struct  HexStringParams
 
class  IFlag
 
class  LogManager
 A singleton that manages all logging configuration and output. More...
 
class  LruCache
 
struct  NoStopStateTag
 
class  NotifyValue
 A class to manage a value that can be modified and notify when it changes. More...
 
class  PlatformPaths
 Cross-platform utilities for file system paths. More...
 
struct  PngImage
 A decoded PNG: palette indices for indexed files, RGBA otherwise. More...
 
struct  RomIdentityHashes
 
struct  SDL_Deleter
 Deleter for SDL_Window and SDL_Renderer. More...
 
struct  SDL_Surface_Deleter
 Custom deleter for SDL_Surface. More...
 
struct  SDL_Texture_Deleter
 Custom deleter for SDL_Texture. More...
 
class  StopSource
 
class  StopToken
 

Enumerations

enum class  Platform {
  kUnknown , kMacOS , kiOS , kWindows ,
  kLinux
}
 
enum class  LogLevel {
  YAZE_DEBUG , INFO , WARNING , ERROR ,
  FATAL
}
 Defines the severity levels for log messages. This allows for filtering messages based on their importance. More...
 
enum class  RomHashMatch { kMismatch , kCrc32 , kLegacyCrc32 , kSha1 }
 

Functions

bool ImageClipboardSupported ()
 
absl::Status SetClipboardPng (const std::vector< uint8_t > &png, const std::string &pasteboard="")
 Replaces the clipboard contents with one PNG image.
 
absl::StatusOr< std::vector< uint8_t > > GetClipboardPng (const std::string &)
 
absl::Status ApplyBpsPatch (const std::vector< uint8_t > &source, const std::vector< uint8_t > &patch, std::vector< uint8_t > &output)
 
absl::Status CreateBpsPatch (const std::vector< uint8_t > &source, const std::vector< uint8_t > &target, std::vector< uint8_t > &patch)
 
std::string GetFileExtension (const std::string &filename)
 Gets the file extension from a filename.
 
std::string GetFileName (const std::string &filename)
 Gets the filename from a full path.
 
std::string LoadFile (const std::string &filename)
 Loads the entire contents of a file into a string.
 
std::string LoadFileFromConfigDir (const std::string &filename)
 Loads a file from the user's config directory.
 
void SaveFile (const std::string &filename, const std::string &contents)
 
std::string GetResourcePath (const std::string &resource_path)
 
FileDialogOptions MakeRomFileDialogOptions (bool include_all_files)
 
std::string GetBundleResourcePath ()
 GetBundleResourcePath returns the path to the bundle resource directory. Specific to MacOS.
 
FlagRegistry * global_flag_registry ()
 
std::string HexByte (uint8_t byte, HexStringParams params)
 
std::string HexWord (uint16_t word, HexStringParams params)
 
std::string HexLong (uint32_t dword, HexStringParams params)
 
std::string HexLongLong (uint64_t qword, HexStringParams params)
 
bool ParseHexString (absl::string_view str, uint64_t *out)
 
bool ParseHexString (absl::string_view str, uint32_t *out)
 
bool ParseHexString (absl::string_view str, int *out)
 
absl::StatusOr< std::vector< uint8_t > > EncodeIndexedPng (int width, int height, const std::vector< uint8_t > &indices, const std::vector< std::array< uint8_t, 4 > > &palette)
 
absl::StatusOr< PngImage > DecodePng (const std::vector< uint8_t > &bytes)
 
absl::StatusOr< std::vector< uint8_t > > ReadBinaryFile (const std::string &path)
 
absl::Status WriteBinaryFile (const std::string &path, const std::vector< uint8_t > &bytes)
 
template<typename... Args>
void logf (const absl::FormatSpec< Args... > &format, Args &&... args)
 
void logf (absl::string_view message)
 
uint32_t CalculateCrc32 (const uint8_t *data, size_t size)
 
std::string ComputeRomHash (const uint8_t *data, size_t size)
 
RomIdentityHashes ComputeRomIdentityHashes (const uint8_t *data, size_t size)
 
std::string ComputeSha1Hex (const uint8_t *data, size_t size)
 Compute SHA-1 hash of data, return lowercase hex string (40 chars).
 
std::string ComputeFileSha1Hex (const std::string &path)
 

Variables

constexpr NoStopStateTag kNoStopState {}
 

Enumeration Type Documentation

◆ Platform

enum class yaze::util::Platform
strong
Enumerator
kUnknown 
kMacOS 
kiOS 
kWindows 
kLinux 

Definition at line 71 of file file_util.h.

◆ LogLevel

enum class yaze::util::LogLevel
strong

Defines the severity levels for log messages. This allows for filtering messages based on their importance.

Enumerator
YAZE_DEBUG 
INFO 
WARNING 
ERROR 
FATAL 

Definition at line 24 of file log.h.

◆ RomHashMatch

enum class yaze::util::RomHashMatch
strong
Enumerator
kMismatch 
kCrc32 
kLegacyCrc32 
kSha1 

Definition at line 15 of file rom_hash.h.

Function Documentation

◆ ImageClipboardSupported()

bool yaze::util::ImageClipboardSupported ( )

◆ SetClipboardPng()

absl::Status yaze::util::SetClipboardPng ( const std::vector< uint8_t > & ,
const std::string &  )

Replaces the clipboard contents with one PNG image.

Definition at line 66 of file image_clipboard.mm.

Referenced by yaze::editor::PixelEditorPanel::CopyToSystemClipboard().

◆ GetClipboardPng()

absl::StatusOr< std::vector< uint8_t > > yaze::util::GetClipboardPng ( const std::string & pasteboard = "")

The clipboard's image as PNG bytes. A TIFF-only image (macOS screenshots and many apps) is converted to PNG. NotFound when there is no image.

Definition at line 70 of file image_clipboard.mm.

Referenced by yaze::editor::PixelEditorPanel::PasteFromSystemClipboard().

◆ ApplyBpsPatch()

absl::Status yaze::util::ApplyBpsPatch ( const std::vector< uint8_t > & source,
const std::vector< uint8_t > & patch,
std::vector< uint8_t > & output )

Definition at line 75 of file bps.cc.

References CalculateCrc32().

Referenced by yaze::cli::handlers::ProjectBuildCommandHandler::Execute(), and yaze::editor::MenuOrchestrator::OnApplyBpsPatch().

Here is the call graph for this function:

◆ CreateBpsPatch()

absl::Status yaze::util::CreateBpsPatch ( const std::vector< uint8_t > & source,
const std::vector< uint8_t > & target,
std::vector< uint8_t > & patch )

Definition at line 228 of file bps.cc.

References CalculateCrc32().

Referenced by yaze::editor::MenuOrchestrator::OnExportBpsPatch().

Here is the call graph for this function:

◆ GetFileExtension()

std::string yaze::util::GetFileExtension ( const std::string & filename)

Gets the file extension from a filename.

Uses std::filesystem for cross-platform consistency.

Parameters
filenameThe name of the file.
Returns
The file extension, or an empty string if none is found.

Definition at line 15 of file file_util.cc.

Referenced by yaze::editor::UICoordinator::DrawGlobalSearch(), yaze::emu::ui::RenderNavBar(), and yaze::editor::MenuTilemapEditorUI::SaveCurrentAs().

◆ GetFileName()

◆ LoadFile()

std::string yaze::util::LoadFile ( const std::string & filename)

Loads the entire contents of a file into a string.

Throws a std::runtime_error if the file cannot be opened.

Parameters
filenameThe full, absolute path to the file.
Returns
The contents of the file as a string.

Definition at line 23 of file file_util.cc.

Referenced by yaze::editor::AssemblyEditor::ChangeActiveFile(), yaze::editor::CustomCollisionPanel::Draw(), yaze::editor::WaterFillPanel::Draw(), yaze::editor::anonymous_namespace{user_settings.cc}::LoadPreferencesFromIni(), and yaze::editor::WorkspaceManager::RefreshPresets().

◆ LoadFileFromConfigDir()

std::string yaze::util::LoadFileFromConfigDir ( const std::string & filename)

Loads a file from the user's config directory.

Parameters
filenameThe name of the file inside the config directory.
Returns
The contents of the file, or an empty string if not found.

Definition at line 38 of file file_util.cc.

References yaze::util::PlatformPaths::GetConfigDirectory().

Referenced by yaze::editor::EditorSelectionDialog::LoadRecentEditors(), and yaze::editor::DashboardPanel::LoadRecentEditors().

Here is the call graph for this function:

◆ SaveFile()

void yaze::util::SaveFile ( const std::string & filename,
const std::string & contents )

◆ GetResourcePath()

std::string yaze::util::GetResourcePath ( const std::string & resource_path)

Definition at line 70 of file file_util.cc.

References GetBundleResourcePath().

Referenced by yaze::zelda3::OverworldUpgradeSystem::ApplyZSCustomOverworldASM(), and yaze::gui::ThemeManager::LoadThemeFromFile().

Here is the call graph for this function:

◆ MakeRomFileDialogOptions()

◆ GetBundleResourcePath()

std::string yaze::util::GetBundleResourcePath ( )

GetBundleResourcePath returns the path to the bundle resource directory. Specific to MacOS.

Referenced by GetResourcePath(), yaze::AssetLoader::GetSearchPaths(), and yaze::anonymous_namespace{font_loader.cc}::SetFontPath().

◆ global_flag_registry()

FlagRegistry * yaze::util::global_flag_registry ( )
inline

◆ HexByte()

◆ HexWord()

std::string yaze::util::HexWord ( uint16_t word,
HexStringParams params )

◆ HexLong()

◆ HexLongLong()

std::string yaze::util::HexLongLong ( uint64_t qword,
HexStringParams params )

◆ ParseHexString() [1/3]

◆ ParseHexString() [2/3]

bool yaze::util::ParseHexString ( absl::string_view str,
uint32_t * out )

Definition at line 142 of file hex.cc.

◆ ParseHexString() [3/3]

bool yaze::util::ParseHexString ( absl::string_view str,
int * out )

Definition at line 151 of file hex.cc.

◆ EncodeIndexedPng()

absl::StatusOr< std::vector< uint8_t > > yaze::util::EncodeIndexedPng ( int width,
int height,
const std::vector< uint8_t > & indices,
const std::vector< std::array< uint8_t, 4 > > & palette )

Encodes an 8-bit indexed PNG. palette holds 1-256 RGBA entries; a tRNS chunk is written when any entry has alpha below 255.

Definition at line 56 of file indexed_png.cc.

Referenced by yaze::editor::EncodeClipboardPng(), yaze::cli::GfxTilemapRenderCommandHandler::Execute(), yaze::zelda3::ExportRoomBackgroundPng(), and yaze::zelda3::ExportSheetBlocksPng().

◆ DecodePng()

◆ ReadBinaryFile()

absl::StatusOr< std::vector< uint8_t > > yaze::util::ReadBinaryFile ( const std::string & path)

◆ WriteBinaryFile()

◆ logf() [1/2]

template<typename... Args>
void yaze::util::logf ( const absl::FormatSpec< Args... > & format,
Args &&... args )
inline

Definition at line 146 of file log.h.

References INFO, yaze::util::LogManager::instance(), and yaze::util::LogManager::log().

Referenced by yaze::editor::Tile16EditSession::AnalyzeTile8SourceData(), yaze::editor::Tile16EditSession::ApplyPaletteToAllImpl(), yaze::editor::Tile16EditSession::ApplyPaletteToQuadrantImpl(), yaze::zelda3::Overworld::AssembleMap32Tiles(), yaze::zelda3::Overworld::AutoDetectDiggableTiles(), yaze::editor::Tile16EditSession::CommitAllChanges(), yaze::editor::Tile16EditSession::CommitChangesToOverworld(), yaze::editor::Tile16EditSession::CyclePalette(), yaze::editor::Tile16EditSession::DiscardAllChanges(), yaze::editor::Tile16EditSession::DiscardChanges(), yaze::editor::Tile16EditSession::DiscardCurrentTileChanges(), yaze::editor::Tile16Editor::DrawBrushAndTilePaletteControls(), yaze::editor::Tile16Editor::DrawPaletteSettings(), yaze::editor::Tile16Editor::DrawTile16EditorWorkbenchColumn(), yaze::editor::Tile16Editor::DrawTile8UsageOverlay(), yaze::editor::Tile16EditSession::DrawToCurrentTile16Impl(), yaze::editor::FindMatchingElement(), yaze::editor::Tile16EditSession::HandleTile16CanvasClick(), yaze::editor::Tile16Editor::HandleTile8SourceSelection(), yaze::i18n::LanguageManager::LoadCatalog(), yaze::zelda3::Overworld::LoadOverworldMaps(), yaze::editor::OverworldEditor::LoadScratchToSelection(), yaze::editor::Tile16EditSession::LoadTile8(), yaze::editor::Tile16EditSession::MarkCurrentTileModified(), yaze::editor::LayoutManager::MaybeReapplyStartupLayout(), yaze::editor::ParseMessageToData(), yaze::editor::TilePaintingManager::PickTile16FromHoveredCanvas(), yaze::editor::Tile16EditSession::PickTile8FromTile16(), yaze::zelda3::ReadMap16Tiles(), yaze::editor::Tile16EditSession::RefreshAllPalettes(), yaze::editor::Tile16EditSession::RefreshTile16Blockset(), yaze::editor::Tile16EditSession::RegenerateTile16BitmapFromROM(), yaze::editor::Tile16EditSession::RequestTileSwitch(), yaze::zelda3::Overworld::SaveAreaSizes(), yaze::zelda3::Overworld::SaveAreaSpecificBGColors(), yaze::zelda3::Overworld::SaveCustomOverworldASM(), yaze::zelda3::SaveItems(), yaze::zelda3::Overworld::SaveLargeMaps(), yaze::zelda3::Overworld::SaveLargeMapsExpanded(), yaze::zelda3::Overworld::SaveMap16Tiles(), yaze::zelda3::Overworld::SaveMap32Expanded(), yaze::zelda3::Overworld::SaveMap32Tiles(), yaze::zelda3::Overworld::SaveMapOverlays(), yaze::zelda3::Overworld::SaveMapProperties(), yaze::zelda3::Overworld::SaveMusic(), yaze::zelda3::Overworld::SaveOverworldMaps(), yaze::zelda3::Overworld::SaveOverworldTilesType(), yaze::editor::Tile16EditSession::SaveTile16ToROM(), yaze::editor::Tile16EditSession::set_palette(), yaze::editor::Tile16EditSession::SetCurrentTile(), yaze::editor::Tile16Editor::UpdateBlockset(), yaze::editor::Tile16EditSession::UpdateROMTile16Data(), and yaze::editor::Tile16EditSession::UpdateTile8Palette().

Here is the call graph for this function:

◆ logf() [2/2]

void yaze::util::logf ( absl::string_view message)
inline

Definition at line 152 of file log.h.

References INFO, yaze::util::LogManager::instance(), and yaze::util::LogManager::log().

Here is the call graph for this function:

◆ CalculateCrc32()

◆ ComputeRomHash()

std::string yaze::util::ComputeRomHash ( const uint8_t * data,
size_t size )

◆ ComputeRomIdentityHashes()

RomIdentityHashes yaze::util::ComputeRomIdentityHashes ( const uint8_t * data,
size_t size )

Definition at line 84 of file rom_hash.cc.

References ComputeRomHash(), and ComputeSha1Hex().

Referenced by yaze::editor::RomSession::CaptureRomIdentity(), and yaze::cli::handlers::ProjectBundleVerifyCommandHandler::Execute().

Here is the call graph for this function:

◆ ComputeSha1Hex()

◆ ComputeFileSha1Hex()

std::string yaze::util::ComputeFileSha1Hex ( const std::string & path)

Compute SHA-1 hash of a file on disk, return lowercase hex string. Returns empty string on read error.

Definition at line 251 of file rom_hash.cc.

References ComputeSha1Hex().

Referenced by yaze::cli::handlers::anonymous_namespace{mesen_handlers.cc}::BuildSavestateMetadata(), yaze::cli::handlers::anonymous_namespace{mesen_handlers.cc}::ComputeSavestateFreshness(), and yaze::cli::handlers::ProjectBundleVerifyCommandHandler::Execute().

Here is the call graph for this function:

Variable Documentation

◆ kNoStopState

constexpr NoStopStateTag yaze::util::kNoStopState {}
inlineconstexpr

Definition at line 11 of file stop_token.h.