Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
myst6re committed Jan 4, 2020
2 parents f4d05b7 + 9311254 commit 3d7c15a
Show file tree
Hide file tree
Showing 40 changed files with 1,485 additions and 742 deletions.
2 changes: 1 addition & 1 deletion BGPreview2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void BGPreview2::mousePressEvent(QMouseEvent *event)

void BGPreview2::savePixmap()
{
QString path = QFileDialog::getSaveFileName(this, tr("Enregistrer l'image"), name, tr("Image PNG (*.png);;Image JPG (*.jpg);;Image BMP (*.bmp);;Portable Pixmap (*.ppm)"));
QString path = QFileDialog::getSaveFileName(this, tr("Enregistrer l'image"), name + ".png", tr("Image PNG (*.png);;Image JPG (*.jpg);;Image BMP (*.bmp);;Portable Pixmap (*.ppm)"));
if(path.isEmpty()) return;

pixmap()->save(path);
Expand Down
8 changes: 4 additions & 4 deletions Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
****************************************************************************/
#include "Data.h"

QString Data::AppPath_cache;
QString Data::AppPathCache;

bool Data::ff8Found()
{
Expand All @@ -30,11 +30,11 @@ QString Data::AppPath()
return Config::value("appPath").toString();
}

if(AppPath_cache.isNull()) {
if(AppPathCache.isNull()) {
QSettings settings("Square Soft, Inc", "Final Fantasy VIII");
AppPath_cache = QDir::cleanPath(settings.value("1.00/AppPath", "").toString());
AppPathCache = QDir::cleanPath(settings.value("1.00/AppPath", "").toString());
}
return AppPath_cache;
return AppPathCache;
}

QString Data::location(int i)
Expand Down
2 changes: 1 addition & 1 deletion Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Data : public QObject
private:
static TranslateChar locations[LOC_COUNT];
static const char *_maplist[MAP_COUNT];
static QString AppPath_cache;
static QString AppPathCache;
};

