Rename SNESPalette, SNESColor to SnesPalette, SnesColor
Create snes_color.h and snes_color.cc to separate concerns
This commit is contained in:
@@ -98,13 +98,13 @@ void GfxGroupEditor::DrawBlocksetViewer(bool sheet_only) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
int sheet_id = rom()->main_blockset_ids[selected_blockset_][i];
|
||||
auto &sheet = *rom()->bitmap_manager()[sheet_id];
|
||||
if (sheet_id != last_sheet_id_) {
|
||||
last_sheet_id_ = sheet_id;
|
||||
auto palette_group = rom()->palette_group("ow_main");
|
||||
auto palette = palette_group[preview_palette_id_];
|
||||
sheet.ApplyPalette(palette);
|
||||
rom()->UpdateBitmap(&sheet);
|
||||
}
|
||||
// if (sheet_id != last_sheet_id_) {
|
||||
// last_sheet_id_ = sheet_id;
|
||||
// auto palette_group = rom()->palette_group("ow_main");
|
||||
// auto palette = palette_group[preview_palette_id_];
|
||||
// sheet.ApplyPalette(palette);
|
||||
// rom()->UpdateBitmap(&sheet);
|
||||
// }
|
||||
gui::BitmapCanvasPipeline(blockset_canvas_, sheet, 256, 0x10 * 0x04,
|
||||
0x20, true, false, 22);
|
||||
}
|
||||
@@ -186,7 +186,7 @@ void GfxGroupEditor::DrawSpritesetViewer(bool sheet_only) {
|
||||
}
|
||||
|
||||
namespace {
|
||||
void DrawPaletteFromPaletteGroup(gfx::SNESPalette &palette) {
|
||||
void DrawPaletteFromPaletteGroup(gfx::SnesPalette &palette) {
|
||||
for (int n = 0; n < palette.size(); n++) {
|
||||
ImGui::PushID(n);
|
||||
if ((n % 8) != 0) ImGui::SameLine(0.0f, ImGui::GetStyle().ItemSpacing.y);
|
||||
|
||||
@@ -53,7 +53,7 @@ class GfxGroupEditor : public SharedROM {
|
||||
gui::Canvas roomset_canvas_;
|
||||
gui::Canvas spriteset_canvas_;
|
||||
|
||||
gfx::SNESPalette palette_;
|
||||
gfx::SnesPalette palette_;
|
||||
gfx::PaletteGroup palette_group_;
|
||||
gfx::Bitmap tile16_blockset_bmp_;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ absl::Status PaletteEditor::Update() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
void PaletteEditor::EditColorInPalette(gfx::SNESPalette& palette, int index) {
|
||||
void PaletteEditor::EditColorInPalette(gfx::SnesPalette& palette, int index) {
|
||||
if (index >= palette.size()) {
|
||||
// Handle error: the index is out of bounds
|
||||
return;
|
||||
@@ -79,8 +79,8 @@ void PaletteEditor::EditColorInPalette(gfx::SNESPalette& palette, int index) {
|
||||
}
|
||||
|
||||
void PaletteEditor::ResetColorToOriginal(
|
||||
gfx::SNESPalette& palette, int index,
|
||||
const gfx::SNESPalette& originalPalette) {
|
||||
gfx::SnesPalette& palette, int index,
|
||||
const gfx::SnesPalette& originalPalette) {
|
||||
if (index >= palette.size() || index >= originalPalette.size()) {
|
||||
// Handle error: the index is out of bounds
|
||||
return;
|
||||
@@ -136,7 +136,7 @@ absl::Status PaletteEditor::DrawPaletteGroup(int category) {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status PaletteEditor::HandleColorPopup(gfx::SNESPalette& palette, int i,
|
||||
absl::Status PaletteEditor::HandleColorPopup(gfx::SnesPalette& palette, int i,
|
||||
int j, int n) {
|
||||
auto col = gfx::ToFloatArray(palette[n]);
|
||||
if (ImGui::ColorEdit4("Edit Color", col.data(), color_popup_flags)) {
|
||||
@@ -167,7 +167,7 @@ absl::Status PaletteEditor::HandleColorPopup(gfx::SNESPalette& palette, int i,
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
void PaletteEditor::DisplayPalette(gfx::SNESPalette& palette, bool loaded) {
|
||||
void PaletteEditor::DisplayPalette(gfx::SnesPalette& palette, bool loaded) {
|
||||
static ImVec4 color = ImVec4(0, 0, 0, 255.f);
|
||||
ImGuiColorEditFlags misc_flags = ImGuiColorEditFlags_AlphaPreview |
|
||||
ImGuiColorEditFlags_NoDragDrop |
|
||||
@@ -245,7 +245,7 @@ void PaletteEditor::DisplayPalette(gfx::SNESPalette& palette, bool loaded) {
|
||||
}
|
||||
}
|
||||
|
||||
void PaletteEditor::DrawPortablePalette(gfx::SNESPalette& palette) {
|
||||
void PaletteEditor::DrawPortablePalette(gfx::SnesPalette& palette) {
|
||||
static bool init = false;
|
||||
if (!init) {
|
||||
InitializeSavedPalette(palette);
|
||||
|
||||
@@ -29,16 +29,16 @@ struct PaletteChange {
|
||||
std::string groupName;
|
||||
size_t paletteIndex;
|
||||
size_t colorIndex;
|
||||
gfx::SNESColor originalColor;
|
||||
gfx::SNESColor newColor;
|
||||
gfx::SnesColor originalColor;
|
||||
gfx::SnesColor newColor;
|
||||
};
|
||||
|
||||
class PaletteEditorHistory {
|
||||
public:
|
||||
// Record a change in the palette editor
|
||||
void RecordChange(const std::string& groupName, size_t paletteIndex,
|
||||
size_t colorIndex, const gfx::SNESColor& originalColor,
|
||||
const gfx::SNESColor& newColor) {
|
||||
size_t colorIndex, const gfx::SnesColor& originalColor,
|
||||
const gfx::SnesColor& newColor) {
|
||||
// Check size and remove the oldest if necessary
|
||||
if (recentChanges.size() >= maxHistorySize) {
|
||||
recentChanges.pop_front();
|
||||
@@ -55,7 +55,7 @@ class PaletteEditorHistory {
|
||||
}
|
||||
|
||||
// Restore the original color
|
||||
gfx::SNESColor GetOriginalColor(const std::string& groupName,
|
||||
gfx::SnesColor GetOriginalColor(const std::string& groupName,
|
||||
size_t paletteIndex,
|
||||
size_t colorIndex) const {
|
||||
for (const auto& change : recentChanges) {
|
||||
@@ -67,7 +67,7 @@ class PaletteEditorHistory {
|
||||
}
|
||||
// Handle error or return default (this is just an example,
|
||||
// handle as appropriate for your application)
|
||||
return gfx::SNESColor();
|
||||
return gfx::SnesColor();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -80,17 +80,17 @@ class PaletteEditor : public SharedROM {
|
||||
absl::Status Update();
|
||||
absl::Status DrawPaletteGroups();
|
||||
|
||||
void EditColorInPalette(gfx::SNESPalette& palette, int index);
|
||||
void ResetColorToOriginal(gfx::SNESPalette& palette, int index,
|
||||
const gfx::SNESPalette& originalPalette);
|
||||
void DisplayPalette(gfx::SNESPalette& palette, bool loaded);
|
||||
void DrawPortablePalette(gfx::SNESPalette& palette);
|
||||
void EditColorInPalette(gfx::SnesPalette& palette, int index);
|
||||
void ResetColorToOriginal(gfx::SnesPalette& palette, int index,
|
||||
const gfx::SnesPalette& originalPalette);
|
||||
void DisplayPalette(gfx::SnesPalette& palette, bool loaded);
|
||||
void DrawPortablePalette(gfx::SnesPalette& palette);
|
||||
absl::Status DrawPaletteGroup(int category);
|
||||
|
||||
private:
|
||||
absl::Status HandleColorPopup(gfx::SNESPalette& palette, int i, int j, int n);
|
||||
absl::Status HandleColorPopup(gfx::SnesPalette& palette, int i, int j, int n);
|
||||
|
||||
void InitializeSavedPalette(const gfx::SNESPalette& palette) {
|
||||
void InitializeSavedPalette(const gfx::SnesPalette& palette) {
|
||||
for (int n = 0; n < palette.size(); n++) {
|
||||
saved_palette_[n].x = palette.GetColor(n).GetRGB().x / 255;
|
||||
saved_palette_[n].y = palette.GetColor(n).GetRGB().y / 255;
|
||||
|
||||
@@ -110,7 +110,7 @@ absl::Status Tile16Editor::UpdateTile16Transfer() {
|
||||
|
||||
absl::Status Tile16Editor::UpdateBlockset() {
|
||||
gui::BeginPadding(2);
|
||||
gui::BeginChildWithScrollbar(55);
|
||||
gui::BeginChildWithScrollbar("##Tile16EditorBlocksetScrollRegion");
|
||||
blockset_canvas_.DrawBackground();
|
||||
gui::EndPadding();
|
||||
blockset_canvas_.DrawContextMenu();
|
||||
|
||||
@@ -109,7 +109,7 @@ class Tile16Editor : public GfxContext, public SharedROM {
|
||||
|
||||
PaletteEditor palette_editor_;
|
||||
|
||||
gfx::SNESPalette palette_;
|
||||
gfx::SnesPalette palette_;
|
||||
zelda3::Overworld transfer_overworld_;
|
||||
|
||||
gfx::BitmapTable graphics_bin_;
|
||||
|
||||
Reference in New Issue
Block a user