yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon.cc
Go to the documentation of this file.
1#include "cli/cli.h"
4#include "absl/flags/flag.h"
5#include "absl/flags/declare.h"
6
7ABSL_DECLARE_FLAG(std::string, rom);
8
9namespace yaze {
10namespace cli {
11
12// Legacy DungeonExport class removed - using new CommandHandler system
13// This implementation should be moved to DungeonExportCommandHandler
14absl::Status HandleDungeonExportLegacy(const std::vector<std::string>& arg_vec) {
15 if (arg_vec.size() < 1) {
16 return absl::InvalidArgumentError("Usage: dungeon export <room_id>");
17 }
18
19 int room_id = std::stoi(arg_vec[0]);
20 std::string rom_file = absl::GetFlag(FLAGS_rom);
21 if (rom_file.empty()) {
22 return absl::InvalidArgumentError("ROM file must be provided via --rom flag.");
23 }
24
25 Rom rom;
26 rom.LoadFromFile(rom_file);
27 if (!rom.is_loaded()) {
28 return absl::AbortedError("Failed to load ROM.");
29 }
30
31 zelda3::DungeonEditorSystem dungeon_editor(&rom);
32 auto room_or = dungeon_editor.GetRoom(room_id);
33 if (!room_or.ok()) {
34 return room_or.status();
35 }
36 zelda3::Room room = room_or.value();
37
38 std::cout << "Room ID: " << room_id << std::endl;
39 std::cout << "Blockset: " << (int)room.blockset << std::endl;
40 std::cout << "Spriteset: " << (int)room.spriteset << std::endl;
41 std::cout << "Palette: " << (int)room.palette << std::endl;
42 std::cout << "Layout: " << (int)room.layout << std::endl;
43
44 return absl::OkStatus();
45}
46
47// Legacy DungeonListObjects class removed - using new CommandHandler system
48// This implementation should be moved to DungeonListObjectsCommandHandler
49absl::Status HandleDungeonListObjectsLegacy(const std::vector<std::string>& arg_vec) {
50 if (arg_vec.size() < 1) {
51 return absl::InvalidArgumentError("Usage: dungeon list-objects <room_id>");
52 }
53
54 int room_id = std::stoi(arg_vec[0]);
55 std::string rom_file = absl::GetFlag(FLAGS_rom);
56 if (rom_file.empty()) {
57 return absl::InvalidArgumentError("ROM file must be provided via --rom flag.");
58 }
59
60 Rom rom;
61 rom.LoadFromFile(rom_file);
62 if (!rom.is_loaded()) {
63 return absl::AbortedError("Failed to load ROM.");
64 }
65
66 zelda3::DungeonEditorSystem dungeon_editor(&rom);
67 auto room_or = dungeon_editor.GetRoom(room_id);
68 if (!room_or.ok()) {
69 return room_or.status();
70 }
71 zelda3::Room room = room_or.value();
72 room.LoadObjects();
73
74 std::cout << "Objects in Room " << room_id << ":" << std::endl;
75 for (const auto& obj : room.GetTileObjects()) {
76 std::cout << absl::StrFormat(" - ID: 0x%04X, Pos: (%d, %d), Size: 0x%02X, Layer: %d\n",
77 obj.id_, obj.x_, obj.y_, obj.size_, obj.layer_);
78 }
79
80 return absl::OkStatus();
81}
82
83} // namespace cli
84} // namespace yaze
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:71
absl::Status LoadFromFile(const std::string &filename, bool z3_load=true)
Definition rom.cc:289
bool is_loaded() const
Definition rom.h:197
Comprehensive dungeon editing system.
absl::StatusOr< Room > GetRoom(int room_id)
uint8_t blockset
Definition room.h:349
uint8_t layout
Definition room.h:352
const std::vector< RoomObject > & GetTileObjects() const
Definition room.h:220
void LoadObjects()
Definition room.cc:606
uint8_t spriteset
Definition room.h:350
uint8_t palette
Definition room.h:351
ABSL_DECLARE_FLAG(std::string, rom)
absl::Status HandleDungeonListObjectsLegacy(const std::vector< std::string > &arg_vec)
Definition dungeon.cc:49
absl::Status HandleDungeonExportLegacy(const std::vector< std::string > &arg_vec)
Definition dungeon.cc:14
Main namespace for the application.