Squashed 'deps/nostalgia/' changes from 3c7652ef..161640fa

161640fa [nostalgia] Cleanup
e42126c9 [nostalgia/core] Improve TileSheet validation, add repair
36942cca [nostalgia,olympic] Replace SpanView with Span<const T>
b14f1d50 [ox] Replace SpanView with Span<const T>
1bf4f246 [applib] Make run take args as a SpanView
edda8e01 [ox/clargs] Add constructor that takes a SpanView
3308b4dd [ox/std] Add missing + and += operators to Span
27f4703a [teagba] Suppress warnings for unsafe buffers
6af00d9a [nostalgia] Enable warnings for unsafe buffers
86b9f931 [olympic] Enable warnings for unsafe buffers
a0ed1b3f [ox/std] Fix Span raw array constructor
8dad624b [studio/applib] Cleanup
dc6605fd [keel] Add missing error checking to pack
c78d3cf6 [ox] Add more unsafe buffer exceptions
cee4f65d [ox/std] Replace an unsafe buffer
cd3eeeef [ox/fs] Suppress unsafe buffer warnings
287d42f2 [ox/clargs] Cleanup
dbbaaa46 [ox/clargs] Enable unsafe buffer warnings
9b8a8c4e [ox/std] Enable unsafe buffer warnings
e44fa288 [cityhash] Add pragmas to ignore unsafe buffer warnings
e13c6e81 [ox/std] Remove raw char* CharBufferWriter constructor
cb55b31a [ox/std] Cleanup
ab3f9e16 [ox/std] Make Span access check message consistent with other messages
8f25ef96 [ox/std] Make CharBufferWriter constructor take a Span
e13eebaf [ox/std] Cleanup an unsafe buffer
114f5c66 [ox/std] Add overflow checking to SpanIterator
df44fe23 [keel] Cleanup
72f4db3d [nostalgia/core/studio] Fix paste command to never paste beyond target dimensions
8a9ff971 [nostalgia/core] Fix resizeSubsheet to work for both growing and shrinking
5a8da59d [keel] Fix readAsset to actually return asset
afa3a13d [keel] Cleanup
6522cf8a [keel] Add ensureValid call to readAsset
f772e48b [ox] Add Vector/Array/Span overflow checking
13bfe881 [nostalgia/core] Fix resizeSubsheet array overflow
50254754 Merge commit '9e11019b87ba27d1dac9e097dc212a126e404218'
bfe890ae [ox] Fix typo in docs
ab5bc1ad [ox/std] Remove oxRequireT and oxRequireMT
abf7548a [nostalgia/core] Add missing include
e2682b5e [studio/modlib] Add missing include
792ad414 [nostalgia] Remove .vs dir

git-subtree-dir: deps/nostalgia
git-subtree-split: 161640fa11986677dc2e1da6ffd4575e38ab31ad
This commit is contained in:
2024-12-04 19:55:17 -06:00
parent 9e11019b87
commit 4ccdfc3a6e
101 changed files with 842 additions and 731 deletions

View File

