Skip to content

Commit

Permalink
Improve XML text export context a little for model attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
myst6re committed Apr 15, 2024
1 parent 3e29160 commit fced841
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/core/field/Section1File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,21 +450,29 @@ bool Section1File::exporter(QIODevice *device, ExportFormat format)
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);
QString groupName, modelName;
for (const FF7Window &win: windows) {
const int groupId = win.groupID;
const GrpScript &grpScript = _grpScripts.at(groupId);
groupName = grpScript.name();
const int modelId = modelID(groupId);

if (modelId >= 0 && modelId < charNames.size()) {
modelName = charNames.at(modelId);
if (modelName.startsWith(mapName)) {
modelName = modelName.mid(mapName.size());
}
if (modelName.endsWith(".char")) {
modelName = modelName.left(modelName.size() - 5);
}
break;
}
stream.writeAttribute("model", name);
}
stream.writeAttribute("group", groupName);
if (!modelName.isEmpty()) {
stream.writeAttribute("model", modelName);
}

}
stream.writeCharacters(text.text());
stream.writeEndElement(); // /text
Expand Down

0 comments on commit fced841

Please sign in to comment.