#include "StarCameraLuaBindings.hpp" #include "StarLuaConverters.hpp" #include "StarWorldCamera.hpp" #include "StarRoot.hpp" namespace Star { LuaCallbacks LuaBindings::makeCameraCallbacks(WorldCamera* camera) { LuaCallbacks callbacks; callbacks.registerCallbackWithSignature("position", bind(&WorldCamera::centerWorldPosition, camera)); callbacks.registerCallbackWithSignature("pixelRatio", bind(&WorldCamera::pixelRatio, camera)); callbacks.registerCallback("setPixelRatio", [camera](float pixelRatio, Maybe smooth) { if (smooth.value()) camera->setTargetPixelRatio(pixelRatio); else camera->setPixelRatio(pixelRatio); Root::singleton().configuration()->set("zoomLevel", pixelRatio); }); callbacks.registerCallbackWithSignature("screenSize", bind(&WorldCamera::screenSize, camera)); callbacks.registerCallbackWithSignature("worldScreenRect", bind(&WorldCamera::worldScreenRect, camera)); callbacks.registerCallbackWithSignature("worldTileRect", bind(&WorldCamera::worldTileRect, camera)); callbacks.registerCallbackWithSignature("tileMinScreen", bind(&WorldCamera::tileMinScreen, camera)); callbacks.registerCallbackWithSignature("screenToWorld", bind(&WorldCamera::screenToWorld, camera, _1)); callbacks.registerCallbackWithSignature("worldToScreen", bind(&WorldCamera::worldToScreen, camera, _1)); return callbacks; } }