Merge branch 'main' into item-models

This commit is contained in:
MihailRis
2024-10-27 22:20:58 +03:00
12 changed files with 141 additions and 7 deletions
+19
View File
@@ -1,6 +1,7 @@
#include "api_lua.hpp"
#include <vector>
#include <cwctype>
#include "../lua_custom_types.hpp"
#include "util/stringutil.hpp"
@@ -63,11 +64,29 @@ static int l_sub(lua::State* L) {
return lua::pushstring(L, util::u32str2str_utf8(string.substr(start, end)));
}
static int l_upper(lua::State* L) {
auto string = util::str2u32str_utf8(lua::require_string(L, 1));
for (auto& c : string) {
c = std::towupper(c);
}
return lua::pushstring(L, util::u32str2str_utf8(string));
}
static int l_lower(lua::State* L) {
auto string = util::str2u32str_utf8(lua::require_string(L, 1));
for (auto& c : string) {
c = std::towlower(c);
}
return lua::pushstring(L, util::u32str2str_utf8(string));
}
const luaL_Reg utf8lib[] = {
{"tobytes", lua::wrap<l_encode>},
{"tostring", lua::wrap<l_decode>},
{"length", lua::wrap<l_length>},
{"codepoint", lua::wrap<l_codepoint>},
{"sub", lua::wrap<l_sub>},
{"upper", lua::wrap<l_upper>},
{"lower", lua::wrap<l_lower>},
{NULL, NULL}
};
@@ -229,8 +229,10 @@ static int l_resize(lua::State* L) {
uint height = touinteger(L, 3);
auto interpName = tostring(L, 4);
auto interpolation = InterpolationType::NEAREST;
if (!std::strcmp(interpName, "linear")) {
if (std::strcmp(interpName, "linear") == 0) {
interpolation = InterpolationType::LINEAR;
} else if (std::strcmp(interpName, "cubic") == 0) {
interpolation = InterpolationType::CUBIC;
}
heightmap->getHeightmap()->resize(width, height, interpolation);
}