[nostalgia/core] Get TileSheetEditor's palette view working

This commit is contained in:
2022-02-16 02:34:43 -06:00
parent c1a374ca04
commit b7f726f4fd
6 changed files with 58 additions and 31 deletions

View File

@@ -63,9 +63,9 @@ void TileSheetEditorImGui::drawTileSheet(const geo::Vec2 &fbSize) noexcept {
const auto fbSizei = geo::Size(static_cast<int>(fbSize.x), static_cast<int>(fbSize.y));
if (m_framebuffer.width != fbSizei.width || m_framebuffer.height != fbSizei.height) {
m_framebuffer = glutils::generateFrameBuffer(fbSizei.width, fbSizei.height);
m_tileSheetEditor.resize(fbSize);
m_tileSheetEditor.resizeView(fbSize);
} else if (m_tileSheetEditor.updated()) {
m_tileSheetEditor.resize(fbSize);
m_tileSheetEditor.resizeView(fbSize);
m_tileSheetEditor.ackUpdate();
}
glBindFramebuffer(GL_FRAMEBUFFER, m_framebuffer);
@@ -93,7 +93,7 @@ void TileSheetEditorImGui::drawTileSheet(const geo::Vec2 &fbSize) noexcept {
const auto &winPos = ImGui::GetWindowPos();
clickPos.x -= winPos.x + 10;
clickPos.y -= winPos.y + 10;
m_tileSheetEditor.hitPixel(fbSize, clickPos);
m_tileSheetEditor.click(fbSize, clickPos, m_palIdx);
}
}
if (io.MouseReleased[0]) {
@@ -102,20 +102,30 @@ void TileSheetEditorImGui::drawTileSheet(const geo::Vec2 &fbSize) noexcept {
}
}
void TileSheetEditorImGui::drawPalettePicker() const noexcept {
void TileSheetEditorImGui::drawPalettePicker() noexcept {
// header
ImGui::BeginTable("PaletteTable", 2);
ImGui::TableSetupColumn("No.", 0, 0.35);
ImGui::TableSetupColumn("Color16", 0, 3);
ImGui::TableHeadersRow();
for (auto i = 1; auto c : m_tileSheetEditor.pal().colors) {
ImGui::TableNextColumn();
ImGui::Text("%d", i);
ImGui::TableNextColumn();
ImGui::Text("(%d, %d, %d)", red16(c), green16(c), blue16(c));
++i;
if (ImGui::BeginTable("PaletteTable", 2, ImGuiTableFlags_RowBg)) {
ImGui::TableSetupColumn("No.", 0, 0.35);
ImGui::TableSetupColumn("Color16", 0, 3);
ImGui::TableHeadersRow();
for (auto i = 0u; auto c: m_tileSheetEditor.pal().colors) {
ImGui::PushID(static_cast<int>(i));
// Column: color idx
ImGui::TableNextColumn();
const auto label = ox::BString<8>() + (i + 1);
const auto rowSelected = i == m_palIdx;
if (ImGui::Selectable(label.c_str(), rowSelected, ImGuiSelectableFlags_SpanAllColumns)) {
m_palIdx = i;
}
// Column: color RGB
ImGui::TableNextColumn();
ImGui::Text("(%d, %d, %d)", red16(c), green16(c), blue16(c));
ImGui::TableNextRow();
ImGui::PopID();
++i;
}
ImGui::EndTable();
}
ImGui::EndTable();
}
}