[keel,nostalgia,turbine] Cleanup
This commit is contained in:
@@ -15,7 +15,7 @@ class Scene {
|
||||
public:
|
||||
explicit Scene(const SceneStatic &sceneStatic) noexcept;
|
||||
|
||||
ox::Error setupDisplay(core::Context *ctx) const noexcept;
|
||||
ox::Error setupDisplay(core::Context &ctx) const noexcept;
|
||||
|
||||
private:
|
||||
void setupLayer(core::Context*, const ox::Vector<uint16_t> &layer, unsigned layerNo) const noexcept;
|
||||
|
@@ -12,17 +12,17 @@ Scene::Scene(const SceneStatic &sceneStatic) noexcept:
|
||||
m_sceneStatic(sceneStatic) {
|
||||
}
|
||||
|
||||
ox::Error Scene::setupDisplay(core::Context *ctx) const noexcept {
|
||||
ox::Error Scene::setupDisplay(core::Context &ctx) const noexcept {
|
||||
if (m_sceneStatic.palettes.empty()) {
|
||||
return OxError(1, "Scene has no palettes");
|
||||
}
|
||||
const auto &palette = m_sceneStatic.palettes[0];
|
||||
oxReturnError(core::loadBgTileSheet(
|
||||
ctx, 0, m_sceneStatic.tilesheet, palette));
|
||||
&ctx, 0, m_sceneStatic.tilesheet, palette));
|
||||
// disable all backgrounds
|
||||
core::setBgStatus(ctx, 0);
|
||||
core::setBgStatus(&ctx, 0);
|
||||
for (auto layerNo = 0u; const auto &layer : m_sceneStatic.tileMapIdx) {
|
||||
setupLayer(ctx, layer, layerNo);
|
||||
setupLayer(&ctx, layer, layerNo);
|
||||
++layerNo;
|
||||
}
|
||||
return {};
|
||||
|
@@ -10,11 +10,11 @@
|
||||
|
||||
namespace nostalgia::scene {
|
||||
|
||||
SceneEditorImGui::SceneEditorImGui(turbine::Context *ctx, ox::CRStringView path):
|
||||
m_editor(ctx, path),
|
||||
m_view(ctx, m_editor.scene()) {
|
||||
m_ctx = ctx;
|
||||
m_itemPath = path;
|
||||
SceneEditorImGui::SceneEditorImGui(turbine::Context &ctx, ox::String path):
|
||||
m_ctx(ctx),
|
||||
m_itemPath(std::move(path)),
|
||||
m_editor(&m_ctx, m_itemPath),
|
||||
m_view(&m_ctx, m_editor.scene()) {
|
||||
const auto lastSlash = std::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset();
|
||||
m_itemName = m_itemPath.substr(lastSlash + 1);
|
||||
setRequiresConstantRefresh(false);
|
||||
@@ -48,9 +48,9 @@ void SceneEditorImGui::onActivated() noexcept {
|
||||
}
|
||||
|
||||
ox::Error SceneEditorImGui::saveItem() noexcept {
|
||||
const auto sctx = applicationData<studio::StudioContext>(*m_ctx);
|
||||
const auto sctx = applicationData<studio::StudioContext>(m_ctx);
|
||||
oxReturnError(sctx->project->writeObj(m_itemPath, &m_editor.scene()));
|
||||
oxReturnError(m_ctx->keelCtx.assetManager.setAsset(m_itemPath, m_editor.scene()));
|
||||
oxReturnError(m_ctx.keelCtx.assetManager.setAsset(m_itemPath, m_editor.scene()));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@@ -16,14 +16,14 @@ namespace nostalgia::scene {
|
||||
class SceneEditorImGui: public studio::Editor {
|
||||
|
||||
private:
|
||||
turbine::Context *m_ctx = nullptr;
|
||||
turbine::Context &m_ctx;
|
||||
ox::String m_itemName;
|
||||
ox::String m_itemPath;
|
||||
SceneEditor m_editor;
|
||||
SceneEditorView m_view;
|
||||
|
||||
public:
|
||||
SceneEditorImGui(turbine::Context *ctx, ox::CRStringView path);
|
||||
SceneEditorImGui(turbine::Context &ctx, ox::String path);
|
||||
|
||||
/**
|
||||
* Returns the name of item being edited.
|
||||
|
@@ -15,7 +15,7 @@ SceneEditorView::SceneEditorView(turbine::Context *tctx, const SceneStatic &scen
|
||||
}
|
||||
|
||||
ox::Error SceneEditorView::setupScene() noexcept {
|
||||
return m_scene.setupDisplay(m_cctx.get());
|
||||
return m_scene.setupDisplay(*m_cctx);
|
||||
}
|
||||
|
||||
void SceneEditorView::draw(int width, int height) noexcept {
|
||||
|
@@ -19,7 +19,7 @@ ox::Vector<studio::EditorMaker> StudioModule::editors(turbine::Context *ctx) con
|
||||
{
|
||||
{"nscn"},
|
||||
[ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
|
||||
return ox::makeCatch<SceneEditorImGui>(ctx, path);
|
||||
return ox::makeCatch<SceneEditorImGui>(*ctx, ox::String(path));
|
||||
}
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user