Squashed 'deps/nostalgia/' changes from e27eee50..f7c3c02c
f7c3c02c Merge commit '1bfb7f99c215e2c74556bd3281f44962b8faaa96' 8f0f1fea [nostalgia/gfx/studio] Make editors use Project::loadObj for their primary assets 2f36a3f6 [studio] Add File -> Reload Project menu item 07e5bf90 [keel] Make keel attempt to delete all existing assets when FS is changed aacff3da [ox/std] Fix UPtr::reset to conform to unique_ptr::reset git-subtree-dir: deps/nostalgia git-subtree-split: f7c3c02c4cbe676ea116ea53f1f31b27f668cd98
This commit is contained in:
3
deps/ox/src/ox/std/memory.hpp
vendored
3
deps/ox/src/ox/std/memory.hpp
vendored
@@ -213,8 +213,7 @@ class UniquePtr {
|
|||||||
return m_t;
|
return m_t;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U, typename UDeleter>
|
constexpr void reset(UniquePtr &&other = UniquePtr()) {
|
||||||
constexpr void reset(UniquePtr<U, UDeleter> &&other = UniquePtr()) {
|
|
||||||
auto t = m_t;
|
auto t = m_t;
|
||||||
m_t = other.release();
|
m_t = other.release();
|
||||||
Deleter()(t);
|
Deleter()(t);
|
||||||
|
@@ -72,7 +72,7 @@ PaletteEditorImGui::PaletteEditorImGui(studio::Context &sctx, ox::StringParam pa
|
|||||||
Editor(sctx, std::move(path)),
|
Editor(sctx, std::move(path)),
|
||||||
m_sctx(sctx),
|
m_sctx(sctx),
|
||||||
m_tctx(sctx.tctx),
|
m_tctx(sctx.tctx),
|
||||||
m_pal(*keel::readObj<Palette>(keelCtx(m_tctx), itemPath()).unwrapThrow()) {
|
m_pal(m_sctx.project->loadObj<Palette>(itemPath()).unwrapThrow()) {
|
||||||
undoStack()->changeTriggered.connect(this, &PaletteEditorImGui::handleCommand);
|
undoStack()->changeTriggered.connect(this, &PaletteEditorImGui::handleCommand);
|
||||||
m_pageRenameDlg.inputSubmitted.connect(this, &PaletteEditorImGui::renamePage);
|
m_pageRenameDlg.inputSubmitted.connect(this, &PaletteEditorImGui::renamePage);
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,7 @@ TileSheetEditorModel::TileSheetEditorModel(
|
|||||||
m_sctx{sctx},
|
m_sctx{sctx},
|
||||||
m_tctx{m_sctx.tctx},
|
m_tctx{m_sctx.tctx},
|
||||||
m_path{std::move(path)},
|
m_path{std::move(path)},
|
||||||
m_img{*readObj<TileSheet>(keelCtx(m_tctx), m_path).unwrapThrow()},
|
m_img{m_sctx.project->loadObj<TileSheet>(m_path).unwrapThrow()},
|
||||||
// ignore failure to load palette
|
// ignore failure to load palette
|
||||||
m_pal{readObj<Palette>(keelCtx(m_tctx), m_img.defaultPalette).value},
|
m_pal{readObj<Palette>(keelCtx(m_tctx), m_img.defaultPalette).value},
|
||||||
m_undoStack{undoStack} {
|
m_undoStack{undoStack} {
|
||||||
|
@@ -25,12 +25,11 @@ ox::Error writeUuidHeader(ox::Writer_c auto &writer, ox::UUID const&uuid) noexce
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ox::Result<T> readAsset(ox::BufferView buff) noexcept {
|
ox::Result<T> readAsset(ox::BufferView buff) noexcept {
|
||||||
std::size_t offset = 0;
|
|
||||||
auto const err = readUuidHeader(buff).error;
|
auto const err = readUuidHeader(buff).error;
|
||||||
if (!err) {
|
if (!err) {
|
||||||
offset = K1HdrSz; // the size of K1 headers
|
buff += K1HdrSz; // the size of K1 headers
|
||||||
}
|
}
|
||||||
auto out = ox::readClaw<T>(buff + offset);
|
auto out = ox::readClaw<T>(buff);
|
||||||
OX_RETURN_ERROR(out);
|
OX_RETURN_ERROR(out);
|
||||||
OX_RETURN_ERROR(ensureValid(out.value));
|
OX_RETURN_ERROR(ensureValid(out.value));
|
||||||
return out;
|
return out;
|
||||||
|
@@ -261,6 +261,9 @@ namespace keel {
|
|||||||
ox::Error setRomFs(Context &ctx, ox::UPtr<ox::FileSystem> &&fs, DuplicateSet &duplicateSet) noexcept {
|
ox::Error setRomFs(Context &ctx, ox::UPtr<ox::FileSystem> &&fs, DuplicateSet &duplicateSet) noexcept {
|
||||||
ctx.rom = std::move(fs);
|
ctx.rom = std::move(fs);
|
||||||
clearUuidMap(ctx);
|
clearUuidMap(ctx);
|
||||||
|
#ifndef OX_BARE_METAL
|
||||||
|
ctx.assetManager.gc();
|
||||||
|
#endif
|
||||||
return buildUuidMap(ctx, &duplicateSet);
|
return buildUuidMap(ctx, &duplicateSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -250,6 +250,9 @@ void StudioUI::drawMenu() noexcept {
|
|||||||
if (ImGui::MenuItem("Open Project...", STUDIO_CTRL "+O")) {
|
if (ImGui::MenuItem("Open Project...", STUDIO_CTRL "+O")) {
|
||||||
m_taskRunner.add(*ox::make<FileDialogManager>(this, &StudioUI::openProjectPath));
|
m_taskRunner.add(*ox::make<FileDialogManager>(this, &StudioUI::openProjectPath));
|
||||||
}
|
}
|
||||||
|
if (ImGui::MenuItem("Reload Project")) {
|
||||||
|
oxLogError(openProjectPath(m_project->projectPath()));
|
||||||
|
}
|
||||||
if (ImGui::BeginMenu("Recent Projects", m_recentProjects.size() > 1)) {
|
if (ImGui::BeginMenu("Recent Projects", m_recentProjects.size() > 1)) {
|
||||||
for (size_t i = 1; i < m_recentProjects.size(); ++i) {
|
for (size_t i = 1; i < m_recentProjects.size(); ++i) {
|
||||||
auto const &p = m_recentProjects[i];
|
auto const &p = m_recentProjects[i];
|
||||||
@@ -636,6 +639,9 @@ ox::Error StudioUI::createOpenProject(ox::StringViewCR path) noexcept {
|
|||||||
|
|
||||||
ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept {
|
ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept {
|
||||||
OX_REQUIRE_M(fs, keel::loadRomFs(path.view()));
|
OX_REQUIRE_M(fs, keel::loadRomFs(path.view()));
|
||||||
|
m_project.reset();
|
||||||
|
m_openFiles.clear();
|
||||||
|
m_editors.clear();
|
||||||
keel::DuplicateSet ds;
|
keel::DuplicateSet ds;
|
||||||
OX_RETURN_ERROR(keel::setRomFs(keelCtx(m_tctx), std::move(fs), ds));
|
OX_RETURN_ERROR(keel::setRomFs(keelCtx(m_tctx), std::move(fs), ds));
|
||||||
if (ds.size()) {
|
if (ds.size()) {
|
||||||
@@ -665,8 +671,6 @@ ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept {
|
|||||||
m_project->dirDeleted.connect(this, &StudioUI::handleDeleteDir);
|
m_project->dirDeleted.connect(this, &StudioUI::handleDeleteDir);
|
||||||
m_project->fileDeleted.connect(this, &StudioUI::handleDeleteFile);
|
m_project->fileDeleted.connect(this, &StudioUI::handleDeleteFile);
|
||||||
m_project->fileMoved.connect(this, &StudioUI::handleMoveFile);
|
m_project->fileMoved.connect(this, &StudioUI::handleMoveFile);
|
||||||
m_openFiles.clear();
|
|
||||||
m_editors.clear();
|
|
||||||
studio::editConfig<StudioConfig>(keelCtx(m_tctx), [&](StudioConfig &config) {
|
studio::editConfig<StudioConfig>(keelCtx(m_tctx), [&](StudioConfig &config) {
|
||||||
auto const pcIt = std::find_if(
|
auto const pcIt = std::find_if(
|
||||||
config.projects.begin(), config.projects.end(),
|
config.projects.begin(), config.projects.end(),
|
||||||
|
@@ -185,10 +185,15 @@ ox::Error Project::writeObj(ox::StringViewCR path, T const &obj) noexcept {
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ox::Result<T> Project::loadObj(ox::StringViewCR path) const noexcept {
|
ox::Result<T> Project::loadObj(ox::StringViewCR path) const noexcept {
|
||||||
OX_REQUIRE(buff, loadBuff(path));
|
OX_REQUIRE_M(buff, loadBuff(path));
|
||||||
if constexpr(ox::is_same_v<T, ox::ModelObject>) {
|
if constexpr(ox::is_same_v<T, ox::ModelObject>) {
|
||||||
return keel::readAsset(m_typeStore, buff);
|
return keel::readAsset(m_typeStore, buff);
|
||||||
} else {
|
} else {
|
||||||
|
OX_REQUIRE(typeId, keel::readAssetTypeId(buff));
|
||||||
|
if (typeId != ox::ModelTypeId_v<T>) {
|
||||||
|
OX_REQUIRE(ah, keel::readAssetHeader(buff));
|
||||||
|
OX_RETURN_ERROR(keel::convertBuffToBuff<T>(m_kctx, buff, ah.clawHdr.fmt).moveTo(buff));
|
||||||
|
}
|
||||||
return keel::readAsset<T>(buff);
|
return keel::readAsset<T>(buff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user