@@ -52,8 +52,7 @@ static ox::Error runApp(
static ox::Error run(
ox::StringViewCR appName,
ox::StringViewCR projectDataDir,
int,
char const**) {
ox::SpanView<const char*>) {
// seed UUID generator
auto const time = std::time(nullptr);
ox::UUID::seedGenerator({
@@ -74,9 +73,8 @@ ox::Error run(
ox::StringView project,
ox::StringView appName,
ox::StringView projectDataDir,
int argc,
char const**argv) noexcept {
return studio::run(ox::sfmt("{} {}", project, appName), projectDataDir, argc, argv);
ox::SpanView<char const*> args) noexcept {
return studio::run(ox::sfmt("{} {}", project, appName), projectDataDir, args);
}
}

View File

@@ -63,12 +63,14 @@ void NewMenu::addItemMaker(ox::UniquePtr<studio::ItemMaker> &&im) noexcept {
void NewMenu::drawNewItemType(studio::StudioContext &sctx) noexcept {
drawWindow(sctx.tctx, &m_open, [this] {
auto items = ox_malloca(m_types.size() * sizeof(char const*), char const*, nullptr);
auto const allocSz = m_types.size() * sizeof(char const*);
auto mem = ox_malloca(allocSz, char const*, nullptr);
auto items = ox::Span{mem.get(), allocSz};
for (auto i = 0u; auto const&im : m_types) {
items.get()[i] = im->typeName.c_str();
items[i] = im->typeName.c_str();
++i;
}
ImGui::ListBox("Item Type", &m_selectedType, items.get(), static_cast<int>(m_types.size()));
ImGui::ListBox("Item Type", &m_selectedType, items.data(), static_cast<int>(m_types.size()));
drawFirstPageButtons();
});
}
@@ -116,11 +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"));
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(OxError(1, "New file error: file already exists"));
return;
}
auto const [path, err] = typeMaker.write(sctx, m_itemName);

View File

@@ -21,7 +21,9 @@ namespace studio {
static ox::Vector<studio::Module const*> modules;
void registerModule(studio::Module const*mod) noexcept {
modules.emplace_back(mod);
if (mod) {
modules.emplace_back(mod);
}
}
@@ -238,18 +240,18 @@ void StudioUI::loadEditorMaker(studio::EditorMaker const&editorMaker) noexcept {
}
}
void StudioUI::loadModule(studio::Module const*mod) noexcept {
for (auto const&editorMaker : mod->editors(m_sctx)) {
void StudioUI::loadModule(studio::Module const&mod) noexcept {
for (auto const&editorMaker : mod.editors(m_sctx)) {
loadEditorMaker(editorMaker);
}
for (auto &im : mod->itemMakers(m_sctx)) {
for (auto &im : mod.itemMakers(m_sctx)) {
m_newMenu.addItemMaker(std::move(im));
}
}
void StudioUI::loadModules() noexcept {
for (auto const mod : modules) {
loadModule(mod);
loadModule(*mod);
}
}

View File

@@ -69,7 +69,7 @@ class StudioUI: public ox::SignalHandler {
void loadEditorMaker(studio::EditorMaker const&editorMaker) noexcept;
void loadModule(studio::Module const*mod) noexcept;
void loadModule(studio::Module const&mod) noexcept;
void loadModules() noexcept;

View File

@@ -5,6 +5,7 @@
#pragma once
#include <ox/std/defines.hpp>
#include <ox/std/string.hpp>
namespace studio {
@@ -24,4 +25,4 @@ ox::Result<ox::String> saveFile(ox::Vector<FDFilterItem> const&exts) noexcept;
ox::Result<ox::String> chooseDirectory() noexcept;
}
}

View File

@@ -189,7 +189,7 @@ bool BeginPopup(turbine::Context &ctx, ox::CStringView popupName, bool &show, Im
* @param selectedIdx
* @return true if new value selected, false otherwise
*/
bool ComboBox(ox::CStringView lbl, ox::SpanView<ox::String> list, size_t &selectedIdx) noexcept;
bool ComboBox(ox::CStringView lbl, ox::Span<const ox::String> list, size_t &selectedIdx) noexcept;
/**
*
@@ -223,7 +223,7 @@ bool ListBox(
* @param selIdx
* @return true if new value selected, false otherwise
*/
bool ListBox(ox::CStringView name, ox::SpanView<ox::String> const&list, size_t &selIdx) noexcept;
bool ListBox(ox::CStringView name, ox::Span<const ox::String> const&list, size_t &selIdx) noexcept;
class FilePicker {
private:

View File

@@ -22,10 +22,12 @@ static ox::Result<ox::String> toResult(nfdresult_t r, NFD::UniquePathN const&pat
switch (r) {
case NFD_OKAY: {
ox::String out;
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
for (auto i = 0u; path.get()[i]; ++i) {
auto const c = static_cast<char>(path.get()[i]);
std::ignore = out.append(&c, 1);
}
OX_ALLOW_UNSAFE_BUFFERS_END
return out;
}
case NFD_CANCEL:
@@ -35,11 +37,11 @@ static ox::Result<ox::String> toResult(nfdresult_t r, NFD::UniquePathN const&pat
}
}
ox::Result<ox::String> saveFile(ox::Vector<FDFilterItem> const&filters) noexcept {
ox::Result<ox::String> saveFile(ox::Vector<FDFilterItem> const&exts) noexcept {
NFD::Guard const guard;
NFD::UniquePathN path;
ox::Vector<nfdnfilteritem_t, 5> filterItems(filters.size());
for (auto i = 0u; auto const&f : filters) {
ox::Vector<nfdnfilteritem_t, 5> filterItems(exts.size());
for (auto i = 0u; auto const&f : exts) {
filterItems[i].name = f.name.data();
filterItems[i].spec = f.spec.data();
++i;

View File

@@ -87,7 +87,7 @@ bool BeginPopup(turbine::Context &ctx, ox::CStringView popupName, bool &show, Im
bool ComboBox(
ox::CStringView lbl,
ox::SpanView<ox::String> list,
ox::Span<const ox::String> list,
size_t &selectedIdx) noexcept {
bool out{};
auto const first = selectedIdx < list.size() ? list[selectedIdx].c_str() : "";
@@ -155,7 +155,7 @@ bool ListBox(
return out;
}
bool ListBox(ox::CStringView name, ox::SpanView<ox::String> const&list, size_t &selIdx) noexcept {
bool ListBox(ox::CStringView name, ox::Span<const ox::String> const&list, size_t &selIdx) noexcept {
return ListBox(name, [list](size_t i) -> ox::CStringView {
return list[i];
}, list.size(), selIdx);