[nostalgia/core/studio] Remove Tile Count field from tile sheet importer
This commit is contained in:
parent
74ef768b6f
commit
33047fc047
@ -56,26 +56,23 @@ namespace {
|
||||
return colors.size();
|
||||
}
|
||||
|
||||
[[nodiscard]] std::unique_ptr<core::NostalgiaGraphic> imgToNg(QString argSrc, int argTiles, int argBpp) {
|
||||
constexpr auto TilePixels = PixelsPerTile;
|
||||
[[nodiscard]] std::unique_ptr<core::NostalgiaGraphic> imgToNg(QString argSrc, int argBpp) {
|
||||
QImage src(argSrc);
|
||||
|
||||
if (src.isNull()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto Pixels = argTiles ? argTiles * TilePixels : src.width() * src.height();
|
||||
if (argTiles == 0) {
|
||||
argTiles = Pixels / PixelsPerTile;
|
||||
}
|
||||
const auto Colors = countColors(src, argTiles);
|
||||
const auto Pixels = src.width() * src.height();
|
||||
const auto Tiles = Pixels / PixelsPerTile;
|
||||
const auto Colors = countColors(src, Tiles);
|
||||
if (argBpp != 4 && argBpp != 8) {
|
||||
argBpp = Colors > 16 ? 8 : 4;
|
||||
}
|
||||
|
||||
QMap<QRgb, int> colors;
|
||||
auto ng = std::make_unique<core::NostalgiaGraphic>();
|
||||
ng->pal.colors.resize(countColors(src, argTiles));
|
||||
ng->pal.colors.resize(countColors(src, Tiles));
|
||||
if (argBpp == 4) {
|
||||
ng->tiles.resize(Pixels / 2);
|
||||
} else {
|
||||
@ -90,7 +87,7 @@ namespace {
|
||||
for (int x = 0; x < src.width(); x++) {
|
||||
for (int y = 0; y < src.height(); y++) {
|
||||
auto destI = pointToIdx(src.width(), x, y);
|
||||
if (destI < argTiles * PixelsPerTile) {
|
||||
if (destI < Tiles * PixelsPerTile) {
|
||||
const auto c = src.pixel(x, y);
|
||||
// assign color a color id for the palette
|
||||
if (!colors.contains(c)) {
|
||||
|
@ -29,6 +29,6 @@ template<typename T>
|
||||
return buff;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::unique_ptr<core::NostalgiaGraphic> imgToNg(QString argInPath, int argTiles, int argBpp = -1);
|
||||
[[nodiscard]] std::unique_ptr<core::NostalgiaGraphic> imgToNg(QString argInPath, int argBpp = -1);
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ ImportTilesheetWizardMainPage::ImportTilesheetWizardMainPage(const studio::Conte
|
||||
auto fileTypes = "(*.png);;(*.bmp);;(*.jpg);;(*.jpeg)";
|
||||
addPathBrowse(tr("Tile Sheet &Path:"), QString(ImportPath) + "*", "",
|
||||
QFileDialog::ExistingFile, fileTypes);
|
||||
addLineEdit(tr("Til&es:"), QString(TileCount), "");
|
||||
}
|
||||
|
||||
ImportTilesheetWizardPalettePage::ImportTilesheetWizardPalettePage(const studio::Context *ctx) {
|
||||
@ -43,13 +42,12 @@ ImportTilesheetWizardPalettePage::ImportTilesheetWizardPalettePage(const studio:
|
||||
int ImportTilesheetWizardPalettePage::accept() {
|
||||
const auto tilesheetName = field(TileSheetName).toString();
|
||||
const auto importPath = field(ImportPath).toString();
|
||||
const auto tileCount = field(TileCount).toInt();
|
||||
const auto paletteName = field(PaletteName).toString();
|
||||
const auto outPath = TileSheetDir + tilesheetName + FileExt_ng;
|
||||
if (!QFile(importPath).exists()) {
|
||||
return OxError(1);
|
||||
}
|
||||
auto ng = imgToNg(importPath, tileCount, 0);
|
||||
auto ng = imgToNg(importPath, 0);
|
||||
if (!ng) {
|
||||
return OxError(1);
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ constexpr auto TileSheetName = "tilesheetName";
|
||||
constexpr auto ImportPath = "importPath";
|
||||
constexpr auto Palette = "palette";
|
||||
constexpr auto PaletteName = "paletteName";
|
||||
constexpr auto TileCount = "tileCount";
|
||||
|
||||
class ImportTilesheetWizardMainPage: public studio::WizardFormPage {
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user