[nostalgia/studio] Add creation of StudioContext
This commit is contained in:
parent
4843e28b9a
commit
778cb78f31
@ -6,6 +6,7 @@
|
||||
|
||||
#include <nostalgia/core/core.hpp>
|
||||
|
||||
#include "lib/context.hpp"
|
||||
#include "studioapp.hpp"
|
||||
|
||||
namespace nostalgia {
|
||||
@ -23,7 +24,8 @@ class StudioUIDrawer: public core::Drawer {
|
||||
};
|
||||
|
||||
static int eventHandler(core::Context *ctx) noexcept {
|
||||
auto ui = core::applicationData<StudioUI>(ctx);
|
||||
auto sctx = core::applicationData<studio::StudioContext>(ctx);
|
||||
auto ui = dynamic_cast<StudioUI*>(sctx->ui);
|
||||
ui->update();
|
||||
return 16;
|
||||
}
|
||||
@ -32,9 +34,11 @@ static ox::Error run(ox::UniquePtr<ox::FileSystem> fs) noexcept {
|
||||
oxRequireM(ctx, core::init(std::move(fs), "NostalgiaStudio"));
|
||||
core::setWindowTitle(ctx.get(), "Nostalgia Studio");
|
||||
core::setEventHandler(ctx.get(), eventHandler);
|
||||
studio::StudioContext studioCtx;
|
||||
core::setApplicationData(ctx.get(), &studioCtx);
|
||||
StudioUI ui(ctx.get());
|
||||
studioCtx.ui = &ui;
|
||||
StudioUIDrawer drawer(&ui);
|
||||
core::setApplicationData(ctx.get(), &ui);
|
||||
ctx->drawers.emplace_back(&drawer);
|
||||
return core::run(ctx.get());
|
||||
}
|
||||
|
@ -215,6 +215,8 @@ ox::Error StudioUI::openProject(const ox::String &path) noexcept {
|
||||
m_ctx->rom = std::move(fs);
|
||||
core::setWindowTitle(m_ctx, ox::sfmt("Nostalgia Studio - {}", path).c_str());
|
||||
m_project = ox::make_unique<studio::Project>(m_ctx->rom.get(), path);
|
||||
auto sctx = applicationData<studio::StudioContext>(m_ctx);
|
||||
sctx->project = m_project.get();
|
||||
m_project->fileAdded.connect(m_projectExplorer, &ProjectExplorer::refreshProjectTreeModel);
|
||||
m_project->fileDeleted.connect(m_projectExplorer, &ProjectExplorer::refreshProjectTreeModel);
|
||||
studio::editConfig<StudioConfig>(m_ctx, [&](StudioConfig *config) {
|
||||
|
Loading…
Reference in New Issue
Block a user