yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
bpp_format_ui.h
Go to the documentation of this file.
1#ifndef YAZE_APP_GUI_BPP_FORMAT_UI_H
2#define YAZE_APP_GUI_BPP_FORMAT_UI_H
3
4#include <string>
5#include <vector>
6#include <functional>
7
9#include "app/gfx/bitmap.h"
11
12namespace yaze {
13namespace gui {
14
22 public:
27 explicit BppFormatUI(const std::string& id);
28
36 bool RenderFormatSelector(gfx::Bitmap* bitmap, const gfx::SnesPalette& palette,
37 std::function<void(gfx::BppFormat)> on_format_changed);
38
44 void RenderAnalysisPanel(const gfx::Bitmap& bitmap, const gfx::SnesPalette& palette);
45
52 void RenderConversionPreview(const gfx::Bitmap& bitmap, gfx::BppFormat target_format,
53 const gfx::SnesPalette& palette);
54
61 void RenderSheetAnalysis(const std::vector<uint8_t>& sheet_data, int sheet_id,
62 const gfx::SnesPalette& palette);
63
69
75
82 bool IsConversionAvailable(gfx::BppFormat from_format, gfx::BppFormat to_format) const;
83
90 int GetConversionEfficiency(gfx::BppFormat from_format, gfx::BppFormat to_format) const;
91
92 private:
93 std::string id_;
99
100 // Analysis cache
101 std::unordered_map<int, gfx::GraphicsSheetAnalysis> cached_analysis_;
102
103 // UI state
106
107 // Helper methods
108 void RenderFormatInfo(const gfx::BppFormatInfo& info);
109 void RenderColorUsageChart(const std::vector<int>& color_usage);
110 void RenderConversionHistory(const std::string& history);
111 std::string GetFormatDescription(gfx::BppFormat format) const;
112 ImVec4 GetFormatColor(gfx::BppFormat format) const;
113 void UpdateAnalysisCache(int sheet_id, const gfx::GraphicsSheetAnalysis& analysis);
114};
115
120 public:
125 explicit BppConversionDialog(const std::string& id);
126
133 void Show(const gfx::Bitmap& bitmap, const gfx::SnesPalette& palette,
134 std::function<void(gfx::BppFormat, bool)> on_convert);
135
140 bool Render();
141
146 bool IsOpen() const { return is_open_; }
147
151 void Close() { is_open_ = false; }
152
153 private:
154 std::string id_;
160 std::function<void(gfx::BppFormat, bool)> convert_callback_;
161
162 // Preview data
163 std::vector<uint8_t> preview_data_;
166
167 // UI state
170
171 // Helper methods
172 void UpdatePreview();
174 void RenderPreview();
175 void RenderOptions();
176 void RenderButtons();
177};
178
183 public:
188 explicit BppComparisonTool(const std::string& id);
189
195 void SetSource(const gfx::Bitmap& bitmap, const gfx::SnesPalette& palette);
196
200 void Render();
201
206 bool IsOpen() const { return is_open_; }
207
211 void Open() { is_open_ = true; }
212
216 void Close() { is_open_ = false; }
217
218 private:
219 std::string id_;
221
222 // Source data
226
227 // Comparison data
228 std::unordered_map<gfx::BppFormat, gfx::Bitmap> comparison_bitmaps_;
229 std::unordered_map<gfx::BppFormat, gfx::SnesPalette> comparison_palettes_;
230 std::unordered_map<gfx::BppFormat, bool> comparison_valid_;
231
232 // UI state
236
237 // Helper methods
238 void GenerateComparisons();
240 void RenderMetrics();
242 std::string CalculateMetrics(gfx::BppFormat format) const;
243};
244
245} // namespace gui
246} // namespace yaze
247
248#endif // YAZE_APP_GUI_BPP_FORMAT_UI_H
Represents a bitmap image optimized for SNES ROM hacking.
Definition bitmap.h:66
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
BPP format comparison tool.
gfx::BppFormat selected_comparison_
std::string CalculateMetrics(gfx::BppFormat format) const
void Close()
Close the tool.
std::unordered_map< gfx::BppFormat, gfx::Bitmap > comparison_bitmaps_
gfx::SnesPalette source_palette_
bool IsOpen() const
Check if tool is open.
void Render()
Render the comparison tool.
void SetSource(const gfx::Bitmap &bitmap, const gfx::SnesPalette &palette)
Set source bitmap for comparison.
std::unordered_map< gfx::BppFormat, gfx::SnesPalette > comparison_palettes_
std::unordered_map< gfx::BppFormat, bool > comparison_valid_
void Open()
Open the tool.
BPP format conversion dialog.
std::function< void(gfx::BppFormat, bool)> convert_callback_
bool Render()
Render the dialog.
bool IsOpen() const
Check if dialog is open.
std::vector< uint8_t > preview_data_
void Show(const gfx::Bitmap &bitmap, const gfx::SnesPalette &palette, std::function< void(gfx::BppFormat, bool)> on_convert)
Show the conversion dialog.
void Close()
Close the dialog.
BPP format selection and conversion UI component.
bool RenderFormatSelector(gfx::Bitmap *bitmap, const gfx::SnesPalette &palette, std::function< void(gfx::BppFormat)> on_format_changed)
Render the BPP format selection UI.
void RenderAnalysisPanel(const gfx::Bitmap &bitmap, const gfx::SnesPalette &palette)
Render format analysis panel.
void SetSelectedFormat(gfx::BppFormat format)
Set the selected BPP format.
int GetConversionEfficiency(gfx::BppFormat from_format, gfx::BppFormat to_format) const
Get conversion efficiency score.
void RenderSheetAnalysis(const std::vector< uint8_t > &sheet_data, int sheet_id, const gfx::SnesPalette &palette)
Render graphics sheet analysis.
ImVec4 GetFormatColor(gfx::BppFormat format) const
std::string GetFormatDescription(gfx::BppFormat format) const
std::string last_analysis_sheet_
gfx::BppFormat GetSelectedFormat() const
Get currently selected BPP format.
bool IsConversionAvailable(gfx::BppFormat from_format, gfx::BppFormat to_format) const
Check if format conversion is available.
void RenderConversionHistory(const std::string &history)
void RenderFormatInfo(const gfx::BppFormatInfo &info)
void UpdateAnalysisCache(int sheet_id, const gfx::GraphicsSheetAnalysis &analysis)
std::unordered_map< int, gfx::GraphicsSheetAnalysis > cached_analysis_
void RenderConversionPreview(const gfx::Bitmap &bitmap, gfx::BppFormat target_format, const gfx::SnesPalette &palette)
Render conversion preview.
gfx::BppFormat preview_format_
gfx::BppFormat selected_format_
void RenderColorUsageChart(const std::vector< int > &color_usage)
BppFormat
BPP format enumeration for SNES graphics.
Main namespace for the application.
BPP format metadata and conversion information.
Graphics sheet analysis result.