Compare commits
No commits in common. "829dc0298e08ae64069ba6e138fe34eb706e2871" and "92d85d1145c065164a0cdea37d5693a2730fb6ca" have entirely different histories.
829dc0298e
...
92d85d1145
24
deps/ox/src/ox/oc/write.hpp
vendored
24
deps/ox/src/ox/oc/write.hpp
vendored
@ -24,8 +24,7 @@ namespace ox {
|
|||||||
|
|
||||||
class OrganicClawWriter {
|
class OrganicClawWriter {
|
||||||
|
|
||||||
friend Result<ox::Buffer> writeOC(const auto &val) noexcept;
|
friend Result<Buffer> writeOC(const auto &val) noexcept;
|
||||||
friend Result<ox::String> writeOCString(const auto &val) noexcept;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Json::Value m_json{Json::Value(Json::objectValue)};
|
Json::Value m_json{Json::Value(Json::objectValue)};
|
||||||
@ -248,27 +247,14 @@ Error OrganicClawWriter::field(const char *key, UnionView<U, force> val) noexcep
|
|||||||
return OxError(0);
|
return OxError(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<ox::Buffer> writeOC(const auto &val) noexcept {
|
Result<Buffer> writeOC(const auto &val) noexcept {
|
||||||
OrganicClawWriter writer;
|
OrganicClawWriter writer;
|
||||||
ModelHandlerInterface<OrganicClawWriter, OpType::Write> handler(&writer);
|
ModelHandlerInterface<OrganicClawWriter, OpType::Write> handler(&writer);
|
||||||
oxReturnError(model(&handler, &val));
|
oxReturnError(model(&handler, &val));
|
||||||
Json::StreamWriterBuilder const jsonBuilder;
|
Json::StreamWriterBuilder jsonBuilder;
|
||||||
const auto str = Json::writeString(jsonBuilder, writer.m_json);
|
const auto str = Json::writeString(jsonBuilder, writer.m_json);
|
||||||
Result<Buffer> buff;
|
Buffer buff(str.size() + 1);
|
||||||
buff.value.resize(str.size() + 1);
|
memcpy(buff.data(), str.c_str(), str.size() + 1);
|
||||||
memcpy(buff.value.data(), str.data(), str.size() + 1);
|
|
||||||
return buff;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result<ox::String> writeOCString(const auto &val) noexcept {
|
|
||||||
OrganicClawWriter writer;
|
|
||||||
ModelHandlerInterface<OrganicClawWriter, OpType::Write> handler(&writer);
|
|
||||||
oxReturnError(model(&handler, &val));
|
|
||||||
Json::StreamWriterBuilder const jsonBuilder;
|
|
||||||
const auto str = Json::writeString(jsonBuilder, writer.m_json);
|
|
||||||
Result<ox::String> buff;
|
|
||||||
buff.value.resize(str.size());
|
|
||||||
memcpy(buff.value.data(), str.data(), str.size() + 1);
|
|
||||||
return buff;
|
return buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
13
deps/ox/src/ox/std/hashmap.hpp
vendored
13
deps/ox/src/ox/std/hashmap.hpp
vendored
@ -64,9 +64,6 @@ class HashMap {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr Vector<K> const&keys() const noexcept;
|
constexpr Vector<K> const&keys() const noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
|
||||||
constexpr Vector<T> values() const noexcept;
|
|
||||||
|
|
||||||
constexpr void clear();
|
constexpr void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -201,16 +198,6 @@ constexpr Vector<K> const&HashMap<K, T>::keys() const noexcept {
|
|||||||
return m_keys;
|
return m_keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename K, typename T>
|
|
||||||
constexpr Vector<T> HashMap<K, T>::values() const noexcept {
|
|
||||||
Vector<T> out;
|
|
||||||
out.reserve(m_pairs.size());
|
|
||||||
for (auto const&p : m_pairs) {
|
|
||||||
out.emplace_back(p->value);
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename K, typename T>
|
template<typename K, typename T>
|
||||||
constexpr void HashMap<K, T>::clear() {
|
constexpr void HashMap<K, T>::clear() {
|
||||||
for (std::size_t i = 0; i < m_pairs.size(); i++) {
|
for (std::size_t i = 0; i < m_pairs.size(); i++) {
|
||||||
|
@ -67,22 +67,12 @@ struct NostalgiaPalette {
|
|||||||
ox::Vector<Color16> colors = {};
|
ox::Vector<Color16> colors = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
oxModelBegin(NostalgiaPalette)
|
|
||||||
oxModelField(colors)
|
|
||||||
oxModelEnd()
|
|
||||||
|
|
||||||
|
|
||||||
struct PaletteV1 {
|
struct PaletteV1 {
|
||||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Palette";
|
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Palette";
|
||||||
static constexpr auto TypeVersion = 1;
|
static constexpr auto TypeVersion = 1;
|
||||||
ox::Vector<Color16> colors;
|
ox::Vector<Color16> colors;
|
||||||
};
|
};
|
||||||
|
|
||||||
oxModelBegin(PaletteV1)
|
|
||||||
oxModelField(colors)
|
|
||||||
oxModelEnd()
|
|
||||||
|
|
||||||
|
|
||||||
struct PaletteV2 {
|
struct PaletteV2 {
|
||||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Palette";
|
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Palette";
|
||||||
static constexpr auto TypeVersion = 2;
|
static constexpr auto TypeVersion = 2;
|
||||||
@ -90,10 +80,6 @@ struct PaletteV2 {
|
|||||||
ox::Vector<ox::Vector<Color16>> pages;
|
ox::Vector<ox::Vector<Color16>> pages;
|
||||||
};
|
};
|
||||||
|
|
||||||
oxModelBegin(PaletteV2)
|
|
||||||
oxModelField(pages)
|
|
||||||
oxModelEnd()
|
|
||||||
|
|
||||||
|
|
||||||
struct PaletteV3 {
|
struct PaletteV3 {
|
||||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Palette";
|
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.Palette";
|
||||||
@ -110,15 +96,6 @@ struct PaletteV3 {
|
|||||||
ox::Vector<ox::Vector<Color16>> pages;
|
ox::Vector<ox::Vector<Color16>> pages;
|
||||||
};
|
};
|
||||||
|
|
||||||
oxModelBegin(PaletteV3::ColorInfo)
|
|
||||||
oxModelField(name)
|
|
||||||
oxModelEnd()
|
|
||||||
|
|
||||||
oxModelBegin(PaletteV3)
|
|
||||||
oxModelField(colorInfo)
|
|
||||||
oxModelField(pages)
|
|
||||||
oxModelEnd()
|
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr bool valid(PaletteV3 const&p) noexcept {
|
constexpr bool valid(PaletteV3 const&p) noexcept {
|
||||||
auto const colors = p.colorInfo.size();
|
auto const colors = p.colorInfo.size();
|
||||||
@ -144,11 +121,6 @@ struct PaletteV4 {
|
|||||||
ox::Vector<PalettePageV1> pages;
|
ox::Vector<PalettePageV1> pages;
|
||||||
};
|
};
|
||||||
|
|
||||||
oxModelBegin(PaletteV4)
|
|
||||||
oxModelField(colorNames)
|
|
||||||
oxModelField(pages)
|
|
||||||
oxModelEnd()
|
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr bool valid(PaletteV4 const&p) noexcept {
|
constexpr bool valid(PaletteV4 const&p) noexcept {
|
||||||
auto const colors = p.colorNames.size();
|
auto const colors = p.colorNames.size();
|
||||||
@ -176,10 +148,6 @@ struct CompactPaletteV1 {
|
|||||||
ox::Vector<ox::Vector<Color16>> pages{};
|
ox::Vector<ox::Vector<Color16>> pages{};
|
||||||
};
|
};
|
||||||
|
|
||||||
oxModelBegin(CompactPaletteV1)
|
|
||||||
oxModelField(pages)
|
|
||||||
oxModelEnd()
|
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr bool valid(CompactPaletteV1 const&p) noexcept {
|
constexpr bool valid(CompactPaletteV1 const&p) noexcept {
|
||||||
size_t colors{};
|
size_t colors{};
|
||||||
@ -286,4 +254,34 @@ constexpr size_t largestPage(CompactPalette const&pal) noexcept {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oxModelBegin(NostalgiaPalette)
|
||||||
|
oxModelField(colors)
|
||||||
|
oxModelEnd()
|
||||||
|
|
||||||
|
oxModelBegin(PaletteV1)
|
||||||
|
oxModelField(colors)
|
||||||
|
oxModelEnd()
|
||||||
|
|
||||||
|
oxModelBegin(PaletteV2)
|
||||||
|
oxModelField(pages)
|
||||||
|
oxModelEnd()
|
||||||
|
|
||||||
|
oxModelBegin(PaletteV3::ColorInfo)
|
||||||
|
oxModelField(name)
|
||||||
|
oxModelEnd()
|
||||||
|
|
||||||
|
oxModelBegin(PaletteV3)
|
||||||
|
oxModelField(colorInfo)
|
||||||
|
oxModelField(pages)
|
||||||
|
oxModelEnd()
|
||||||
|
|
||||||
|
oxModelBegin(PaletteV4)
|
||||||
|
oxModelField(colorNames)
|
||||||
|
oxModelField(pages)
|
||||||
|
oxModelEnd()
|
||||||
|
|
||||||
|
oxModelBegin(CompactPaletteV1)
|
||||||
|
oxModelField(pages)
|
||||||
|
oxModelEnd()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ PaletteEditorImGui::PaletteEditorImGui(studio::StudioContext &sctx, ox::StringPa
|
|||||||
m_sctx(sctx),
|
m_sctx(sctx),
|
||||||
m_tctx(sctx.tctx),
|
m_tctx(sctx.tctx),
|
||||||
m_pal(*keel::readObj<Palette>(keelCtx(m_tctx), itemPath()).unwrapThrow()) {
|
m_pal(*keel::readObj<Palette>(keelCtx(m_tctx), itemPath()).unwrapThrow()) {
|
||||||
if (keel::ensureValid(m_pal).errCode) {
|
if (!valid(m_pal)) {
|
||||||
throw OxException(1, "PaletteEditorImGui: invalid Palette object");
|
throw OxException(1, "PaletteEditorImGui: invalid Palette object");
|
||||||
}
|
}
|
||||||
undoStack()->changeTriggered.connect(this, &PaletteEditorImGui::handleCommand);
|
undoStack()->changeTriggered.connect(this, &PaletteEditorImGui::handleCommand);
|
||||||
|
@ -76,8 +76,8 @@ static ox::Error pack(
|
|||||||
oxReturnError(appendBinary(romBuff, dstBuff, *pl));
|
oxReturnError(appendBinary(romBuff, dstBuff, *pl));
|
||||||
oxOutf("Final ROM buff size: {} bytes\n", romBuff.size());
|
oxOutf("Final ROM buff size: {} bytes\n", romBuff.size());
|
||||||
oxReturnError(writeFileBuff(argRomBin, romBuff));
|
oxReturnError(writeFileBuff(argRomBin, romBuff));
|
||||||
oxRequire(manifestJson, ox::writeOCString(manifest));
|
oxRequire(manifestJson, ox::writeOC(manifest));
|
||||||
oxReturnError(writeFileBuff(argManifest, {manifestJson.data(), manifestJson.len()}));
|
oxReturnError(writeFileBuff(argManifest, manifestJson));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class Project {
|
|||||||
|
|
||||||
void indexFile(ox::CRStringView path) noexcept;
|
void indexFile(ox::CRStringView path) noexcept;
|
||||||
|
|
||||||
ox::Error writeBuff(ox::CRStringView path, ox::BufferView const&buff) noexcept;
|
ox::Error writeBuff(ox::CRStringView path, ox::Buffer const&buff) noexcept;
|
||||||
|
|
||||||
ox::Result<ox::Buffer> loadBuff(ox::CRStringView path) const noexcept;
|
ox::Result<ox::Buffer> loadBuff(ox::CRStringView path) const noexcept;
|
||||||
|
|
||||||
|
@ -81,10 +81,12 @@ ox::Error Project::writeTypeStore() noexcept {
|
|||||||
// write all descriptors because we don't know which types T depends on
|
// write all descriptors because we don't know which types T depends on
|
||||||
oxReturnError(mkdir(m_typeDescPath));
|
oxReturnError(mkdir(m_typeDescPath));
|
||||||
for (auto const &t: m_typeStore.typeList()) {
|
for (auto const &t: m_typeStore.typeList()) {
|
||||||
oxRequire(typeOut, ox::writeClaw(*t, ox::ClawFormat::Organic));
|
oxRequireM(typeOut, ox::writeClaw(*t, ox::ClawFormat::Organic));
|
||||||
|
// replace garbage last character with new line
|
||||||
|
*typeOut.back().value = '\n';
|
||||||
// write to FS
|
// write to FS
|
||||||
auto const typePath = ox::sfmt("{}/{}", m_typeDescPath, buildTypeId(*t));
|
auto const typePath = ox::sfmt("{}/{}", m_typeDescPath, buildTypeId(*t));
|
||||||
oxReturnError(writeBuff(typePath, {typeOut.data(), typeOut.size() - 1}));
|
oxReturnError(writeBuff(typePath, typeOut));
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -112,7 +114,7 @@ void Project::indexFile(ox::CRStringView path) noexcept {
|
|||||||
m_fileExtFileMap[ext].emplace_back(path);
|
m_fileExtFileMap[ext].emplace_back(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error Project::writeBuff(ox::CRStringView path, ox::BufferView const&buff) noexcept {
|
ox::Error Project::writeBuff(ox::CRStringView path, ox::Buffer const&buff) noexcept {
|
||||||
constexpr auto HdrSz = 40;
|
constexpr auto HdrSz = 40;
|
||||||
ox::Buffer outBuff;
|
ox::Buffer outBuff;
|
||||||
outBuff.reserve(buff.size() + HdrSz);
|
outBuff.reserve(buff.size() + HdrSz);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user