yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
polyhedral_editor_panel.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_GRAPHICS_POLYHEDRAL_EDITOR_PANEL_H_
2#define YAZE_APP_EDITOR_GRAPHICS_POLYHEDRAL_EDITOR_PANEL_H_
3
4#include <string>
5#include <vector>
6
7#include "absl/status/status.h"
10#include "rom/rom.h"
11
12namespace yaze {
13namespace editor {
14
15struct PolyVertex {
16 int x = 0;
17 int y = 0;
18 int z = 0;
19};
20
21struct PolyFace {
22 uint8_t shade = 0;
23 std::vector<uint8_t> vertex_indices;
24};
25
26struct PolyShape {
27 std::string name;
28 uint8_t vertex_count = 0;
29 uint8_t face_count = 0;
30 uint16_t vertex_ptr = 0;
31 uint16_t face_ptr = 0;
32 std::vector<PolyVertex> vertices;
33 std::vector<PolyFace> faces;
34};
35
37 public:
38 explicit PolyhedralEditorPanel(Rom* rom = nullptr) : rom_(rom) {}
39
40 // ==========================================================================
41 // EditorPanel Identity
42 // ==========================================================================
43
44 std::string GetId() const override { return "graphics.polyhedral"; }
45 std::string GetDisplayName() const override { return "Polyhedral Editor"; }
46 std::string GetIcon() const override { return ICON_MD_VIEW_IN_AR; }
47 std::string GetEditorCategory() const override { return "Graphics"; }
48 int GetPriority() const override { return 50; }
49
50 // ==========================================================================
51 // EditorPanel Lifecycle
52 // ==========================================================================
53
54 void SetRom(Rom* rom) {
55 rom_ = rom;
56 data_loaded_ = false;
57 }
58
59 absl::Status Load();
60
64 void Draw(bool* p_open) override;
65
69 absl::Status Update();
70
71 private:
72 enum class PlotPlane { kXY, kXZ, kYZ };
73
74 absl::Status LoadShapes();
75 absl::Status SaveShapes();
76 absl::Status WriteShape(const PolyShape& shape);
77 void DrawShapeEditor(PolyShape& shape);
78 void DrawVertexList(PolyShape& shape);
79 void DrawFaceList(PolyShape& shape);
80 void DrawPlot(const char* label, PlotPlane plane, PolyShape& shape);
81 void DrawPreview(PolyShape& shape);
82
83 uint32_t TablePc() const;
84
85 Rom* rom_ = nullptr;
86 bool data_loaded_ = false;
87 bool dirty_ = false;
90
91 std::vector<PolyShape> shapes_;
92};
93
94} // namespace editor
95} // namespace yaze
96
97#endif // YAZE_APP_EDITOR_GRAPHICS_POLYHEDRAL_EDITOR_PANEL_H_
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:24
Base interface for all logical panel components.
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
int GetPriority() const override
Get display priority for menu ordering.
std::string GetEditorCategory() const override
Editor category this panel belongs to.
void Draw(bool *p_open) override
Draw the polyhedral editor UI (EditorPanel interface)
std::string GetId() const override
Unique identifier for this panel.
void DrawPlot(const char *label, PlotPlane plane, PolyShape &shape)
absl::Status WriteShape(const PolyShape &shape)
std::string GetIcon() const override
Material Design icon for this panel.
absl::Status Update()
Legacy Update method for backward compatibility.
#define ICON_MD_VIEW_IN_AR
Definition icons.h:2090
std::vector< uint8_t > vertex_indices
std::vector< PolyFace > faces
std::vector< PolyVertex > vertices