uianimation.d 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. module scripts.lua.uianimation;
  2. import bindbc.lua;
  3. import raylib;
  4. import variables;
  5. import graphics.effects;
  6. import std.conv;
  7. import system.debugwriteln;
  8. import system.config;
  9. import std.string;
  10. import std.algorithm;
  11. import system.init;
  12. import graphics.playback;
  13. import std.file;
  14. import graphics.collision;
  15. import audio.sfx;
  16. extern (C) nothrow int luaL_loadUIAnimation(lua_State *L) {
  17. try {
  18. //loads from uifx folder HPFF files, in which png textures are stored
  19. framesUI = loadAnimationFramesUI(to!string(luaL_checkstring(L, 1)), to!string(luaL_checkstring(L, 2)));
  20. if (lua_gettop(L) == 3) {
  21. frameDuration = luaL_checknumber(L, 3);
  22. debug debugWriteln("frameDuration: ", frameDuration);
  23. }
  24. } catch (Exception e) {
  25. debugWriteln(e.msg);
  26. }
  27. return 0;
  28. }
  29. extern (C) nothrow int luaL_playUIAnimation(lua_State *L) {
  30. debug debugWriteln("Animation UI start");
  31. try {
  32. if (lua_gettop(L) == 0) playAnimation = true;
  33. else {
  34. debugWriteln("animationAlpha before reconfig: ", animationAlpha);
  35. animationAlpha = luaL_checkinteger(L, 1).to!ubyte;
  36. debugWriteln("animationAlpha after reconfig: ", animationAlpha);
  37. playAnimation = true;
  38. }
  39. } catch (Exception e) {
  40. debugWriteln(e.msg);
  41. }
  42. return 0;
  43. }
  44. extern (C) nothrow int luaL_stopUIAnimation(lua_State *L) {
  45. playAnimation = false;
  46. debug debugWriteln("Animation UI stop");
  47. frameDuration = 0.016f;
  48. currentFrame = 0;
  49. return 0;
  50. }
  51. extern (C) nothrow int luaL_unloadUIAnimation(lua_State *L) {
  52. try {
  53. for (int i = 0; i < framesUI.length; i++) {
  54. UnloadTexture(framesUI[i]);
  55. }
  56. } catch (Exception e) {
  57. debugWriteln(e.msg);
  58. }
  59. return 0;
  60. }