[nostalgia/core/studio] Remove implicit sign conversions
This commit is contained in:
parent
b9c2f3631d
commit
4064592acc
@ -11,6 +11,8 @@ add_library(
|
||||
rsrc.qrc
|
||||
)
|
||||
|
||||
target_compile_options(NostalgiaCore-Studio PRIVATE -Wsign-conversion)
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaCore-Studio
|
||||
Qt5::Core
|
||||
|
@ -22,7 +22,7 @@ namespace {
|
||||
const auto r = static_cast<uint32_t>(c.red()) >> 3;
|
||||
const auto g = static_cast<uint32_t>(c.green()) >> 3;
|
||||
const auto b = static_cast<uint32_t>(c.blue()) >> 3;
|
||||
const auto a = static_cast<uint32_t>(c.alpha()) > 128 ? 1 : 0;
|
||||
const auto a = static_cast<uint32_t>(c.alpha() > 128 ? 1 : 0);
|
||||
return (a << 15) | (r << 10) | (g << 5) | (b << 0);
|
||||
}
|
||||
|
||||
@ -72,11 +72,11 @@ namespace {
|
||||
|
||||
QMap<QRgb, int> colors;
|
||||
auto ng = std::make_unique<core::NostalgiaGraphic>();
|
||||
ng->pal.colors.resize(countColors(src, Tiles));
|
||||
ng->pal.colors.resize(static_cast<std::size_t>(countColors(src, Tiles)));
|
||||
if (argBpp == 4) {
|
||||
ng->tiles.resize(Pixels / 2);
|
||||
ng->tiles.resize(static_cast<std::size_t>(Pixels / 2));
|
||||
} else {
|
||||
ng->tiles.resize(Pixels);
|
||||
ng->tiles.resize(static_cast<std::size_t>(Pixels));
|
||||
}
|
||||
ng->bpp = argBpp;
|
||||
ng->columns = src.width() / TileWidth;
|
||||
@ -97,12 +97,12 @@ namespace {
|
||||
// set pixel color
|
||||
if (argBpp == 4) {
|
||||
if (destI % 2) { // is odd number pixel
|
||||
ng->tiles[destI / 2] |= colors[c] << 4;
|
||||
ng->tiles[static_cast<std::size_t>(destI / 2)] |= colors[c] << 4;
|
||||
} else {
|
||||
ng->tiles[destI / 2] |= colors[c];
|
||||
ng->tiles[static_cast<std::size_t>(destI / 2)] |= colors[c];
|
||||
}
|
||||
} else {
|
||||
ng->tiles[destI] = colors[c];
|
||||
ng->tiles[static_cast<std::size_t>(destI)] = static_cast<std::size_t>(colors[c]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -110,7 +110,7 @@ namespace {
|
||||
|
||||
// store colors in palette with the corresponding color id
|
||||
for (auto key : colors.keys()) {
|
||||
auto colorId = colors[key];
|
||||
auto colorId = static_cast<std::size_t>(colors[key]);
|
||||
ng->pal.colors[colorId] = toGbaColor(key);
|
||||
}
|
||||
|
||||
|
@ -191,14 +191,14 @@ QString PaletteEditor::itemName() const {
|
||||
}
|
||||
|
||||
void PaletteEditor::addColor(int idx, Color16 c) {
|
||||
m_pal->colors.insert(idx, c);
|
||||
m_pal->colors.insert(static_cast<std::size_t>(idx), c);
|
||||
addTableRow(idx, c);
|
||||
setUnsavedChanges(true);
|
||||
}
|
||||
|
||||
void PaletteEditor::rmColor(int idx) {
|
||||
rmTableRow(idx);
|
||||
m_pal->colors.erase(idx);
|
||||
m_pal->colors.erase(static_cast<std::size_t>(idx));
|
||||
setUnsavedChanges(true);
|
||||
}
|
||||
|
||||
@ -209,7 +209,7 @@ void PaletteEditor::addTableRow(int i, Color16 c) {
|
||||
m_table->setItem(i, 1, mkCell(green16(c)));
|
||||
m_table->setItem(i, 2, mkCell(blue16(c)));
|
||||
m_table->setItem(i, 3, mkCell(alpha16(c)));
|
||||
m_table->setItem(i, 4, mkCell(toQColor(m_pal->colors[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);
|
||||
}
|
||||
|
||||
@ -225,12 +225,12 @@ void PaletteEditor::setTableRow(int idx, Color16 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, 3)->setText(QString::number(alpha16(c)));
|
||||
m_table->item(idx, 4)->setText(toQColor(m_pal->colors[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);
|
||||
}
|
||||
|
||||
void PaletteEditor::updateColor(int idx, Color16 c) {
|
||||
m_pal->colors[idx] = c;
|
||||
m_pal->colors[static_cast<std::size_t>(idx)] = c;
|
||||
setTableRow(idx, c);
|
||||
setUnsavedChanges(true);
|
||||
}
|
||||
@ -266,7 +266,7 @@ void PaletteEditor::colorSelected() {
|
||||
}
|
||||
|
||||
void PaletteEditor::cellChanged(int row, int) {
|
||||
auto oldColor = m_pal->colors[row];
|
||||
auto oldColor = m_pal->colors[static_cast<std::size_t>(row)];
|
||||
auto newColor = rowColor(row);
|
||||
undoStack()->push(new UpdateColorCommand(this, row, oldColor, newColor));
|
||||
}
|
||||
@ -278,7 +278,7 @@ void PaletteEditor::addColorClicked() {
|
||||
|
||||
void PaletteEditor::rmColorClicked() {
|
||||
auto row = m_table->currentRow();
|
||||
undoStack()->push(new RemoveColorCommand(this, m_pal->colors[row], row));
|
||||
undoStack()->push(new RemoveColorCommand(this, m_pal->colors[static_cast<std::size_t>(row)], row));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -366,10 +366,10 @@ std::unique_ptr<NostalgiaGraphic> SheetData::toNostalgiaGraphic() const {
|
||||
ng->bpp = highestColorIdx > 15 ? 8 : 4;
|
||||
ng->columns = m_columns;
|
||||
ng->rows = m_rows;
|
||||
auto pixelCount = ng->rows * ng->columns * PixelsPerTile;
|
||||
auto pixelCount = static_cast<std::size_t>(ng->rows * ng->columns * PixelsPerTile);
|
||||
if (ng->bpp == 4) {
|
||||
ng->tiles.resize(pixelCount / 2);
|
||||
for (int i = 0; i < pixelCount; ++i) {
|
||||
for (std::size_t i = 0; i < pixelCount; ++i) {
|
||||
if (i & 1) {
|
||||
ng->tiles[i / 2] |= static_cast<uint8_t>(m_pixels[i]) << 4;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user