yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
palette_editor.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_PALETTE_EDITOR_H
2#define YAZE_APP_EDITOR_PALETTE_EDITOR_H
3
4#include "absl/status/status.h"
8#include "app/gui/canvas.h"
9#include "app/gui/icons.h"
10#include "app/rom.h"
11#include "imgui/imgui.h"
12
13namespace yaze {
14namespace app {
15namespace editor {
16
17namespace palette_internal {
25
27 public:
28 void RecordChange(const std::string& group_name, size_t palette_index,
29 size_t color_index, const gfx::SnesColor& original_color,
30 const gfx::SnesColor& new_color) {
31 if (recent_changes_.size() >= kMaxHistorySize) {
32 recent_changes_.pop_front();
33 }
34
35 recent_changes_.push_back(
36 {group_name, palette_index, color_index, original_color, new_color});
37 }
38
39 gfx::SnesColor RestoreOriginalColor(const std::string& group_name,
40 size_t palette_index,
41 size_t color_index) const {
42 for (const auto& change : recent_changes_) {
43 if (change.group_name == group_name &&
44 change.palette_index == palette_index &&
45 change.color_index == color_index) {
46 return change.original_color;
47 }
48 }
49 return gfx::SnesColor();
50 }
51
52 auto size() const { return recent_changes_.size(); }
53
55 return recent_changes_[index].new_color;
56 }
58 return recent_changes_[index].original_color;
59 }
60
61 const std::deque<PaletteChange>& GetRecentChanges() const {
62 return recent_changes_;
63 }
64
65 private:
66 std::deque<PaletteChange> recent_changes_;
67 static const size_t kMaxHistorySize = 50;
68};
69} // namespace palette_internal
70
71absl::Status DisplayPalette(gfx::SnesPalette& palette, bool loaded);
72
77class PaletteEditor : public SharedRom, public Editor {
78 public:
83
84 absl::Status Update() override;
85
86 absl::Status Cut() override { return absl::OkStatus(); }
87 absl::Status Copy() override { return absl::OkStatus(); }
88 absl::Status Paste() override { return absl::OkStatus(); }
89 absl::Status Undo() override { return absl::OkStatus(); }
90 absl::Status Redo() override { return absl::OkStatus(); }
91 absl::Status Find() override { return absl::OkStatus(); }
92
94
95 absl::Status EditColorInPalette(gfx::SnesPalette& palette, int index);
96 absl::Status ResetColorToOriginal(gfx::SnesPalette& palette, int index,
97 const gfx::SnesPalette& originalPalette);
98 absl::Status DrawPaletteGroup(int category, bool right_side = false);
99
100 void DrawCustomPalette();
101
102 void DrawModifiedColors();
103
104 private:
105 absl::Status HandleColorPopup(gfx::SnesPalette& palette, int i, int j, int n);
106
107 absl::Status status_;
109
111
112 std::vector<gfx::SnesColor> custom_palette_;
113
114 ImVec4 saved_palette_[256] = {};
115
117};
118
119} // namespace editor
120} // namespace app
121} // namespace yaze
122
123#endif
A class to hold a shared pointer to a Rom object.
Definition rom.h:585
Interface for editor classes.
Definition editor.h:39
Manage graphics group configurations in a Rom.
Allows the user to view and edit in game palettes.
absl::Status ResetColorToOriginal(gfx::SnesPalette &palette, int index, const gfx::SnesPalette &originalPalette)
absl::Status Update() override
absl::Status Cut() override
absl::Status Copy() override
absl::Status Redo() override
absl::Status HandleColorPopup(gfx::SnesPalette &palette, int i, int j, int n)
std::vector< gfx::SnesColor > custom_palette_
absl::Status Find() override
absl::Status Paste() override
absl::Status EditColorInPalette(gfx::SnesPalette &palette, int index)
absl::Status DrawPaletteGroup(int category, bool right_side=false)
absl::Status Undo() override
palette_internal::PaletteEditorHistory history_
void RecordChange(const std::string &group_name, size_t palette_index, size_t color_index, const gfx::SnesColor &original_color, const gfx::SnesColor &new_color)
gfx::SnesColor RestoreOriginalColor(const std::string &group_name, size_t palette_index, size_t color_index) const
const std::deque< PaletteChange > & GetRecentChanges() const
SNES Color container.
Definition snes_color.h:38
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
absl::Status DisplayPalette(gfx::SnesPalette &palette, bool loaded)
Definition common.cc:21