[olympic/studio,nostalgia] Change Editor item name to item path, make
TileSheetEditorImGui inherit from Editor
This commit is contained in:
@ -224,7 +224,7 @@ void StudioUI::drawTabs() noexcept {
|
||||
if (m_activeEditor != e.get()) {
|
||||
m_activeEditor = e.get();
|
||||
studio::editConfig<StudioConfig>(keelCtx(m_ctx), [&](StudioConfig *config) {
|
||||
config->activeTabItemName = m_activeEditor->itemName();
|
||||
config->activeTabItemName = m_activeEditor->itemPath();
|
||||
});
|
||||
}
|
||||
if (m_activeEditorUpdatePending == e.get()) {
|
||||
@ -326,7 +326,7 @@ ox::Error StudioUI::openFile(ox::CRStringView path) noexcept {
|
||||
ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab) noexcept {
|
||||
if (m_openFiles.contains(path)) {
|
||||
for (auto &e : m_editors) {
|
||||
if (makeActiveTab && e->itemName() == path) {
|
||||
if (makeActiveTab && e->itemPath() == path) {
|
||||
m_activeEditor = e.get();
|
||||
m_activeEditorUpdatePending = e.get();
|
||||
break;
|
||||
|
@ -32,7 +32,7 @@ class BaseEditor: public Widget {
|
||||
* Returns the name of item being edited.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
virtual ox::CStringView itemName() const noexcept = 0;
|
||||
virtual ox::CStringView itemPath() const noexcept = 0;
|
||||
|
||||
[[nodiscard]]
|
||||
virtual ox::CStringView itemDisplayName() const noexcept;
|
||||
@ -98,11 +98,7 @@ class BaseEditor: public Widget {
|
||||
* Returns the undo stack holding changes to the item being edited.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
virtual UndoStack *undoStack() noexcept {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static ox::StringView pathToItemName(ox::CRStringView path) noexcept;
|
||||
virtual UndoStack *undoStack() noexcept;
|
||||
|
||||
void setRequiresConstantRefresh(bool value) noexcept;
|
||||
|
||||
@ -127,15 +123,16 @@ class Editor: public studio::BaseEditor {
|
||||
Editor(ox::StringView itemPath) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
ox::CStringView itemName() const noexcept final;
|
||||
ox::CStringView itemPath() const noexcept final;
|
||||
|
||||
[[nodiscard]]
|
||||
ox::CStringView itemDisplayName() const noexcept final;
|
||||
|
||||
[[nodiscard]]
|
||||
UndoStack *undoStack() noexcept final;
|
||||
|
||||
private:
|
||||
ox::Error markUnsavedChanges(const UndoCommand*) noexcept;
|
||||
ox::Error markUnsavedChanges(UndoCommand const*) noexcept;
|
||||
};
|
||||
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace studio {
|
||||
|
||||
ox::CStringView BaseEditor::itemDisplayName() const noexcept {
|
||||
return itemName();
|
||||
return itemPath();
|
||||
}
|
||||
|
||||
void BaseEditor::cut() {
|
||||
@ -37,7 +37,7 @@ bool BaseEditor::requiresConstantRefresh() const noexcept {
|
||||
}
|
||||
|
||||
void BaseEditor::close() const {
|
||||
this->closed.emit(itemName());
|
||||
this->closed.emit(itemPath());
|
||||
}
|
||||
|
||||
void BaseEditor::save() noexcept {
|
||||
@ -46,9 +46,9 @@ void BaseEditor::save() noexcept {
|
||||
setUnsavedChanges(false);
|
||||
} else {
|
||||
if constexpr(ox::defines::Debug) {
|
||||
oxErrorf("Could not save file {}: {} ({}:{})", itemName(), toStr(err), err.file, err.line);
|
||||
oxErrorf("Could not save file {}: {} ({}:{})", itemPath(), toStr(err), err.file, err.line);
|
||||
} else {
|
||||
oxErrorf("Could not save file {}: {}", itemName(), toStr(err));
|
||||
oxErrorf("Could not save file {}: {}", itemPath(), toStr(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -102,9 +102,8 @@ ox::Error BaseEditor::saveItem() noexcept {
|
||||
return OxError(0);
|
||||
}
|
||||
|
||||
ox::StringView BaseEditor::pathToItemName(ox::CRStringView path) noexcept {
|
||||
const auto lastSlash = std::find(path.rbegin(), path.rend(), '/').offset();
|
||||
return substr(path, lastSlash + 1);
|
||||
UndoStack *BaseEditor::undoStack() noexcept {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void BaseEditor::setRequiresConstantRefresh(bool value) noexcept {
|
||||
@ -119,7 +118,7 @@ Editor::Editor(ox::StringView itemPath) noexcept:
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
ox::CStringView Editor::itemName() const noexcept {
|
||||
ox::CStringView Editor::itemPath() const noexcept {
|
||||
return m_itemPath;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user