Squashed 'deps/nostalgia/' changes from 161640fa..a75c4a11
a75c4a11 [nfde] Address CMake warning, remove unwanted logging 347a1657 [sample_project] Update type descriptors fd64bfae [keel] Fix a use after free, cleanup aaeec20a [nostalgia/player] Fix build 37030f9c [keel] Cleanup pack tool 462f2bca [nostalgia,olympic] Change macro names to comply with broader conventions dc72500b [glutils] Change macro names to comply with broader conventions 962fe8bc [ox] Change macro names to comply with broader conventions 305eb626 [studio] Fix build 4754359a [ox/std] Cleanup Vec2 dc07f3d5 [studio] Change FilePicker consturctor to take StringParams fcdcfd10 [ox/std] Run liccor b74f6a7a [studio,turbine] Run liccor ac7e5be1 [ox] Remove OxException ed910c0b [nostalgia/core/studio/tilesheeteditor] Fix access overflow on out of bounds Fill command 345fb038 [ox] Remove OxError 9881253f [glutils] Cleanup OxError 96d27eec [nostalgia,olympic] Cleanup 28ebe93b [ox/std] Make source_location::current only init if valid e849e7a3 [ox/std] Add source_location e6777b0a [cityhash] Add install rule c488c336 [turbine/glfw] Fix mandatoryRefreshPeriodEnd tracking 003f9720 [turbine/glfw] Move MandatoryRefreshPeriod to config.hpp d85a10af [nostalgia/core/studio] Cleanup ff05d860 [turbine/glfw] Replace uninterruptedRefreshes with mandatoryRefreshPeriodEnd 76794037 [turbine] Add init wrapper that takes FS path c51a45e1 [olympic] Cleanup a6e24ff2 [ox/std] Add CString type alias e0ec9e0c [nostalgia,olympic] Move olympic::run to global namespace 9a42a9b9 [nfde] Fix Windows warnings 03a05c51 Merge commit '4ccdfc3a6e5bd501968903a01f7d8141b6f88375' bd91137d [nostalgia,olympic] Fix pack tool build for Windows 2b7d1294 [nostalgia/core/studio] Fix MSVC build git-subtree-dir: deps/nostalgia git-subtree-split: a75c4a11d3c555f4d3bed1ea1f70bb29fe49e99c
This commit is contained in:
@@ -12,6 +12,7 @@ add_library(
|
||||
)
|
||||
target_compile_definitions(
|
||||
StudioAppLib PUBLIC
|
||||
OLYMPIC_GUI_APP=1
|
||||
OLYMPIC_LOAD_STUDIO_MODULES=1
|
||||
OLYMPIC_APP_NAME="Studio"
|
||||
)
|
||||
|
@@ -37,7 +37,7 @@ static ox::Error runApp(
|
||||
ox::StringViewCR appName,
|
||||
ox::StringViewCR projectDataDir,
|
||||
ox::UPtr<ox::FileSystem> &&fs) noexcept {
|
||||
oxRequireM(ctx, turbine::init(std::move(fs), appName));
|
||||
OX_REQUIRE_M(ctx, turbine::init(std::move(fs), appName));
|
||||
turbine::setWindowTitle(*ctx, keelCtx(*ctx).appName);
|
||||
turbine::setKeyEventHandler(*ctx, keyEventHandler);
|
||||
turbine::setRefreshWithin(*ctx, 0);
|
||||
@@ -67,14 +67,10 @@ static ox::Error run(
|
||||
|
||||
}
|
||||
|
||||
namespace olympic {
|
||||
|
||||
ox::Error run(
|
||||
ox::StringView project,
|
||||
ox::StringView appName,
|
||||
ox::StringView projectDataDir,
|
||||
ox::SpanView<char const*> args) noexcept {
|
||||
ox::SpanView<ox::CString> args) noexcept {
|
||||
return studio::run(ox::sfmt("{} {}", project, appName), projectDataDir, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -118,12 +118,12 @@ void NewMenu::drawLastPageButtons(studio::StudioContext &sctx) noexcept {
|
||||
|
||||
void NewMenu::finish(studio::StudioContext &sctx) noexcept {
|
||||
if (m_itemName.len() == 0) {
|
||||
oxLogError(OxError(1, "New file error: no file name"));
|
||||
oxLogError(ox::Error(1, "New file error: no file name"));
|
||||
return;
|
||||
}
|
||||
auto const&typeMaker = *m_types[static_cast<std::size_t>(m_selectedType)];
|
||||
if (sctx.project->exists(typeMaker.itemPath(m_itemName))) {
|
||||
oxLogError(OxError(1, "New file error: file already exists"));
|
||||
oxLogError(ox::Error(1, "New file error: file already exists"));
|
||||
return;
|
||||
}
|
||||
auto const [path, err] = typeMaker.write(sctx, m_itemName);
|
||||
|
@@ -16,16 +16,16 @@ static ox::Result<ox::UniquePtr<ProjectTreeModel>> buildProjectTreeModel(
|
||||
ox::StringView path,
|
||||
ProjectTreeModel *parent) noexcept {
|
||||
auto const fs = explorer.romFs();
|
||||
oxRequire(stat, fs->stat(path));
|
||||
OX_REQUIRE(stat, fs->stat(path));
|
||||
auto out = ox::make_unique<ProjectTreeModel>(explorer, ox::String(name), parent);
|
||||
if (stat.fileType == ox::FileType::Directory) {
|
||||
oxRequireM(children, fs->ls(path));
|
||||
OX_REQUIRE_M(children, fs->ls(path));
|
||||
std::sort(children.begin(), children.end());
|
||||
ox::Vector<ox::UniquePtr<ProjectTreeModel>> outChildren;
|
||||
for (auto const&childName : children) {
|
||||
if (childName[0] != '.') {
|
||||
auto const childPath = ox::sfmt("{}/{}", path, childName);
|
||||
oxRequireM(child, buildProjectTreeModel(explorer, childName, childPath, out.get()));
|
||||
OX_REQUIRE_M(child, buildProjectTreeModel(explorer, childName, childPath, out.get()));
|
||||
outChildren.emplace_back(std::move(child));
|
||||
}
|
||||
}
|
||||
@@ -52,9 +52,9 @@ void ProjectExplorer::setModel(ox::UPtr<ProjectTreeModel> &&model) noexcept {
|
||||
}
|
||||
|
||||
ox::Error ProjectExplorer::refreshProjectTreeModel(ox::StringViewCR) noexcept {
|
||||
oxRequireM(model, buildProjectTreeModel(*this, "Project", "/", nullptr));
|
||||
OX_REQUIRE_M(model, buildProjectTreeModel(*this, "Project", "/", nullptr));
|
||||
setModel(std::move(model));
|
||||
return OxError(0);
|
||||
return ox::Error(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -36,12 +36,12 @@ struct StudioConfig {
|
||||
bool showProjectExplorer = true;
|
||||
};
|
||||
|
||||
oxModelBegin(StudioConfig)
|
||||
oxModelFieldRename(activeTabItemName, active_tab_item_name)
|
||||
oxModelFieldRename(projectPath, project_path)
|
||||
oxModelFieldRename(openFiles, open_files)
|
||||
oxModelFieldRename(showProjectExplorer, show_project_explorer)
|
||||
oxModelEnd()
|
||||
OX_MODEL_BEGIN(StudioConfig)
|
||||
OX_MODEL_FIELD_RENAME(activeTabItemName, active_tab_item_name)
|
||||
OX_MODEL_FIELD_RENAME(projectPath, project_path)
|
||||
OX_MODEL_FIELD_RENAME(openFiles, open_files)
|
||||
OX_MODEL_FIELD_RENAME(showProjectExplorer, show_project_explorer)
|
||||
OX_MODEL_END()
|
||||
|
||||
StudioUI::StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexcept:
|
||||
m_sctx(*this, ctx),
|
||||
@@ -222,7 +222,7 @@ void StudioUI::drawTabs() noexcept {
|
||||
m_activeEditor = nullptr;
|
||||
}
|
||||
try {
|
||||
oxThrowError(m_editors.erase(it).moveTo(it));
|
||||
OX_THROW_ERROR(m_editors.erase(it).moveTo(it));
|
||||
} catch (ox::Exception const&ex) {
|
||||
oxErrf("Editor tab deletion failed: {} ({}:{})\n", ex.what(), ex.file, ex.line);
|
||||
} catch (std::exception const&ex) {
|
||||
@@ -323,15 +323,15 @@ void StudioUI::handleKeyInput() noexcept {
|
||||
ox::Error StudioUI::createOpenProject(ox::StringViewCR path) noexcept {
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directories(toStdStringView(path), ec);
|
||||
oxReturnError(OxError(ec.value() != 0, "Could not create project directory"));
|
||||
oxReturnError(openProjectPath(path));
|
||||
OX_RETURN_ERROR(ox::Error(ec.value() != 0, "Could not create project directory"));
|
||||
OX_RETURN_ERROR(openProjectPath(path));
|
||||
return m_project->writeTypeStore();
|
||||
}
|
||||
|
||||
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_REQUIRE_M(fs, keel::loadRomFs(path.view()));
|
||||
OX_RETURN_ERROR(keel::setRomFs(keelCtx(m_ctx), std::move(fs)));
|
||||
OX_RETURN_ERROR(
|
||||
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);
|
||||
@@ -354,7 +354,7 @@ ox::Error StudioUI::openFile(ox::StringViewCR path) noexcept {
|
||||
|
||||
ox::Error StudioUI::openFileActiveTab(ox::StringViewCR path, bool makeActiveTab) noexcept {
|
||||
if (!m_project) {
|
||||
return OxError(1, "No project open to open a file from");
|
||||
return ox::Error(1, "No project open to open a file from");
|
||||
}
|
||||
if (m_openFiles.contains(path)) {
|
||||
for (auto &e : m_editors) {
|
||||
@@ -366,7 +366,7 @@ ox::Error StudioUI::openFileActiveTab(ox::StringViewCR path, bool makeActiveTab)
|
||||
}
|
||||
return {};
|
||||
}
|
||||
oxRequire(ext, studio::fileExt(path));
|
||||
OX_REQUIRE(ext, studio::fileExt(path));
|
||||
// create Editor
|
||||
BaseEditor *editor = nullptr;
|
||||
auto const err = m_editorMakers.contains(ext) ?
|
||||
|
@@ -60,11 +60,11 @@ ox::Error writeConfig(keel::Context &ctx, ox::StringViewCR name, T const&data) n
|
||||
//oxErrf("Could not create config directory: {} - {}\n", path, toStr(err));
|
||||
return err;
|
||||
}
|
||||
oxRequireM(buff, ox::writeOC(data));
|
||||
OX_REQUIRE_M(buff, ox::writeOC(data));
|
||||
*buff.back().value = '\n';
|
||||
if (auto const err = fs.write(path, buff.data(), buff.size())) {
|
||||
//oxErrf("Could not read config file: {} - {}\n", path, toStr(err));
|
||||
return OxError(2, "Could not read config file");
|
||||
return ox::Error(2, "Could not read config file");
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@@ -24,18 +24,18 @@ constexpr ImTextureID toImTextureID(ox::Unsigned_c auto id) noexcept
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ox::Result<T> getDragDropPayload(ox::CStringView name) noexcept {
|
||||
ox::Result<T> getDragDropPayload(ox::CStringViewCR name) noexcept {
|
||||
auto const payload = ImGui::AcceptDragDropPayload(name.c_str());
|
||||
if (!payload) {
|
||||
return OxError(1, "No drag/drop payload");
|
||||
return ox::Error(1, "No drag/drop payload");
|
||||
}
|
||||
return ox::readClaw<T>({
|
||||
reinterpret_cast<char const*>(payload->Data),
|
||||
static_cast<size_t>(payload->DataSize)});
|
||||
}
|
||||
|
||||
ox::Error setDragDropPayload(ox::CStringView name, auto const&obj) noexcept {
|
||||
oxRequire(buff, ox::writeClaw(obj, ox::ClawFormat::Metal));
|
||||
ox::Error setDragDropPayload(ox::CStringViewCR name, auto const&obj) noexcept {
|
||||
OX_REQUIRE(buff, ox::writeClaw(obj, ox::ClawFormat::Metal));
|
||||
ImGui::SetDragDropPayload(name.c_str(), buff.data(), buff.size());
|
||||
return {};
|
||||
}
|
||||
@@ -88,7 +88,7 @@ class DragDropTarget {
|
||||
}
|
||||
};
|
||||
|
||||
inline auto dragDropTarget(auto const&cb) noexcept {
|
||||
auto dragDropTarget(auto const&cb) noexcept {
|
||||
if constexpr(ox::is_same_v<decltype(cb()), ox::Error>) {
|
||||
if (ig::DragDropTarget const tgt; tgt) [[unlikely]] {
|
||||
return cb();
|
||||
@@ -104,7 +104,7 @@ inline auto dragDropTarget(auto const&cb) noexcept {
|
||||
|
||||
class ChildStackItem {
|
||||
public:
|
||||
explicit ChildStackItem(ox::CStringView id, ImVec2 const&sz = {}) noexcept;
|
||||
explicit ChildStackItem(ox::CStringViewCR id, ImVec2 const&sz = {}) noexcept;
|
||||
~ChildStackItem() noexcept;
|
||||
};
|
||||
|
||||
@@ -112,7 +112,7 @@ class IDStackItem {
|
||||
public:
|
||||
explicit IDStackItem(int id) noexcept;
|
||||
explicit IDStackItem(const char *id) noexcept;
|
||||
explicit IDStackItem(ox::CStringView id) noexcept;
|
||||
explicit IDStackItem(ox::CStringViewCR id) noexcept;
|
||||
~IDStackItem() noexcept;
|
||||
};
|
||||
|
||||
@@ -126,7 +126,7 @@ class IndentStackItem {
|
||||
|
||||
void centerNextWindow(turbine::Context &ctx) noexcept;
|
||||
|
||||
bool PushButton(ox::CStringView lbl, ImVec2 const&btnSz = BtnSz) noexcept;
|
||||
bool PushButton(ox::CStringViewCR lbl, ImVec2 const&btnSz = BtnSz) noexcept;
|
||||
|
||||
template<typename Str>
|
||||
struct TextInput {
|
||||
@@ -180,7 +180,7 @@ PopupResponse PopupControlsOkCancel(float popupWidth, bool &popupOpen);
|
||||
PopupResponse PopupControlsOkCancel(bool &popupOpen);
|
||||
|
||||
[[nodiscard]]
|
||||
bool BeginPopup(turbine::Context &ctx, ox::CStringView popupName, bool &show, ImVec2 const&sz = {285, 0});
|
||||
bool BeginPopup(turbine::Context &ctx, ox::CStringViewCR popupName, bool &show, ImVec2 const&sz = {285, 0});
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -199,19 +199,19 @@ bool ComboBox(ox::CStringView lbl, ox::Span<const ox::String> list, size_t &sele
|
||||
* @return true if new value selected, false otherwise
|
||||
*/
|
||||
bool ComboBox(
|
||||
ox::CStringView lbl,
|
||||
ox::CStringViewCR lbl,
|
||||
std::function<ox::CStringView(size_t)> const&f,
|
||||
size_t strCnt,
|
||||
size_t &selectedIdx) noexcept;
|
||||
|
||||
bool FileComboBox(
|
||||
ox::CStringView lbl,
|
||||
studio::StudioContext &sctx,
|
||||
ox::StringView fileExt,
|
||||
ox::CStringViewCR lbl,
|
||||
StudioContext &sctx,
|
||||
ox::StringViewCR fileExt,
|
||||
size_t &selectedIdx) noexcept;
|
||||
|
||||
bool ListBox(
|
||||
ox::CStringView name,
|
||||
ox::CStringViewCR name,
|
||||
std::function<ox::CStringView(size_t)> const&f,
|
||||
size_t strCnt,
|
||||
size_t &selIdx) noexcept;
|
||||
@@ -223,7 +223,7 @@ bool ListBox(
|
||||
* @param selIdx
|
||||
* @return true if new value selected, false otherwise
|
||||
*/
|
||||
bool ListBox(ox::CStringView name, ox::Span<const ox::String> const&list, size_t &selIdx) noexcept;
|
||||
bool ListBox(ox::CStringViewCR name, ox::SpanView<ox::String> const&list, size_t &selIdx) noexcept;
|
||||
|
||||
class FilePicker {
|
||||
private:
|
||||
@@ -237,8 +237,8 @@ class FilePicker {
|
||||
|
||||
FilePicker(
|
||||
studio::StudioContext &sctx,
|
||||
ox::String title,
|
||||
ox::String fileExt,
|
||||
ox::StringParam title,
|
||||
ox::StringParam fileExt,
|
||||
ImVec2 const&size = {}) noexcept;
|
||||
|
||||
void draw() noexcept;
|
||||
|
@@ -79,7 +79,7 @@ class ItemMakerT: public ItemMaker {
|
||||
ox::Result<ox::String> write(studio::StudioContext &sctx, ox::StringView const pName) const noexcept override {
|
||||
auto const path = itemPath(pName);
|
||||
createUuidMapping(keelCtx(sctx.tctx), path, ox::UUID::generate().unwrap());
|
||||
oxReturnError(sctx.project->writeObj(path, m_item, m_fmt));
|
||||
OX_RETURN_ERROR(sctx.project->writeObj(path, m_item, m_fmt));
|
||||
return path;
|
||||
}
|
||||
};
|
||||
|
@@ -31,7 +31,7 @@ enum class ProjectEvent {
|
||||
constexpr ox::Result<ox::StringView> fileExt(ox::StringViewCR path) noexcept {
|
||||
auto const extStart = ox::find(path.crbegin(), path.crend(), '.').offset();
|
||||
if (!extStart) {
|
||||
return OxError(1, "file path does not have valid extension");
|
||||
return ox::Error(1, "file path does not have valid extension");
|
||||
}
|
||||
return substr(path, extStart + 1);
|
||||
}
|
||||
@@ -130,39 +130,39 @@ class Project {
|
||||
|
||||
template<typename T>
|
||||
ox::Error Project::writeObj(ox::StringViewCR path, T const&obj, ox::ClawFormat fmt) noexcept {
|
||||
oxRequireM(buff, ox::writeClaw(obj, fmt));
|
||||
OX_REQUIRE_M(buff, ox::writeClaw(obj, fmt));
|
||||
if (fmt == ox::ClawFormat::Organic) {
|
||||
buff.pop_back();
|
||||
}
|
||||
// write to FS
|
||||
oxReturnError(mkdir(parentDir(path)));
|
||||
oxReturnError(writeBuff(path, buff));
|
||||
OX_RETURN_ERROR(mkdir(parentDir(path)));
|
||||
OX_RETURN_ERROR(writeBuff(path, buff));
|
||||
// write type descriptor
|
||||
if (m_typeStore.get<T>().error) {
|
||||
oxReturnError(ox::buildTypeDef(m_typeStore, obj));
|
||||
OX_RETURN_ERROR(ox::buildTypeDef(m_typeStore, obj));
|
||||
}
|
||||
oxRequire(desc, m_typeStore.get<T>());
|
||||
OX_REQUIRE(desc, m_typeStore.get<T>());
|
||||
auto const descPath = ox::sfmt("{}/{}", m_typeDescPath, buildTypeId(*desc));
|
||||
auto const descExists = m_fs.exists(descPath);
|
||||
if (!descExists) {
|
||||
oxReturnError(writeTypeStore());
|
||||
OX_RETURN_ERROR(writeTypeStore());
|
||||
}
|
||||
oxReturnError(keel::reloadAsset(m_ctx, path));
|
||||
oxRequire(uuid, pathToUuid(m_ctx, path));
|
||||
OX_RETURN_ERROR(keel::reloadAsset(m_ctx, path));
|
||||
OX_REQUIRE(uuid, pathToUuid(m_ctx, path));
|
||||
fileUpdated.emit(path, uuid);
|
||||
return {};
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ox::Error Project::writeObj(ox::StringViewCR path, T const&obj) noexcept {
|
||||
oxRequire(ext, fileExt(path));
|
||||
OX_REQUIRE(ext, fileExt(path));
|
||||
auto const fmt = m_typeFmt[ext].or_value(ox::ClawFormat::Metal);
|
||||
return writeObj(path, obj, fmt);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ox::Result<T> Project::loadObj(ox::StringViewCR path) const noexcept {
|
||||
oxRequire(buff, loadBuff(path));
|
||||
OX_REQUIRE(buff, loadBuff(path));
|
||||
if constexpr(ox::is_same_v<T, ox::ModelObject>) {
|
||||
return keel::readAsset(m_typeStore, buff);
|
||||
} else {
|
||||
@@ -180,7 +180,7 @@ ox::Error Project::subscribe(ProjectEvent e, ox::SignalHandler *tgt, Functor &&s
|
||||
break;
|
||||
case ProjectEvent::FileRecognized:
|
||||
{
|
||||
oxRequire(files, listFiles());
|
||||
OX_REQUIRE(files, listFiles());
|
||||
for (auto const&f : files) {
|
||||
slot(f);
|
||||
}
|
||||
|
@@ -1,3 +1,6 @@
|
||||
/*
|
||||
* Copyright 2016 - 2024 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -30,7 +33,7 @@ constexpr auto iterateSelection(studio::Selection const&sel, auto const&cb) {
|
||||
for (auto x = sel.a.x; x <= sel.b.x; ++x) {
|
||||
for (auto y = sel.a.y; y <= sel.b.y; ++y) {
|
||||
if constexpr(retErr) {
|
||||
oxReturnError(cb(x, y));
|
||||
OX_RETURN_ERROR(cb(x, y));
|
||||
} else {
|
||||
cb(x, y);
|
||||
}
|
||||
@@ -46,7 +49,7 @@ constexpr auto iterateSelectionRows(studio::Selection const&sel, auto const&cb)
|
||||
for (auto y = sel.a.y; y <= sel.b.y; ++y) {
|
||||
for (auto x = sel.a.x; x <= sel.b.x; ++x) {
|
||||
if constexpr(retErr) {
|
||||
oxReturnError(cb(x, y));
|
||||
OX_RETURN_ERROR(cb(x, y));
|
||||
} else {
|
||||
cb(x, y);
|
||||
}
|
||||
|
@@ -31,9 +31,9 @@ OX_ALLOW_UNSAFE_BUFFERS_END
|
||||
return out;
|
||||
}
|
||||
case NFD_CANCEL:
|
||||
return OxError(1, "Operation cancelled");
|
||||
return ox::Error(1, "Operation cancelled");
|
||||
default:
|
||||
return OxError(2, NFD::GetError());
|
||||
return ox::Error(2, NFD::GetError());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
namespace studio::ig {
|
||||
|
||||
ChildStackItem::ChildStackItem(ox::CStringView id, ImVec2 const&sz) noexcept {
|
||||
ChildStackItem::ChildStackItem(ox::CStringViewCR id, ImVec2 const&sz) noexcept {
|
||||
ImGui::BeginChild(id.c_str(), sz);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ IDStackItem::IDStackItem(const char *id) noexcept {
|
||||
ImGui::PushID(id);
|
||||
}
|
||||
|
||||
IDStackItem::IDStackItem(ox::CStringView id) noexcept: IDStackItem(id.c_str()) {}
|
||||
IDStackItem::IDStackItem(ox::CStringViewCR id) noexcept: IDStackItem(id.c_str()) {}
|
||||
|
||||
IDStackItem::~IDStackItem() noexcept {
|
||||
ImGui::PopID();
|
||||
@@ -50,7 +50,7 @@ void centerNextWindow(turbine::Context &ctx) noexcept {
|
||||
ImGui::SetNextWindowPos(ImVec2(screenW / mod, screenH / mod), ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
}
|
||||
|
||||
bool PushButton(ox::CStringView lbl, ImVec2 const&btnSz) noexcept {
|
||||
bool PushButton(ox::CStringViewCR lbl, ImVec2 const&btnSz) noexcept {
|
||||
return ImGui::Button(lbl.c_str(), btnSz);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ PopupResponse PopupControlsOkCancel(bool &popupOpen) {
|
||||
return PopupControlsOkCancel(ImGui::GetContentRegionAvail().x + 17, popupOpen);
|
||||
}
|
||||
|
||||
bool BeginPopup(turbine::Context &ctx, ox::CStringView popupName, bool &show, ImVec2 const&sz) {
|
||||
bool BeginPopup(turbine::Context &ctx, ox::CStringViewCR popupName, bool &show, ImVec2 const&sz) {
|
||||
constexpr auto modalFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
|
||||
centerNextWindow(ctx);
|
||||
ImGui::OpenPopup(popupName.c_str());
|
||||
@@ -105,7 +105,7 @@ bool ComboBox(
|
||||
}
|
||||
|
||||
bool ComboBox(
|
||||
ox::CStringView lbl,
|
||||
ox::CStringViewCR lbl,
|
||||
std::function<ox::CStringView(size_t)> const&f,
|
||||
size_t strCnt,
|
||||
size_t &selectedIdx) noexcept {
|
||||
@@ -125,16 +125,16 @@ bool ComboBox(
|
||||
}
|
||||
|
||||
bool FileComboBox(
|
||||
ox::CStringView lbl,
|
||||
ox::CStringViewCR lbl,
|
||||
StudioContext &sctx,
|
||||
ox::StringView fileExt,
|
||||
ox::StringViewCR fileExt,
|
||||
size_t &selectedIdx) noexcept {
|
||||
auto const&list = sctx.project->fileList(fileExt);
|
||||
return ComboBox(lbl, list, selectedIdx);
|
||||
}
|
||||
|
||||
bool ListBox(
|
||||
ox::CStringView name,
|
||||
ox::CStringViewCR name,
|
||||
std::function<ox::CStringView(size_t)> const&f,
|
||||
size_t strCnt,
|
||||
size_t &selIdx) noexcept {
|
||||
@@ -155,7 +155,7 @@ bool ListBox(
|
||||
return out;
|
||||
}
|
||||
|
||||
bool ListBox(ox::CStringView name, ox::Span<const ox::String> const&list, size_t &selIdx) noexcept {
|
||||
bool ListBox(ox::CStringViewCR name, ox::SpanView<ox::String> const&list, size_t &selIdx) noexcept {
|
||||
return ListBox(name, [list](size_t i) -> ox::CStringView {
|
||||
return list[i];
|
||||
}, list.size(), selIdx);
|
||||
@@ -164,8 +164,8 @@ bool ListBox(ox::CStringView name, ox::Span<const ox::String> const&list, size_t
|
||||
|
||||
FilePicker::FilePicker(
|
||||
StudioContext &sctx,
|
||||
ox::String title,
|
||||
ox::String fileExt,
|
||||
ox::StringParam title,
|
||||
ox::StringParam fileExt,
|
||||
ImVec2 const&size) noexcept:
|
||||
m_sctx(sctx),
|
||||
m_title(std::move(title)),
|
||||
|
@@ -36,7 +36,7 @@ Project::Project(keel::Context &ctx, ox::String path, ox::StringViewCR projectDa
|
||||
oxTracef("studio", "Project: {}", m_path);
|
||||
generateTypes(m_typeStore);
|
||||
if (ox::defines::Debug) {
|
||||
oxThrowError(writeTypeStore());
|
||||
OX_THROW_ERROR(writeTypeStore());
|
||||
}
|
||||
buildFileIndex();
|
||||
}
|
||||
@@ -44,7 +44,7 @@ Project::Project(keel::Context &ctx, ox::String path, ox::StringViewCR projectDa
|
||||
ox::Error Project::create() noexcept {
|
||||
std::error_code ec;
|
||||
std::filesystem::create_directory(m_path.toStdString(), ec);
|
||||
return OxError(static_cast<ox::ErrorCode>(ec.value()), "PassThroughFS: mkdir failed");
|
||||
return ox::Error(static_cast<ox::ErrorCode>(ec.value()), "PassThroughFS: mkdir failed");
|
||||
}
|
||||
|
||||
ox::String const&Project::projectPath() const noexcept {
|
||||
@@ -58,11 +58,11 @@ ox::FileSystem &Project::romFs() noexcept {
|
||||
ox::Error Project::mkdir(ox::StringViewCR path) const noexcept {
|
||||
auto const [stat, err] = m_fs.stat(path);
|
||||
if (err) {
|
||||
oxReturnError(m_fs.mkdir(path, true));
|
||||
OX_RETURN_ERROR(m_fs.mkdir(path, true));
|
||||
fileUpdated.emit(path, {});
|
||||
}
|
||||
return stat.fileType == ox::FileType::Directory ?
|
||||
ox::Error{} : OxError(1, "path exists as normal file");
|
||||
ox::Error{} : ox::Error(1, "path exists as normal file");
|
||||
}
|
||||
|
||||
ox::Result<ox::FileStat> Project::stat(ox::StringViewCR path) const noexcept {
|
||||
@@ -79,12 +79,12 @@ ox::Vector<ox::String> const&Project::fileList(ox::StringViewCR ext) noexcept {
|
||||
|
||||
ox::Error Project::writeTypeStore() noexcept {
|
||||
// write all descriptors because we don't know which types T depends on
|
||||
oxReturnError(mkdir(m_typeDescPath));
|
||||
OX_RETURN_ERROR(mkdir(m_typeDescPath));
|
||||
for (auto const &t: m_typeStore.typeList()) {
|
||||
oxRequire(typeOut, ox::writeClaw(*t, ox::ClawFormat::Organic));
|
||||
OX_REQUIRE(typeOut, ox::writeClaw(*t, ox::ClawFormat::Organic));
|
||||
// write to FS
|
||||
auto const typePath = ox::sfmt("{}/{}", m_typeDescPath, buildTypeId(*t));
|
||||
oxReturnError(writeBuff(typePath, {typeOut.data(), typeOut.size() - 1}));
|
||||
OX_RETURN_ERROR(writeBuff(typePath, {typeOut.data(), typeOut.size() - 1}));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
@@ -119,11 +119,11 @@ ox::Error Project::writeBuff(ox::StringViewCR path, ox::BufferView const&buff) n
|
||||
ox::BufferWriter writer(&outBuff);
|
||||
auto const [uuid, err] = pathToUuid(m_ctx, path);
|
||||
if (!err) {
|
||||
oxReturnError(keel::writeUuidHeader(writer, uuid));
|
||||
OX_RETURN_ERROR(keel::writeUuidHeader(writer, uuid));
|
||||
}
|
||||
oxReturnError(writer.write(buff.data(), buff.size()));
|
||||
OX_RETURN_ERROR(writer.write(buff.data(), buff.size()));
|
||||
auto const newFile = m_fs.stat(path).error != 0;
|
||||
oxReturnError(m_fs.write(path, outBuff.data(), outBuff.size(), ox::FileType::NormalFile));
|
||||
OX_RETURN_ERROR(m_fs.write(path, outBuff.data(), outBuff.size(), ox::FileType::NormalFile));
|
||||
if (newFile) {
|
||||
fileAdded.emit(path);
|
||||
indexFile(path);
|
||||
@@ -138,16 +138,16 @@ ox::Result<ox::Buffer> Project::loadBuff(ox::StringViewCR path) const noexcept {
|
||||
}
|
||||
|
||||
ox::Error Project::lsProcDir(ox::Vector<ox::String> *paths, ox::StringViewCR path) const noexcept {
|
||||
oxRequire(files, m_fs.ls(path));
|
||||
OX_REQUIRE(files, m_fs.ls(path));
|
||||
for (auto const&name : files) {
|
||||
auto fullPath = ox::sfmt("{}/{}", path, name);
|
||||
oxRequire(stat, m_fs.stat(ox::StringView(fullPath)));
|
||||
OX_REQUIRE(stat, m_fs.stat(ox::StringView(fullPath)));
|
||||
switch (stat.fileType) {
|
||||
case ox::FileType::NormalFile:
|
||||
paths->emplace_back(std::move(fullPath));
|
||||
break;
|
||||
case ox::FileType::Directory:
|
||||
oxReturnError(lsProcDir(paths, fullPath));
|
||||
OX_RETURN_ERROR(lsProcDir(paths, fullPath));
|
||||
break;
|
||||
case ox::FileType::None:
|
||||
break;
|
||||
@@ -158,7 +158,7 @@ ox::Error Project::lsProcDir(ox::Vector<ox::String> *paths, ox::StringViewCR pat
|
||||
|
||||
ox::Result<ox::Vector<ox::String>> Project::listFiles(ox::StringViewCR path) const noexcept {
|
||||
ox::Vector<ox::String> paths;
|
||||
oxReturnError(lsProcDir(&paths, path));
|
||||
OX_RETURN_ERROR(lsProcDir(&paths, path));
|
||||
return paths;
|
||||
}
|
||||
|
||||
|
@@ -1,3 +1,6 @@
|
||||
/*
|
||||
* Copyright 2016 - 2024 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <studio/undocommand.hpp>
|
||||
|
||||
|
@@ -10,7 +10,7 @@ ox::Error UndoStack::push(ox::UPtr<UndoCommand> &&cmd) noexcept {
|
||||
for (auto const i = m_stackIdx; i < m_stack.size();) {
|
||||
std::ignore = m_stack.erase(i);
|
||||
}
|
||||
oxReturnError(cmd->redo());
|
||||
OX_RETURN_ERROR(cmd->redo());
|
||||
redoTriggered.emit(cmd.get());
|
||||
changeTriggered.emit(cmd.get());
|
||||
if (m_stack.empty() || !(*m_stack.back().value)->mergeWith(*cmd)) {
|
||||
@@ -27,7 +27,7 @@ ox::Error UndoStack::push(ox::UPtr<UndoCommand> &&cmd) noexcept {
|
||||
ox::Error UndoStack::redo() noexcept {
|
||||
if (m_stackIdx < m_stack.size()) {
|
||||
auto &c = m_stack[m_stackIdx];
|
||||
oxReturnError(c->redo());
|
||||
OX_RETURN_ERROR(c->redo());
|
||||
++m_stackIdx;
|
||||
redoTriggered.emit(c.get());
|
||||
changeTriggered.emit(c.get());
|
||||
@@ -38,7 +38,7 @@ ox::Error UndoStack::redo() noexcept {
|
||||
ox::Error UndoStack::undo() noexcept {
|
||||
if (m_stackIdx) {
|
||||
auto &c = m_stack[--m_stackIdx];
|
||||
oxReturnError(c->undo());
|
||||
OX_RETURN_ERROR(c->undo());
|
||||
undoTriggered.emit(c.get());
|
||||
changeTriggered.emit(c.get());
|
||||
}
|
||||
|
Reference in New Issue
Block a user