[nostalgia] Update Studio to handle tabs and open directory dialog on Mac, Update core::init
This commit is contained in:
@@ -21,24 +21,29 @@ class StudioUIDrawer: public core::Drawer {
|
||||
explicit StudioUIDrawer(StudioUI *ui) noexcept: m_ui(ui) {
|
||||
}
|
||||
protected:
|
||||
void draw(core::Context *ctx) noexcept final {
|
||||
m_ui->draw(ctx);
|
||||
void draw(core::Context*) noexcept final {
|
||||
m_ui->draw();
|
||||
}
|
||||
};
|
||||
|
||||
static int eventHandler(core::Context *ctx) noexcept {
|
||||
auto ui = ctx->customData<StudioUI>();
|
||||
ui->update(ctx);
|
||||
ui->update();
|
||||
return 16;
|
||||
}
|
||||
|
||||
static ox::Error run(ox::FileSystem *fs) noexcept {
|
||||
oxRequireM(ctx, core::init(fs));
|
||||
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);
|
||||
StudioUI ui;
|
||||
StudioUIDrawer drawer(&ui);
|
||||
ctx->setCustomData(&ui);
|
||||
ox::UniquePtr<StudioUI> ui;
|
||||
try {
|
||||
ui = ox::make_unique<StudioUI>(ctx.get());
|
||||
} catch (ox::Exception &ex) {
|
||||
return ex.toError();
|
||||
}
|
||||
StudioUIDrawer drawer(ui.get());
|
||||
ctx->setCustomData(ui.get());
|
||||
ctx->drawers.emplace_back(&drawer);
|
||||
return core::run(ctx.get());
|
||||
}
|
||||
@@ -47,10 +52,10 @@ static ox::Error run(int argc, const char **argv) noexcept {
|
||||
ox::trace::init();
|
||||
if (argc >= 2) {
|
||||
const auto path = argv[1];
|
||||
oxRequire(fs, core::loadRomFs(path));
|
||||
return run(fs.get());
|
||||
oxRequireM(fs, core::loadRomFs(path));
|
||||
return run(std::move(fs));
|
||||
} else {
|
||||
return run(nullptr);
|
||||
return run(ox::UniquePtr<ox::FileSystem>(nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user