#endif // DATA_H
2 changes: 1 addition & 1 deletion Deling.desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Desktop Entry]
Type=Application
Version=0.10.0b
Version=0.10.1b
Name=Deling
GenericName=FF8 Field Editor
GenericName[fr]=Éditeur d'écrans FF8
Expand Down
9 changes: 9 additions & 0 deletions Deling.pro
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ lessThan(QT_MAJOR_VERSION, 5) {

# Input
HEADERS += MainWindow.h \
EncounterExporter.h \
PreviewWidget.h \
QLZ4.h \
ScriptExporter.h \
parameters.h \
Data.h \
Config.h \
Expand Down Expand Up @@ -109,8 +111,10 @@ HEADERS += MainWindow.h \
JsmExpression.h

SOURCES += MainWindow.cpp \
EncounterExporter.cpp \
PreviewWidget.cpp \
QLZ4.cpp \
ScriptExporter.cpp \
main.cpp \
Data.cpp \
Config.cpp \
Expand Down Expand Up @@ -222,6 +226,11 @@ RESOURCES += Deling.qrc

# include lz4
!win32 {
macos {
INCLUDEPATH += /usr/local/include
LIBS += -L/usr/local/lib
}

LIBS += -llz4
} else {
INCLUDEPATH += lz4
Expand Down
79 changes: 79 additions & 0 deletions EncounterExporter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/****************************************************************************
** Deling Final Fantasy VIII Field Editor
** Copyright (C) 2009-2020 Arzel Jérôme <[email protected]>
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "EncounterExporter.h"
#include "FieldPC.h"
#include "FieldArchivePC.h"

EncounterExporter::EncounterExporter(FieldArchive *archive) :
_archive(archive)
{

}

bool EncounterExporter::toDir(const QDir &dir, ArchiveObserver *observer)
{
if (!_archive) {
return false;
}

FieldArchiveIterator it = _archive->iterator();

if (observer) {
observer->setObserverMaximum(quint32(_archive->nbFields()));
}

int i = 0;

while (it.hasNext()) {
Field *f = it.next();

if (observer) {
if (observer->observerWasCanceled()) {
return false;
}
observer->setObserverValue(i++);
}

if (f && f->isOpen() && (!f->isPc() || ((FieldPC *)f)->open2(((FieldArchivePC *)_archive)->getFsArchive())) && f->hasMrtFile()) {
MrtFile *mrt = f->getMrtFile();
QString fieldName = f->name();

if (fieldName.isEmpty()) {
fieldName = QObject::tr("sans-nom");
}

QFile file(dir.filePath(fieldName + ".txt"));
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {
for (int i = 0; i < 4; ++i) {
file.write(QString("Stage %1\n").arg(mrt->formation(i)).toUtf8());
}
if (f->hasRatFile()) {
RatFile *rat = f->getRatFile();
file.write(QString("Rate %1\n").arg(rat->rate()).toUtf8());
} else {
file.write(QString("Rate -\n").toUtf8());
}
} else {
_lastErrorString = file.errorString();
return false;
}
}
}

return true;
}
36 changes: 36 additions & 0 deletions EncounterExporter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/****************************************************************************
** Deling Final Fantasy VIII Field Editor
** Copyright (C) 2009-2020 Arzel Jérôme <[email protected]>
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#ifndef ENCOUNTEREXPORTER_H
#define ENCOUNTEREXPORTER_H

#include "FieldArchive.h"

class EncounterExporter
{
public:
explicit EncounterExporter(FieldArchive *archive);
bool toDir(const QDir &dir, ArchiveObserver *observer = nullptr);
inline const QString &errorString() const {
return _lastErrorString;
}
private:
FieldArchive *_archive;
QString _lastErrorString;
};

#endif // ENCOUNTEREXPORTER_H
11 changes: 11 additions & 0 deletions FieldArchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,17 @@ QList<int> FieldArchive::searchAllCards(int fieldID) const
return QList<int>();
}

QList<int> FieldArchive::searchAllCardPlayers(int fieldID) const
{
Field *field = getField(fieldID);

if(field && field->hasJsmFile()) {
return field->getJsmFile()->searchAllCardPlayers(field->name());
}

return QList<int>();
}

QMap<Field *, QList<int> > FieldArchive::searchAllBattles() const
{
QMap<Field *, QList<int> > battles;
Expand Down
6 changes: 6 additions & 0 deletions FieldArchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "Field.h"
#include "files/MchFile.h"

typedef QListIterator<Field *> FieldArchiveIterator;

class FieldArchive
{
public:
Expand Down Expand Up @@ -55,13 +57,17 @@ class FieldArchive
QMultiMap<int, QString> searchAllVars() const;
QList<int> searchAllSpells(int fieldID) const;
QList<int> searchAllCards(int fieldID) const;
QList<int> searchAllCardPlayers(int fieldID) const;
QMap<Field *, QList<int> > searchAllBattles() const;
QMultiMap<int, Field *> searchAllMoments() const;
QMap<int, int> searchAllOpcodeTypes() const;
QList<Vertex_s> searchAllSavePoints() const;
QStringList fieldList() const;
const QStringList &mapList() const;
void setMapList(const QStringList &mapList);
inline FieldArchiveIterator iterator() const {
return QListIterator<Field *>(fields);
}
protected:
QString errorMsg;
QList<Field *> fields;
Expand Down
4 changes: 2 additions & 2 deletions FsArchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ QList<FsArchive::Error> FsArchive::appendFiles(const QStringList &sources, const
data = LZS::compress(data);
int size = data.size();
data.prepend((char *)&size, 4);
} else if(FiCompression::CompressionLz4) {
} else if(compression == FiCompression::CompressionLz4) {
data = QLZ4::compress(data);
int size = data.size();
data.prepend((char *)&size, 4);
Expand Down Expand Up @@ -798,7 +798,7 @@ QList<FsArchive::Error> FsArchive::appendDir(const QString &source, const QStrin

foreach (const QString &relativePath, listDirsRec(&sourceDir)) {
sources << sourceDir.absoluteFilePath(relativePath);
destinations << destination + "\\" + relativePath;
destinations << destination + "\\" + QString(relativePath).replace('/', '\\');
}

return appendFiles(sources, destinations, compression, progress);
Expand Down
4 changes: 3 additions & 1 deletion FsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ void FsDialog::generatePreview()
int index;
if((index = FF8Image::findFirstTim(data)) != -1)
{
preview->imagePreview(QPixmap::fromImage(TimFile(data.mid(index)).image()), fileName);
TimFile timFile(data.mid(index));
timFile.setCurrentColorTable(currentPal);
preview->imagePreview(QPixmap::fromImage(timFile.image()), fileName, currentPal, timFile.colorTableCount());
}
else
{
Expand Down
Loading

0 comments on commit 3d7c15a

Please sign in to comment.