-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
874 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#include "cstreamwriter.h" | ||
|
||
CStreamWriter::CStreamWriter(QFile* file) | ||
{ | ||
this->file = file; | ||
tabCount = 0; | ||
|
||
stream = new QTextStream(file); | ||
} | ||
|
||
void CStreamWriter::writeEndl() | ||
{ | ||
*stream << endl; | ||
} | ||
|
||
void CStreamWriter::writeInclude(QString file) | ||
{ | ||
*stream << "#include \"" << file << "\"" << endl; | ||
} | ||
|
||
|
||
void CStreamWriter::writeNode(Node* n, QString prefix, int index, bool comma) | ||
{ | ||
*stream << "\t{ &" << prefix << "_path_" << index << ", " << n->getAreaId() << ", " << n->getUnk0() | ||
<< ", " << n->getUnk1() << ", " << n->getIconId() << ", " << n->getSettings() << ", {0, 0, 0} }"; | ||
|
||
if (comma) | ||
*stream << ","; | ||
*stream << endl; | ||
} | ||
|
||
void CStreamWriter::writeNodes(QList<Node*>* nodes, QString prefix) | ||
{ | ||
writePaths(nodes, prefix); | ||
|
||
*stream << "node " << prefix << "_nodes[] =" << endl << "{" << endl; | ||
|
||
for (int i = 0; i < nodes->length(); i++) | ||
{ | ||
Node* n = nodes->at(i); | ||
bool comma = (i != (nodes->length()-1)); | ||
writeNode(n, prefix, i, comma); | ||
} | ||
|
||
*stream << "};" << endl; | ||
} | ||
|
||
|
||
void CStreamWriter::writePaths(QList<Node *> *nodes, QString prefix) | ||
{ | ||
for (int i = 0; i < nodes->length(); i++) | ||
{ | ||
Node* n = nodes->at(i); | ||
|
||
*stream << "path " << prefix << "_path_" << i << " =" << endl << "{" << endl; | ||
|
||
for (int j = 0; j < n->pathList()->count(); j++) | ||
{ | ||
Path* p = n->pathList()->at(j); | ||
*stream << "\t{" << p->endingNodeId << ", " << p->animationId << ", " << p->settings << ", 0}," << endl; | ||
} | ||
|
||
*stream << "\t{255, 0, 0, 0}" << endl << "};" << endl << endl; | ||
} | ||
} | ||
|
||
|
||
void CStreamWriter::writeVisibleNode(Node* n, bool comma) | ||
{ | ||
*stream << "\t{ " | ||
<< "{" << n->getUnlock(0) << ", " << n->getUnlock(1) << ", " << n->getUnlock(2) << ", " << n->getUnlock(3) << "}, " | ||
<< "{" << n->getUnlockSecret(0) << ", " << n->getUnlockSecret(1) << ", " << n->getUnlockSecret(2) << ", " << n->getUnlockSecret(3) << "}, " | ||
<< n->getCameraScroll() << ", " | ||
<< n->getCameraScrollSecret() << ", " | ||
<< n->getx() << ", " | ||
<< n->gety() << ", " | ||
<< n->getz() | ||
<< " }"; | ||
|
||
if (comma) | ||
*stream << ","; | ||
*stream << endl; | ||
} | ||
|
||
void CStreamWriter::writeVisibleNodes(QList<Node*>* nodes, QString prefix) | ||
{ | ||
*stream << "visibleNode " << prefix << "_visibleNodes[] =" << endl << "{" << endl; | ||
|
||
for (int i = 0; i < nodes->length(); i++) | ||
{ | ||
Node* n = nodes->at(i); | ||
bool comma = (i != (nodes->length()-1)); | ||
writeVisibleNode(n, comma); | ||
} | ||
|
||
*stream << "};" << endl; | ||
} | ||
|
||
|
||
void CStreamWriter::writePathBehavior(PathBehavior* p, bool comma) | ||
{ | ||
*stream << "\t{" << p->getAnimationId() << ", " << p->getStarCoinCost() << ", " << p->getSettings() << ", 0}"; | ||
if (comma) | ||
*stream << ","; | ||
*stream << endl; | ||
} | ||
|
||
void CStreamWriter::writePathBehaviors(QList<PathBehavior*>* paths, QString prefix) | ||
{ | ||
*stream << "pathBehavior " << prefix << "_pathBehaviors[] =" << endl << "{" << endl; | ||
|
||
for (int i = 0; i < paths->length(); i++) | ||
{ | ||
PathBehavior* p = paths->at(i); | ||
bool comma = (i != (paths->length()-1)); | ||
writePathBehavior(p, comma); | ||
} | ||
|
||
*stream << "};" << endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#ifndef CSTREAMWRITER_H | ||
#define CSTREAMWRITER_H | ||
|
||
#include <mapobjects.h> | ||
|
||
#include <QFile> | ||
#include <QTextStream> | ||
|
||
class CStreamWriter | ||
{ | ||
public: | ||
CStreamWriter(QFile* file); | ||
|
||
void writeEndl(); | ||
void writeInclude(QString file); | ||
|
||
void writeNode(Node* n, QString prefix, int index, bool comma=false); | ||
void writeNodes(QList<Node*>* nodes, QString prefix); | ||
|
||
void writePaths(QList<Node*>* nodes, QString prefix); | ||
|
||
void writeVisibleNode(Node* n, bool comma=false); | ||
void writeVisibleNodes(QList<Node*>* nodes, QString prefix); | ||
|
||
void writePathBehavior(PathBehavior* p, bool comma=false); | ||
void writePathBehaviors(QList<PathBehavior*>* paths, QString prefix); | ||
|
||
private: | ||
QFile* file; | ||
QTextStream* stream; | ||
|
||
int tabCount; | ||
}; | ||
|
||
#endif // CSTREAMWRITER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#include "exportmapdialog.h" | ||
#include "ui_exportmapdialog.h" | ||
|
||
#include <QFileDialog> | ||
#include <QDebug> | ||
|
||
ExportMapDialog::ExportMapDialog(QWidget *parent) : | ||
QDialog(parent), | ||
ui(new Ui::ExportMapDialog) | ||
{ | ||
ui->setupUi(this); | ||
|
||
setWindowTitle("Goomatlas - Export Map"); | ||
settings = new QSettings("Blarg City", "Goombatlas"); | ||
|
||
QStringList worlds; | ||
worlds << "World 1" | ||
<< "World 2" | ||
<< "World 3" | ||
<< "World 4" | ||
<< "World 5" | ||
<< "World 6" | ||
<< "World 7" | ||
<< "World 8"; | ||
ui->worldNumberBox->addItems(worlds); | ||
|
||
QRegExp rx("^[a-zA-Z0-9_]*$"); | ||
QRegExpValidator* valid = new QRegExpValidator(rx,this); | ||
ui->customPrefixBox->setValidator(valid); | ||
|
||
ui->worldNumberBox->setCurrentIndex(settings->value("lastWorld", "0").toInt()); | ||
ui->cFileBox->setText(settings->value("lastCPath", "").toString()); | ||
ui->rFileBox->setText(settings->value("lastRPath", "").toString()); | ||
|
||
checkOk(); | ||
} | ||
|
||
ExportMapDialog::~ExportMapDialog() | ||
{ | ||
delete ui; | ||
delete settings; | ||
} | ||
|
||
void ExportMapDialog::checkOk() | ||
{ | ||
ui->okBtn->setEnabled((ui->cFileBox->text() != "" && ui->rFileBox->text() != "")); | ||
} | ||
|
||
void ExportMapDialog::on_okBtn_clicked() | ||
{ | ||
settings->setValue("lastWorld", ui->worldNumberBox->currentIndex()); | ||
settings->setValue("lastCPath", ui->cFileBox->text()); | ||
settings->setValue("lastRPath", ui->rFileBox->text()); | ||
accept(); | ||
} | ||
|
||
void ExportMapDialog::on_cancelBtn_clicked() | ||
{ | ||
reject(); | ||
} | ||
|
||
void ExportMapDialog::on_selectCBtn_clicked() | ||
{ | ||
QString dir = ui->cFileBox->text(); | ||
if (dir == "") | ||
dir = QDir::currentPath(); | ||
|
||
QString path = QFileDialog::getSaveFileName(this, "Save C File", dir, "C Files (*.c)"); | ||
|
||
if (path == "") | ||
return; | ||
|
||
ui->cFileBox->setText(path); | ||
|
||
QStringList list = path.split("/"); | ||
|
||
if (list.length() < 2) | ||
return; | ||
|
||
QString replPath = path; | ||
replPath.chop(list.at(list.length()-1).length() + list.at(list.length()-2).length() + 1); | ||
replPath.append("replaces.x"); | ||
|
||
QFileInfo check(replPath); | ||
if (check.exists()) | ||
ui->rFileBox->setText(replPath); | ||
|
||
checkOk(); | ||
} | ||
|
||
void ExportMapDialog::on_selectRBtn_clicked() | ||
{ | ||
QString dir = ui->rFileBox->text(); | ||
if (dir == "") | ||
dir = QDir::currentPath(); | ||
|
||
QString path = QFileDialog::getSaveFileName(this, "Save Replaces File", dir, "Replaces Files (*.x)"); | ||
|
||
if (path == "") | ||
return; | ||
|
||
ui->rFileBox->setText(path); | ||
|
||
checkOk(); | ||
} | ||
|
||
QString ExportMapDialog::getCPath() | ||
{ | ||
return ui->cFileBox->text(); | ||
} | ||
|
||
QString ExportMapDialog::getReplacesPath() | ||
{ | ||
return ui->rFileBox->text(); | ||
} | ||
|
||
QString ExportMapDialog::getPrefix() | ||
{ | ||
if (ui->customPrefixBox->text() != "") | ||
return ui->customPrefixBox->text(); | ||
|
||
return QString("w%1").arg(ui->worldNumberBox->currentIndex()+1); | ||
} | ||
|
||
int ExportMapDialog::getWorldId() | ||
{ | ||
return ui->worldNumberBox->currentIndex()+1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#ifndef EXPORTMAPDIALOG_H | ||
#define EXPORTMAPDIALOG_H | ||
|
||
#include <QDialog> | ||
#include <QSettings> | ||
|
||
namespace Ui { | ||
class ExportMapDialog; | ||
} | ||
|
||
class ExportMapDialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit ExportMapDialog(QWidget *parent = 0); | ||
~ExportMapDialog(); | ||
|
||
QString getCPath(); | ||
QString getReplacesPath(); | ||
QString getPrefix(); | ||
int getWorldId(); | ||
|
||
private slots: | ||
void on_okBtn_clicked(); | ||
|
||
void on_cancelBtn_clicked(); | ||
|
||
void on_selectCBtn_clicked(); | ||
|
||
void on_selectRBtn_clicked(); | ||
|
||
private: | ||
Ui::ExportMapDialog *ui; | ||
|
||
QSettings* settings; | ||
|
||
void checkOk(); | ||
}; | ||
|
||
#endif // EXPORTMAPDIALOG_H |
Oops, something went wrong.