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

Generates and manages tile16 editing proposals. More...

#include <tile16_proposal_generator.h>

Public Member Functions

 Tile16ProposalGenerator ()=default
 
absl::StatusOr< Tile16ProposalGenerateFromCommands (const std::string &prompt, const std::vector< std::string > &commands, const std::string &ai_service, Rom *rom)
 Generate a tile16 proposal from an AI-generated command list.
 
absl::Status ApplyProposal (const Tile16Proposal &proposal, Rom *rom)
 Apply a proposal to a ROM (typically a sandbox).
 
absl::StatusOr< gfx::BitmapGenerateDiff (const Tile16Proposal &proposal, Rom *before_rom, Rom *after_rom)
 Generate a visual diff bitmap for a proposal.
 
absl::Status SaveProposal (const Tile16Proposal &proposal, const std::string &path)
 Save a proposal to a JSON file for later review.
 
absl::StatusOr< Tile16ProposalLoadProposal (const std::string &path)
 Load a proposal from a JSON file.
 

Private Member Functions

absl::StatusOr< Tile16ChangeParseSetTileCommand (const std::string &command, Rom *rom)
 Parse a single "overworld set-tile" command into a Tile16Change.
 
absl::StatusOr< std::vector< Tile16Change > > ParseSetAreaCommand (const std::string &command, Rom *rom)
 Parse a "overworld set-area" command into multiple Tile16Changes.
 
absl::StatusOr< std::vector< Tile16Change > > ParseReplaceTileCommand (const std::string &command, Rom *rom)
 Parse a "overworld replace-tile" command into multiple Tile16Changes.
 
std::string GenerateProposalId () const
 Generate a unique proposal ID.
 

Friends

class Tile16ProposalGeneratorTest
 

Detailed Description

Generates and manages tile16 editing proposals.

This class bridges the AI service with the overworld editing system, providing a safe sandbox workflow for reviewing and applying changes.

Definition at line 63 of file tile16_proposal_generator.h.

Constructor & Destructor Documentation

◆ Tile16ProposalGenerator()

yaze::cli::Tile16ProposalGenerator::Tile16ProposalGenerator ( )
default

Member Function Documentation

◆ GenerateFromCommands()

absl::StatusOr< Tile16Proposal > yaze::cli::Tile16ProposalGenerator::GenerateFromCommands ( const std::string &  prompt,
const std::vector< std::string > &  commands,
const std::string &  ai_service,
Rom rom 
)

Generate a tile16 proposal from an AI-generated command list.

Parameters
promptThe original user prompt
commandsList of commands from AI (e.g., "overworld set-tile ...")
ai_serviceName of the AI service used
romReference ROM for validation
Returns
Tile16Proposal with parsed changes

Definition at line 488 of file tile16_proposal_generator.cc.

References yaze::cli::Tile16Proposal::ai_service, yaze::cli::Tile16Proposal::changes, yaze::cli::Tile16Proposal::created_at, GenerateProposalId(), yaze::cli::Tile16Proposal::id, ParseReplaceTileCommand(), ParseSetAreaCommand(), ParseSetTileCommand(), yaze::cli::Tile16Proposal::PENDING, yaze::cli::Tile16Proposal::prompt, yaze::cli::Tile16Proposal::reasoning, and yaze::cli::Tile16Proposal::status.

Referenced by yaze::cli::agent::CreateProposalFromAgentResponse(), and yaze::cli::agent::HandlePlanCommand().

Here is the call graph for this function:

◆ ApplyProposal()

absl::Status yaze::cli::Tile16ProposalGenerator::ApplyProposal ( const Tile16Proposal proposal,
Rom rom 
)

Apply a proposal to a ROM (typically a sandbox).

This modifies the ROM in memory but doesn't save to disk. Used for preview and testing.

Parameters
proposalThe proposal to apply
romThe ROM to modify
Returns
Status indicating success or failure

Definition at line 548 of file tile16_proposal_generator.cc.

References yaze::cli::Tile16Proposal::changes, yaze::Rom::is_loaded(), yaze::zelda3::Overworld::Load(), yaze::zelda3::Overworld::set_current_world(), and yaze::zelda3::Overworld::SetTile().

Referenced by yaze::cli::agent::CreateProposalFromAgentResponse().

Here is the call graph for this function:

◆ GenerateDiff()

absl::StatusOr< gfx::Bitmap > yaze::cli::Tile16ProposalGenerator::GenerateDiff ( const Tile16Proposal proposal,
Rom before_rom,
Rom after_rom 
)

Generate a visual diff bitmap for a proposal.

Creates a side-by-side or overlay comparison of before/after state.

Parameters
proposalThe proposal to visualize
before_romROM in original state
after_romROM with proposal applied
Returns
Bitmap showing the visual difference

