Skip to content

Commit

Permalink
Fix json writting
Browse files Browse the repository at this point in the history
  • Loading branch information
edunad committed Jun 19, 2024
1 parent e22ea47 commit 63401e1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
12 changes: 6 additions & 6 deletions rawrbox.math/src/easing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ namespace rawrbox {
case Easing::STEP:
return val < 0.5F ? 0.F : 1.F;
case Easing::EASE_IN_QUAD:
return std::pow<float>(val, 2.F);
return static_cast<float>(std::pow(val, 2.F));
case Easing::EASE_OUT_QUAD:
return 1.F - std::pow<float>(1.F - val, 2.F);
return 1.F - static_cast<float>(std::pow(1.F - val, 2.F));
case Easing::EASE_IN_OUT_QUAD:
return val < 0.5F ? 2.F * std::pow<float>(val, 2.F) : 1.F - std::pow<float>(-2.F * val + 2.F, 2.F) / 2.F;
return val < 0.5F ? 2.F * static_cast<float>(std::pow(val, 2.F)) : 1.F - static_cast<float>(std::pow(-2.F * val + 2.F, 2.F)) / 2.F;
case Easing::EASE_IN_CUBIC:
return std::pow<float>(val, 3.F);
return static_cast<float>(std::pow(val, 3.F));
case Easing::EASE_OUT_CUBIC:
return 1.F - std::pow<float>(1.F - val, 3.F);
return 1.F - static_cast<float>(std::pow(1.F - val, 3.F));
case Easing::EASE_IN_OUT_CUBIC:
return val < 0.5F ? 4.F * std::pow<float>(val, 3.F) : 1.F - std::pow<float>(-2.F * val + 2.F, 3.F) / 2.F;
return val < 0.5F ? 4.F * static_cast<float>(std::pow(val, 3.F)) : 1.F - static_cast<float>(std::pow(-2.F * val + 2.F, 3.F)) / 2.F;
default:
throw std::runtime_error("[RawrBox-Easing] Unsupported easing");
}
Expand Down
10 changes: 4 additions & 6 deletions rawrbox.utils/src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ namespace rawrbox {

void Settings::save() {
auto fileName = this->getFileName();

std::ofstream out(fileName);
if (!out.is_open()) throw this->_logger->error("Failed to save settings '{}'", fileName);

out << glz::write<glz::opts{.prettify = true}>(this->_settings)->c_str();
out.close();
auto ec = glz::write_file_json(this->_settings, fileName, std::string{});
if (ec) {
throw this->_logger->error("Failed to save settings '{}'", fileName);
}
}

void Settings::load(std::string data) {
Expand Down
6 changes: 6 additions & 0 deletions samples/014-scripting/mods/test-mod/src/test.luau
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ function testRawrbox()
for i = 0, 15 do
print(string.vformat("[{}] = {}", i, m[i]))
end

print("Test printTable")
printTable({
aaa = 1,
test = "test",
})
end

0 comments on commit 63401e1

Please sign in to comment.