Skip to content

Commit

Permalink
Merge branch 'feat/obey_v2' of github.com:ObEngine/ObEngine into feat…
Browse files Browse the repository at this point in the history
…/obey_v2
  • Loading branch information
Sygmei committed Aug 8, 2023
2 parents 28931ad + b879efa commit ae767b0
Show file tree
Hide file tree
Showing 28 changed files with 188 additions and 338 deletions.
2 changes: 1 addition & 1 deletion engine/Lib/Helpers/Vili.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,4 @@ end

function vili.from_msgpack_as_vili(data)
return vili.msgpack.from_string(data);
end
end
3 changes: 2 additions & 1 deletion extlibs/vili-msgpack/src/msgpack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ namespace vili::msgpack
StackFrameState { static_cast<uint32_t>(object_length), true });
idx += size_header_length;
}
break;
default:
found_code = false;
break;
Expand Down Expand Up @@ -761,7 +762,7 @@ namespace vili::msgpack
}
else
{
throw std::runtime_error("unknown instruction code");
throw std::runtime_error(fmt::format("unknown instruction code '{}'", code));
}
}
if (first_element)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace sol
namespace obe::script::vili_lua_bridge::bindings
{
void load_function_vili_to_lua(sol::state_view state);
void load_function_vili_to_lua_keep_order(sol::state_view state);
void load_function_lua_to_vili(sol::state_view state);
void load_function_vili_object_to_lua_table(sol::state_view state);
void load_function_vili_object_to_lua_table_keep_order(sol::state_view state);
Expand All @@ -15,5 +16,4 @@ namespace obe::script::vili_lua_bridge::bindings
void load_function_lua_table_to_vili_object(sol::state_view state);
void load_function_lua_value_to_vili_primitive(sol::state_view state);
void load_function_lua_table_to_vili_array(sol::state_view state);
void load_function_vili_to_lua_keep_order_proxy(sol::state_view state);
};
8 changes: 4 additions & 4 deletions include/Core/Script/ViliLuaBridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
namespace obe::script::vili_lua_bridge
{
sol::lua_value vili_to_lua(const vili::node& convert);
/**
* \proxy{obe::script::vili_lua_bridge::vili_to_lua_keep_order_proxy}
*/

sol::lua_value vili_to_lua_keep_order(sol::state_view state, const vili::node& convert);

vili::node lua_to_vili(const sol::object& convert);
Expand Down Expand Up @@ -70,6 +68,8 @@ namespace obe::script::vili_lua_bridge
* \return The converted Lua Table in ListAttribute form
*/
vili::node lua_table_to_vili_array(const sol::table& convert);

/**
* \proxy{obe::script::vili_lua_bridge::vili_to_lua_keep_order}
*/
sol::lua_value vili_to_lua_keep_order_proxy(sol::this_state state, const vili::node& convert);
} // namespace obe::script::vili_lua_bridge
2 changes: 1 addition & 1 deletion src/Core/Bindings/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ namespace obe::bindings
obe::script::Helpers::bindings::load_function_pairs_from(state);
obe::script::Helpers::bindings::load_function_ordered_table(state);
obe::script::vili_lua_bridge::bindings::load_function_vili_to_lua(state);
obe::script::vili_lua_bridge::bindings::load_function_vili_to_lua_keep_order(state);
obe::script::vili_lua_bridge::bindings::load_function_lua_to_vili(state);
obe::script::vili_lua_bridge::bindings::load_function_vili_object_to_lua_table(state);
obe::script::vili_lua_bridge::bindings::load_function_vili_object_to_lua_table_keep_order(
Expand All @@ -509,7 +510,6 @@ namespace obe::bindings
obe::script::vili_lua_bridge::bindings::load_function_lua_table_to_vili_object(state);
obe::script::vili_lua_bridge::bindings::load_function_lua_value_to_vili_primitive(state);
obe::script::vili_lua_bridge::bindings::load_function_lua_table_to_vili_array(state);
obe::script::vili_lua_bridge::bindings::load_function_vili_to_lua_keep_order_proxy(state);
obe::system::package::bindings::load_function_get_package_location(state);
obe::system::package::bindings::load_function_package_exists(state);
obe::system::package::bindings::load_function_list_packages(state);
Expand Down
72 changes: 24 additions & 48 deletions src/Core/Bindings/obe/animation/Animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,17 @@ namespace obe::animation::bindings
bind_animation_group["get_size"] = &obe::animation::AnimationGroup::get_size;
bind_animation_group["is_over"] = &obe::animation::AnimationGroup::is_over;
bind_animation_group["next"] = sol::overload(
[](obe::animation::AnimationGroup* self) -> void
{
[](obe::animation::AnimationGroup* self) -> void {
return self->next();
},
[](obe::animation::AnimationGroup* self, bool force) -> void
{
[](obe::animation::AnimationGroup* self, bool force) -> void {
return self->next(force);
});
bind_animation_group["previous"] = sol::overload(
[](obe::animation::AnimationGroup* self) -> void
{
[](obe::animation::AnimationGroup* self) -> void {
return self->previous();
},
[](obe::animation::AnimationGroup* self, bool force) -> void
{
[](obe::animation::AnimationGroup* self, bool force) -> void {
return self->previous(force);
});
bind_animation_group["push_frame_index"]
Expand Down Expand Up @@ -142,8 +138,7 @@ namespace obe::animation::bindings
bind_animation_state["reset"] = &obe::animation::AnimationState::reset;
bind_animation_state["update"] = &obe::animation::AnimationState::update;
bind_animation_state["get_animation"]
= [](obe::animation::AnimationState* self) -> const obe::animation::Animation*
{
= [](obe::animation::AnimationState* self) -> const obe::animation::Animation* {
return &self->get_animation();
};
bind_animation_state["get_current_frame_index"]
Expand All @@ -164,26 +159,22 @@ namespace obe::animation::bindings
bind_animator["get_current_animation"] = &obe::animation::Animator::get_current_animation;
bind_animator["get_current_texture"] = &obe::animation::Animator::get_current_texture;
bind_animator["load"] = sol::overload(
[](obe::animation::Animator* self, obe::system::Path path) -> void
{
[](obe::animation::Animator* self, obe::system::Path path) -> void {
return self->load(path);
},
[](obe::animation::Animator* self, obe::system::Path path,
obe::engine::ResourceManager* resources) -> void
{
obe::engine::ResourceManager* resources) -> void {
return self->load(path, resources);
});
bind_animator["set_animation"] = &obe::animation::Animator::set_animation;
bind_animator["set_paused"] = &obe::animation::Animator::set_paused;
bind_animator["update"] = &obe::animation::Animator::update;
bind_animator["set_target"] = sol::overload(
[](obe::animation::Animator* self, obe::graphics::Sprite& sprite) -> void
{
[](obe::animation::Animator* self, obe::graphics::Sprite& sprite) -> void {
return self->set_target(sprite);
},
[](obe::animation::Animator* self, obe::graphics::Sprite& sprite,
obe::animation::AnimatorTargetScaleMode target_scale_mode) -> void
{
obe::animation::AnimatorTargetScaleMode target_scale_mode) -> void {
return self->set_target(sprite, target_scale_mode);
});
bind_animator["get_filesystem_path"] = &obe::animation::Animator::get_filesystem_path;
Expand All @@ -204,13 +195,11 @@ namespace obe::animation::bindings
bind_animator_state["set_paused"] = &obe::animation::AnimatorState::set_paused;
bind_animator_state["update"] = &obe::animation::AnimatorState::update;
bind_animator_state["set_target"] = sol::overload(
[](obe::animation::AnimatorState* self, obe::graphics::Sprite& sprite) -> void
{
[](obe::animation::AnimatorState* self, obe::graphics::Sprite& sprite) -> void {
return self->set_target(sprite);
},
[](obe::animation::AnimatorState* self, obe::graphics::Sprite& sprite,
obe::animation::AnimatorTargetScaleMode target_scale_mode) -> void
{
obe::animation::AnimatorTargetScaleMode target_scale_mode) -> void {
return self->set_target(sprite, target_scale_mode);
});
bind_animator_state["reset"] = &obe::animation::AnimatorState::reset;
Expand All @@ -220,8 +209,7 @@ namespace obe::animation::bindings
bind_animator_state["get_current_texture"]
= &obe::animation::AnimatorState::get_current_texture;
bind_animator_state["get_animator"]
= [](obe::animation::AnimatorState* self) -> const obe::animation::Animator*
{
= [](obe::animation::AnimatorState* self) -> const obe::animation::Animator* {
return &self->get_animator();
};
}
Expand Down Expand Up @@ -411,71 +399,59 @@ namespace obe::animation::bindings
sol::table animation_namespace = state["obe"]["animation"].get<sol::table>();
animation_namespace["Tween"] = sol::overload(
[](obe::graphics::Color from, obe::graphics::Color to,
obe::time::TimeUnit duration) -> ValueTweening<obe::graphics::Color>
{
obe::time::TimeUnit duration) -> ValueTweening<obe::graphics::Color> {
return obe::animation::ValueTweening<obe::graphics::Color>(from, to, duration);
},
[](obe::graphics::Color from, obe::graphics::Color to, obe::time::TimeUnit duration,
obe::animation::easing::EasingFunction easing)
-> ValueTweening<obe::graphics::Color>
{
-> ValueTweening<obe::graphics::Color> {
return obe::animation::ValueTweening<obe::graphics::Color>(
from, to, duration, easing);
},
[](obe::transform::UnitVector from, obe::transform::UnitVector to,
obe::time::TimeUnit duration) -> ValueTweening<obe::transform::UnitVector>
{
obe::time::TimeUnit duration) -> ValueTweening<obe::transform::UnitVector> {
return obe::animation::ValueTweening<obe::transform::UnitVector>(
from, to, duration);
},
[](obe::transform::UnitVector from, obe::transform::UnitVector to,
obe::time::TimeUnit duration, obe::animation::easing::EasingFunction easing)
-> ValueTweening<obe::transform::UnitVector>
{
-> ValueTweening<obe::transform::UnitVector> {
return obe::animation::ValueTweening<obe::transform::UnitVector>(
from, to, duration, easing);
},
[](obe::transform::Rect from, obe::transform::Rect to,
obe::time::TimeUnit duration) -> ValueTweening<obe::transform::Rect>
{
obe::time::TimeUnit duration) -> ValueTweening<obe::transform::Rect> {
return obe::animation::ValueTweening<obe::transform::Rect>(from, to, duration);
},
[](obe::transform::Rect from, obe::transform::Rect to, obe::time::TimeUnit duration,
obe::animation::easing::EasingFunction easing)
-> ValueTweening<obe::transform::Rect>
{
-> ValueTweening<obe::transform::Rect> {
return obe::animation::ValueTweening<obe::transform::Rect>(
from, to, duration, easing);
},
[](obe::collision::Trajectory from, obe::collision::Trajectory to,
obe::time::TimeUnit duration) -> ValueTweening<obe::collision::Trajectory>
{
obe::time::TimeUnit duration) -> ValueTweening<obe::collision::Trajectory> {
return obe::animation::ValueTweening<obe::collision::Trajectory>(
from, to, duration);
},
[](obe::collision::Trajectory from, obe::collision::Trajectory to,
obe::time::TimeUnit duration, obe::animation::easing::EasingFunction easing)
-> ValueTweening<obe::collision::Trajectory>
{
-> ValueTweening<obe::collision::Trajectory> {
return obe::animation::ValueTweening<obe::collision::Trajectory>(
from, to, duration, easing);
},
[](int from, int to, obe::time::TimeUnit duration) -> ValueTweening<int>
{
[](int from, int to, obe::time::TimeUnit duration) -> ValueTweening<int> {
return obe::animation::ValueTweening<int>(from, to, duration);
},
[](int from, int to, obe::time::TimeUnit duration,
obe::animation::easing::EasingFunction easing) -> ValueTweening<int>
{
obe::animation::easing::EasingFunction easing) -> ValueTweening<int> {
return obe::animation::ValueTweening<int>(from, to, duration, easing);
},
[](double from, double to, obe::time::TimeUnit duration) -> ValueTweening<double>
{
[](double from, double to, obe::time::TimeUnit duration) -> ValueTweening<double> {
return obe::animation::ValueTweening<double>(from, to, duration);
},
[](double from, double to, obe::time::TimeUnit duration,
obe::animation::easing::EasingFunction easing) -> ValueTweening<double>
{
obe::animation::easing::EasingFunction easing) -> ValueTweening<double> {
return obe::animation::ValueTweening<double>(from, to, duration, easing);
});
}
Expand Down
6 changes: 2 additions & 4 deletions src/Core/Bindings/obe/audio/Audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ namespace obe::audio::bindings
= audio_namespace.new_usertype<obe::audio::AudioManager>("AudioManager",
sol::call_constructor, sol::constructors<obe::audio::AudioManager()>());
bind_audio_manager["load"] = sol::overload(
[](obe::audio::AudioManager* self, const obe::system::Path& path) -> obe::audio::Sound
{
[](obe::audio::AudioManager* self, const obe::system::Path& path) -> obe::audio::Sound {
return self->load(path);
},
[](obe::audio::AudioManager* self, const obe::system::Path& path,
obe::audio::LoadPolicy load_policy) -> obe::audio::Sound
{
obe::audio::LoadPolicy load_policy) -> obe::audio::Sound {
return self->load(path, load_policy);
});
}
Expand Down
Loading

0 comments on commit ae767b0

Please sign in to comment.