version.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. default:
  70. return "Torque Engine";
  71. };
  72. #endif
  73. }
  74. const char* getCompileTimeString()
  75. {
  76. return __DATE__ " at " __TIME__;
  77. }
  78. //----------------------------------------------------------------
  79. ConsoleFunctionGroupBegin( CompileInformation, "Functions to get version information about the current executable." );
  80. ConsoleFunction( getVersionNumber, S32, 1, 1, "Get the version of the engine build, as a string.\n\n"
  81. "@ingroup Debugging")
  82. {
  83. return getVersionNumber();
  84. }
  85. ConsoleFunction( getAppVersionNumber, S32, 1, 1, "Get the version of the application build, as a string.\n\n"
  86. "@ingroup Debugging")
  87. {
  88. return getAppVersionNumber();
  89. }
  90. ConsoleFunction( getVersionString, const char*, 1, 1, "Get the version of the engine build, as a human readable string.\n\n"
  91. "@ingroup Debugging")
  92. {
  93. return getVersionString();
  94. }
  95. ConsoleFunction( getAppVersionString, const char*, 1, 1, "Get the version of the aplication, as a human readable string.\n\n"
  96. "@ingroup Debugging")
  97. {
  98. return getAppVersionString();
  99. }
  100. ConsoleFunction( getEngineName, const char*, 1, 1, "Get the name of the engine product that this is running from, as a string.\n\n"
  101. "@ingroup Debugging")
  102. {
  103. return getEngineProductString();
  104. }
  105. ConsoleFunction( getCompileTimeString, const char*, 1, 1, "Get the time of compilation.\n\n"
  106. "@ingroup Debugging")
  107. {
  108. return getCompileTimeString();
  109. }
  110. ConsoleFunction( getBuildString, const char*, 1, 1, "Get the type of build, \"Debug\" or \"Release\".\n\n"
  111. "@ingroup Debugging")
  112. {
  113. #ifdef TORQUE_DEBUG
  114. return "Debug";
  115. #else
  116. return "Release";
  117. #endif
  118. }
  119. ConsoleFunctionGroupEnd( CompileInformation );
  120. ConsoleFunction(isDemo, bool, 1, 1, "")
  121. {
  122. #ifdef TORQUE_DEMO
  123. return true;
  124. #else
  125. return false;
  126. #endif
  127. }
  128. ConsoleFunction(isWebDemo, bool, 1, 1, "")
  129. {
  130. #ifdef TORQUE_DEMO
  131. return Platform::getWebDeployment();
  132. #else
  133. return false;
  134. #endif
  135. }