update palette editor and palette set viewer
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "app/editor/utils/editor.h"
|
||||
#include "app/editor/modules/palette_editor.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gfx/snes_tile.h"
|
||||
|
||||
@@ -30,6 +30,9 @@ using ImGui::TableNextColumn;
|
||||
using ImGui::TableNextRow;
|
||||
using ImGui::TableSetupColumn;
|
||||
|
||||
using gfx::kPaletteGroupNames;
|
||||
using gfx::PaletteCategory;
|
||||
|
||||
absl::Status GfxGroupEditor::Update() {
|
||||
if (ImGui::BeginTabBar("GfxGroupEditor")) {
|
||||
if (ImGui::BeginTabItem("Main")) {
|
||||
@@ -235,11 +238,14 @@ void DrawPaletteFromPaletteGroup(gfx::SnesPalette &palette) {
|
||||
} // namespace
|
||||
|
||||
void GfxGroupEditor::DrawPaletteViewer() {
|
||||
auto dungeon_main_palette_val =
|
||||
static uint8_t &dungeon_main_palette_val =
|
||||
rom()->paletteset_ids[selected_paletteset_][0];
|
||||
auto dungeon_spr_pal_1_val = rom()->paletteset_ids[selected_paletteset_][1];
|
||||
auto dungeon_spr_pal_2_val = rom()->paletteset_ids[selected_paletteset_][2];
|
||||
auto dungeon_spr_pal_3_val = rom()->paletteset_ids[selected_paletteset_][3];
|
||||
static uint8_t &dungeon_spr_pal_1_val =
|
||||
rom()->paletteset_ids[selected_paletteset_][1];
|
||||
static uint8_t &dungeon_spr_pal_2_val =
|
||||
rom()->paletteset_ids[selected_paletteset_][2];
|
||||
static uint8_t &dungeon_spr_pal_3_val =
|
||||
rom()->paletteset_ids[selected_paletteset_][3];
|
||||
|
||||
gui::InputHexByte("Dungeon Main", &dungeon_main_palette_val);
|
||||
gui::InputHexByte("Dungeon Spr Pal 1", &dungeon_spr_pal_1_val);
|
||||
@@ -249,18 +255,37 @@ void GfxGroupEditor::DrawPaletteViewer() {
|
||||
auto &palette = *rom()->mutable_palette_group()->dungeon_main.mutable_palette(
|
||||
rom()->paletteset_ids[selected_paletteset_][0]);
|
||||
DrawPaletteFromPaletteGroup(palette);
|
||||
SameLine();
|
||||
rom()->resource_label()->SelectableLabelWithNameEdit(
|
||||
false, kPaletteGroupNames[PaletteCategory::kDungeons].data(),
|
||||
std::to_string(dungeon_main_palette_val), "Unnamed dungeon palette");
|
||||
|
||||
auto &spr_aux_pal1 =
|
||||
*rom()->mutable_palette_group()->sprites_aux1.mutable_palette(
|
||||
rom()->paletteset_ids[selected_paletteset_][1]);
|
||||
DrawPaletteFromPaletteGroup(spr_aux_pal1);
|
||||
SameLine();
|
||||
rom()->resource_label()->SelectableLabelWithNameEdit(
|
||||
false, kPaletteGroupNames[PaletteCategory::kSpritesAux1].data(),
|
||||
std::to_string(dungeon_spr_pal_1_val), "Dungeon Spr Pal 1");
|
||||
|
||||
auto &spr_aux_pal2 =
|
||||
*rom()->mutable_palette_group()->sprites_aux2.mutable_palette(
|
||||
rom()->paletteset_ids[selected_paletteset_][2]);
|
||||
DrawPaletteFromPaletteGroup(spr_aux_pal2);
|
||||
SameLine();
|
||||
rom()->resource_label()->SelectableLabelWithNameEdit(
|
||||
false, kPaletteGroupNames[PaletteCategory::kSpritesAux2].data(),
|
||||
std::to_string(dungeon_spr_pal_2_val), "Dungeon Spr Pal 2");
|
||||
|
||||
auto &spr_aux_pal3 =
|
||||
*rom()->mutable_palette_group()->sprites_aux3.mutable_palette(
|
||||
rom()->paletteset_ids[selected_paletteset_][3]);
|
||||
DrawPaletteFromPaletteGroup(spr_aux_pal3);
|
||||
SameLine();
|
||||
rom()->resource_label()->SelectableLabelWithNameEdit(
|
||||
false, kPaletteGroupNames[PaletteCategory::kSpritesAux3].data(),
|
||||
std::to_string(dungeon_spr_pal_3_val), "Dungeon Spr Pal 3");
|
||||
}
|
||||
|
||||
} // namespace editor
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/status/statusor.h"
|
||||
#include "app/editor/modules/palette_editor.h"
|
||||
#include "app/editor/utils/editor.h"
|
||||
#include "app/gfx/bitmap.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
@@ -54,8 +53,6 @@ class GfxGroupEditor : public SharedRom {
|
||||
uint8_t selected_spriteset_ = 0;
|
||||
uint8_t selected_paletteset_ = 0;
|
||||
|
||||
PaletteEditor palette_editor_;
|
||||
|
||||
gui::Canvas blockset_canvas_;
|
||||
gui::Canvas roomset_canvas_;
|
||||
gui::Canvas spriteset_canvas_;
|
||||
|
||||
@@ -45,6 +45,8 @@ using ImGui::Text;
|
||||
using ImGui::TreeNode;
|
||||
using ImGui::TreePop;
|
||||
|
||||
using namespace gfx;
|
||||
|
||||
constexpr ImGuiTableFlags kPaletteTableFlags =
|
||||
ImGuiTableFlags_Reorderable | ImGuiTableFlags_Resizable |
|
||||
ImGuiTableFlags_SizingStretchSame;
|
||||
@@ -87,7 +89,8 @@ absl::Status PaletteEditor::Update() {
|
||||
if (BeginTable("paletteEditorTable", 2, kPaletteTableFlags, ImVec2(0, 0))) {
|
||||
TableSetupColumn("Palette Groups", ImGuiTableColumnFlags_WidthStretch,
|
||||
GetContentRegionAvail().x);
|
||||
TableSetupColumn("Metadata", ImGuiTableColumnFlags_WidthStretch,
|
||||
TableSetupColumn("Palette Sets and Metadata",
|
||||
ImGuiTableColumnFlags_WidthStretch,
|
||||
GetContentRegionAvail().x);
|
||||
TableHeadersRow();
|
||||
TableNextRow();
|
||||
@@ -100,6 +103,8 @@ absl::Status PaletteEditor::Update() {
|
||||
DisplayCategoryTable();
|
||||
|
||||
TableNextColumn();
|
||||
gfx_group_editor_.DrawPaletteViewer();
|
||||
Separator();
|
||||
static bool in_use = false;
|
||||
ImGui::Checkbox("Palette in use? ", &in_use);
|
||||
Separator();
|
||||
@@ -205,11 +210,6 @@ absl::Status PaletteEditor::DrawPaletteGroup(int category) {
|
||||
|
||||
static bool edit_color = false;
|
||||
for (int j = 0; j < size; j++) {
|
||||
rom()->resource_label()->SelectableLabelWithNameEdit(
|
||||
false, palette_group_name.data(), /*key=*/std::to_string(j),
|
||||
"Unnamed Palette");
|
||||
SameLine();
|
||||
|
||||
gfx::SnesPalette* palette = palette_group.mutable_palette(j);
|
||||
auto pal_size = palette->size();
|
||||
|
||||
@@ -238,6 +238,10 @@ absl::Status PaletteEditor::DrawPaletteGroup(int category) {
|
||||
|
||||
PopID();
|
||||
}
|
||||
SameLine();
|
||||
rom()->resource_label()->SelectableLabelWithNameEdit(
|
||||
false, palette_group_name.data(), /*key=*/std::to_string(j),
|
||||
"Unnamed Palette");
|
||||
}
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "app/editor/modules/gfx_group_editor.h"
|
||||
#include "app/editor/utils/editor.h"
|
||||
#include "app/gfx/snes_palette.h"
|
||||
#include "app/gui/canvas.h"
|
||||
@@ -14,37 +15,6 @@ namespace yaze {
|
||||
namespace app {
|
||||
namespace editor {
|
||||
|
||||
constexpr int kNumPalettes = 14;
|
||||
|
||||
enum PaletteCategory {
|
||||
kSword,
|
||||
kShield,
|
||||
kClothes,
|
||||
kWorldColors,
|
||||
kAreaColors,
|
||||
kGlobalSprites,
|
||||
kSpritesAux1,
|
||||
kSpritesAux2,
|
||||
kSpritesAux3,
|
||||
kDungeons,
|
||||
kWorldMap,
|
||||
kDungeonMap,
|
||||
kTriforce,
|
||||
kCrystal
|
||||
};
|
||||
|
||||
static constexpr absl::string_view kPaletteCategoryNames[] = {
|
||||
"Sword", "Shield", "Clothes", "World Colors",
|
||||
"Area Colors", "Global Sprites", "Sprites Aux1", "Sprites Aux2",
|
||||
"Sprites Aux3", "Dungeons", "World Map", "Dungeon Map",
|
||||
"Triforce", "Crystal"};
|
||||
|
||||
static constexpr absl::string_view kPaletteGroupNames[] = {
|
||||
"swords", "shields", "armors", "ow_main",
|
||||
"ow_aux", "global_sprites", "sprites_aux1", "sprites_aux2",
|
||||
"sprites_aux3", "dungeon_main", "ow_mini_map", "ow_mini_map",
|
||||
"3d_object", "3d_object"};
|
||||
|
||||
namespace palette_internal {
|
||||
struct PaletteChange {
|
||||
std::string group_name;
|
||||
@@ -136,18 +106,19 @@ class PaletteEditor : public SharedRom, public Editor {
|
||||
}
|
||||
|
||||
absl::Status status_;
|
||||
|
||||
palette_internal::PaletteEditorHistory history_;
|
||||
|
||||
ImVec4 saved_palette_[256] = {};
|
||||
gfx::SnesColor current_color_;
|
||||
|
||||
GfxGroupEditor gfx_group_editor_;
|
||||
|
||||
ImVec4 saved_palette_[256] = {};
|
||||
ImGuiColorEditFlags color_popup_flags =
|
||||
ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_NoAlpha;
|
||||
ImGuiColorEditFlags palette_button_flags = ImGuiColorEditFlags_NoAlpha;
|
||||
ImGuiColorEditFlags palette_button_flags_2 = ImGuiColorEditFlags_NoAlpha |
|
||||
ImGuiColorEditFlags_NoPicker |
|
||||
ImGuiColorEditFlags_NoTooltip;
|
||||
|
||||
palette_internal::PaletteEditorHistory history_;
|
||||
};
|
||||
|
||||
} // namespace editor
|
||||
|
||||
Reference in New Issue
Block a user