Skip to content

Commit

Permalink
Merge pull request #16 from myst6re/release/0.11.0
Browse files Browse the repository at this point in the history
Release/0.11.0
  • Loading branch information
myst6re committed Apr 12, 2021
2 parents 23aefd2 + 03859d8 commit 078ad47
Show file tree
Hide file tree
Showing 61 changed files with 2,063 additions and 925 deletions.
67 changes: 67 additions & 0 deletions BackgroundExporter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/****************************************************************************
** 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 "BackgroundExporter.h"
#include "FieldPC.h"
#include "FieldArchivePC.h"

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

}

bool BackgroundExporter::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->hasBackgroundFile()) {
BackgroundFile *background = f->getBackgroundFile();
QString fieldName = f->name();

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

if (!background->background().save(dir.filePath(fieldName + ".png"))) {
_lastErrorString = QObject::tr("Impossible d'exporter '%1' en image").arg(fieldName);
}
}
}

return true;
}
36 changes: 36 additions & 0 deletions BackgroundExporter.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 BACKGROUNDEXPORTER_H
#define BACKGROUNDEXPORTER_H

#include "FieldArchive.h"

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

#endif // BACKGROUNDEXPORTER_H
30 changes: 2 additions & 28 deletions CharaModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,13 @@
****************************************************************************/
#include "CharaModel.h"

CharaModel::CharaModel(const QString &name, const QList<quint32> &toc, const QByteArray &data) :
_name(name)
{
open(toc, data);
}

CharaModel::CharaModel(const QString &name) :
_name(name)
{
}

CharaModel::CharaModel()
{
}

bool CharaModel::open(const QList<quint32> &toc, const QByteArray &data)
CharaModel::CharaModel(const QString &name, const QList<TimFile> &textures) :
_name(name), _textures(textures)
{
_textures.clear();

// Toc = tim offsets + data offset + data size

for(int i=0 ; i<toc.size()-2 ; ++i) {
quint32 pos = toc.at(i) & 0xFFFFFF;
// qDebug() << "ouverture tim" << pos << ((toc.at(i+1) & 0xFFFFFF) - pos);
_textures.append(TimFile(data.mid(pos, (toc.at(i+1) & 0xFFFFFF) - pos)));
if(!_textures.last().isValid()) {
qWarning() << "CharaModel::open tim error: unknown format!" << _name << i;
}
}

// qDebug() << "charaModel ouvert" << _name;

return true;
}

bool CharaModel::isEmpty() const
Expand Down
3 changes: 1 addition & 2 deletions CharaModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
class CharaModel
{
public:
CharaModel(const QString &name, const QList<quint32> &toc, const QByteArray &data);
CharaModel(const QString &name);
CharaModel();
explicit CharaModel(const QString &name, const QList<TimFile> &textures = QList<TimFile>());
bool open(const QList<quint32> &toc, const QByteArray &data);
bool isEmpty() const;
QString name() const;
Expand Down
6 changes: 6 additions & 0 deletions Deling.pro
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ lessThan(QT_MAJOR_VERSION, 5) {

# Input
HEADERS += MainWindow.h \
BackgroundExporter.h \
EncounterExporter.h \
PreviewWidget.h \
QLZ4.h \
ScriptExporter.h \
SearchAll.h \
parameters.h \
Data.h \
Config.h \
Expand Down Expand Up @@ -56,6 +58,7 @@ HEADERS += MainWindow.h \
FieldArchivePC.h \
JsmOpcode.h \
PlainTextEdit.h \
widgets/AboutDialog.h \
widgets/PageWidget.h \
widgets/BackgroundWidget.h \
widgets/JsmWidget.h \
Expand Down Expand Up @@ -111,10 +114,12 @@ HEADERS += MainWindow.h \
JsmExpression.h

SOURCES += MainWindow.cpp \
BackgroundExporter.cpp \
EncounterExporter.cpp \
PreviewWidget.cpp \
QLZ4.cpp \
ScriptExporter.cpp \
SearchAll.cpp \
main.cpp \
Data.cpp \
Config.cpp \
Expand Down Expand Up @@ -147,6 +152,7 @@ SOURCES += MainWindow.cpp \
FieldArchivePC.cpp \
JsmOpcode.cpp \
PlainTextEdit.cpp \
widgets/AboutDialog.cpp \
widgets/PageWidget.cpp \
widgets/BackgroundWidget.cpp \
widgets/JsmWidget.cpp \
Expand Down
12 changes: 10 additions & 2 deletions FF8DiscArchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ QByteArray FF8DiscArchive::fileLZS(const FF8DiscFile &file, bool strict)
if((strict && file.getSize() != lzsSize+4) || (!strict && (lzsSize + 4)/SECTOR_SIZE_DATA + (int)(lzsSize%SECTOR_SIZE_DATA != 0) != file.getSize()/SECTOR_SIZE_DATA + (int)(file.getSize()%SECTOR_SIZE_DATA != 0)))
return QByteArray();

return LZS::decompressAll(readIso(lzsSize).constData(), lzsSize);
return LZS::decompress(readIso(lzsSize).constData(), lzsSize);
}

QByteArray FF8DiscArchive::fileGZ(const FF8DiscFile &file)
Expand Down Expand Up @@ -174,7 +174,7 @@ bool FF8DiscArchive::extractGZ(const FF8DiscFile &file, const QString &destinati
const QList<FF8DiscFile> &FF8DiscArchive::rootDirectory()
{
if(!rootFiles.isEmpty() || !IMGFound()) return rootFiles;
searchFiles();
//searchFiles();

quint32 position, size, numSectors = sizeIMG / SECTOR_SIZE_DATA;
qint64 maxPos;
Expand Down Expand Up @@ -232,6 +232,14 @@ const FF8DiscFile &FF8DiscArchive::rootFile(int id)
return rootDirectory().at(id);
}

const FF8DiscFile &FF8DiscArchive::sysFntTdwFile()
{
if (isDemo()) {
return rootFile(isJp() ? 9 : 8);
}
return rootFile(129);
}

const FF8DiscFile &FF8DiscArchive::fieldBinFile()
{
if (isDemo()) {
Expand Down
1 change: 1 addition & 0 deletions FF8DiscArchive.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class FF8DiscArchive : public IsoArchive
const QList<FF8DiscFile> &rootDirectory();
int rootCount();
const FF8DiscFile &rootFile(int id);
const FF8DiscFile &sysFntTdwFile();
const FF8DiscFile &fieldBinFile();
// QList<FF8DiscFile> worldmapDirectory();
// FF8DiscFile worldmapFile(int id);
Expand Down
12 changes: 12 additions & 0 deletions FF8Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,18 @@ FF8Font *FF8Font::openFont(const QString &tdwPath, const QString &txtPath)
}
}

void FF8Font::registerFont(const QString &name, FF8Font *font)
{
fonts.insert(name, font);
}

void FF8Font::deregisterFont(const QString &name)
{
if(fonts.contains(name)) {
delete fonts.take(name);
}
}

FF8Font *FF8Font::font(QString name)
{
if(name.isEmpty()) {
Expand Down
2 changes: 2 additions & 0 deletions FF8Font.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class FF8Font

static bool listFonts();
static QStringList fontList();
static void registerFont(const QString &name, FF8Font *font);
static void deregisterFont(const QString &name);
static FF8Font *font(QString name);
static FF8Font *getCurrentConfigFont();
static bool saveFonts();
Expand Down
Loading

0 comments on commit 078ad47

Please sign in to comment.