Skip to content

Commit

Permalink
Merge pull request #120 from myst6re/release/1.8.5
Browse files Browse the repository at this point in the history
Release/1.8.5
  • Loading branch information
myst6re authored Aug 30, 2021
2 parents 64d2fbe + 7af3367 commit 5231723
Show file tree
Hide file tree
Showing 56 changed files with 1,310 additions and 645 deletions.
374 changes: 199 additions & 175 deletions Makou_Reactor_fr.ts

Large diffs are not rendered by default.

382 changes: 199 additions & 183 deletions Makou_Reactor_ja.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
** along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#define PROG_NAME "Makou Reactor"
#define PROG_VERSION "1.8.4"
#define PROG_VERSION "1.8.5"
#define PROG_FULLNAME QString("%1 %2").arg(PROG_NAME, PROG_VERSION)

#define RC_PRODUCT_VERSION 1,8,4,0
#define RC_PRODUCT_VERSION 1,8,5,0
#define RC_FILE_DESCRIPTION_STR "Makou Reactor FF7 Field Editor"
#define RC_COMPANY_NAME_STR "myst6re"

Expand Down
23 changes: 10 additions & 13 deletions Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Window::Window() :
actionEncounter = menu->addAction(tr("Encounte&rs..."), this, SLOT(encounterManager()), QKeySequence("Ctrl+N"));
menu->addAction(tr("Tutorials/&Sounds..."), this, SLOT(tutManager()), QKeySequence("Ctrl+K"));
QAction *actionWalkmesh = menu->addAction(QIcon(":/images/location.png"), tr("&Walkmesh..."), this, SLOT(walkmeshManager()), QKeySequence("Ctrl+W"));
menu->addAction(tr("&Background..."), this, SLOT(backgroundManager()), QKeySequence("Ctrl+B"));
menu->addAction(QIcon(":/images/background.png"), tr("&Background..."), this, SLOT(backgroundManager()), QKeySequence("Ctrl+B"));
actionMisc = menu->addAction(tr("M&iscellaneous..."), this, SLOT(miscManager()));
menu->addSeparator();
menu->addAction(tr("Variable Mana&ger..."), this, SLOT(varManager()), QKeySequence("Ctrl+G"));
Expand Down Expand Up @@ -1159,7 +1159,7 @@ void Window::exportCurrentMap()
fieldLzs = tr("PC Field Map (*)"),
dat = tr("Data DAT File (*.DAT)"),
mim = tr("Textures MIM File (*.MIM)"),
fieldDec = tr("Uncompressed PC Field Map (*)");
fieldDec = tr("Uncompressed PC Field Map (*.dec)");

name = _fieldList->selectedItems().first()->text(0);

Expand All @@ -1174,18 +1174,18 @@ void Window::exportCurrentMap()
path = QFileDialog::getSaveFileName(this, tr("Export the current file"), path+name, types, &selectedFilter);
if (path.isNull()) return;
int error = 4;
bool compressed = selectedFilter == fieldLzs;
bool decompressed = selectedFilter == fieldDec;

if (field->isModified()) {
error = field->save(path, compressed);
error = field->save(path, !decompressed);
} else {
QString extension;
if (selectedFilter == dat) {
extension = "DAT";
} else if (selectedFilter == mim) {
extension = "MIM";
}
error = fieldArchive->io()->exportFieldData(field, extension, path, !compressed);
error = fieldArchive->io()->exportFieldData(field, extension, path, decompressed);
}

QString out;
Expand Down Expand Up @@ -1298,11 +1298,9 @@ void Window::importToCurrentMap()
int index;
QString name, selectedFilter,
pc = tr("PC Field Map (*)"),
dat = tr("DAT File (*.DAT)"),
decPc = tr("Uncompressed PC Field Map (*)"),
decDat = tr("Uncompressed DAT File (*)");
dat = tr("PS Field Map (*.DAT)");
QStringList filter;
filter << pc << dat << decPc << decDat;
filter << dat << pc;

name = _fieldList->selectedItems().first()->text(0);
if (fieldArchive->io()->isPS())
Expand All @@ -1312,8 +1310,7 @@ void Window::importToCurrentMap()
path = QFileDialog::getOpenFileName(this, tr("Import a file"), path+name, filter.join(";;"), &selectedFilter);
if (path.isNull()) return;

