yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
minecart_track_editor_panel.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_PANELS_MINECART_TRACK_EDITOR_PANEL_H
2#define YAZE_APP_EDITOR_DUNGEON_PANELS_MINECART_TRACK_EDITOR_PANEL_H
3
4#include <array>
5#include <cstdint>
6#include <functional>
7#include <string>
8#include <unordered_map>
9#include <vector>
10
12#include "app/gui/core/icons.h"
13#include "core/project.h"
14#include "rom/rom.h"
15#include "zelda3/dungeon/room.h"
16
17namespace yaze::editor {
18
20 int id;
24};
25
26} // namespace yaze::editor
27
29
30namespace yaze::editor {
31
33 public:
34 explicit MinecartTrackEditorPanel(const std::string& start_root = "")
35 : project_root_(start_root) {}
36
37 // WindowContent overrides
38 std::string GetId() const override { return "dungeon.minecart_tracks"; }
39 std::string GetDisplayName() const override { return "Minecart Tracks"; }
40 std::string GetIcon() const override { return ICON_MD_TRAIN; }
41 std::string GetEditorCategory() const override { return "Dungeon"; }
42
43 void Draw(bool* p_open) override;
44
45 // Custom methods
46 void SetProjectRoot(const std::string& root);
48 rooms_ = rooms;
49 audit_dirty_ = true;
50 }
52 project_ = project;
54 audit_dirty_ = true;
55 }
56 void SetRom(Rom* rom) { rom_ = rom; }
57 void SaveTracks();
58
59 // Coordinate picking from dungeon canvas
60 // When picking mode is active, the next canvas click will set the coordinates
61 // for the selected track slot
62 void SetPickedCoordinates(int room_id, uint16_t camera_x, uint16_t camera_y);
63 bool IsPickingCoordinates() const { return picking_mode_; }
65 const std::vector<MinecartTrack>& GetTracks();
66
67 // Callback to navigate to a specific room for coordinate picking
68 using RoomNavigationCallback = std::function<void(int room_id)>;
70 room_navigation_callback_ = std::move(callback);
71 }
72
73 private:
74 void LoadTracks();
75 bool ParseSection(const std::string& content, const std::string& label,
76 std::vector<int>& out_values);
77 std::string FormatSection(const std::string& label,
78 const std::vector<int>& values);
79 void StartCoordinatePicking(int track_index);
81 void RebuildAuditCache();
82 bool IsDefaultTrack(const MinecartTrack& track) const;
85 bool UpdateOverlayList(const char* label, std::string& input,
86 std::vector<uint16_t>& target);
87
89 bool has_track_collision = false;
90 bool has_stop_tiles = false;
91 bool has_minecart_sprite = false;
93 std::vector<int> track_subtypes;
94 };
95
96 std::vector<MinecartTrack> tracks_;
97 std::string project_root_;
98 Rom* rom_ = nullptr;
101 std::unordered_map<int, RoomTrackAudit> room_audit_;
102 std::unordered_map<int, std::vector<int>> track_usage_rooms_;
103 std::vector<bool> track_subtype_used_;
104 bool audit_dirty_ = true;
105 bool loaded_ = false;
106 std::string status_message_;
107 bool show_success_ = false;
108 float success_timer_ = 0.0f;
109
110 // Coordinate picking state
111 bool picking_mode_ = false;
113
114 // Last picked coordinates (for display)
115 uint16_t last_picked_x_ = 0;
116 uint16_t last_picked_y_ = 0;
117 bool has_picked_coords_ = false;
118
120
121 // Overlay config input state
128};
129
130} // namespace yaze::editor
131
132#endif
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
void SetProject(project::YazeProject *project)
std::string FormatSection(const std::string &label, const std::vector< int > &values)
bool IsDefaultTrack(const MinecartTrack &track) const
std::string GetId() const override
Unique identifier for this panel.
std::string GetIcon() const override
Material Design icon for this panel.
std::string GetEditorCategory() const override
Editor category this panel belongs to.
void Draw(bool *p_open) override
Draw the panel content.
const std::vector< MinecartTrack > & GetTracks()
std::unordered_map< int, RoomTrackAudit > room_audit_
std::function< void(int room_id)> RoomNavigationCallback
void SetRoomNavigationCallback(RoomNavigationCallback callback)
MinecartTrackEditorPanel(const std::string &start_root="")
std::unordered_map< int, std::vector< int > > track_usage_rooms_
bool ParseSection(const std::string &content, const std::string &label, std::vector< int > &out_values)
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
void SetPickedCoordinates(int room_id, uint16_t camera_x, uint16_t camera_y)
bool UpdateOverlayList(const char *label, std::string &input, std::vector< uint16_t > &target)
Base interface for all logical window content components.
#define ICON_MD_TRAIN
Definition icons.h:2005
Editors are the view controllers for the application.
Modern project structure with comprehensive settings consolidation.
Definition project.h:164