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