[keel,nostalgia,studio,turbine] Cleanup structure of Turbine

This commit is contained in:
2023-12-08 23:59:02 -06:00
parent 1298051a1a
commit facde6bdce
60 changed files with 669 additions and 557 deletions

View File

@@ -17,9 +17,9 @@ namespace nostalgia::core {
PaletteEditorImGui::PaletteEditorImGui(turbine::Context &ctx, ox::CRStringView path):
m_ctx(ctx),
m_itemPath(std::move(path)),
m_itemPath(path),
m_itemName(m_itemPath.substr(std::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset() + 1)),
m_pal(*keel::readObj<Palette>(m_ctx.keelCtx, ox::FileAddress(m_itemPath.c_str())).unwrapThrow()) {
m_pal(*keel::readObj<Palette>(keelCtx(m_ctx), ox::FileAddress(m_itemPath.c_str())).unwrapThrow()) {
}
ox::String const&PaletteEditorImGui::itemName() const noexcept {

View File

@@ -567,10 +567,10 @@ class PaletteChangeCommand: public TileSheetCommand {
TileSheetEditorModel::TileSheetEditorModel(turbine::Context &ctx, ox::StringView path):
m_ctx(ctx),
m_path(path) {
oxRequireT(img, readObj<TileSheet>(m_ctx.keelCtx, m_path));
oxRequireT(img, readObj<TileSheet>(keelCtx(m_ctx), m_path));
m_img = *img;
if (m_img.defaultPalette) {
oxThrowError(readObj<Palette>(m_ctx.keelCtx, m_img.defaultPalette).moveTo(&m_pal));
oxThrowError(readObj<Palette>(keelCtx(m_ctx), m_img.defaultPalette).moveTo(&m_pal));
}
m_pal.updated.connect(this, &TileSheetEditorModel::markUpdated);
m_undoStack.changeTriggered.connect(this, &TileSheetEditorModel::markUpdatedCmdId);
@@ -634,7 +634,7 @@ ox::StringView TileSheetEditorModel::palPath() const noexcept {
constexpr ox::StringView uuidPrefix = "uuid://";
if (ox::beginsWith(path, uuidPrefix)) {
auto uuid = ox::StringView(path.data() + uuidPrefix.bytes(), path.bytes() - uuidPrefix.bytes());
auto out = m_ctx.keelCtx.uuidToPath.at(uuid);
auto out = keelCtx(m_ctx).uuidToPath.at(uuid);
if (out.error) {
return {};
}
@@ -645,7 +645,7 @@ ox::StringView TileSheetEditorModel::palPath() const noexcept {
}
ox::Error TileSheetEditorModel::setPalette(ox::String const&path) noexcept {
oxRequire(uuid, m_ctx.keelCtx.pathToUuid.at(path));
oxRequire(uuid, keelCtx(m_ctx).pathToUuid.at(path));
pushCommand(ox::make<PaletteChangeCommand>(activeSubSheetIdx(), m_img, uuid->toString()));
return {};
}
@@ -753,7 +753,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.keelCtx, ox::StringView(m_img.defaultPalette.getPath().value)).moveTo(&m_pal));
oxReturnError(readObj<Palette>(keelCtx(m_ctx), ox::StringView(m_img.defaultPalette.getPath().value)).moveTo(&m_pal));
}
auto tsCmd = dynamic_cast<const TileSheetCommand*>(cmd);
auto idx = m_img.validateSubSheetIdx(tsCmd->subsheetIdx());