[keel,nostalgia,studio,turbine] Make turbine::Context have a keel::Context instead of being one

This commit is contained in:
2023-06-20 00:56:55 -05:00
parent d4eaade326
commit c5233e0d1d
24 changed files with 134 additions and 79 deletions

View File

@@ -26,7 +26,7 @@ ox::Result<PaletteEditorImGui*> PaletteEditorImGui::make(turbine::Context *ctx,
out->m_itemPath = path;
const auto lastSlash = std::find(out->m_itemPath.rbegin(), out->m_itemPath.rend(), '/').offset();
out->m_itemName = out->m_itemPath.substr(lastSlash + 1);
oxRequire(pal, keel::readObj<Palette>(out->m_ctx, ox::FileAddress(out->m_itemPath.c_str())));
oxRequire(pal, keel::readObj<Palette>(&out->m_ctx->keelCtx, ox::FileAddress(out->m_itemPath.c_str())));
out->m_pal = *pal;
return out.release();
}
@@ -148,7 +148,7 @@ void PaletteEditorImGui::draw(turbine::Context*) noexcept {
ox::Error PaletteEditorImGui::saveItem() noexcept {
const auto sctx = applicationData<studio::StudioContext>(*m_ctx);
oxReturnError(sctx->project->writeObj(m_itemPath, &m_pal));
oxReturnError(m_ctx->assetManager.setAsset(m_itemPath, m_pal));
oxReturnError(m_ctx->keelCtx.assetManager.setAsset(m_itemPath, m_pal));
return {};
}

View File

@@ -566,10 +566,10 @@ class PaletteChangeCommand: public TileSheetCommand {
TileSheetEditorModel::TileSheetEditorModel(turbine::Context *ctx, ox::String path):
m_ctx(ctx),
m_path(std::move(path)) {
oxRequireT(img, readObj<TileSheet>(ctx, m_path));
oxRequireT(img, readObj<TileSheet>(&ctx->keelCtx, m_path));
m_img = *img;
if (m_img.defaultPalette) {
oxThrowError(readObj<Palette>(ctx, m_img.defaultPalette).moveTo(&m_pal));
oxThrowError(readObj<Palette>(&ctx->keelCtx, m_img.defaultPalette).moveTo(&m_pal));
}
m_pal.updated.connect(this, &TileSheetEditorModel::markUpdated);
m_undoStack.changeTriggered.connect(this, &TileSheetEditorModel::markUpdatedCmdId);
@@ -633,7 +633,7 @@ ox::StringView TileSheetEditorModel::palPath() const noexcept {
constexpr ox::StringView uuidPrefix = "uuid://";
if (ox::beginsWith(path, uuidPrefix)) {
auto uuid = ox::StringView(path + uuidPrefix.bytes(), ox_strlen(path) - uuidPrefix.bytes());
auto out = m_ctx->uuidToPath.at(uuid);
auto out = m_ctx->keelCtx.uuidToPath.at(uuid);
if (out.error) {
return {};
}
@@ -644,7 +644,7 @@ ox::StringView TileSheetEditorModel::palPath() const noexcept {
}
ox::Error TileSheetEditorModel::setPalette(const ox::String &path) noexcept {
oxRequire(uuid, m_ctx->pathToUuid.at(path));
oxRequire(uuid, m_ctx->keelCtx.pathToUuid.at(path));
pushCommand(ox::make<PaletteChangeCommand>(activeSubSheetIdx(), m_img, uuid->toString()));
return {};
}
@@ -752,7 +752,7 @@ ox::Error TileSheetEditorModel::markUpdatedCmdId(const studio::UndoCommand *cmd)
m_updated = true;
const auto cmdId = cmd->commandId();
if (static_cast<CommandId>(cmdId) == CommandId::PaletteChange) {
oxReturnError(readObj<Palette>(m_ctx, ox::StringView(m_img.defaultPalette.getPath().value)).moveTo(&m_pal));
oxReturnError(readObj<Palette>(&m_ctx->keelCtx, ox::StringView(m_img.defaultPalette.getPath().value)).moveTo(&m_pal));
}
auto tsCmd = dynamic_cast<const TileSheetCommand*>(cmd);
auto idx = m_img.validateSubSheetIdx(tsCmd->subsheetIdx());
@@ -774,7 +774,7 @@ void TileSheetEditorModel::ackUpdate() noexcept {
ox::Error TileSheetEditorModel::saveFile() noexcept {
const auto sctx = applicationData<studio::StudioContext>(*m_ctx);
oxReturnError(sctx->project->writeObj(m_path, &m_img));
return m_ctx->assetManager.setAsset(m_path, m_img).error;
return m_ctx->keelCtx.assetManager.setAsset(m_path, m_img).error;
}
bool TileSheetEditorModel::pixelSelected(std::size_t idx) const noexcept {