[nostalgia] Switch Studio to PassThroughFS
This commit is contained in:
parent
e5c5c0da43
commit
af0e24d9bf
3
.vscode/c_cpp_properties.json
vendored
3
.vscode/c_cpp_properties.json
vendored
@ -30,7 +30,8 @@
|
||||
],
|
||||
"compilerPath": "/usr/bin/clang",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17"
|
||||
"cppStandard": "c++17",
|
||||
"compileCommands": "${workspaceFolder}/build/linux-x86_64-debug/compile_commands.json"
|
||||
},
|
||||
{
|
||||
"name": "Linux",
|
||||
|
@ -45,6 +45,7 @@ if(NOT MSVC)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
# forces colored output when using ninja
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
12
Dockerfile
12
Dockerfile
@ -1,4 +1,4 @@
|
||||
FROM fedora:28
|
||||
FROM fedora:29
|
||||
|
||||
RUN dnf update -y
|
||||
|
||||
@ -33,11 +33,11 @@ RUN dnf install -y ninja-build
|
||||
###############################################################################
|
||||
# Install devkitARM
|
||||
|
||||
RUN dnf install -y lbzip2
|
||||
RUN curl -o /tmp/devkitArm.tar.bz2 -SL https://phoenixnap.dl.sourceforge.net/project/devkitpro/devkitARM/devkitARM_r47/devkitARM_r47-x86_64-linux.tar.bz2
|
||||
WORKDIR /opt
|
||||
RUN tar xf /tmp/devkitArm.tar.bz2
|
||||
ENV DEVKITARM /opt/devkitARM
|
||||
#RUN dnf install -y lbzip2
|
||||
#RUN curl -o /tmp/devkitArm.tar.bz2 -SL https://phoenixnap.dl.sourceforge.net/project/devkitpro/devkitARM/devkitARM_r47/devkitARM_r47-x86_64-linux.tar.bz2
|
||||
#WORKDIR /opt
|
||||
#RUN tar xf /tmp/devkitArm.tar.bz2
|
||||
#ENV DEVKITARM /opt/devkitARM
|
||||
|
||||
###############################################################################
|
||||
# Setup sudoers
|
||||
|
8
Makefile
8
Makefile
@ -31,15 +31,15 @@ test:
|
||||
${ENV_RUN} ./scripts/run-make build test
|
||||
|
||||
run: install
|
||||
./dist/current/bin/nostalgia -debug
|
||||
${ENV_RUN} ./dist/current/bin/nostalgia -debug
|
||||
run-studio: install
|
||||
./dist/current/bin/nostalgia-studio -profile dist/current/share/nostalgia-studio.json
|
||||
${ENV_RUN} ./dist/current/bin/nostalgia-studio -profile dist/current/share/nostalgia-studio.json
|
||||
gba-run: gba-pkg
|
||||
mgba-qt nostalgia.gba
|
||||
gdb: make
|
||||
gdb ./build/current/src/wombat/wombat
|
||||
${ENV_RUN} gdb ./build/current/src/wombat/wombat
|
||||
gdb-studio: install
|
||||
gdb --args ./dist/current/bin/nostalgia-studio -profile dist/current/share/nostalgia-studio.json
|
||||
${ENV_RUN} gdb --args ./dist/current/bin/nostalgia-studio -profile dist/current/share/nostalgia-studio.json
|
||||
|
||||
devenv-image:
|
||||
docker build . -t ${DEVENV_IMAGE}
|
||||
|
@ -4,5 +4,5 @@ set -e
|
||||
|
||||
for f in $(find $1 -maxdepth 1 -mindepth 1 -type d)
|
||||
do
|
||||
cmake --build "$f" --target $2 -- -j
|
||||
cmake --build "$f" --target $2
|
||||
done
|
||||
|
@ -6,21 +6,28 @@ Param(
|
||||
)
|
||||
|
||||
$project=(Get-Location).Path
|
||||
$buildTool=""
|
||||
|
||||
if (${target} -eq "windows") {
|
||||
$toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/Mingw.cmake"
|
||||
$buildTool="-GNinja"
|
||||
} elseif (${target} -eq "gba") {
|
||||
$toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/GBA.cmake"
|
||||
$nostalgiaBuildType="-DNOSTALGIA_BUILD_TYPE=GBA"
|
||||
$oxUseStdLib="-DOX_USE_STDLIB=OFF"
|
||||
} else {
|
||||
$buildTool="-GNinja"
|
||||
}
|
||||
|
||||
if (${buildType} -eq "asan") {
|
||||
$buildTypeArgs="-DUSE_ASAN=ON -DCMAKE_BUILD_TYPE=Debug"
|
||||
$buildTypeArgs="-DCMAKE_BUILD_TYPE=Debug"
|
||||
$sanitizerArgs="-DUSE_ASAN=ON"
|
||||
} elseif (${buildType} -eq "debug") {
|
||||
$buildTypeArgs="-DCMAKE_BUILD_TYPE=Debug"
|
||||
$sanitizerArgs=""
|
||||
} elseif (${buildType} -eq "release") {
|
||||
$buildTypeArgs="-DCMAKE_BUILD_TYPE=Release"
|
||||
$sanitizerArgs=""
|
||||
}
|
||||
|
||||
if (${env:NOSTALGIA_QT_PATH} -ne "") {
|
||||
@ -40,6 +47,7 @@ cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON `
|
||||
$nostalgiaBuildType `
|
||||
$oxUseStdLib `
|
||||
$buildTypeArgs `
|
||||
$sanitizerArgs `
|
||||
$qtPath `
|
||||
$toolchain `
|
||||
$project
|
||||
|
21
src/nostalgia/common/fileaddr.hpp
Normal file
21
src/nostalgia/common/fileaddr.hpp
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2016 - 2018 gtalent2@gmail.com
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace nostalgia::common {
|
||||
|
||||
class FileAddr {
|
||||
private:
|
||||
union {
|
||||
ox::BString<255> path;
|
||||
uint64_t inode;
|
||||
} m_data;
|
||||
};
|
||||
|
||||
}
|
@ -8,14 +8,12 @@
|
||||
|
||||
#include <ox/fs/fs.hpp>
|
||||
|
||||
namespace nostalgia {
|
||||
namespace core {
|
||||
namespace nostalgia::core {
|
||||
|
||||
// User Input Output
|
||||
struct Context {
|
||||
ox::FileSystem32 *rom = nullptr;
|
||||
ox::FileSystem *rom = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,11 +9,12 @@
|
||||
#include "addresses.hpp"
|
||||
#include "panic.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace core {
|
||||
#include <ox/std/std.hpp>
|
||||
|
||||
namespace nostalgia::core {
|
||||
|
||||
struct HeapSegment {
|
||||
size_t size;
|
||||
std::size_t size;
|
||||
uint8_t inUse;
|
||||
HeapSegment *next;
|
||||
|
||||
@ -32,12 +33,11 @@ void initHeap() {
|
||||
_heapIdx->inUse = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
using namespace nostalgia::core;
|
||||
|
||||
void *malloc(size_t allocSize) {
|
||||
void *malloc(std::size_t allocSize) {
|
||||
// add space for heap segment header data
|
||||
const auto fullSize = allocSize + sizeof(HeapSegment);
|
||||
auto seg = _heapIdx;
|
||||
@ -117,11 +117,11 @@ void free(void *ptrIn) {
|
||||
}
|
||||
}
|
||||
|
||||
void *operator new(size_t allocSize) {
|
||||
void *operator new(std::size_t allocSize) {
|
||||
return malloc(allocSize);
|
||||
}
|
||||
|
||||
void *operator new[](size_t allocSize) {
|
||||
void *operator new[](std::size_t allocSize) {
|
||||
return malloc(allocSize);
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QFile>
|
||||
|
||||
#include "import_tilesheet_wizard.hpp"
|
||||
@ -13,15 +14,15 @@
|
||||
namespace nostalgia {
|
||||
namespace core {
|
||||
|
||||
const QString ImportTilesheetWizardPage::TILESHEET_DIR = "/TileSheets/";
|
||||
const QString ImportTilesheetWizardPage::TILESHEET_NAME = "projectName";
|
||||
const QString ImportTilesheetWizardPage::IMPORT_PATH = "projectPath";
|
||||
const QString ImportTilesheetWizardPage::TileSheetDir = "/TileSheets/";
|
||||
const QString ImportTilesheetWizardPage::TileSheetName = "projectName";
|
||||
const QString ImportTilesheetWizardPage::ImportPath = "projectPath";
|
||||
const QString ImportTilesheetWizardPage::BPP = "bpp";
|
||||
|
||||
ImportTilesheetWizardPage::ImportTilesheetWizardPage(const studio::Context *ctx) {
|
||||
m_ctx = ctx;
|
||||
addLineEdit(tr("&Tile Sheet Name:"), TILESHEET_NAME + "*", "", [this](QString) {
|
||||
auto importPath = field(IMPORT_PATH).toString();
|
||||
addLineEdit(tr("&Tile Sheet Name:"), TileSheetName + "*", "", [this](QString) {
|
||||
auto importPath = field(ImportPath).toString();
|
||||
if (QFile(importPath).exists()) {
|
||||
return 0;
|
||||
} else {
|
||||
@ -31,31 +32,38 @@ ImportTilesheetWizardPage::ImportTilesheetWizardPage(const studio::Context *ctx)
|
||||
}
|
||||
);
|
||||
auto fileTypes = "(*.png);;(*.bmp);;(*.jpg);;(*.jpeg)";
|
||||
addPathBrowse(tr("Tile Sheet &Path:"), IMPORT_PATH + "*", "",
|
||||
addPathBrowse(tr("Tile Sheet &Path:"), ImportPath + "*", "",
|
||||
QFileDialog::ExistingFile, fileTypes);
|
||||
addComboBox(tr("Bits Per Pixe&l:"), BPP, {"4", "8"});
|
||||
}
|
||||
|
||||
int ImportTilesheetWizardPage::accept() {
|
||||
auto tilesheetName = field(TILESHEET_NAME).toString();
|
||||
auto importPath = field(IMPORT_PATH).toString();
|
||||
auto tilesheetName = field(TileSheetName).toString();
|
||||
auto importPath = field(ImportPath).toString();
|
||||
QFile importFile(importPath);
|
||||
if (importFile.exists()) {
|
||||
return importImage(importFile, field(TILESHEET_NAME).toString());
|
||||
return importImage(importFile, field(TileSheetName).toString());
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int ImportTilesheetWizardPage::importImage(QFile &srcFile, QString tilesheetName) {
|
||||
auto buffSize = srcFile.size();
|
||||
uint8_t buff[buffSize];
|
||||
if (srcFile.exists()) {
|
||||
srcFile.open(QIODevice::ReadOnly);
|
||||
if (srcFile.read((char*) buff, buffSize) > 0) {
|
||||
auto buff = srcFile.readAll();
|
||||
QImage srcImg;
|
||||
if (srcImg.loadFromData(buff)) {
|
||||
int err = 0;
|
||||
m_ctx->project->mkdir(TILESHEET_DIR);
|
||||
err |= m_ctx->project->write(TILESHEET_DIR + tilesheetName, buff, buffSize);
|
||||
// ensure image is PNG
|
||||
QByteArray out;
|
||||
QBuffer outBuffer(&out);
|
||||
outBuffer.open(QIODevice::WriteOnly);
|
||||
srcImg.save(&outBuffer, "PNG");
|
||||
// make sure tile sheet directory exists
|
||||
m_ctx->project->mkdir(TileSheetDir);
|
||||
// write image
|
||||
err |= m_ctx->project->write(TileSheetDir + tilesheetName + ".png", reinterpret_cast<uint8_t*>(out.data()), out.size());
|
||||
err |= m_ctx->project->saveRomFs();
|
||||
return err;
|
||||
} else {
|
||||
|
@ -15,9 +15,9 @@ namespace core {
|
||||
|
||||
class ImportTilesheetWizardPage: public studio::WizardFormPage {
|
||||
private:
|
||||
static const QString TILESHEET_DIR;
|
||||
static const QString TILESHEET_NAME;
|
||||
static const QString IMPORT_PATH;
|
||||
static const QString TileSheetDir;
|
||||
static const QString TileSheetName;
|
||||
static const QString ImportPath;
|
||||
static const QString BPP;
|
||||
const studio::Context *m_ctx = nullptr;
|
||||
|
||||
|
@ -8,12 +8,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ox/fs/filestore.hpp>
|
||||
#include <ox/fs/fs.hpp>
|
||||
|
||||
namespace nostalgia {
|
||||
namespace core {
|
||||
namespace nostalgia::core {
|
||||
|
||||
typedef ox::FileStore32::InodeId_t InodeId_t;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ target_link_libraries(
|
||||
NostalgiaCore
|
||||
OxFS
|
||||
OxStd
|
||||
OxTrace
|
||||
OxMetalClaw
|
||||
)
|
||||
|
||||
add_custom_target("nostalgia.bin")
|
||||
|
@ -13,7 +13,7 @@ using namespace nostalgia::core;
|
||||
using namespace nostalgia::world;
|
||||
|
||||
int main() {
|
||||
ox::FileSystem32 fs(loadRom(), false);
|
||||
ox::FileSystem32 fs(ox::FileStore32(loadRom(), 33554432)); // 32 MB
|
||||
Context ctx;
|
||||
init(&ctx);
|
||||
ctx.rom = &fs;
|
||||
|
@ -12,6 +12,7 @@ add_executable(
|
||||
|
||||
target_link_libraries(
|
||||
nostalgia-studio
|
||||
c++fs
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
OxClArgs
|
||||
|
@ -20,10 +20,12 @@ install(TARGETS NostalgiaStudio
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaStudio
|
||||
c++fs
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
OxFS
|
||||
OxMetalClaw
|
||||
OxTrace
|
||||
OxStd
|
||||
)
|
||||
|
||||
@ -48,6 +50,7 @@ add_executable(
|
||||
|
||||
target_link_libraries(
|
||||
NostalgiaStudioJsonTest
|
||||
c++fs
|
||||
NostalgiaStudio
|
||||
)
|
||||
|
||||
|
@ -6,30 +6,44 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QVector>
|
||||
|
||||
#include "oxfstreeview.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace studio {
|
||||
namespace nostalgia::studio {
|
||||
|
||||
using namespace ox;
|
||||
|
||||
OxFSFile::OxFSFile(FileSystem *fs, QString path, OxFSFile *parentItem) {
|
||||
OxFSFile::OxFSFile(PassThroughFS *fs, QString path, OxFSFile *parentItem) {
|
||||
m_path = path;
|
||||
m_parentItem = parentItem;
|
||||
|
||||
// find children
|
||||
if (fs) {
|
||||
QVector<DirectoryListing<QString>> ls;
|
||||
if (fs->stat((const char*) m_path.toUtf8()).fileType == FileType_Directory) {
|
||||
fs->ls(m_path.toUtf8(), &ls);
|
||||
qSort(ls);
|
||||
}
|
||||
for (auto v : ls) {
|
||||
if (v.name != "." && v.name != "..") {
|
||||
auto ch = new OxFSFile(fs, m_path + "/" + v.name, this);
|
||||
m_childItems.push_back(ch);
|
||||
QVector<QString> ls;
|
||||
auto stat = fs->stat(static_cast<const char*>(m_path.toUtf8()));
|
||||
if (!stat.error) {
|
||||
if (stat.value.fileType == FileType_Directory) {
|
||||
fs->ls(m_path.toUtf8(), [&ls](const char *name, ox::InodeId_t inode) {
|
||||
ls.push_back(name);
|
||||
return OxError(0);
|
||||
});
|
||||
qSort(ls);
|
||||
}
|
||||
auto p = m_path;
|
||||
// make sure ends with path separator
|
||||
if (fs->stat(p.toUtf8().data()).value.fileType == FileType_Directory &&
|
||||
p.size() && p.back() != QDir::separator()) {
|
||||
p += QDir::separator();
|
||||
}
|
||||
for (auto name : ls) {
|
||||
if (name != "." && name != "..") {
|
||||
qDebug() << "name:" << m_path + name;
|
||||
auto ch = new OxFSFile(fs, m_path + name, this);
|
||||
m_childItems.push_back(ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -101,7 +115,7 @@ QString OxFSFile::name() const {
|
||||
|
||||
// OxFSModel
|
||||
|
||||
OxFSModel::OxFSModel(FileSystem *fs, QObject *parent) {
|
||||
OxFSModel::OxFSModel(PassThroughFS *fs, QObject *parent) {
|
||||
m_rootItem = new OxFSFile(fs, "");
|
||||
}
|
||||
|
||||
@ -203,4 +217,3 @@ void OxFSModel::setupModelData(const QStringList &lines, OxFSFile *parent) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class OxFSFile {
|
||||
QVector<OxFSFile*> m_childItems;
|
||||
|
||||
public:
|
||||
OxFSFile(ox::FileSystem *fs, QString path, OxFSFile *parentItem = nullptr);
|
||||
OxFSFile(ox::PassThroughFS *fs, QString path, OxFSFile *parentItem = nullptr);
|
||||
|
||||
~OxFSFile();
|
||||
|
||||
@ -54,7 +54,7 @@ class OxFSModel: public QAbstractItemModel {
|
||||
OxFSFile *m_rootItem = nullptr;
|
||||
|
||||
public:
|
||||
explicit OxFSModel(ox::FileSystem *fs, QObject *parent = 0);
|
||||
explicit OxFSModel(ox::PassThroughFS *fs, QObject *parent = 0);
|
||||
|
||||
~OxFSModel();
|
||||
|
||||
|
@ -11,14 +11,14 @@
|
||||
|
||||
#include "project.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace studio {
|
||||
namespace nostalgia::studio {
|
||||
|
||||
using namespace ox;
|
||||
|
||||
QString Project::ROM_FILE = "/ROM.oxfs";
|
||||
|
||||
Project::Project(QString path) {
|
||||
Project::Project(QString path): m_fs(path.toUtf8()) {
|
||||
qDebug() << "Project:" << path;
|
||||
m_path = path;
|
||||
}
|
||||
|
||||
@ -27,16 +27,6 @@ Project::~Project() {
|
||||
|
||||
void Project::create() {
|
||||
QDir().mkpath(m_path);
|
||||
|
||||
auto buffSize = 1024;
|
||||
auto buff = new uint8_t[buffSize];
|
||||
FileSystem32::format(buff, buffSize, true);
|
||||
m_fs = std::unique_ptr<ox::FileSystem>{createFileSystem(buff, buffSize, true)};
|
||||
|
||||
QFile file(m_path + ROM_FILE);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write((const char*) buff, buffSize);
|
||||
file.close();
|
||||
}
|
||||
|
||||
int Project::openRomFs() {
|
||||
@ -46,9 +36,8 @@ int Project::openRomFs() {
|
||||
if (file.exists()) {
|
||||
file.open(QIODevice::ReadOnly);
|
||||
if (file.read((char*) buff.get(), buffSize) > 0) {
|
||||
m_fs = std::unique_ptr<ox::FileSystem>{createFileSystem(buff.get(), buffSize, true)};
|
||||
if (m_fs) {
|
||||
buff.release();
|
||||
m_fsBuff = std::move(buff);
|
||||
if (m_fs.valid()) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
@ -63,32 +52,31 @@ int Project::openRomFs() {
|
||||
|
||||
int Project::saveRomFs() const {
|
||||
int err = 0;
|
||||
QFile file(m_path + ROM_FILE);
|
||||
err |= file.open(QIODevice::WriteOnly) == false;
|
||||
err |= file.write((const char*) m_fs->buff(), m_fs->size()) == -1;
|
||||
file.close();
|
||||
//QFile file(m_path + ROM_FILE);
|
||||
//err |= file.open(QIODevice::WriteOnly) == false;
|
||||
//err |= file.write((const char*) m_fsBuff.get(), m_fs.size()) == -1;
|
||||
//file.close();
|
||||
return err;
|
||||
}
|
||||
|
||||
FileSystem *Project::romFs() {
|
||||
return m_fs.get();
|
||||
PassThroughFS *Project::romFs() {
|
||||
return &m_fs;
|
||||
}
|
||||
|
||||
int Project::mkdir(QString path) const {
|
||||
auto err = m_fs->mkdir(path.toUtf8().data(), true);
|
||||
auto err = m_fs.mkdir(path.toUtf8().data(), true);
|
||||
emit updated(path);
|
||||
return err;
|
||||
}
|
||||
|
||||
int Project::write(QString path, uint8_t *buff, size_t buffLen) const {
|
||||
auto err = m_fs->write(path.toUtf8().data(), buff, buffLen);
|
||||
auto err = m_fs.write(path.toUtf8().data(), buff, buffLen);
|
||||
emit updated(path);
|
||||
return err;
|
||||
}
|
||||
|
||||
ox::FileStat Project::stat(QString path) const {
|
||||
return m_fs->stat(path.toUtf8().data());
|
||||
return m_fs.stat(path.toUtf8().data());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,8 @@ class Project: public QObject {
|
||||
static QString ROM_FILE;
|
||||
|
||||
QString m_path = "";
|
||||
std::unique_ptr<ox::FileSystem> m_fs;
|
||||
std::unique_ptr<uint8_t[]> m_fsBuff;
|
||||
mutable ox::PassThroughFS m_fs;
|
||||
|
||||
public:
|
||||
Project(QString path);
|
||||
@ -38,7 +39,7 @@ class Project: public QObject {
|
||||
|
||||
int saveRomFs() const;
|
||||
|
||||
ox::FileSystem *romFs();
|
||||
ox::PassThroughFS *romFs();
|
||||
|
||||
int mkdir(QString path) const;
|
||||
|
||||
|
@ -336,8 +336,8 @@ void Wizard::setAccept(std::function<int(QWizard*)> acceptFunc) {
|
||||
|
||||
void Wizard::accept() {
|
||||
auto page = dynamic_cast<WizardFormPage*>(currentPage());
|
||||
if (page != nullptr and page->accept() == 0 and
|
||||
m_acceptFunc != nullptr and m_acceptFunc(this) == 0) {
|
||||
if ((page == nullptr || page->accept() == 0) &&
|
||||
m_acceptFunc != nullptr && m_acceptFunc(this) == 0) {
|
||||
QDialog::accept();
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace studio {
|
||||
struct WizardMaker {
|
||||
QString name;
|
||||
std::function<QVector<QWizardPage*>()> make;
|
||||
std::function<int(QWizard*)> onAccept;
|
||||
std::function<int(QWizard*)> onAccept = [](QWizard*) { return 0; };
|
||||
};
|
||||
|
||||
class WizardSelect: public QWizardPage {
|
||||
|
@ -46,7 +46,7 @@ MainWindow::MainWindow(QString profilePath) {
|
||||
auto screenSize = QApplication::desktop()->screenGeometry();
|
||||
|
||||
// set window to 75% of screen width, and center NostalgiaStudioProfile
|
||||
auto sizePct = 0.75;
|
||||
constexpr auto sizePct = 0.75;
|
||||
resize(screenSize.width() * sizePct, screenSize.height() * sizePct);
|
||||
move(-x(), -y());
|
||||
move(screenSize.width() * (1 - sizePct) / 2, screenSize.height() * (1 - sizePct) / 2);
|
||||
@ -226,7 +226,6 @@ int MainWindow::writeState(QString path) {
|
||||
int MainWindow::openProject(QString projectPath) {
|
||||
auto err = closeProject();
|
||||
auto project = new Project(projectPath);
|
||||
err |= project->openRomFs();
|
||||
if (err == 0) {
|
||||
if (m_ctx.project) {
|
||||
delete m_ctx.project;
|
||||
@ -238,6 +237,7 @@ int MainWindow::openProject(QString projectPath) {
|
||||
connect(m_ctx.project, SIGNAL(updated(QString)), m_oxfsView, SLOT(updateFile(QString)));
|
||||
m_importAction->setEnabled(true);
|
||||
m_state.projectPath = projectPath;
|
||||
qInfo() << "Open project:" << projectPath;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
@ -318,16 +318,20 @@ void MainWindow::showNewWizard() {
|
||||
[this, ProjectName, ProjectPath](QWizard *wizard) {
|
||||
auto projectName = wizard->field(ProjectName).toString();
|
||||
auto projectPath = wizard->field(ProjectPath).toString();
|
||||
qInfo() << "Project creation: final step";
|
||||
if (QDir(projectPath).exists()) {
|
||||
auto path = projectPath + "/" + projectName;
|
||||
if (!QDir(path).exists()) {
|
||||
Project(path).create();
|
||||
openProject(path);
|
||||
qInfo() << "Project creation successful:" << path;
|
||||
return 0;
|
||||
} else {
|
||||
qInfo() << "Project file exists:" << path;
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
qInfo() << "Project destination directory does not exist:" << projectPath;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,8 @@ target_link_libraries(
|
||||
OxClArgs
|
||||
OxFS
|
||||
OxStd
|
||||
OxTrace
|
||||
OxMetalClaw
|
||||
NostalgiaCommon
|
||||
NostalgiaCore
|
||||
)
|
||||
|
@ -118,21 +118,28 @@ int run(ClArgs args) {
|
||||
size_t fsBuffSize;
|
||||
auto fsBuff = loadFileBuff(argFsPath, &fsBuffSize);
|
||||
if (fsBuff && !err) {
|
||||
auto fs = createFileSystem(fsBuff, fsBuffSize);
|
||||
auto fs = FileSystem32(FileStore32(fsBuff, fsBuffSize));
|
||||
|
||||
if (fs) {
|
||||
fs = expandCopyCleanup(fs, fs->size() + fs->spaceNeeded(imgDataBuffSize));
|
||||
fsBuff = fs->buff(); // update fsBuff pointer in case there is a new buff
|
||||
err |= fs->write(argInode, imgDataBuff, imgDataBuffSize);
|
||||
if (fs.valid()) {
|
||||
const auto sizeNeeded = fs.size() + fs.spaceNeeded(imgDataBuffSize);
|
||||
if (sizeNeeded > fsBuffSize) {
|
||||
auto newBuff = new uint8_t[sizeNeeded];
|
||||
memcpy(newBuff, fsBuff, fsBuffSize);
|
||||
delete[] fsBuff;
|
||||
fsBuff = newBuff;
|
||||
fsBuffSize = sizeNeeded;
|
||||
}
|
||||
fsBuff = fs.buff(); // update fsBuff pointer in case there is a new buff
|
||||
err |= fs.write(argInode, imgDataBuff, imgDataBuffSize);
|
||||
|
||||
if (!err) {
|
||||
if (argCompact) {
|
||||
fs->resize();
|
||||
FileStore32(fsBuff, fsBuffSize).compact();
|
||||
}
|
||||
|
||||
auto fsFile = fopen(argFsPath.toUtf8(), "wb");
|
||||
if (fsFile) {
|
||||
err = fwrite(fsBuff, fs->size(), 1, fsFile) != 1;
|
||||
err = fwrite(fsBuff, fs.size(), 1, fsFile) != 1;
|
||||
err |= fclose(fsFile);
|
||||
if (err) {
|
||||
cerr << "Could not write to file system file.\n";
|
||||
@ -143,8 +150,6 @@ int run(ClArgs args) {
|
||||
} else {
|
||||
err = 3;
|
||||
}
|
||||
|
||||
delete fs;
|
||||
} else {
|
||||
err = 4;
|
||||
}
|
||||
|
@ -8,8 +8,7 @@
|
||||
|
||||
#include "world.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
namespace world {
|
||||
namespace nostalgia::world {
|
||||
|
||||
using namespace common;
|
||||
using namespace core;
|
||||
@ -49,4 +48,3 @@ void Zone::setTile(int x, int y, Tile *td) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user