SceneLabel.lua 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. require "Polycode/SceneEntity"
  2. class "SceneLabel" (SceneEntity)
  3. function SceneLabel:SceneLabel(...)
  4. if type(arg[1]) == "table" and count(arg) == 1 then
  5. if ""..arg[1]:class() == "SceneEntity" then
  6. self.__ptr = arg[1].__ptr
  7. return
  8. end
  9. end
  10. for k,v in pairs(arg) do
  11. if type(v) == "table" then
  12. if v.__ptr ~= nil then
  13. arg[k] = v.__ptr
  14. end
  15. end
  16. end
  17. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  18. self.__ptr = Polycore.SceneLabel(unpack(arg))
  19. Polycore.__ptr_lookup[self.__ptr] = self
  20. end
  21. end
  22. function SceneLabel:testMouseCollision(x, y)
  23. local retVal = Polycore.SceneLabel_testMouseCollision(self.__ptr, x, y)
  24. return retVal
  25. end
  26. function SceneLabel:setText(newText)
  27. local retVal = Polycore.SceneLabel_setText(self.__ptr, newText.__ptr)
  28. end
  29. function SceneLabel:getLabel()
  30. local retVal = Polycore.SceneLabel_getLabel(self.__ptr)
  31. if retVal == nil then return nil end
  32. if Polycore.__ptr_lookup[retVal] ~= nil then
  33. return Polycore.__ptr_lookup[retVal]
  34. else
  35. Polycore.__ptr_lookup[retVal] = Label("__skip_ptr__")
  36. Polycore.__ptr_lookup[retVal].__ptr = retVal
  37. return Polycore.__ptr_lookup[retVal]
  38. end
  39. end
  40. function SceneLabel:Render()
  41. local retVal = Polycore.SceneLabel_Render(self.__ptr)
  42. end
  43. function SceneLabel:__delete()
  44. Polycore.__ptr_lookup[self.__ptr] = nil
  45. Polycore.delete_SceneLabel(self.__ptr)
  46. end