bool isDat = selectedFilter == dat || selectedFilter == decDat;
bool isCompressed = !isDat && (selectedFilter == pc || selectedFilter == decPc);
bool isDat = selectedFilter == dat;

ImportDialog dialog((isDat && fieldArchive->io()->isPS())
|| (!isDat && fieldArchive->io()->isPC()),
Expand All @@ -1328,8 +1325,8 @@ void Window::importToCurrentMap()
}

QFile bsxDevice(dialog.bsxPath()), mimDevice(dialog.mimPath());
if (!field->importer(path, isDat, isCompressed, parts, &bsxDevice, &mimDevice)) {

if (!field->importer(path, isDat, dialog.isCompressed(), parts, &bsxDevice, &mimDevice)) {
QMessageBox::warning(this, tr("Error"), field->errorString());
return;
}
Expand Down
4 changes: 4 additions & 0 deletions core/PsColor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include <QtCore>
#include <QRgb>
#define COEFF_COLOR 8.2258064516129032258064516129032 // 255/31
#define psColorAlphaBit(color) \
((color >> 15) & 1)
#define setPsColorAlphaBit(color, alpha) \
((color & 0x7FFF) | (alpha << 15))

class PsColor
{
Expand Down
36 changes: 27 additions & 9 deletions core/TimFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool TimFile::open(const QByteArray &data)
{
// QTime t;t.start();

quint32 palSize=0, imgSize=0, color=0;
quint32 palSize=0, color=0;
quint16 w, h;
const char *constData = data.constData();
bool hasPal;
Expand Down Expand Up @@ -94,13 +94,16 @@ bool TimFile::open(const QByteArray &data)
for (int i=0; i<nbPal; ++i)
{
QVector<QRgb> pal;
QBitArray alphaBits(onePalSize);

for (quint16 j=0; j<onePalSize; ++j) {
memcpy(&color, &constData[20+pos*2+j*2], 2);
pal.append(PsColor::fromPsColor(color, true));
alphaBits.setBit(j, psColorAlphaBit(color));
}

_colorTables.append(pal);
_alphaBits.append(alphaBits);

pos += pos % palW == 0 ? onePalSize : palW - onePalSize;
}
Expand All @@ -125,7 +128,7 @@ bool TimFile::open(const QByteArray &data)
if ((quint32)dataSize < 20+palSize)
return false;

memcpy(&imgSize, &constData[8+palSize], 4);
memcpy(&sizeImgSection, &constData[8+palSize], 4);
memcpy(&imgX, &constData[12+palSize], 2);
memcpy(&imgY, &constData[14+palSize], 2);
memcpy(&w, &constData[16+palSize], 2);
Expand All @@ -134,8 +137,8 @@ bool TimFile::open(const QByteArray &data)
else if (bpp==1) w*=2;

// qDebug() << QString("-Image-");
// qDebug() << QString("Size = %1, w = %2, h = %3").arg(imgSize).arg(w).arg(h);
// qDebug() << QString("TIM Size = %1").arg(8+palSize+imgSize);
// qDebug() << QString("Size = %1, w = %2, h = %3").arg(sizeImgSection).arg(w).arg(h);
// qDebug() << QString("TIM Size = %1").arg(8+palSize+sizeImgSection);

_image = QImage(w, h, hasPal ? QImage::Format_Indexed8 : QImage::Format_ARGB32);
if (hasPal) {
Expand Down Expand Up @@ -195,10 +198,13 @@ bool TimFile::open(const QByteArray &data)
}
else if (bpp==2)
{
QBitArray alphaBits;

while (i<size && y<h)
{
memcpy(&color, &constData[20+palSize+i], 2);
pixels[x + y*w] = PsColor::fromPsColor(color, true);
alphaBits.setBit(i / 2, psColorAlphaBit(color));

++x;
if (x==w)
Expand All @@ -208,6 +214,8 @@ bool TimFile::open(const QByteArray &data)
}
i+=2;
}

_alphaBits.append(alphaBits);
}
else if (bpp==3)
{
Expand All @@ -232,6 +240,8 @@ bool TimFile::open(const QByteArray &data)

bool TimFile::save(QByteArray &data) const
{
Q_ASSERT(_colorTables.size() == _alphaBits.size());

bool hasPal = bpp <= 1;
quint32 flag = (hasPal << 3) | (bpp & 3);

Expand All @@ -249,30 +259,37 @@ bool TimFile::save(QByteArray &data) const
data.append((char *)&palW, 2);
data.append((char *)&palH, 2);

int colorTableId = 0;
for (const QVector<QRgb> &colorTable : _colorTables) {
const QBitArray &alphaBit = _alphaBits.at(colorTableId);
int i;

Q_ASSERT(colorTable.size() == colorPerPal);
Q_ASSERT(alphaBit.size() == colorPerPal);

for (i=0; i<colorTable.size() && i<colorPerPal; ++i) {
quint16 psColor = PsColor::toPsColor(colorTable.at(i));
psColor = setPsColorAlphaBit(psColor, alphaBit.at(i));
data.append((char *)&psColor, 2);
}
if (i<colorPerPal) {
data.append(QByteArray(colorPerPal - i, '\0'));
}

++colorTableId;
}

quint16 width = _image.width(), height = _image.height();
quint32 sizeImgSection = 12;
if (bpp==0) {
width/=4;
sizeImgSection += _image.width()/2 * height;
}
else {
width/=2;
sizeImgSection += _image.width() * height;
}

data.append((char *)&sizeImgSection, 4);
data.append("\x00\x00\x00\x00", 4);
data.append((char *)&imgX, 2);
data.append((char *)&imgY, 2);
data.append((char *)&width, 2);
data.append((char *)&height, 2);

Expand All @@ -290,7 +307,7 @@ bool TimFile::save(QByteArray &data) const
}
} else {
quint16 width = _image.width(), height = _image.height();
quint32 sizeImgSection = 12 + width * bpp * height;
const QBitArray &alphaBit = _alphaBits.first();

data.append((char *)&sizeImgSection, 4);
data.append((char *)&imgX, 2);
Expand All @@ -302,6 +319,7 @@ bool TimFile::save(QByteArray &data) const
for (int x=0; x<width; ++x) {
if (bpp == 2) {
quint16 color = PsColor::toPsColor(_image.pixel(x, y));
setPsColorAlphaBit(color, alphaBit.at(y * width + x));
data.append((char *)&color, 2);
} else {
QRgb c = _image.pixel(x, y);
Expand Down
2 changes: 2 additions & 0 deletions core/TimFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ class TimFile : public TextureFile
bool save(QByteArray &data) const;
private:
quint8 bpp;
quint32 sizeImgSection;
quint16 palX, palY;
quint16 palW, palH;
quint16 imgX, imgY;
QList<QBitArray> _alphaBits;
};

#endif // TIMFILE_H
20 changes: 18 additions & 2 deletions core/WindowBinFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool WindowBinFile::open(const QByteArray &data)
const char *constData = data.constData();
int cur=0;
quint16 size;
QList<quint16> positions, sizes;
QList<int> positions, sizes;

while (cur + 2 < data.size()) {
positions.append(cur);
Expand Down Expand Up @@ -94,7 +94,9 @@ bool WindowBinFile::open(const QByteArray &data)

void WindowBinFile::saveSection(const QByteArray &section, QByteArray &data, quint16 type)
{
QByteArray compressedData = GZIP::compress(section, 9);
// With compression = 9 and compression = 0, a flag we don't want is set in the header
QByteArray compressedData = GZIP::compress(section, 8);
compressedData[9] = '\x03'; // Force OS = Unix
quint16 size = compressedData.size();
data.append((char *)&size, 2);
size = section.size();
Expand Down Expand Up @@ -283,13 +285,27 @@ int WindowBinFile::palette(FontColor color, quint8 table) const

int WindowBinFile::absoluteId(quint8 table, quint8 id)
{
if (id >= tableSize(table)) {
return -1;
}

int absId = id;
for (int i=0; i<table; ++i) {
absId += tableSize(i);
}
return absId;
}

quint8 WindowBinFile::charInfo(quint8 table, quint8 id) const
{
return _charWidth.value(absoluteId(table, id));
}

void WindowBinFile::setCharInfo(quint8 table, quint8 id, quint8 info)
{
_charWidth.replace(absoluteId(table, id), info);
}

quint8 WindowBinFile::charWidth(quint8 table, quint8 id) const
{
return CHARACTER_WIDTH(charInfo(table, id));
Expand Down
8 changes: 2 additions & 6 deletions core/WindowBinFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,8 @@ class WindowBinFile
bool openFont2(const QByteArray &data);
bool openFontSize(const QByteArray &data);
static int absoluteId(quint8 table, quint8 id);
inline quint8 charInfo(quint8 table, quint8 id) const {
return _charWidth.value(absoluteId(table, id));
}
inline void setCharInfo(quint8 table, quint8 id, quint8 info) {
_charWidth.replace(absoluteId(table, id), info);
}
quint8 charInfo(quint8 table, quint8 id) const;
void setCharInfo(quint8 table, quint8 id, quint8 info);

QVector<quint8> _charWidth;
TimFile _icons, _font, _font2;
Expand Down
4 changes: 0 additions & 4 deletions core/field/BackgroundIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ bool BackgroundIOPC::write(const BackgroundFile &background) const
return false;
}

if (device()->write("FINAL FANTASY7", 14) != 14) {
return false;
}

return true;
}

Expand Down
35 changes: 33 additions & 2 deletions core/field/BsxFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ bool BsxFile::read(QList<FieldModelFilePS *> &models)
return false;
}



return true;
}

Expand Down Expand Up @@ -951,3 +949,36 @@ bool BsxFile::write(const QList<FieldModelFilePS> &models) const
Q_UNUSED(models)
return false;
}

bool BsxFile::writeModelHeader(const FieldModelFilePS &model) const
{
BsxModelHeader modelHeader;

if (sizeof(BsxModelHeader) != device()->peek((char *)&modelHeader, sizeof(BsxModelHeader))) {
qWarning() << "BsxFile::writeModelHeader model read error 1";
return false;
}

const QList<FieldModelColorDir> &lightColors = model.lightColors();
modelHeader.colorADir1 = lightColors.at(0).dirA;
modelHeader.colorADir2 = lightColors.at(0).dirB;
modelHeader.colorADir3 = lightColors.at(0).dirC;
QRGB_2_COLORRGB(lightColors.at(0).color, modelHeader.colorA);
modelHeader.colorBDir1 = lightColors.at(1).dirA;
modelHeader.colorBDir2 = lightColors.at(1).dirB;
modelHeader.colorBDir3 = lightColors.at(1).dirC;
QRGB_2_COLORRGB(lightColors.at(1).color, modelHeader.colorB);
modelHeader.colorCDir1 = lightColors.at(2).dirA;
modelHeader.colorCDir2 = lightColors.at(2).dirB;
modelHeader.colorCDir3 = lightColors.at(2).dirC;
QRGB_2_COLORRGB(lightColors.at(2).color, modelHeader.colorC);
QRGB_2_COLORRGB(model.globalColor(), modelHeader.globalColor);
modelHeader.scale = model.scale();

if (sizeof(BsxModelHeader) != device()->write((char *)&modelHeader, sizeof(BsxModelHeader))) {
qWarning() << "BsxFile::writeModelHeader model write error 2";
return false;
}

return true;
}
2 changes: 2 additions & 0 deletions core/field/BsxFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#define MODEL_SCALE_PS 4096.0f //31.0f
#define COLORRGB_2_QRGB(c) qRgb(c.red, c.green, c.blue)
#define QRGB_2_COLORRGB(c, r) r.red = qRed(c);r.green = qGreen(c);r.blue = qBlue(c)

struct BsxModelsHeader {
quint32 psxMemory;
Expand Down Expand Up @@ -199,6 +200,7 @@ class BsxFile : public IO
virtual bool seekModels();
virtual bool seekTextures();
virtual bool write(const QList<FieldModelFilePS> &models) const;
virtual bool writeModelHeader(const FieldModelFilePS &model) const;
protected:
bool readHeader();
bool readModelsHeader();
Expand Down
Loading

0 comments on commit 5231723

Please sign in to comment.