[olympic,nostalgia] Cleanup with StringParam
All checks were successful
Build / build (push) Successful in 2m33s
All checks were successful
Build / build (push) Successful in 2m33s
This commit is contained in:
@ -13,7 +13,7 @@
|
||||
namespace studio {
|
||||
|
||||
NewMenu::NewMenu() noexcept {
|
||||
setTitle(ox::String("New Item"));
|
||||
setTitle("New Item");
|
||||
setSize({230, 140});
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
|
||||
namespace studio {
|
||||
|
||||
NewProject::NewProject(ox::String projectDatadir) noexcept: m_projectDataDir(std::move(projectDatadir)) {
|
||||
setTitle(ox::String("New Project"));
|
||||
NewProject::NewProject(ox::StringParam projectDatadir) noexcept: m_projectDataDir(std::move(projectDatadir)) {
|
||||
setTitle("New Project");
|
||||
setSize({230, 140});
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ class NewProject: public studio::Popup {
|
||||
bool m_open = false;
|
||||
|
||||
public:
|
||||
NewProject(ox::String projectDatadir) noexcept;
|
||||
NewProject(ox::StringParam projectDatadir) noexcept;
|
||||
|
||||
void open() noexcept override;
|
||||
|
||||
|
@ -41,12 +41,12 @@ oxModelBegin(StudioConfig)
|
||||
oxModelFieldRename(showProjectExplorer, show_project_explorer)
|
||||
oxModelEnd()
|
||||
|
||||
StudioUI::StudioUI(turbine::Context &ctx, ox::StringView projectDataDir) noexcept:
|
||||
StudioUI::StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexcept:
|
||||
m_sctx(*this, ctx),
|
||||
m_ctx(ctx),
|
||||
m_projectDataDir(projectDataDir),
|
||||
m_projectDataDir(std::move(projectDataDir)),
|
||||
m_projectExplorer(m_ctx),
|
||||
m_newProject(ox::String(projectDataDir)),
|
||||
m_newProject(m_projectDataDir),
|
||||
m_aboutPopup(m_ctx) {
|
||||
turbine::setApplicationData(m_ctx, &m_sctx);
|
||||
m_projectExplorer.fileChosen.connect(this, &StudioUI::openFile);
|
||||
@ -326,11 +326,11 @@ ox::Error StudioUI::createOpenProject(ox::CRStringView path) noexcept {
|
||||
return m_project->writeTypeStore();
|
||||
}
|
||||
|
||||
ox::Error StudioUI::openProjectPath(ox::CRStringView path) noexcept {
|
||||
oxRequireM(fs, keel::loadRomFs(path));
|
||||
ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept {
|
||||
oxRequireM(fs, keel::loadRomFs(path.view()));
|
||||
oxReturnError(keel::setRomFs(keelCtx(m_ctx), std::move(fs)));
|
||||
oxReturnError(
|
||||
ox::make_unique_catch<studio::Project>(keelCtx(m_ctx), ox::String(path), m_projectDataDir)
|
||||
ox::make_unique_catch<studio::Project>(keelCtx(m_ctx), std::move(path), m_projectDataDir)
|
||||
.moveTo(m_project));
|
||||
auto const sctx = applicationData<studio::StudioContext>(m_ctx);
|
||||
sctx->project = m_project.get();
|
||||
@ -364,7 +364,7 @@ ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab)
|
||||
}
|
||||
return {};
|
||||
}
|
||||
oxRequire(ext, studio::fileExt(path).to<ox::String>([](auto const&v) {return ox::String(v);}));
|
||||
oxRequire(ext, studio::fileExt(path));
|
||||
// create Editor
|
||||
studio::BaseEditor *editor = nullptr;
|
||||
if (!m_editorMakers.contains(ext)) {
|
||||
@ -392,7 +392,7 @@ ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab)
|
||||
m_activeEditorUpdatePending = editor;
|
||||
}
|
||||
// save to config
|
||||
studio::editConfig<StudioConfig>(keelCtx(m_ctx), [&](StudioConfig &config) {
|
||||
studio::editConfig<StudioConfig>(keelCtx(m_ctx), [&path](StudioConfig &config) {
|
||||
if (!config.openFiles.contains(path)) {
|
||||
config.openFiles.emplace_back(path);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ class StudioUI: public ox::SignalHandler {
|
||||
bool m_showProjectExplorer = true;
|
||||
|
||||
public:
|
||||
explicit StudioUI(turbine::Context &ctx, ox::StringView projectDataDir) noexcept;
|
||||
explicit StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexcept;
|
||||
|
||||
void handleKeyEvent(turbine::Key, bool down) noexcept;
|
||||
|
||||
@ -85,7 +85,7 @@ class StudioUI: public ox::SignalHandler {
|
||||
|
||||
ox::Error createOpenProject(ox::CRStringView path) noexcept;
|
||||
|
||||
ox::Error openProjectPath(ox::CRStringView path) noexcept;
|
||||
ox::Error openProjectPath(ox::StringParam path) noexcept;
|
||||
|
||||
ox::Error openFile(ox::CRStringView path) noexcept;
|
||||
|
||||
|
@ -123,7 +123,7 @@ class Editor: public studio::BaseEditor {
|
||||
ox::String m_itemName;
|
||||
|
||||
public:
|
||||
Editor(ox::StringView itemPath) noexcept;
|
||||
Editor(ox::StringParam itemPath) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
ox::CStringView itemPath() const noexcept final;
|
||||
|
@ -19,17 +19,17 @@ class ItemMaker {
|
||||
ox::String const parentDir;
|
||||
ox::String const fileExt;
|
||||
constexpr explicit ItemMaker(
|
||||
ox::StringView pName,
|
||||
ox::StringView pParentDir,
|
||||
ox::StringView pFileExt) noexcept:
|
||||
typeName(pName),
|
||||
parentDir(pParentDir),
|
||||
fileExt(pFileExt) {
|
||||
ox::StringParam pName,
|
||||
ox::StringParam pParentDir,
|
||||
ox::StringParam pFileExt) noexcept:
|
||||
typeName{std::move(pName)},
|
||||
parentDir{std::move(pParentDir)},
|
||||
fileExt{std::move(pFileExt)} {
|
||||
}
|
||||
virtual ~ItemMaker() noexcept = default;
|
||||
|
||||
[[nodiscard]]
|
||||
inline virtual ox::String itemPath(ox::StringView pName) const noexcept {
|
||||
virtual ox::String itemPath(ox::StringView pName) const noexcept {
|
||||
return ox::sfmt("/{}/{}.{}", parentDir, pName, fileExt);
|
||||
}
|
||||
|
||||
@ -39,8 +39,7 @@ class ItemMaker {
|
||||
* @param pName
|
||||
* @return path of file or error in Result
|
||||
*/
|
||||
virtual ox::Result<ox::String> write(
|
||||
studio::StudioContext &ctx, ox::CRStringView pName) const noexcept = 0;
|
||||
virtual ox::Result<ox::String> write(StudioContext &ctx, ox::StringView pName) const noexcept = 0;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@ -50,36 +49,36 @@ class ItemMakerT: public ItemMaker {
|
||||
ox::ClawFormat const m_fmt;
|
||||
public:
|
||||
constexpr ItemMakerT(
|
||||
ox::StringView pDisplayName,
|
||||
ox::StringView pParentDir,
|
||||
ox::StringView fileExt,
|
||||
ox::StringParam pDisplayName,
|
||||
ox::StringParam pParentDir,
|
||||
ox::StringParam fileExt,
|
||||
ox::ClawFormat pFmt = ox::ClawFormat::Metal) noexcept:
|
||||
ItemMaker(pDisplayName, pParentDir, fileExt),
|
||||
ItemMaker(std::move(pDisplayName), std::move(pParentDir), std::move(fileExt)),
|
||||
m_fmt(pFmt) {
|
||||
}
|
||||
constexpr ItemMakerT(
|
||||
ox::StringView pDisplayName,
|
||||
ox::StringView pParentDir,
|
||||
ox::StringView fileExt,
|
||||
ox::StringParam pDisplayName,
|
||||
ox::StringParam pParentDir,
|
||||
ox::StringParam fileExt,
|
||||
T pItem,
|
||||
ox::ClawFormat pFmt) noexcept:
|
||||
ItemMaker(pDisplayName, pParentDir, fileExt),
|
||||
ItemMaker(std::move(pDisplayName), std::move(pParentDir), std::move(fileExt)),
|
||||
m_item(std::move(pItem)),
|
||||
m_fmt(pFmt) {
|
||||
}
|
||||
constexpr ItemMakerT(
|
||||
ox::StringView pDisplayName,
|
||||
ox::StringView pParentDir,
|
||||
ox::StringView fileExt,
|
||||
ox::StringParam pDisplayName,
|
||||
ox::StringParam pParentDir,
|
||||
ox::StringParam fileExt,
|
||||
T &&pItem,
|
||||
ox::ClawFormat pFmt) noexcept:
|
||||
ItemMaker(pDisplayName, pParentDir, fileExt),
|
||||
m_item(std::move(pItem)),
|
||||
m_fmt(pFmt) {
|
||||
ItemMaker(std::move(pDisplayName), std::move(pParentDir), std::move(fileExt)),
|
||||
m_item(std::move(pItem)),
|
||||
m_fmt(pFmt) {
|
||||
}
|
||||
ox::Result<ox::String> write(studio::StudioContext &sctx, ox::CRStringView pName) const noexcept override {
|
||||
ox::Result<ox::String> write(studio::StudioContext &sctx, ox::StringView const pName) const noexcept override {
|
||||
auto const path = itemPath(pName);
|
||||
keel::createUuidMapping(keelCtx(sctx.tctx), path, ox::UUID::generate().unwrap());
|
||||
createUuidMapping(keelCtx(sctx.tctx), path, ox::UUID::generate().unwrap());
|
||||
oxReturnError(sctx.project->writeObj(path, m_item, m_fmt));
|
||||
return path;
|
||||
}
|
||||
|
@ -35,9 +35,9 @@ class Module {
|
||||
|
||||
template<typename Editor>
|
||||
[[nodiscard]]
|
||||
studio::EditorMaker editorMaker(studio::StudioContext &ctx, ox::CRStringView ext) noexcept {
|
||||
studio::EditorMaker editorMaker(studio::StudioContext &ctx, ox::StringParam ext) noexcept {
|
||||
return {
|
||||
{ox::String(ext)},
|
||||
{std::move(ext)},
|
||||
[&ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
|
||||
return ox::makeCatch<Editor>(ctx, path);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class Popup {
|
||||
m_size = {static_cast<float>(sz.width), static_cast<float>(sz.height)};
|
||||
}
|
||||
|
||||
constexpr void setTitle(ox::String title) noexcept {
|
||||
constexpr void setTitle(ox::StringParam title) noexcept {
|
||||
m_title = std::move(title);
|
||||
}
|
||||
|
||||
|
@ -115,8 +115,8 @@ void BaseEditor::setRequiresConstantRefresh(bool value) noexcept {
|
||||
}
|
||||
|
||||
|
||||
Editor::Editor(ox::StringView itemPath) noexcept:
|
||||
m_itemPath(itemPath),
|
||||
Editor::Editor(ox::StringParam itemPath) noexcept:
|
||||
m_itemPath(std::move(itemPath)),
|
||||
m_itemName(m_itemPath.substr(std::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset() + 1)) {
|
||||
m_undoStack.changeTriggered.connect(this, &Editor::markUnsavedChanges);
|
||||
}
|
||||
|
Reference in New Issue
Block a user