Add new Zone wizard
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include <ox/fs/filesystem.hpp>
|
||||
#include <ox/mc/mc.hpp>
|
||||
|
||||
namespace nostalgia {
|
||||
namespace studio {
|
||||
@@ -41,6 +42,12 @@ class Project: public QObject {
|
||||
|
||||
int write(QString path, uint8_t *buff, size_t buffLen) const;
|
||||
|
||||
/**
|
||||
* Writes a MetalClaw object to the project at the given path.
|
||||
*/
|
||||
template<typename T>
|
||||
int writeObj(QString path, T *obj) const;
|
||||
|
||||
ox::FileStat stat(QString path) const;
|
||||
|
||||
signals:
|
||||
@@ -48,5 +55,29 @@ class Project: public QObject {
|
||||
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
int Project::writeObj(QString path, T *obj) const {
|
||||
int err = 0;
|
||||
auto buffLen = 1024 * 1024 * 10;
|
||||
QByteArray buff(buffLen, 0);
|
||||
|
||||
// write MetalClaw
|
||||
size_t mcSize = 0;
|
||||
err |= ox::write((uint8_t*) buff.data(), buffLen, obj, &mcSize);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
// write to FS
|
||||
err |= write(path, (uint8_t*) buff.data(), mcSize);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
emit updated(path);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user