platform_ScriptBinding.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. /*! @defgroup PlatformFunctions Platform
  23. @ingroup TorqueScriptFunctions
  24. @{
  25. */
  26. /*! Use the setMouseLock function to un/lock the mouse.
  27. @param isLocked A boolean value.
  28. @return No return value
  29. */
  30. ConsoleFunctionWithDocs( setMouseLock, ConsoleVoid, 2, 2, ( isLocked ))
  31. {
  32. Platform::setMouseLock(dAtob(argv[1]));
  33. }
  34. //-----------------------------------------------------------------------------
  35. /*! Use the getRealTime function to the computer time in milliseconds.
  36. @return Returns the current real time in milliseconds.
  37. @sa getSimTime
  38. */
  39. ConsoleFunctionWithDocs( getRealTime, ConsoleInt, 1, 1, ())
  40. {
  41. return Platform::getRealMilliseconds();
  42. }
  43. //-----------------------------------------------------------------------------
  44. /*! Get the local time
  45. @return the local time formatted as: monthday/month/year hour/minute/second
  46. */
  47. ConsoleFunctionWithDocs( getLocalTime, ConsoleString, 1, 1, ())
  48. {
  49. char* buf = Con::getReturnBuffer(128);
  50. Platform::LocalTime lt;
  51. Platform::getLocalTime(lt);
  52. dSprintf(buf, 128, "%d/%d/%d %02d:%02d:%02d",
  53. lt.monthday,
  54. lt.month + 1,
  55. lt.year + 1900,
  56. lt.hour,
  57. lt.min,
  58. lt.sec);
  59. return buf;
  60. }
  61. /*! Use the getClipboard function to get the contents of the GUI clipboard.
  62. @return Returns a string equal to the current contents of the copy the clipboard, or a NULL strain if the copy clipboard is empty.
  63. @sa setClipboard
  64. */
  65. ConsoleFunctionWithDocs( getClipboard, ConsoleString, 1, 1, ())
  66. {
  67. return Platform::getClipboard();
  68. };
  69. /*! Use the setClipboard function to Set value on clipboard to string.
  70. @param string The new value to place in the GUI clipboard.
  71. @return Returns true if successful, false otherwise.
  72. @sa getClipoard")
  73. */
  74. ConsoleFunctionWithDocs( setClipboard, ConsoleBool, 2, 2, ( string ))
  75. {
  76. return Platform::setClipboard(argv[1]);
  77. };
  78. /*! Creates a UUID string.
  79. */
  80. ConsoleFunctionWithDocs( createUUID, ConsoleString, 1, 1, () )
  81. {
  82. return Platform::createUUID();
  83. }
  84. /*! @} */ // group PlatformFunctions