[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
@@ -14,15 +14,27 @@ TileSheetEditorModel::TileSheetEditorModel(Context *ctx, const ox::String &path)
oxThrowError(readObj<NostalgiaPalette>(ctx, m_img.defaultPalette).moveTo(&m_pal));
}
void TileSheetEditorModel::draw(const geo::Point &pt, std::size_t palIdx) noexcept {
void TileSheetEditorModel::cut() {
}
void TileSheetEditorModel::copy() {
}
void TileSheetEditorModel::paste() {
}
void TileSheetEditorModel::drawCommand(const geo::Point &pt, std::size_t palIdx) noexcept {
if (m_ongoingDrawCommand) {
m_updated = m_ongoingDrawCommand->append(ptToIdx(pt, m_img.columns));
} else {
pushCommand(new DrawCommand(&m_img, ptToIdx(pt, m_img.columns), palIdx));
const auto idx = ptToIdx(pt, m_img.columns);
if (m_img.getPixel(idx) != palIdx) {
pushCommand(new DrawCommand(&m_img, idx, palIdx));
}
}
}
void TileSheetEditorModel::endDraw() noexcept {
void TileSheetEditorModel::endDrawCommand() noexcept {
m_ongoingDrawCommand = nullptr;
}