[olympic/studio] Change Studio modules to pass StudioContext instead of turbine::Context
All checks were successful
Build / build (push) Successful in 2m23s

This commit is contained in:
Gary Talent 2024-01-20 15:40:08 -06:00
parent 5d1f680a51
commit 124c7029bd
13 changed files with 26 additions and 24 deletions

View File

@ -15,9 +15,9 @@
namespace nostalgia::core {
PaletteEditorImGui::PaletteEditorImGui(turbine::Context &ctx, ox::CRStringView path):
PaletteEditorImGui::PaletteEditorImGui(studio::StudioContext &ctx, ox::CRStringView path):
Editor(path),
m_ctx(ctx),
m_ctx(ctx.tctx),
m_pal(*keel::readObj<Palette>(keelCtx(m_ctx), ox::FileAddress(itemPath())).unwrapThrow()) {
undoStack()->changeTriggered.connect(this, &PaletteEditorImGui::handleCommand);
}

View File

@ -20,7 +20,7 @@ class PaletteEditorImGui: public studio::Editor {
size_t m_page = 0;
public:
PaletteEditorImGui(turbine::Context &ctx, ox::CRStringView path);
PaletteEditorImGui(studio::StudioContext &ctx, ox::CRStringView path);
void keyStateChanged(turbine::Key key, bool down) override;

View File

@ -12,14 +12,14 @@
namespace nostalgia::core {
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 {
studio::editorMaker<TileSheetEditorImGui>(ctx, FileExt_ng),
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;
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));

View File

@ -75,9 +75,9 @@ static ox::Error toPngFile(
8)));
}
TileSheetEditorImGui::TileSheetEditorImGui(turbine::Context &ctx, ox::CRStringView path):
TileSheetEditorImGui::TileSheetEditorImGui(studio::StudioContext &ctx, ox::CRStringView path):
Editor(path),
m_ctx(ctx),
m_ctx(ctx.tctx),
m_view(m_ctx, path, *undoStack()),
m_model(m_view.model()) {
oxIgnoreError(setPaletteSelection());

View File

@ -73,7 +73,7 @@ class TileSheetEditorImGui: public studio::Editor {
Tool m_tool = Tool::Draw;
public:
TileSheetEditorImGui(turbine::Context &ctx, ox::CRStringView path);
TileSheetEditorImGui(studio::StudioContext &ctx, ox::CRStringView path);
~TileSheetEditorImGui() override = default;

View File

@ -10,9 +10,9 @@
namespace nostalgia::scene {
SceneEditorImGui::SceneEditorImGui(turbine::Context &ctx, ox::StringView path):
SceneEditorImGui::SceneEditorImGui(studio::StudioContext &ctx, ox::StringView path):
Editor(path),
m_ctx(ctx),
m_ctx(ctx.tctx),
m_editor(m_ctx, path),
m_view(m_ctx, m_editor.scene()) {
setRequiresConstantRefresh(false);

View File

@ -21,7 +21,7 @@ class SceneEditorImGui: public studio::Editor {
SceneEditorView m_view;
public:
SceneEditorImGui(turbine::Context &ctx, ox::StringView path);
SceneEditorImGui(studio::StudioContext &ctx, ox::StringView path);
void draw(turbine::Context&) noexcept final;

View File

@ -12,12 +12,12 @@ constexpr ox::StringLiteral FileExt_nscn("nscn");
class StudioModule: public studio::Module {
public:
ox::Vector<studio::EditorMaker> editors(turbine::Context &ctx) const noexcept override {
ox::Vector<studio::EditorMaker> editors(studio::StudioContext &ctx) const noexcept override {
return {
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;
return out;
}

View File

@ -50,7 +50,7 @@ static ox::Error runApp(
turbine::setConstantRefresh(*ctx, false);
studio::StudioContext studioCtx(*ctx);
turbine::setApplicationData(*ctx, &studioCtx);
StudioUI ui(*ctx, projectDataDir);
StudioUI ui(studioCtx, projectDataDir);
studioCtx.ui = &ui;
StudioUIDrawer drawer(ui);
turbine::gl::addDrawer(*ctx, &drawer);

View File

@ -40,8 +40,9 @@ oxModelBegin(StudioConfig)
oxModelFieldRename(show_project_explorer, showProjectExplorer)
oxModelEnd()
StudioUI::StudioUI(turbine::Context &ctx, ox::StringView projectDataDir) noexcept:
m_ctx(ctx),
StudioUI::StudioUI(studio::StudioContext &ctx, ox::StringView projectDataDir) noexcept:
m_sctx(ctx),
m_ctx(ctx.tctx),
m_projectDataDir(projectDataDir),
m_projectExplorer(m_ctx),
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 {
for (auto const&editorMaker : mod->editors(m_ctx)) {
for (auto const&editorMaker : mod->editors(m_sctx)) {
loadEditorMaker(editorMaker);
}
for (auto &im : mod->itemMakers(m_ctx)) {
for (auto &im : mod->itemMakers(m_sctx)) {
m_newMenu.addItemMaker(std::move(im));
}
}

View File

@ -24,6 +24,7 @@ class StudioUI: public ox::SignalHandler {
friend class StudioUIDrawer;
private:
studio::StudioContext &m_sctx;
turbine::Context &m_ctx;
ox::String m_projectDataDir;
ox::UPtr<studio::Project> m_project;
@ -47,7 +48,7 @@ class StudioUI: public ox::SignalHandler {
bool m_showProjectExplorer = true;
public:
explicit StudioUI(turbine::Context &ctx, ox::StringView projectDataDir) noexcept;
explicit StudioUI(studio::StudioContext &ctx, ox::StringView projectDataDir) noexcept;
void update() noexcept;

View File

@ -27,15 +27,15 @@ class Module {
public:
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>
[[nodiscard]]
studio::EditorMaker editorMaker(turbine::Context &ctx, ox::CRStringView ext) noexcept {
studio::EditorMaker editorMaker(studio::StudioContext &ctx, ox::CRStringView ext) noexcept {
return {
{ox::String(ext)},
[&ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {

View File

@ -6,11 +6,11 @@
namespace studio {
ox::Vector<EditorMaker> Module::editors(turbine::Context&) const {
ox::Vector<EditorMaker> Module::editors(studio::StudioContext&) const {
return {};
}
ox::Vector<ox::UPtr<ItemMaker>> Module::itemMakers(turbine::Context&) const {
ox::Vector<ox::UPtr<ItemMaker>> Module::itemMakers(studio::StudioContext&) const {
return {};
}