Write JASC files with \r\n line endings

This commit is contained in:
Marcus Huderle 2019-04-06 19:58:38 -05:00
parent fe22a2fbbc
commit a61dd168cf
2 changed files with 6 additions and 15 deletions

View file

@ -277,14 +277,14 @@ void PaletteUtil::writeJASC(QString filepath, QVector<QRgb> palette, int offset,
return;
}
QString text = "JASC-PAL\n0100\n";
text += QString::number(nColors) + "\n";
QString text = "JASC-PAL\r\n0100\r\n";
text += QString::number(nColors) + "\r\n";
for (int i = offset; i < offset + nColors; i++) {
QRgb color = palette.at(i);
text += QString::number(qRed(color)) + " "
+ QString::number(qGreen(color)) + " "
+ QString::number(qBlue(color)) + "\n";
+ QString::number(qBlue(color)) + "\r\n";
}
QFile file(filepath);

View file

@ -4,6 +4,7 @@
#include "historyitem.h"
#include "log.h"
#include "parseutil.h"
#include "paletteutil.h"
#include "tile.h"
#include "tileset.h"
#include "event.h"
@ -720,20 +721,10 @@ void Project::saveTilesetTilesImage(Tileset *tileset) {
}
void Project::saveTilesetPalettes(Tileset *tileset, bool primary) {
PaletteUtil parser;
for (int i = 0; i < Project::getNumPalettesTotal(); i++) {
QString filepath = tileset->palettePaths.at(i);
QString content = "JASC-PAL\r\n";
content += "0100\r\n";
content += "16\r\n";
for (int j = 0; j < 16; j++) {
QRgb color = tileset->palettes->at(i).at(j);
content += QString("%1 %2 %3\r\n")
.arg(qRed(color))
.arg(qGreen(color))
.arg(qBlue(color));
}
saveTextFile(filepath, content);
parser.writeJASC(filepath, tileset->palettes->at(i).toVector(), 0, 16);
}
}