yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
automation.cc
Go to the documentation of this file.
2
4
5namespace yaze {
6namespace editor {
7
8// ============================================================================
9// Canvas Automation API Integration (Phase 4)
10// ============================================================================
11
13 auto* api = ow_map_canvas_.GetAutomationAPI();
14
15 // Set tile paint callback
16 api->SetTilePaintCallback([this](int x, int y, int tile_id) {
17 return AutomationSetTile(x, y, tile_id);
18 });
19
20 // Set tile query callback
21 api->SetTileQueryCallback(
22 [this](int x, int y) { return AutomationGetTile(x, y); });
23}
24
25bool OverworldEditor::AutomationSetTile(int x, int y, int tile_id) {
26 if (!overworld_.is_loaded()) {
27 return false;
28 }
29
30 // Bounds check
31 if (x < 0 || y < 0 || x >= 512 || y >= 512) {
32 return false;
33 }
34
35 // Set current world based on current_map_
38
39 // Set the tile in the overworld data structure
40 overworld_.SetTile(x, y, static_cast<uint16_t>(tile_id));
41
42 // Update the bitmap
43 auto tile_data = gfx::GetTilemapData(tile16_blockset_, tile_id);
44 if (!tile_data.empty()) {
45 tile_painting_->RenderUpdatedMapBitmap(
46 ImVec2(static_cast<float>(x * 16), static_cast<float>(y * 16)),
47 tile_data);
48 return true;
49 }
50
51 return false;
52}
53
55 if (!overworld_.is_loaded()) {
56 return -1;
57 }
58
59 // Bounds check
60 if (x < 0 || y < 0 || x >= 512 || y >= 512) {
61 return -1;
62 }
63
64 // Set current world
67
68 return overworld_.GetTile(x, y);
69}
70
71} // namespace editor
72} // namespace yaze
bool AutomationSetTile(int x, int y, int tile_id)
Definition automation.cc:25
std::unique_ptr< TilePaintingManager > tile_painting_
int AutomationGetTile(int x, int y)
Definition automation.cc:54
void SetTilePaintCallback(TilePaintCallback callback)
CanvasAutomationAPI * GetAutomationAPI()
Definition canvas.cc:2054
void set_current_world(int world)
Definition overworld.h:810
auto is_loaded() const
Definition overworld.h:803
void set_current_map(int i)
Definition overworld.h:809
uint16_t GetTile(int x, int y) const
Definition overworld.h:813
void SetTile(int x, int y, uint16_t tile_id)
Definition overworld.h:822
std::vector< uint8_t > GetTilemapData(Tilemap &tilemap, int tile_id)
Definition tilemap.cc:268