ScreenLabel.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. require "Polycode/ScreenShape"
  2. class "ScreenLabel" (ScreenShape)
  3. function ScreenLabel:ScreenLabel(...)
  4. if type(arg[1]) == "table" and count(arg) == 1 then
  5. if ""..arg[1]:class() == "ScreenShape" 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.ScreenLabel(unpack(arg))
  19. Polycore.__ptr_lookup[self.__ptr] = self
  20. end
  21. end
  22. function ScreenLabel:addDropShadow(color, size, offsetX, offsetY)
  23. local retVal = Polycore.ScreenLabel_addDropShadow(self.__ptr, color.__ptr, size, offsetX, offsetY)
  24. end
  25. function ScreenLabel:setText(newText)
  26. local retVal = Polycore.ScreenLabel_setText(self.__ptr, newText.__ptr)
  27. end
  28. function ScreenLabel:getText()
  29. local retVal = Polycore.ScreenLabel_getText(self.__ptr)
  30. if retVal == nil then return nil end
  31. if Polycore.__ptr_lookup[retVal] ~= nil then
  32. return Polycore.__ptr_lookup[retVal]
  33. else
  34. Polycore.__ptr_lookup[retVal] = String("__skip_ptr__")
  35. Polycore.__ptr_lookup[retVal].__ptr = retVal
  36. return Polycore.__ptr_lookup[retVal]
  37. end
  38. end
  39. function ScreenLabel:getLabel()
  40. local retVal = Polycore.ScreenLabel_getLabel(self.__ptr)
  41. if retVal == nil then return nil end
  42. if Polycore.__ptr_lookup[retVal] ~= nil then
  43. return Polycore.__ptr_lookup[retVal]
  44. else
  45. Polycore.__ptr_lookup[retVal] = Label("__skip_ptr__")
  46. Polycore.__ptr_lookup[retVal].__ptr = retVal
  47. return Polycore.__ptr_lookup[retVal]
  48. end
  49. end
  50. function ScreenLabel:__delete()
  51. Polycore.__ptr_lookup[self.__ptr] = nil
  52. Polycore.delete_ScreenLabel(self.__ptr)
  53. end