Definition at line 583 of file tile16_proposal_generator.cc.

References yaze::cli::Tile16Proposal::changes, yaze::zelda3::Overworld::GetTile(), yaze::Rom::is_loaded(), yaze::zelda3::Overworld::Load(), yaze::zelda3::Overworld::set_current_world(), and yaze::gfx::Bitmap::SetPixel().

◆ SaveProposal()

absl::Status yaze::cli::Tile16ProposalGenerator::SaveProposal ( const Tile16Proposal proposal,
const std::string &  path 
)

Save a proposal to a JSON file for later review.

Parameters
proposalThe proposal to save
pathFile path to save to
Returns
Status indicating success or failure

Definition at line 701 of file tile16_proposal_generator.cc.

References yaze::cli::Tile16Proposal::ToJson().

Referenced by yaze::cli::agent::CreateProposalFromAgentResponse(), and yaze::cli::agent::HandlePlanCommand().

Here is the call graph for this function:

◆ LoadProposal()

absl::StatusOr< Tile16Proposal > yaze::cli::Tile16ProposalGenerator::LoadProposal ( const std::string &  path)

Load a proposal from a JSON file.

Parameters
pathFile path to load from
Returns
The loaded proposal or error

Definition at line 717 of file tile16_proposal_generator.cc.

References yaze::cli::Tile16Proposal::FromJson().

Here is the call graph for this function:

◆ ParseSetTileCommand()

absl::StatusOr< Tile16Change > yaze::cli::Tile16ProposalGenerator::ParseSetTileCommand ( const std::string &  command,
Rom rom 
)
private

Parse a single "overworld set-tile" command into a Tile16Change.

Expected format: "overworld set-tile --map 0 --x 10 --y 20 --tile 0x02E"

Definition at line 242 of file tile16_proposal_generator.cc.

References yaze::zelda3::Overworld::GetTile(), yaze::Rom::is_loaded(), yaze::zelda3::Overworld::Load(), yaze::cli::Tile16Change::map_id, yaze::cli::Tile16Change::new_tile, yaze::cli::Tile16Change::old_tile, yaze::zelda3::Overworld::set_current_world(), yaze::cli::Tile16Change::x, and yaze::cli::Tile16Change::y.

Referenced by GenerateFromCommands().

Here is the call graph for this function:

◆ ParseSetAreaCommand()

absl::StatusOr< std::vector< Tile16Change > > yaze::cli::Tile16ProposalGenerator::ParseSetAreaCommand ( const std::string &  command,
Rom rom 
)
private

Parse a "overworld set-area" command into multiple Tile16Changes.

Expected format: "overworld set-area --map 0 --x 10 --y 20 --width 5 --height 3 --tile 0x02E"

Definition at line 305 of file tile16_proposal_generator.cc.

References yaze::zelda3::Overworld::GetTile(), yaze::Rom::is_loaded(), yaze::zelda3::Overworld::Load(), yaze::cli::Tile16Change::map_id, yaze::cli::Tile16Change::new_tile, yaze::cli::Tile16Change::old_tile, yaze::zelda3::Overworld::set_current_world(), yaze::cli::Tile16Change::x, and yaze::cli::Tile16Change::y.

Referenced by GenerateFromCommands().

Here is the call graph for this function:

◆ ParseReplaceTileCommand()

absl::StatusOr< std::vector< Tile16Change > > yaze::cli::Tile16ProposalGenerator::ParseReplaceTileCommand ( const std::string &  command,
Rom rom 
)
private

Parse a "overworld replace-tile" command into multiple Tile16Changes.

Expected format: "overworld replace-tile --map 0 --old-tile 0x02E --new-tile 0x030" Can also specify optional bounds: –x-min 0 –y-min 0 –x-max 31 –y-max 31

Definition at line 395 of file tile16_proposal_generator.cc.

References yaze::zelda3::Overworld::GetTile(), yaze::Rom::is_loaded(), yaze::zelda3::Overworld::Load(), yaze::cli::Tile16Change::map_id, yaze::cli::Tile16Change::new_tile, yaze::cli::Tile16Change::old_tile, yaze::zelda3::Overworld::set_current_world(), yaze::cli::Tile16Change::x, and yaze::cli::Tile16Change::y.

Referenced by GenerateFromCommands().

Here is the call graph for this function:

◆ GenerateProposalId()

std::string yaze::cli::Tile16ProposalGenerator::GenerateProposalId ( ) const
private

Generate a unique proposal ID.

Definition at line 231 of file tile16_proposal_generator.cc.

Referenced by GenerateFromCommands().

Friends And Related Symbol Documentation

◆ Tile16ProposalGeneratorTest

friend class Tile16ProposalGeneratorTest
friend

Definition at line 68 of file tile16_proposal_generator.h.


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