Files
yaze/src/cli/handlers/dungeon.cc
scawful ba50d89e7d Update z3ed CLI tool and project build configuration
- Updated `.clang-tidy` and `.clangd` configurations for improved code quality checks and diagnostics.
- Added new submodules for JSON and HTTP libraries to support future features.
- Refined README and documentation files to standardize naming conventions and improve clarity.
- Introduced a new command palette in the CLI for easier command access and execution.
- Implemented various CLI handlers for managing ROM, sprites, palettes, and dungeon functionalities.
- Enhanced the TUI components for better user interaction and command execution.
- Added AI service integration for generating commands based on user prompts, expanding the CLI's capabilities.
2025-10-01 08:57:10 -04:00

79 lines
2.3 KiB
C++

#include "cli/z3ed.h"
#include "app/zelda3/dungeon/dungeon_editor_system.h"
#include "app/zelda3/dungeon/room.h"
#include "absl/flags/flag.h"
#include "absl/flags/declare.h"
ABSL_DECLARE_FLAG(std::string, rom);
namespace yaze {
namespace cli {
absl::Status DungeonExport::Run(const std::vector<std::string>& arg_vec) {
if (arg_vec.size() < 1) {
return absl::InvalidArgumentError("Usage: dungeon export <room_id>");
}
int room_id = std::stoi(arg_vec[0]);
std::string rom_file = absl::GetFlag(FLAGS_rom);
if (rom_file.empty()) {
return absl::InvalidArgumentError("ROM file must be provided via --rom flag.");
}
rom_.LoadFromFile(rom_file);
if (!rom_.is_loaded()) {
return absl::AbortedError("Failed to load ROM.");
}
zelda3::DungeonEditorSystem dungeon_editor(&rom_);
auto room_or = dungeon_editor.GetRoom(room_id);
if (!room_or.ok()) {
return room_or.status();
}
zelda3::Room room = room_or.value();
std::cout << "Room ID: " << room_id << std::endl;
std::cout << "Blockset: " << (int)room.blockset << std::endl;
std::cout << "Spriteset: " << (int)room.spriteset << std::endl;
std::cout << "Palette: " << (int)room.palette << std::endl;
std::cout << "Layout: " << (int)room.layout << std::endl;
return absl::OkStatus();
}
absl::Status DungeonListObjects::Run(const std::vector<std::string>& arg_vec) {
if (arg_vec.size() < 1) {
return absl::InvalidArgumentError("Usage: dungeon list-objects <room_id>");
}
int room_id = std::stoi(arg_vec[0]);
std::string rom_file = absl::GetFlag(FLAGS_rom);
if (rom_file.empty()) {
return absl::InvalidArgumentError("ROM file must be provided via --rom flag.");
}
rom_.LoadFromFile(rom_file);
if (!rom_.is_loaded()) {
return absl::AbortedError("Failed to load ROM.");
}
zelda3::DungeonEditorSystem dungeon_editor(&rom_);
auto room_or = dungeon_editor.GetRoom(room_id);
if (!room_or.ok()) {
return room_or.status();
}
zelda3::Room room = room_or.value();
room.LoadObjects();
std::cout << "Objects in Room " << room_id << ":" << std::endl;
for (const auto& obj : room.GetTileObjects()) {
std::cout << absl::StrFormat(" - ID: 0x%04X, Pos: (%d, %d), Size: 0x%02X, Layer: %d\n",
obj.id_, obj.x_, obj.y_, obj.size_, obj.layer_);
}
return absl::OkStatus();
}
} // namespace cli
} // namespace yaze