[nostalgia] Add basic support for subsheets

This commit is contained in:
2022-02-26 22:48:18 -06:00
parent 329ecb3266
commit e8a046c2dc
20 changed files with 630 additions and 238 deletions

View File

@@ -50,8 +50,7 @@ class NOSTALGIASTUDIO_EXPORT Project {
/**
* Writes a MetalClaw object to the project at the given path.
*/
template<typename T>
ox::Error writeObj(const ox::String &path, T *obj) const noexcept;
ox::Error writeObj(const ox::String &path, auto *obj) const noexcept;
template<typename T>
ox::Result<ox::UniquePtr<T>> loadObj(const ox::String &path) const noexcept;
@@ -86,8 +85,7 @@ class NOSTALGIASTUDIO_EXPORT Project {
};
template<typename T>
ox::Error Project::writeObj(const ox::String &path, T *obj) const noexcept {
ox::Error Project::writeObj(const ox::String &path, auto *obj) const noexcept {
// write MetalClaw
oxRequireM(buff, ox::writeClaw(obj, ox::ClawFormat::Metal));
// write to FS

View File

@@ -17,7 +17,7 @@ enum class TaskState {
class Task: public ox::SignalHandler {
public:
virtual ~Task() noexcept = default;
~Task() noexcept override = default;
virtual TaskState update(nostalgia::core::Context *ctx) noexcept = 0;
};

View File

@@ -12,25 +12,30 @@ void UndoStack::push(UndoCommand *cmd) noexcept {
}
m_stack.emplace_back(cmd);
++m_stackIdx;
auto cmdId = cmd->commandId();
cmd->redo();
redoTriggered.emit();
changeTriggered.emit();
redoTriggered.emit(cmdId);
changeTriggered.emit(cmdId);
}
void UndoStack::redo() noexcept {
if (m_stackIdx < m_stack.size()) {
m_stack[m_stackIdx++]->redo();
auto &c = m_stack[m_stackIdx++];
auto cmdId = c->commandId();
c->redo();
redoTriggered.emit(cmdId);
changeTriggered.emit(cmdId);
}
redoTriggered.emit();
changeTriggered.emit();
}
void UndoStack::undo() noexcept {
if (m_stackIdx) {
m_stack[--m_stackIdx]->undo();
auto &c = m_stack[--m_stackIdx];
auto cmdId = c->commandId();
c->undo();
undoTriggered.emit(cmdId);
changeTriggered.emit(cmdId);
}
undoTriggered.emit();
changeTriggered.emit();
}
}

View File

@@ -16,6 +16,8 @@ class UndoCommand {
virtual ~UndoCommand() noexcept = default;
virtual void redo() noexcept = 0;
virtual void undo() noexcept = 0;
[[nodiscard]]
virtual int commandId() const noexcept = 0;
};
class UndoStack {
@@ -40,9 +42,9 @@ class UndoStack {
return m_stackIdx;
}
ox::Signal<ox::Error()> redoTriggered;
ox::Signal<ox::Error()> undoTriggered;
ox::Signal<ox::Error()> changeTriggered;
ox::Signal<ox::Error(int)> redoTriggered;
ox::Signal<ox::Error(int)> undoTriggered;
ox::Signal<ox::Error(int)> changeTriggered;
};
}

View File

@@ -12,7 +12,8 @@ namespace nostalgia::studio {
class Widget: public ox::SignalHandler {
public:
~Widget() noexcept override = default;
virtual void draw(core::Context*) noexcept = 0;
};
}
}