From 398a5655f42378176a1e596af6d399a180ffb733 Mon Sep 17 00:00:00 2001
From: Kae <80987908+Novaenia@users.noreply.github.com>
Date: Mon, 3 Jul 2023 08:51:42 +1000
Subject: Add Drawable <-> Lua conversion to LuaGameConverters
---
.../game/scripting/StarLuaAnimationComponent.hpp | 28 ++--------------------
1 file changed, 2 insertions(+), 26 deletions(-)
(limited to 'source/game/scripting/StarLuaAnimationComponent.hpp')
diff --git a/source/game/scripting/StarLuaAnimationComponent.hpp b/source/game/scripting/StarLuaAnimationComponent.hpp
index 76c3f28..6d94466 100644
--- a/source/game/scripting/StarLuaAnimationComponent.hpp
+++ b/source/game/scripting/StarLuaAnimationComponent.hpp
@@ -61,36 +61,12 @@ LuaAnimationComponent::LuaAnimationComponent() {
animationCallbacks.registerCallback("clearDrawables", [this]() {
m_drawables.clear();
});
- animationCallbacks.registerCallback("addDrawable", [this](LuaTable const& drawableTable, Maybe renderLayerName) {
+ animationCallbacks.registerCallback("addDrawable", [this](Drawable drawable, Maybe renderLayerName) {
Maybe renderLayer;
if (renderLayerName)
renderLayer = parseRenderLayer(*renderLayerName);
- Color color = drawableTable.get>("color").value(Color::White);
-
- Drawable drawable;
- if (auto line = drawableTable.get>("line"))
- drawable = Drawable::makeLine(line.take(), drawableTable.get("width"), color);
- else if (auto poly = drawableTable.get>("poly"))
- drawable = Drawable::makePoly(poly.take(), color);
- else if (auto image = drawableTable.get>("image"))
- drawable = Drawable::makeImage(image.take(), 1.0f / TilePixels, drawableTable.get>("centered").value(true), Vec2F(), color);
- else
- throw LuaAnimationComponentException("Drawable table must have 'line', 'poly', or 'image'");
-
- if (auto transformation = drawableTable.get>("transformation"))
- drawable.transform(*transformation);
- if (auto rotation = drawableTable.get>("rotation"))
- drawable.rotate(*rotation);
- if (drawableTable.get("mirrored"))
- drawable.scale(Vec2F(-1, 1));
- if (auto scale = drawableTable.get>("scale"))
- drawable.scale(*scale);
- if (auto position = drawableTable.get>("position"))
- drawable.translate(*position);
-
- drawable.fullbright = drawableTable.get("fullbright");
-
+ drawable.scale(1.0f / TilePixels);
m_drawables.append({move(drawable), renderLayer});
});
animationCallbacks.registerCallback("clearLightSources", [this]() {
--
cgit v1.2.3