[nostalgia,studio] Cleanup string handling
This commit is contained in:
parent
6b7c002a10
commit
348193ae9e
@ -16,5 +16,5 @@ int main(int argc, const char **argv) {
|
||||
#endif
|
||||
nostalgia::registerKeelModules();
|
||||
nostalgia::registerStudioModules();
|
||||
return studio::main("Nostalgia Studio", ox::String(".nostalgia"), argc, argv);
|
||||
return studio::main("Nostalgia Studio", ".nostalgia", argc, argv);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ int main(StudioOptions&&);
|
||||
|
||||
int main(
|
||||
ox::CRStringView appName,
|
||||
ox::String projectDataDir,
|
||||
ox::CRStringView projectDataDir,
|
||||
int argc,
|
||||
const char **argv);
|
||||
|
||||
|
@ -19,13 +19,13 @@ namespace studio {
|
||||
|
||||
class StudioUIDrawer: public turbine::gl::Drawer {
|
||||
private:
|
||||
StudioUI *m_ui = nullptr;
|
||||
StudioUI &m_ui;
|
||||
public:
|
||||
explicit StudioUIDrawer(StudioUI *ui) noexcept: m_ui(ui) {
|
||||
explicit StudioUIDrawer(StudioUI &ui) noexcept: m_ui(ui) {
|
||||
}
|
||||
protected:
|
||||
void draw(turbine::Context&) noexcept final {
|
||||
m_ui->draw();
|
||||
m_ui.draw();
|
||||
}
|
||||
};
|
||||
|
||||
@ -44,7 +44,7 @@ static void keyEventHandler(turbine::Context &ctx, turbine::Key key, bool down)
|
||||
|
||||
static ox::Error runApp(
|
||||
ox::CRStringView appName,
|
||||
ox::String projectDataDir,
|
||||
ox::CRStringView projectDataDir,
|
||||
ox::UniquePtr<ox::FileSystem> fs) noexcept {
|
||||
oxRequireM(ctx, turbine::init(std::move(fs), appName));
|
||||
turbine::setWindowTitle(*ctx, ctx->keelCtx.appName);
|
||||
@ -53,9 +53,9 @@ static ox::Error runApp(
|
||||
turbine::setConstantRefresh(*ctx, false);
|
||||
studio::StudioContext studioCtx;
|
||||
turbine::setApplicationData(*ctx, &studioCtx);
|
||||
StudioUI ui(ctx.get(), std::move(projectDataDir));
|
||||
StudioUI ui(ctx.get(), projectDataDir);
|
||||
studioCtx.ui = &ui;
|
||||
StudioUIDrawer drawer(&ui);
|
||||
StudioUIDrawer drawer(ui);
|
||||
turbine::gl::addDrawer(*ctx, &drawer);
|
||||
const auto err = turbine::run(*ctx);
|
||||
turbine::gl::removeDrawer(*ctx, &drawer);
|
||||
@ -64,7 +64,7 @@ static ox::Error runApp(
|
||||
|
||||
int main(
|
||||
ox::CRStringView appName,
|
||||
ox::String projectDataDir,
|
||||
ox::CRStringView projectDataDir,
|
||||
int,
|
||||
const char**) {
|
||||
OX_INIT_DEBUG_LOGGER(loggerConn, appName)
|
||||
@ -75,13 +75,13 @@ int main(
|
||||
static_cast<uint64_t>(time << 1)
|
||||
});
|
||||
// run app
|
||||
const auto err = runApp(appName, std::move(projectDataDir), ox::UniquePtr<ox::FileSystem>(nullptr));
|
||||
const auto err = runApp(appName, projectDataDir, ox::UniquePtr<ox::FileSystem>(nullptr));
|
||||
oxAssert(err, "Something went wrong...");
|
||||
return static_cast<int>(err);
|
||||
}
|
||||
|
||||
int main(StudioOptions &&opts, int argc = 0, const char **argv = nullptr) {
|
||||
return main(opts.appName, std::move(opts.projectDataDir), argc, argv);
|
||||
return main(opts.appName, opts.projectDataDir, argc, argv);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,9 +33,9 @@ oxModelBegin(StudioConfig)
|
||||
oxModelFieldRename(show_project_explorer, showProjectExplorer)
|
||||
oxModelEnd()
|
||||
|
||||
StudioUI::StudioUI(turbine::Context *ctx, ox::String projectDir) noexcept:
|
||||
StudioUI::StudioUI(turbine::Context *ctx, ox::StringView projectDir) noexcept:
|
||||
m_ctx(ctx),
|
||||
m_projectDir(std::move(projectDir)),
|
||||
m_projectDir(projectDir),
|
||||
m_projectExplorer(ox::make_unique<ProjectExplorer>(m_ctx)),
|
||||
m_aboutPopup(*ctx) {
|
||||
m_projectExplorer->fileChosen.connect(this, &StudioUI::openFile);
|
||||
@ -253,8 +253,8 @@ void StudioUI::drawTabs() noexcept {
|
||||
}
|
||||
}
|
||||
|
||||
void StudioUI::loadEditorMaker(const studio::EditorMaker &editorMaker) noexcept {
|
||||
for (const auto &ext : editorMaker.fileTypes) {
|
||||
void StudioUI::loadEditorMaker(studio::EditorMaker const&editorMaker) noexcept {
|
||||
for (auto const&ext : editorMaker.fileTypes) {
|
||||
m_editorMakers[ext] = editorMaker.make;
|
||||
}
|
||||
}
|
||||
@ -370,7 +370,7 @@ ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab)
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Error StudioUI::closeFile(const ox::String &path) noexcept {
|
||||
ox::Error StudioUI::closeFile(ox::CRStringView path) noexcept {
|
||||
if (!m_openFiles.contains(path)) {
|
||||
return OxError(0);
|
||||
}
|
||||
|
@ -44,14 +44,14 @@ class StudioUI: public ox::SignalHandler {
|
||||
bool m_showProjectExplorer = true;
|
||||
|
||||
public:
|
||||
explicit StudioUI(turbine::Context *ctx, ox::String projectDir) noexcept;
|
||||
explicit StudioUI(turbine::Context *ctx, ox::StringView projectDir) noexcept;
|
||||
|
||||
void update() noexcept;
|
||||
|
||||
void handleKeyEvent(turbine::Key, bool down) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr auto project() noexcept {
|
||||
constexpr studio::Project *project() noexcept {
|
||||
return m_project.get();
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ class StudioUI: public ox::SignalHandler {
|
||||
|
||||
void drawTabs() noexcept;
|
||||
|
||||
void loadEditorMaker(const studio::EditorMaker &editorMaker) noexcept;
|
||||
void loadEditorMaker(studio::EditorMaker const&editorMaker) noexcept;
|
||||
|
||||
void loadModule(const studio::Module *mod) noexcept;
|
||||
|
||||
@ -85,7 +85,7 @@ class StudioUI: public ox::SignalHandler {
|
||||
|
||||
ox::Error openFileActiveTab(ox::CRStringView path, bool makeActiveTab) noexcept;
|
||||
|
||||
ox::Error closeFile(const ox::String &path) noexcept;
|
||||
ox::Error closeFile(ox::CRStringView path) noexcept;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user