[keel,nostalgia,turbine] Cleanup
This commit is contained in:
@@ -12,8 +12,15 @@ namespace studio {
|
||||
|
||||
void registerModule(const studio::Module*) noexcept;
|
||||
|
||||
struct StudioOptions {
|
||||
ox::String appName;
|
||||
ox::String projectDataDir;
|
||||
};
|
||||
|
||||
int main(StudioOptions&&);
|
||||
|
||||
int main(
|
||||
const char *appName,
|
||||
ox::CRStringView appName,
|
||||
ox::String projectDataDir,
|
||||
int argc,
|
||||
const char **argv);
|
||||
|
@@ -5,12 +5,14 @@
|
||||
#include <ctime>
|
||||
|
||||
#include <ox/logconn/logconn.hpp>
|
||||
#include <ox/logconn/def.hpp>
|
||||
#include <ox/std/trace.hpp>
|
||||
#include <ox/std/uuid.hpp>
|
||||
#include <keel/media.hpp>
|
||||
#include <turbine/turbine.hpp>
|
||||
|
||||
#include <studio/context.hpp>
|
||||
#include <studioapp/studioapp.hpp>
|
||||
#include "studioapp.hpp"
|
||||
|
||||
namespace studio {
|
||||
@@ -61,30 +63,26 @@ static ox::Error runApp(
|
||||
}
|
||||
|
||||
int main(
|
||||
const char *appName,
|
||||
ox::CRStringView appName,
|
||||
ox::String projectDataDir,
|
||||
int,
|
||||
const char **) {
|
||||
#ifdef DEBUG
|
||||
ox::LoggerConn loggerConn;
|
||||
const auto loggerErr = loggerConn.initConn(appName);
|
||||
if (loggerErr) {
|
||||
oxErrf("Could not connect to logger: {}\n", toStr(loggerErr));
|
||||
} else {
|
||||
ox::trace::setLogger(&loggerConn);
|
||||
}
|
||||
#endif
|
||||
ox::trace::init();
|
||||
// run app
|
||||
const char**) {
|
||||
OX_INIT_DEBUG_LOGGER(loggerConn, appName)
|
||||
// seed UUID generator
|
||||
const auto time = std::time(nullptr);
|
||||
ox::UUID::seedGenerator({
|
||||
static_cast<uint64_t>(time),
|
||||
static_cast<uint64_t>(time << 1)
|
||||
});
|
||||
// run app
|
||||
const auto err = runApp(appName, std::move(projectDataDir), ox::UniquePtr<ox::FileSystem>(nullptr));
|
||||
oxAssert(err, "Something went wrong...");
|
||||
return static_cast<int>(err);
|
||||
}
|
||||
|
||||
int main(StudioOptions &&opts, int argc = 0, const char **argv = nullptr) {
|
||||
return main(opts.appName, std::move(opts.projectDataDir), argc, argv);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -57,7 +57,7 @@ void NewMenu::drawNewItemType(turbine::Context *ctx) noexcept {
|
||||
drawWindow(ctx, &m_open, [this] {
|
||||
auto items = ox_malloca(m_types.size() * sizeof(const char*), const char*, nullptr);
|
||||
for (auto i = 0u; const auto &im : m_types) {
|
||||
items[i] = im->name.c_str();
|
||||
items.get()[i] = im->name.c_str();
|
||||
++i;
|
||||
}
|
||||
ImGui::ListBox("Item Type", &m_selectedType, items.get(), static_cast<int>(m_types.size()));
|
||||
|
@@ -11,7 +11,7 @@
|
||||
namespace studio {
|
||||
|
||||
static ox::Result<ox::UniquePtr<ProjectTreeModel>>
|
||||
buildProjectTreeModel(ProjectExplorer *explorer, ox::CRStringView name, ox::CRStringView path, ProjectTreeModel *parent) noexcept {
|
||||
buildProjectTreeModel(ProjectExplorer *explorer, ox::String name, ox::CRStringView path, ProjectTreeModel *parent) noexcept {
|
||||
const auto fs = explorer->romFs();
|
||||
oxRequire(stat, fs->stat(path));
|
||||
auto out = ox::make_unique<ProjectTreeModel>(explorer, name, parent);
|
||||
|
@@ -305,7 +305,7 @@ ox::Error StudioUI::openProject(ox::CRStringView path) noexcept {
|
||||
oxRequireM(fs, keel::loadRomFs(path));
|
||||
oxReturnError(keel::setRomFs(&m_ctx->keelCtx, std::move(fs)));
|
||||
turbine::setWindowTitle(*m_ctx, ox::sfmt("{} - {}", m_ctx->keelCtx.appName, path));
|
||||
m_project = ox::make_unique<studio::Project>(&m_ctx->keelCtx, path, m_projectDir);
|
||||
m_project = ox::make_unique<studio::Project>(&m_ctx->keelCtx, ox::String(path), m_projectDir);
|
||||
auto sctx = applicationData<studio::StudioContext>(*m_ctx);
|
||||
sctx->project = m_project.get();
|
||||
m_project->fileAdded.connect(m_projectExplorer.get(), &ProjectExplorer::refreshProjectTreeModel);
|
||||
@@ -313,7 +313,7 @@ ox::Error StudioUI::openProject(ox::CRStringView path) noexcept {
|
||||
m_openFiles.clear();
|
||||
m_editors.clear();
|
||||
studio::editConfig<StudioConfig>(&m_ctx->keelCtx, [&](StudioConfig *config) {
|
||||
config->projectPath = path;
|
||||
config->projectPath = ox::String(path);
|
||||
config->openFiles.clear();
|
||||
});
|
||||
return m_projectExplorer->refreshProjectTreeModel();
|
||||
@@ -324,7 +324,9 @@ ox::Error StudioUI::openFile(ox::CRStringView path) noexcept {
|
||||
}
|
||||
|
||||
ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab) noexcept {
|
||||
if (m_openFiles.contains(path)) {
|
||||
// Warning: StringView to String
|
||||
auto const pathStr = ox::String(path);
|
||||
if (m_openFiles.contains(pathStr)) {
|
||||
for (auto &e : m_editors) {
|
||||
if (makeActiveTab && e->itemName() == path) {
|
||||
m_activeEditor = e.get();
|
||||
@@ -334,7 +336,7 @@ ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab)
|
||||
}
|
||||
return OxError(0);
|
||||
}
|
||||
oxRequire(ext, studio::fileExt(path));
|
||||
oxRequire(ext, studio::fileExt(path).to<ox::String>([](auto const&v) {return ox::String(v);}));
|
||||
// create Editor
|
||||
studio::BaseEditor *editor = nullptr;
|
||||
if (!m_editorMakers.contains(ext)) {
|
||||
@@ -363,7 +365,7 @@ ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab)
|
||||
}
|
||||
// save to config
|
||||
studio::editConfig<StudioConfig>(&m_ctx->keelCtx, [&](StudioConfig *config) {
|
||||
if (!config->openFiles.contains(path)) {
|
||||
if (!config->openFiles.contains(pathStr)) {
|
||||
config->openFiles.emplace_back(path);
|
||||
}
|
||||
});
|
||||
|
@@ -88,10 +88,4 @@ class StudioUI: public ox::SignalHandler {
|
||||
ox::Error closeFile(const ox::String &path) noexcept;
|
||||
};
|
||||
|
||||
int main(
|
||||
const char *appName,
|
||||
ox::String projectDataDir,
|
||||
[[maybe_unused]] int argc,
|
||||
[[maybe_unused]] const char **argv);
|
||||
|
||||
}
|
||||
|
@@ -57,7 +57,8 @@ bool Project::exists(ox::CRStringView path) const noexcept {
|
||||
}
|
||||
|
||||
const ox::Vector<ox::String> &Project::fileList(ox::CRStringView ext) noexcept {
|
||||
return m_fileExtFileMap[ext];
|
||||
// Warning: StringView to String
|
||||
return m_fileExtFileMap[ox::String(ext)];
|
||||
}
|
||||
|
||||
void Project::buildFileIndex() noexcept {
|
||||
@@ -80,7 +81,8 @@ void Project::indexFile(ox::CRStringView path) noexcept {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
m_fileExtFileMap[ext].emplace_back(path);
|
||||
// Warning: StringView to String
|
||||
m_fileExtFileMap[ox::String(ext)].emplace_back(path);
|
||||
}
|
||||
|
||||
ox::Error Project::writeBuff(const ox::StringView &path, const ox::Buffer &buff) noexcept {
|
||||
@@ -88,7 +90,8 @@ ox::Error Project::writeBuff(const ox::StringView &path, const ox::Buffer &buff)
|
||||
ox::Buffer outBuff;
|
||||
outBuff.reserve(buff.size() + HdrSz);
|
||||
ox::BufferWriter writer(&outBuff);
|
||||
const auto [uuid, err] = m_ctx->pathToUuid.at(path);
|
||||
// Warning: StringView to String
|
||||
const auto [uuid, err] = m_ctx->pathToUuid.at(ox::String(path));
|
||||
if (!err) {
|
||||
oxReturnError(keel::writeUuidHeader(writer, *uuid));
|
||||
}
|
||||
|
Reference in New Issue
Block a user