version.cpp 4.2 KB

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