main.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. // Constants for referencing video resolution preferences
  23. $WORD::RES_X = 0;
  24. $WORD::RES_Y = 1;
  25. $WORD::FULLSCREEN = 2;
  26. $WORD::BITDEPTH = 3;
  27. $WORD::REFRESH = 4;
  28. $WORD::AA = 5;
  29. //---------------------------------------------------------------------------------------------
  30. // CorePackage
  31. // Adds functionality for this mod to some standard functions.
  32. //---------------------------------------------------------------------------------------------
  33. package CorePackage
  34. {
  35. //---------------------------------------------------------------------------------------------
  36. // onStart
  37. // Called when the engine is starting up. Initializes this mod.
  38. //---------------------------------------------------------------------------------------------
  39. function onStart()
  40. {
  41. Parent::onStart();
  42. // Here is where we will do the video device stuff, so it overwrites the defaults
  43. // First set the PCI device variables (yes AGP/PCI-E works too)
  44. $isFirstPersonVar = 1;
  45. // Uncomment to enable AdvancedLighting on the Mac (T3D 2009 Beta 3)
  46. //$pref::machax::enableAdvancedLighting = true;
  47. // Uncomment to disable ShaderGen, useful when debugging
  48. //$ShaderGen::GenNewShaders = false;
  49. // Uncomment to dump disassembly for any shader that is compiled to disk.
  50. // These will appear as shadername_dis.txt in the same path as the
  51. // hlsl or glsl shader.
  52. //$gfx::disassembleAllShaders = true;
  53. // Uncomment useNVPerfHud to allow you to start up correctly
  54. // when you drop your executable onto NVPerfHud
  55. //$Video::useNVPerfHud = true;
  56. // Uncomment these to allow you to force your app into using
  57. // a specific pixel shader version (0 is for fixed function)
  58. //$pref::Video::forcePixVersion = true;
  59. //$pref::Video::forcedPixVersion = 0;
  60. if ($platform $= "macos")
  61. $pref::Video::displayDevice = "OpenGL";
  62. //else
  63. //$pref::Video::displayDevice = "D3D9";
  64. // Initialise stuff.
  65. exec("./scripts/client/core.cs");
  66. initializeCore();
  67. exec("./scripts/client/client.cs");
  68. exec("./scripts/server/server.cs");
  69. exec("./scripts/gui/guiTreeViewCtrl.cs");
  70. exec("./scripts/gui/messageBoxes/messageBox.ed.cs");
  71. echo(" % - Initialized Core");
  72. }
  73. //---------------------------------------------------------------------------------------------
  74. // onExit
  75. // Called when the engine is shutting down. Shutdowns this mod.
  76. //---------------------------------------------------------------------------------------------
  77. function onExit()
  78. {
  79. // Shutdown stuff.
  80. shutdownCore();
  81. Parent::onExit();
  82. }
  83. function loadKeybindings()
  84. {
  85. $keybindCount = 0;
  86. // Load up the active projects keybinds.
  87. if(isFunction("setupKeybinds"))
  88. setupKeybinds();
  89. }
  90. //---------------------------------------------------------------------------------------------
  91. // displayHelp
  92. // Prints the command line options available for this mod.
  93. //---------------------------------------------------------------------------------------------
  94. function displayHelp() {
  95. // Let the parent do its stuff.
  96. Parent::displayHelp();
  97. error("Core Mod options:\n" @
  98. " -fullscreen Starts game in full screen mode\n" @
  99. " -windowed Starts game in windowed mode\n" @
  100. " -autoVideo Auto detect video, but prefers OpenGL\n" @
  101. " -openGL Force OpenGL acceleration\n" @
  102. " -directX Force DirectX acceleration\n" @
  103. " -voodoo2 Force Voodoo2 acceleration\n" @
  104. " -prefs <configFile> Exec the config file\n");
  105. }
  106. //---------------------------------------------------------------------------------------------
  107. // parseArgs
  108. // Parses the command line arguments and processes those valid for this mod.
  109. //---------------------------------------------------------------------------------------------
  110. function parseArgs()
  111. {
  112. // Let the parent grab the arguments it wants first.
  113. Parent::parseArgs();
  114. // Loop through the arguments.
  115. for (%i = 1; %i < $Game::argc; %i++)
  116. {
  117. %arg = $Game::argv[%i];
  118. %nextArg = $Game::argv[%i+1];
  119. %hasNextArg = $Game::argc - %i > 1;
  120. switch$ (%arg)
  121. {
  122. case "-fullscreen":
  123. $cliFullscreen = true;
  124. $argUsed[%i]++;
  125. case "-windowed":
  126. $cliFullscreen = false;
  127. $argUsed[%i]++;
  128. case "-openGL":
  129. $pref::Video::displayDevice = "OpenGL";
  130. $argUsed[%i]++;
  131. case "-directX":
  132. $pref::Video::displayDevice = "D3D";
  133. $argUsed[%i]++;
  134. case "-voodoo2":
  135. $pref::Video::displayDevice = "Voodoo2";
  136. $argUsed[%i]++;
  137. case "-autoVideo":
  138. $pref::Video::displayDevice = "";
  139. $argUsed[%i]++;
  140. case "-prefs":
  141. $argUsed[%i]++;
  142. if (%hasNextArg) {
  143. exec(%nextArg, true, true);
  144. $argUsed[%i+1]++;
  145. %i++;
  146. }
  147. else
  148. error("Error: Missing Command Line argument. Usage: -prefs <path/script.cs>");
  149. }
  150. }
  151. }
  152. };
  153. activatePackage(CorePackage);