version.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 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. #include "platform/platform.h"
  23. #include "app/version.h"
  24. #include "console/console.h"
  25. #include "console/engineAPI.h"
  26. static const U32 csgVersionNumber = TORQUE_GAME_ENGINE;
  27. static const U32 appVersionNumber = TORQUE_APP_VERSION;
  28. U32 getVersionNumber()
  29. {
  30. return csgVersionNumber;
  31. }
  32. U32 getAppVersionNumber()
  33. {
  34. return appVersionNumber;
  35. }
  36. const char* getVersionString()
  37. {
  38. return TORQUE_GAME_ENGINE_VERSION_STRING;
  39. }
  40. const char* getAppVersionString()
  41. {
  42. return TORQUE_APP_VERSION_STRING;
  43. }
  44. /// TGE 0001
  45. /// TGEA 0002
  46. /// TGB 0003
  47. /// TGEA 360 0004
  48. /// TGE WII 0005
  49. /// Torque 3D 0006
  50. /// Torque 3D MIT 0007
  51. const char* getEngineProductString()
  52. {
  53. #ifndef TORQUE_ENGINE_PRODUCT
  54. return "Torque Engine";
  55. #else
  56. switch (TORQUE_ENGINE_PRODUCT)
  57. {
  58. case 0001:
  59. return "Torque Game Engine";
  60. case 0002:
  61. return "Torque Game Engine Advanced";
  62. case 0003:
  63. return "Torque 2D";
  64. case 0004:
  65. return "Torque 360";
  66. case 0005:
  67. return "Torque for Wii";
  68. case 0006:
  69. return "Torque 3D";
  70. case 0007:
  71. return "Torque 3D MIT";
  72. case 0010:
  73. return "Ueberengine";
  74. default:
  75. return "Torque Engine";
  76. };
  77. #endif
  78. }
  79. const char* getCompileTimeString()
  80. {
  81. return __DATE__ " at " __TIME__;
  82. }
  83. //----------------------------------------------------------------
  84. ConsoleFunctionGroupBegin( CompileInformation, "Functions to get version information about the current executable." );
  85. DefineConsoleFunction( getVersionNumber, S32, (), , "Get the version of the engine build, as a string.\n\n"
  86. "@ingroup Debugging")
  87. {
  88. return getVersionNumber();
  89. }
  90. DefineConsoleFunction( getAppVersionNumber, S32, (), , "Get the version of the application build, as a string.\n\n"
  91. "@ingroup Debugging")
  92. {
  93. return getAppVersionNumber();
  94. }
  95. DefineConsoleFunction( getVersionString, const char*, (), , "Get the version of the engine build, as a human readable string.\n\n"
  96. "@ingroup Debugging")
  97. {
  98. return getVersionString();
  99. }
  100. DefineConsoleFunction( getAppVersionString, const char*, (), , "Get the version of the aplication build, as a human readable string.\n\n"
  101. "@ingroup Debugging")
  102. {
  103. return getAppVersionString();
  104. }
  105. DefineConsoleFunction( getEngineName, const char*, (), , "Get the name of the engine product that this is running from, as a string.\n\n"
  106. "@ingroup Debugging")
  107. {
  108. return getEngineProductString();
  109. }
  110. DefineConsoleFunction( getCompileTimeString, const char*, (), , "Get the time of compilation.\n\n"
  111. "@ingroup Debugging")
  112. {
  113. return getCompileTimeString();
  114. }
  115. DefineConsoleFunction( getBuildString, const char*, (), , "Get the type of build, \"Debug\" or \"Release\".\n\n"
  116. "@ingroup Debugging")
  117. {
  118. #ifdef TORQUE_DEBUG
  119. return "Debug";
  120. #else
  121. return "Release";
  122. #endif
  123. }
  124. ConsoleFunctionGroupEnd( CompileInformation );