Skip to content

Commit

Permalink
Add context details in text XML export
Browse files Browse the repository at this point in the history
  • Loading branch information
myst6re committed Apr 15, 2024
1 parent 9b1bd35 commit 3e29160
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/3d/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void Renderer::draw(RendererPrimitiveType _type, float _pointSize)
}
}

if (!mIndex.isCreated() && !mIndex.create()) {
if (!mIndex.isCreated() && !mIndex.create()) {
#ifdef QT_DEBUG
qWarning() << "Cannot create the index buffer";
#endif
Expand Down
37 changes: 36 additions & 1 deletion src/core/field/Section1File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "Field.h"
#include "core/Config.h"
#include "core/FF7Font.h"
#include "FieldModelLoaderPC.h"

Section1File::Section1File(Field *field) :
FieldPart(field), _scale(0), _version(0)
Expand Down Expand Up @@ -421,16 +422,50 @@ bool Section1File::exporter(QIODevice *device, ExportFormat format)
if (!device->open(QIODevice::WriteOnly | QIODevice::Truncate)) {
return false;
}

QStringList charNames;
QString mapName = field()->name();

if (field()->isPC()) {
FieldModelLoaderPC *modelLoader = static_cast<FieldModelLoaderPC *>(field()->fieldModelLoader());
if (modelLoader != nullptr) {
charNames = modelLoader->charNames();
}
InfFile *inf = field()->inf();
if (inf != nullptr) {
mapName = inf->mapName();
}
}

QXmlStreamWriter stream(device);
stream.setAutoFormatting(true);
stream.writeStartDocument();
stream.writeStartElement("field");
stream.writeAttribute("name", field()->name());
stream.writeStartElement("texts");
int id=0;
int id = 0;
for (const FF7String &text : texts()) {
stream.writeStartElement("text");
stream.writeAttribute("id", QString::number(id));
QList<FF7Window> windows;
listWindows(id, windows);
if (!windows.empty()) {
const int groupId = windows.first().groupID;
const GrpScript &grpScript = _grpScripts.at(groupId);
stream.writeAttribute("group", grpScript.name());
const int modelId = modelID(groupId);

if (modelId >= 0 && modelId < charNames.size()) {
QString name = charNames.at(modelId);
if (name.startsWith(mapName)) {
name = name.mid(mapName.size());
}
if (name.endsWith(".char")) {
name = name.left(name.size() - 5);
}
stream.writeAttribute("model", name);
}
}
stream.writeCharacters(text.text());
stream.writeEndElement(); // /text
++id;
Expand Down

0 comments on commit 3e29160

Please sign in to comment.