[nostalgia] Replace C strings with StringViews

This commit is contained in:
2022-12-31 14:59:17 -06:00
parent ca07dc6152
commit 2c2fce2c5a
17 changed files with 119 additions and 94 deletions
@@ -19,7 +19,7 @@ ox::Result<PaletteEditorImGui*> PaletteEditorImGui::make(Context *ctx, const ox:
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, core::readObj<Palette>(out->m_ctx, out->m_itemPath));
oxRequire(pal, core::readObj<Palette>(out->m_ctx, ox::FileAddress(out->m_itemPath.c_str())));
out->m_pal = *pal;
return out.release();
}
@@ -511,7 +511,7 @@ class PaletteChangeCommand: public TileSheetCommand {
m_idx = idx;
m_img = img;
m_oldPalette = m_img->defaultPalette;
m_newPalette = newPalette;
m_newPalette = ox::FileAddress(newPalette);
}
void redo() noexcept final {
@@ -538,7 +538,7 @@ class PaletteChangeCommand: public TileSheetCommand {
TileSheetEditorModel::TileSheetEditorModel(Context *ctx, ox::String path) {
m_ctx = ctx;
m_path = std::move(path);
oxRequireT(img, readObj<TileSheet>(ctx, m_path.c_str()));
oxRequireT(img, readObj<TileSheet>(ctx, m_path));
m_img = *img;
if (m_img.defaultPalette) {
oxThrowError(readObj<Palette>(ctx, m_img.defaultPalette).moveTo(&m_pal));
@@ -709,7 +709,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, m_img.defaultPalette.getPath().value).moveTo(&m_pal));
oxReturnError(readObj<Palette>(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());