System.hx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. package hxd;
  2. enum Platform {
  3. IOS;
  4. Android;
  5. WebGL;
  6. PC;
  7. Console;
  8. FlashPlayer;
  9. }
  10. enum SystemValue {
  11. IsTouch;
  12. IsWindowed;
  13. IsMobile;
  14. }
  15. enum KeyboardLayout {
  16. QWERTY;
  17. AZERTY;
  18. QWERTZ;
  19. QZERTY;
  20. Unknown;
  21. }
  22. class System {
  23. public static var width(get,never) : Int;
  24. public static var height(get, never) : Int;
  25. public static var lang(get, never) : String;
  26. public static var platform(get, never) : Platform;
  27. public static var screenDPI(get,never) : Float;
  28. /**
  29. Sets current cursor and can be replaced by custom function to manually operate displayed cursor.
  30. When called, it should call `hxd.System.setNativeCursor` and pass desired `hxd.Cursor` to it.
  31. **/
  32. public static var setCursor : Cursor -> Void = setNativeCursor;
  33. /**
  34. Can be used to temporarly disable infinite loop check
  35. **/
  36. public static var allowTimeout(get, set) : Bool;
  37. /**
  38. If you have a time consuming calculus that might trigger a timeout, you can either disable timeouts with [allowTimeout] or call timeoutTick() frequently.
  39. **/
  40. public static function timeoutTick() : Void {
  41. }
  42. static var loopFunc : Void -> Void;
  43. public static function getCurrentLoop() : Void -> Void {
  44. return loopFunc;
  45. }
  46. public static function setLoop( f : Void -> Void ) : Void {
  47. loopFunc = f;
  48. }
  49. public static function start( callb : Void -> Void ) : Void {
  50. }
  51. /**
  52. Sets currently shown cursor.
  53. This method is designated to be used by custom `hxd.System.setCursor`.
  54. Calling it outside of automated Interactive cursor update system leads to undefined behavior, and not advised.
  55. **/
  56. public static function setNativeCursor( c : Cursor ) : Void {
  57. }
  58. public static function getDeviceName() : String {
  59. return "Unknown";
  60. }
  61. public static function getDefaultFrameRate() : Float {
  62. return 60.;
  63. }
  64. public static function getValue( s : SystemValue ) : Bool {
  65. return false;
  66. }
  67. public static function exit() : Void {
  68. }
  69. public static function openURL( url : String ) : Void {}
  70. public static function setClipboardText( text : String ) : Bool {
  71. return false;
  72. }
  73. public static function getClipboardText() : String {
  74. return null;
  75. }
  76. public static function getLocale() : String {
  77. return "en_EN";
  78. }
  79. public static function getKeyboardLayout() : KeyboardLayout {
  80. return Unknown;
  81. }
  82. public static dynamic function onKeyboardLayoutChange() : Void {}
  83. // getters
  84. static function get_width() : Int return 0;
  85. static function get_height() : Int return 0;
  86. static function get_lang() : String return "en";
  87. static function get_platform() : Platform return PC;
  88. static function get_screenDPI() : Int return 72;
  89. static function get_allowTimeout() return false;
  90. static function set_allowTimeout(b) return false;
  91. }