[nostalgia/core/studio] Remove alpha bit from PaletteEditor

This commit is contained in:
Gary Talent 2021-02-02 02:24:44 -06:00
parent bc8d50f3e7
commit 983a9b87d5
2 changed files with 9 additions and 12 deletions

View File

@ -46,7 +46,7 @@ struct GbaTileMapTarget {
template<typename T> template<typename T>
ox::Error modelRead(T *io, GbaPaletteTarget *t) { ox::Error modelRead(T *io, GbaPaletteTarget *t) {
io->template setTypeInfo<GbaPaletteTarget>(); io->template setTypeInfo<GbaPaletteTarget>();
auto colorHandler = [t](std::size_t i, Color16 *c) { const auto colorHandler = [t](std::size_t i, Color16 *c) {
t->palette[i] = *c; t->palette[i] = *c;
return OxError(0); return OxError(0);
}; };
@ -148,9 +148,9 @@ ox::Error loadBgTileSheet(Context *ctx,
oxReturnError(ox::readMC(ts, tsStat.size, &target)); oxReturnError(ox::readMC(ts, tsStat.size, &target));
// load external palette if available // load external palette if available
if (paletteAddr) { if (paletteAddr) {
auto [palStat, palStatErr] = ctx->rom->stat(paletteAddr); const auto [palStat, palStatErr] = ctx->rom->stat(paletteAddr);
oxReturnError(palStatErr); oxReturnError(palStatErr);
auto [pal, palErr] = ctx->rom->read(paletteAddr); const auto [pal, palErr] = ctx->rom->read(paletteAddr);
oxReturnError(palErr); oxReturnError(palErr);
oxReturnError(ox::readMC(pal, palStat.size, &target.pal)); oxReturnError(ox::readMC(pal, palStat.size, &target.pal));
} }

View File

@ -203,7 +203,7 @@ QWidget *PaletteEditorColorTableDelegate::createEditor(QWidget *parent, const QS
} }
void PaletteEditorColorTableDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &idx) const { void PaletteEditorColorTableDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &idx) const {
if (idx.column() != 4) { if (idx.column() != 3) {
QStyledItemDelegate::paint(painter, opt, idx); QStyledItemDelegate::paint(painter, opt, idx);
} else { } else {
auto color = idx.model()->data(idx, Qt::DisplayRole).toString(); auto color = idx.model()->data(idx, Qt::DisplayRole).toString();
@ -250,10 +250,10 @@ PaletteEditor::PaletteEditor(QString path, const studio::Context *ctx, QWidget *
m_table = new QTableWidget(this); m_table = new QTableWidget(this);
m_table->setItemDelegate(&m_colorTableDelegate); m_table->setItemDelegate(&m_colorTableDelegate);
m_table->setColumnCount(5); m_table->setColumnCount(4);
m_table->setSelectionBehavior(QAbstractItemView::SelectRows); m_table->setSelectionBehavior(QAbstractItemView::SelectRows);
m_table->setSelectionMode(QAbstractItemView::SingleSelection); m_table->setSelectionMode(QAbstractItemView::SingleSelection);
m_table->setHorizontalHeaderLabels(QStringList() << tr("Red") << tr("Green") << tr("Blue") << tr("Alpha") << tr("Color Preview")); m_table->setHorizontalHeaderLabels(QStringList() << tr("Red") << tr("Green") << tr("Blue") << tr("Color Preview"));
m_table->horizontalHeader()->setStretchLastSection(true); m_table->horizontalHeader()->setStretchLastSection(true);
m_table->verticalHeader()->hide(); m_table->verticalHeader()->hide();
canvasLyt->addWidget(m_table); canvasLyt->addWidget(m_table);
@ -277,8 +277,7 @@ void PaletteEditor::addTableRow(int i, Color16 c) {
m_table->setItem(i, 0, mkCell(red16(c))); m_table->setItem(i, 0, mkCell(red16(c)));
m_table->setItem(i, 1, mkCell(green16(c))); m_table->setItem(i, 1, mkCell(green16(c)));
m_table->setItem(i, 2, mkCell(blue16(c))); m_table->setItem(i, 2, mkCell(blue16(c)));
m_table->setItem(i, 3, mkCell(alpha16(c))); m_table->setItem(i, 3, mkCell(toQColor(m_pal->colors[static_cast<std::size_t>(i)]).name(QColor::HexArgb), false));
m_table->setItem(i, 4, mkCell(toQColor(m_pal->colors[static_cast<std::size_t>(i)]).name(QColor::HexArgb), false));
connect(m_table, &QTableWidget::cellChanged, this, &PaletteEditor::cellChanged); connect(m_table, &QTableWidget::cellChanged, this, &PaletteEditor::cellChanged);
} }
@ -293,8 +292,7 @@ void PaletteEditor::setTableRow(int idx, Color16 c) {
m_table->item(idx, 0)->setText(QString::number(red16(c))); m_table->item(idx, 0)->setText(QString::number(red16(c)));
m_table->item(idx, 1)->setText(QString::number(green16(c))); m_table->item(idx, 1)->setText(QString::number(green16(c)));
m_table->item(idx, 2)->setText(QString::number(blue16(c))); m_table->item(idx, 2)->setText(QString::number(blue16(c)));
m_table->item(idx, 3)->setText(QString::number(alpha16(c))); m_table->item(idx, 3)->setText(toQColor(m_pal->colors[static_cast<std::size_t>(idx)]).name(QColor::HexArgb));
m_table->item(idx, 4)->setText(toQColor(m_pal->colors[static_cast<std::size_t>(idx)]).name(QColor::HexArgb));
connect(m_table, &QTableWidget::cellChanged, this, &PaletteEditor::cellChanged); connect(m_table, &QTableWidget::cellChanged, this, &PaletteEditor::cellChanged);
} }
@ -342,8 +340,7 @@ Color16 PaletteEditor::rowColor(int row) const {
auto r = static_cast<uint8_t>(m_table->item(row, 0)->text().toInt()); auto r = static_cast<uint8_t>(m_table->item(row, 0)->text().toInt());
auto g = static_cast<uint8_t>(m_table->item(row, 1)->text().toInt()); auto g = static_cast<uint8_t>(m_table->item(row, 1)->text().toInt());
auto b = static_cast<uint8_t>(m_table->item(row, 2)->text().toInt()); auto b = static_cast<uint8_t>(m_table->item(row, 2)->text().toInt());
auto a = static_cast<uint8_t>(m_table->item(row, 3)->text().toInt()); return color16(r, g, b);
return color16(r, g, b, a);
} }
void PaletteEditor::colorSelected() { void PaletteEditor::colorSelected() {