Compare commits
4 Commits
a7cf267385
...
945a55f94a
Author | SHA1 | Date | |
---|---|---|---|
945a55f94a | |||
2173b12c67 | |||
aa970b1fc0 | |||
6ad79b305c |
4
deps/ox/src/ox/mc/test/tests.cpp
vendored
4
deps/ox/src/ox/mc/test/tests.cpp
vendored
@ -316,7 +316,7 @@ std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
testIn.Union.Int = 93;
|
||||
oxAssert(ox::writeMC(dataBuff.data(), dataBuff.size(), testIn), "Data generation failed");
|
||||
ox::TypeStore typeStore;
|
||||
const auto [type, typeErr] = ox::buildTypeDef(&typeStore, &testIn);
|
||||
const auto [type, typeErr] = ox::buildTypeDef(typeStore, testIn);
|
||||
oxAssert(typeErr, "Descriptor write failed");
|
||||
ox::ModelObject testOut;
|
||||
oxReturnError(testOut.setType(type));
|
||||
@ -368,7 +368,7 @@ std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
testIn.Struct.IString = "Test String 2";
|
||||
oxAssert(ox::writeMC(dataBuff, dataBuffLen, testIn), "Data generation failed");
|
||||
ox::TypeStore typeStore;
|
||||
const auto [type, typeErr] = ox::buildTypeDef(&typeStore, &testIn);
|
||||
const auto [type, typeErr] = ox::buildTypeDef(typeStore, testIn);
|
||||
oxAssert(typeErr, "Descriptor write failed");
|
||||
ox::BufferReader br({dataBuff, dataBuffLen});
|
||||
oxReturnError(ox::walkModel<ox::MetalClawReader>(type, br,
|
||||
|
10
deps/ox/src/ox/model/descwrite.hpp
vendored
10
deps/ox/src/ox/model/descwrite.hpp
vendored
@ -357,8 +357,8 @@ constexpr const DescriptorType *TypeDescWriter::getType(StringViewCR tn, int typ
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr Result<DescriptorType*> buildTypeDef(TypeStore *typeStore) noexcept {
|
||||
TypeDescWriter writer(typeStore);
|
||||
constexpr Result<DescriptorType*> buildTypeDef(TypeStore &typeStore) noexcept {
|
||||
TypeDescWriter writer(&typeStore);
|
||||
ModelHandlerInterface<TypeDescWriter, ox::OpType::Reflect> handler(&writer);
|
||||
if (std::is_constant_evaluated()) {
|
||||
std::allocator<T> a;
|
||||
@ -373,10 +373,10 @@ constexpr Result<DescriptorType*> buildTypeDef(TypeStore *typeStore) noexcept {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
constexpr Result<DescriptorType*> buildTypeDef(TypeStore *typeStore, T *val) noexcept {
|
||||
TypeDescWriter writer(typeStore);
|
||||
constexpr Result<DescriptorType*> buildTypeDef(TypeStore &typeStore, T &val) noexcept {
|
||||
TypeDescWriter writer(&typeStore);
|
||||
ModelHandlerInterface<TypeDescWriter, ox::OpType::Reflect> handler(&writer);
|
||||
oxReturnError(model(&handler, val));
|
||||
oxReturnError(model(&handler, &val));
|
||||
return writer.definition();
|
||||
}
|
||||
|
||||
|
4
deps/ox/src/ox/oc/test/tests.cpp
vendored
4
deps/ox/src/ox/oc/test/tests.cpp
vendored
@ -207,7 +207,7 @@ const std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
testIn.Union.Int = 93;
|
||||
oxAssert(ox::writeOC(testIn).moveTo(dataBuff), "Data generation failed");
|
||||
ox::TypeStore typeStore;
|
||||
auto type = ox::buildTypeDef(&typeStore, &testIn);
|
||||
auto type = ox::buildTypeDef(typeStore, testIn);
|
||||
oxAssert(type.error, "Descriptor write failed");
|
||||
ox::ModelObject testOut;
|
||||
oxReturnError(testOut.setType(type.value));
|
||||
@ -257,7 +257,7 @@ const std::map<ox::StringView, ox::Error(*)()> tests = {
|
||||
auto [oc, ocErr] = ox::writeOC(testIn);
|
||||
oxAssert(ocErr, "Data generation failed");
|
||||
ox::TypeStore typeStore;
|
||||
auto type = ox::buildTypeDef(&typeStore, &testIn);
|
||||
auto type = ox::buildTypeDef(typeStore, testIn);
|
||||
oxAssert(type.error, "Descriptor write failed");
|
||||
oxReturnError(ox::walkModel<ox::OrganicClawReader>(type.value, oc.data(), oc.size(),
|
||||
[](const ox::Vector<ox::FieldName>&, const ox::Vector<ox::String>&, const ox::DescriptorField &f,
|
||||
|
@ -239,9 +239,13 @@ void PaletteEditorImGui::drawColorEditor() noexcept {
|
||||
name = currentName;
|
||||
ImGui::InputText("Name", name.data(), name.cap() + 1);
|
||||
ImGui::Separator();
|
||||
bool inputFocused = false;
|
||||
ImGui::InputInt("Red", &r, 1, 5);
|
||||
inputFocused |= ImGui::IsItemFocused();
|
||||
ImGui::InputInt("Green", &g, 1, 5);
|
||||
inputFocused |= ImGui::IsItemFocused();
|
||||
ImGui::InputInt("Blue", &b, 1, 5);
|
||||
inputFocused |= ImGui::IsItemFocused();
|
||||
if (ig::PushButton("Apply to all pages", {-1, ig::BtnSz.y})) {
|
||||
std::ignore = pushCommand<ApplyColorAllPagesCommand>(
|
||||
m_pal, m_page, m_selectedColorRow);
|
||||
@ -249,6 +253,17 @@ void PaletteEditorImGui::drawColorEditor() noexcept {
|
||||
r = ox::max(r, 0);
|
||||
g = ox::max(g, 0);
|
||||
b = ox::max(b, 0);
|
||||
if (!inputFocused) {
|
||||
for (auto i = 0u; i < ox::min<size_t>(10, largestPage(m_pal)); ++i) {
|
||||
auto const key = static_cast<ImGuiKey>(ImGuiKey_1 + i);
|
||||
if (ImGui::IsKeyPressed(key, false)) {
|
||||
m_selectedColorRow = i;
|
||||
}
|
||||
}
|
||||
if (ImGui::GetIO().KeysDown[ImGuiKey_0]) {
|
||||
m_selectedColorRow = ox::min<size_t>(9, largestPage(m_pal));
|
||||
}
|
||||
}
|
||||
auto const newColor = color16(r, g, b, a);
|
||||
if (c != newColor) {
|
||||
std::ignore = pushCommand<UpdateColorCommand>(m_pal, m_page, m_selectedColorRow, newColor);
|
||||
|
@ -15,7 +15,7 @@ using TypeDescGenerator = ox::Error(*)(ox::TypeStore&);
|
||||
|
||||
template<typename T>
|
||||
ox::Error generateTypeDesc(ox::TypeStore &ts) noexcept {
|
||||
return ox::buildTypeDef<T>(&ts).error;
|
||||
return ox::buildTypeDef<T>(ts).error;
|
||||
}
|
||||
|
||||
class Module {
|
||||
|
@ -131,12 +131,15 @@ 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));
|
||||
if (fmt == ox::ClawFormat::Organic) {
|
||||
buff.pop_back();
|
||||
}
|
||||
// write to FS
|
||||
oxReturnError(mkdir(parentDir(path)));
|
||||
oxReturnError(writeBuff(path, ox::BufferView{buff} + (fmt == ox::ClawFormat::Organic)));
|
||||
oxReturnError(writeBuff(path, buff));
|
||||
// write type descriptor
|
||||
if (m_typeStore.get<T>().error) {
|
||||
oxReturnError(ox::buildTypeDef(&m_typeStore, &obj));
|
||||
oxReturnError(ox::buildTypeDef(m_typeStore, obj));
|
||||
}
|
||||
oxRequire(desc, m_typeStore.get<T>());
|
||||
auto const descPath = ox::sfmt("{}/{}", m_typeDescPath, buildTypeId(*desc));
|
||||
|
Loading…
x
Reference in New Issue
Block a user