Skip to content

Commit

Permalink
Defold plugin: Removed script creation part
Browse files Browse the repository at this point in the history
  • Loading branch information
yahuaru authored and bjorn committed Aug 15, 2016
1 parent ffe06a0 commit 2465cdc
Showing 1 changed file with 1 addition and 45 deletions.
46 changes: 1 addition & 45 deletions src/plugins/defold/defoldplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ static QString replaceTags(QString context, const QVariantHash &map)

QStringList DefoldPlugin::outputFiles(const Tiled::Map *, const QString &fileName) const
{
return QStringList() << fileName
<< fileName + QLatin1String(".script");
return QStringList() << fileName;
}

QString DefoldPlugin::nameFilter() const
Expand Down Expand Up @@ -141,49 +140,6 @@ bool DefoldPlugin::write(const Tiled::Map *map, const QString &fileName)
return false;
}

QSaveFile scriptFile(fileName + QLatin1String(".script"));
if (!scriptFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
qWarning("Couldn't open save file.");
return false;
}

QTextStream unitsFileStream(&scriptFile);
unitsFileStream << "map_nodes = {" << endl;

for (int y = 0; y < layerHeight; ++y) {
unitsFileStream <<"{";
for (int x = 0; x < layerWidth; ++x) {
unitsFileStream << "\t" << types[x][y] << ",";
}
unitsFileStream <<"}," << endl;
}

unitsFileStream << "}" << endl;
unitsFileStream << endl;
unitsFileStream << "Objects = {" << endl;
foreach (Tiled::ObjectGroup *group, map->objectGroups()) {
for (Tiled::MapObject *object : group->objects()) {
unitsFileStream << "\t{" << endl;
QString name = object->name();
QPointF pos = object->position();
unitsFileStream << "\tname = \"" << name << "\"," << endl;
unitsFileStream << "\tx = " << std::floor((float)pos.x() / (cellWidth / 2.0f)) * cellWidth / 2 << "," << endl;
unitsFileStream << "\ty = " << std::floor((float)pos.y() / (cellHeight / 2.0f)) * cellHeight / 2 << "," << endl;
unitsFileStream << "\t}," << endl;
}
}
unitsFileStream << "}" << endl;

if (scriptFile.error() != QSaveFile::NoError) {
mError = scriptFile.errorString();
return false;
}

if (!scriptFile.commit()) {
mError = scriptFile.errorString();
return false;
}

return true;
}

Expand Down

0 comments on commit 2465cdc

Please sign in to comment.