[olympic/studio] Change Studio modules to pass StudioContext instead of turbine::Context
All checks were successful
Build / build (push) Successful in 2m23s
All checks were successful
Build / build (push) Successful in 2m23s
This commit is contained in:
parent
5d1f680a51
commit
124c7029bd
@ -15,9 +15,9 @@
|
|||||||
|
|
||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
PaletteEditorImGui::PaletteEditorImGui(turbine::Context &ctx, ox::CRStringView path):
|
PaletteEditorImGui::PaletteEditorImGui(studio::StudioContext &ctx, ox::CRStringView path):
|
||||||
Editor(path),
|
Editor(path),
|
||||||
m_ctx(ctx),
|
m_ctx(ctx.tctx),
|
||||||
m_pal(*keel::readObj<Palette>(keelCtx(m_ctx), ox::FileAddress(itemPath())).unwrapThrow()) {
|
m_pal(*keel::readObj<Palette>(keelCtx(m_ctx), ox::FileAddress(itemPath())).unwrapThrow()) {
|
||||||
undoStack()->changeTriggered.connect(this, &PaletteEditorImGui::handleCommand);
|
undoStack()->changeTriggered.connect(this, &PaletteEditorImGui::handleCommand);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ class PaletteEditorImGui: public studio::Editor {
|
|||||||
size_t m_page = 0;
|
size_t m_page = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PaletteEditorImGui(turbine::Context &ctx, ox::CRStringView path);
|
PaletteEditorImGui(studio::StudioContext &ctx, ox::CRStringView path);
|
||||||
|
|
||||||
void keyStateChanged(turbine::Key key, bool down) override;
|
void keyStateChanged(turbine::Key key, bool down) override;
|
||||||
|
|
||||||
|
@ -12,14 +12,14 @@
|
|||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
class StudioModule: public studio::Module {
|
class StudioModule: public studio::Module {
|
||||||
ox::Vector<studio::EditorMaker> editors(turbine::Context &ctx) const noexcept final {
|
ox::Vector<studio::EditorMaker> editors(studio::StudioContext &ctx) const noexcept final {
|
||||||
return {
|
return {
|
||||||
studio::editorMaker<TileSheetEditorImGui>(ctx, FileExt_ng),
|
studio::editorMaker<TileSheetEditorImGui>(ctx, FileExt_ng),
|
||||||
studio::editorMaker<PaletteEditorImGui>(ctx, FileExt_npal),
|
studio::editorMaker<PaletteEditorImGui>(ctx, FileExt_npal),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Vector<ox::UPtr<studio::ItemMaker>> itemMakers(turbine::Context&) const noexcept final {
|
ox::Vector<ox::UPtr<studio::ItemMaker>> itemMakers(studio::StudioContext&) const noexcept final {
|
||||||
ox::Vector<ox::UniquePtr<studio::ItemMaker>> out;
|
ox::Vector<ox::UniquePtr<studio::ItemMaker>> out;
|
||||||
out.emplace_back(ox::make<studio::ItemMakerT<core::TileSheet>>("Tile Sheet", "TileSheets", FileExt_ng));
|
out.emplace_back(ox::make<studio::ItemMakerT<core::TileSheet>>("Tile Sheet", "TileSheets", FileExt_ng));
|
||||||
out.emplace_back(ox::make<studio::ItemMakerT<core::Palette>>("Palette", "Palettes", FileExt_npal));
|
out.emplace_back(ox::make<studio::ItemMakerT<core::Palette>>("Palette", "Palettes", FileExt_npal));
|
||||||
|
@ -75,9 +75,9 @@ static ox::Error toPngFile(
|
|||||||
8)));
|
8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TileSheetEditorImGui::TileSheetEditorImGui(turbine::Context &ctx, ox::CRStringView path):
|
TileSheetEditorImGui::TileSheetEditorImGui(studio::StudioContext &ctx, ox::CRStringView path):
|
||||||
Editor(path),
|
Editor(path),
|
||||||
m_ctx(ctx),
|
m_ctx(ctx.tctx),
|
||||||
m_view(m_ctx, path, *undoStack()),
|
m_view(m_ctx, path, *undoStack()),
|
||||||
m_model(m_view.model()) {
|
m_model(m_view.model()) {
|
||||||
oxIgnoreError(setPaletteSelection());
|
oxIgnoreError(setPaletteSelection());
|
||||||
|
@ -73,7 +73,7 @@ class TileSheetEditorImGui: public studio::Editor {
|
|||||||
Tool m_tool = Tool::Draw;
|
Tool m_tool = Tool::Draw;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TileSheetEditorImGui(turbine::Context &ctx, ox::CRStringView path);
|
TileSheetEditorImGui(studio::StudioContext &ctx, ox::CRStringView path);
|
||||||
|
|
||||||
~TileSheetEditorImGui() override = default;
|
~TileSheetEditorImGui() override = default;
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
namespace nostalgia::scene {
|
namespace nostalgia::scene {
|
||||||
|
|
||||||
SceneEditorImGui::SceneEditorImGui(turbine::Context &ctx, ox::StringView path):
|
SceneEditorImGui::SceneEditorImGui(studio::StudioContext &ctx, ox::StringView path):
|
||||||
Editor(path),
|
Editor(path),
|
||||||
m_ctx(ctx),
|
m_ctx(ctx.tctx),
|
||||||
m_editor(m_ctx, path),
|
m_editor(m_ctx, path),
|
||||||
m_view(m_ctx, m_editor.scene()) {
|
m_view(m_ctx, m_editor.scene()) {
|
||||||
setRequiresConstantRefresh(false);
|
setRequiresConstantRefresh(false);
|
||||||
|
@ -21,7 +21,7 @@ class SceneEditorImGui: public studio::Editor {
|
|||||||
SceneEditorView m_view;
|
SceneEditorView m_view;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SceneEditorImGui(turbine::Context &ctx, ox::StringView path);
|
SceneEditorImGui(studio::StudioContext &ctx, ox::StringView path);
|
||||||
|
|
||||||
void draw(turbine::Context&) noexcept final;
|
void draw(turbine::Context&) noexcept final;
|
||||||
|
|
||||||
|
@ -12,12 +12,12 @@ constexpr ox::StringLiteral FileExt_nscn("nscn");
|
|||||||
|
|
||||||
class StudioModule: public studio::Module {
|
class StudioModule: public studio::Module {
|
||||||
public:
|
public:
|
||||||
ox::Vector<studio::EditorMaker> editors(turbine::Context &ctx) const noexcept override {
|
ox::Vector<studio::EditorMaker> editors(studio::StudioContext &ctx) const noexcept override {
|
||||||
return {
|
return {
|
||||||
studio::editorMaker<SceneEditorImGui>(ctx, FileExt_nscn),
|
studio::editorMaker<SceneEditorImGui>(ctx, FileExt_nscn),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
ox::Vector<ox::UPtr<studio::ItemMaker>> itemMakers(turbine::Context&) const noexcept override {
|
ox::Vector<ox::UPtr<studio::ItemMaker>> itemMakers(studio::StudioContext&) const noexcept override {
|
||||||
ox::Vector<ox::UPtr<studio::ItemMaker>> out;
|
ox::Vector<ox::UPtr<studio::ItemMaker>> out;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ static ox::Error runApp(
|
|||||||
turbine::setConstantRefresh(*ctx, false);
|
turbine::setConstantRefresh(*ctx, false);
|
||||||
studio::StudioContext studioCtx(*ctx);
|
studio::StudioContext studioCtx(*ctx);
|
||||||
turbine::setApplicationData(*ctx, &studioCtx);
|
turbine::setApplicationData(*ctx, &studioCtx);
|
||||||
StudioUI ui(*ctx, projectDataDir);
|
StudioUI ui(studioCtx, projectDataDir);
|
||||||
studioCtx.ui = &ui;
|
studioCtx.ui = &ui;
|
||||||
StudioUIDrawer drawer(ui);
|
StudioUIDrawer drawer(ui);
|
||||||
turbine::gl::addDrawer(*ctx, &drawer);
|
turbine::gl::addDrawer(*ctx, &drawer);
|
||||||
|
@ -40,8 +40,9 @@ oxModelBegin(StudioConfig)
|
|||||||
oxModelFieldRename(show_project_explorer, showProjectExplorer)
|
oxModelFieldRename(show_project_explorer, showProjectExplorer)
|
||||||
oxModelEnd()
|
oxModelEnd()
|
||||||
|
|
||||||
StudioUI::StudioUI(turbine::Context &ctx, ox::StringView projectDataDir) noexcept:
|
StudioUI::StudioUI(studio::StudioContext &ctx, ox::StringView projectDataDir) noexcept:
|
||||||
m_ctx(ctx),
|
m_sctx(ctx),
|
||||||
|
m_ctx(ctx.tctx),
|
||||||
m_projectDataDir(projectDataDir),
|
m_projectDataDir(projectDataDir),
|
||||||
m_projectExplorer(m_ctx),
|
m_projectExplorer(m_ctx),
|
||||||
m_newProject(ox::String(projectDataDir)),
|
m_newProject(ox::String(projectDataDir)),
|
||||||
@ -288,10 +289,10 @@ void StudioUI::loadEditorMaker(studio::EditorMaker const&editorMaker) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void StudioUI::loadModule(studio::Module const*mod) noexcept {
|
void StudioUI::loadModule(studio::Module const*mod) noexcept {
|
||||||
for (auto const&editorMaker : mod->editors(m_ctx)) {
|
for (auto const&editorMaker : mod->editors(m_sctx)) {
|
||||||
loadEditorMaker(editorMaker);
|
loadEditorMaker(editorMaker);
|
||||||
}
|
}
|
||||||
for (auto &im : mod->itemMakers(m_ctx)) {
|
for (auto &im : mod->itemMakers(m_sctx)) {
|
||||||
m_newMenu.addItemMaker(std::move(im));
|
m_newMenu.addItemMaker(std::move(im));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ class StudioUI: public ox::SignalHandler {
|
|||||||
friend class StudioUIDrawer;
|
friend class StudioUIDrawer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
studio::StudioContext &m_sctx;
|
||||||
turbine::Context &m_ctx;
|
turbine::Context &m_ctx;
|
||||||
ox::String m_projectDataDir;
|
ox::String m_projectDataDir;
|
||||||
ox::UPtr<studio::Project> m_project;
|
ox::UPtr<studio::Project> m_project;
|
||||||
@ -47,7 +48,7 @@ class StudioUI: public ox::SignalHandler {
|
|||||||
bool m_showProjectExplorer = true;
|
bool m_showProjectExplorer = true;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StudioUI(turbine::Context &ctx, ox::StringView projectDataDir) noexcept;
|
explicit StudioUI(studio::StudioContext &ctx, ox::StringView projectDataDir) noexcept;
|
||||||
|
|
||||||
void update() noexcept;
|
void update() noexcept;
|
||||||
|
|
||||||
|
@ -27,15 +27,15 @@ class Module {
|
|||||||
public:
|
public:
|
||||||
virtual ~Module() noexcept = default;
|
virtual ~Module() noexcept = default;
|
||||||
|
|
||||||
virtual ox::Vector<EditorMaker> editors(turbine::Context &ctx) const;
|
virtual ox::Vector<EditorMaker> editors(studio::StudioContext &ctx) const;
|
||||||
|
|
||||||
virtual ox::Vector<ox::UPtr<ItemMaker>> itemMakers(turbine::Context&) const;
|
virtual ox::Vector<ox::UPtr<ItemMaker>> itemMakers(studio::StudioContext&) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Editor>
|
template<typename Editor>
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
studio::EditorMaker editorMaker(turbine::Context &ctx, ox::CRStringView ext) noexcept {
|
studio::EditorMaker editorMaker(studio::StudioContext &ctx, ox::CRStringView ext) noexcept {
|
||||||
return {
|
return {
|
||||||
{ox::String(ext)},
|
{ox::String(ext)},
|
||||||
[&ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
|
[&ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
namespace studio {
|
namespace studio {
|
||||||
|
|
||||||
ox::Vector<EditorMaker> Module::editors(turbine::Context&) const {
|
ox::Vector<EditorMaker> Module::editors(studio::StudioContext&) const {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Vector<ox::UPtr<ItemMaker>> Module::itemMakers(turbine::Context&) const {
|
ox::Vector<ox::UPtr<ItemMaker>> Module::itemMakers(studio::StudioContext&) const {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user