BloodknightStudios

Untitled

Dec 2nd, 2015
261
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.74 KB | None | 0 0
  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.  
  23. // BKS debug trace(1) set to trace(0) to disable
  24. trace(1);
  25.  
  26. // Set the name of our application
  27. $appName = "Uebergame";
  28.  
  29. // The directory it is run from
  30. $defaultGame = "scripts";
  31.  
  32. // Set profile directory
  33. $Pref::Video::ProfilePath = "scripts/client/profile";
  34.  
  35. function createCanvas(%windowTitle)
  36. {
  37. if ($isDedicated)
  38. {
  39. GFXInit::createNullDevice();
  40. return true;
  41. }
  42.  
  43. // Create the Canvas
  44. %foo = new GuiCanvas(Canvas)
  45. {
  46. displayWindow = false;
  47. };
  48.  
  49. // Set the window title
  50. if (isObject(Canvas))
  51. Canvas.setWindowTitle($appName);
  52.  
  53. return true;
  54. }
  55.  
  56. // Display the optional commandline arguements
  57. $displayHelp = false;
  58.  
  59. // Use these to record and play back crashes
  60. //saveJournal("editorOnFileQuitCrash.jrn");
  61. //playJournal("editorOnFileQuitCrash.jrn", false);
  62.  
  63. //------------------------------------------------------------------------------
  64. // Check if a script file exists, compiled or not.
  65. function isScriptFile(%path)
  66. {
  67. if( isFile(%path @ ".dso") || isFile(%path) )
  68. return true;
  69.  
  70. return false;
  71. }
  72.  
  73. //------------------------------------------------------------------------------
  74. // Process command line arguments
  75. exec("scripts/parseArgs.cs");
  76.  
  77. $isDedicated = false;
  78. $dirCount = 2;
  79. $userDirs = $defaultGame @ ";art;levels";
  80.  
  81. // load tools scripts if we're a tool build
  82. if (isToolBuild())
  83. $userDirs = "tools;" @ $userDirs;
  84.  
  85.  
  86. // Parse the executable arguments with the standard
  87. // function from scripts/coremain.cs
  88. defaultParseArgs();
  89.  
  90.  
  91. if($dirCount == 0) {
  92. $userDirs = $defaultGame;
  93. $dirCount = 1;
  94. }
  95.  
  96. //-----------------------------------------------------------------------------
  97. // Display a splash window immediately to improve app responsiveness before
  98. // engine is initialized and main window created
  99. if (!$isDedicated)
  100. displaySplashWindow();
  101.  
  102.  
  103. //-----------------------------------------------------------------------------
  104. // The displayHelp, onStart, onExit and parseArgs function are overriden
  105. // by mod packages to get hooked into initialization and cleanup.
  106.  
  107. function onStart()
  108. {
  109. // Default startup function
  110. }
  111.  
  112. function onExit()
  113. {
  114. // OnExit is called directly from C++ code, whereas onStart is
  115. // invoked at the end of this file.
  116. }
  117.  
  118. function parseArgs()
  119. {
  120. // Here for mod override, the arguments have already
  121. // been parsed.
  122. }
  123.  
  124. function compileFiles(%pattern)
  125. {
  126. %path = filePath(%pattern);
  127.  
  128. %saveDSO = $Scripts::OverrideDSOPath;
  129. %saveIgnore = $Scripts::ignoreDSOs;
  130.  
  131. $Scripts::OverrideDSOPath = %path;
  132. $Scripts::ignoreDSOs = false;
  133. %mainCsFile = makeFullPath("main.cs");
  134.  
  135. for (%file = findFirstFileMultiExpr(%pattern); %file !$= ""; %file = findNextFileMultiExpr(%pattern))
  136. {
  137. // we don't want to try and compile the primary main.cs
  138. if(%mainCsFile !$= %file)
  139. compile(%file, true);
  140. }
  141.  
  142. $Scripts::OverrideDSOPath = %saveDSO;
  143. $Scripts::ignoreDSOs = %saveIgnore;
  144.  
  145. }
  146.  
  147. if($compileAll)
  148. {
  149. echo(" --- Compiling all files ---");
  150. compileFiles("*.cs");
  151. compileFiles("*.gui");
  152. compileFiles("*.ts");
  153. echo(" --- Exiting after compile ---");
  154. quit();
  155. }
  156.  
  157. if($compileTools)
  158. {
  159. echo(" --- Compiling tools scritps ---");
  160. compileFiles("tools/*.cs");
  161. compileFiles("tools/*.gui");
  162. compileFiles("tools/*.ts");
  163. echo(" --- Exiting after compile ---");
  164. quit();
  165. }
  166.  
  167. package Help {
  168. function onExit() {
  169. // Override onExit when displaying help
  170. }
  171. };
  172.  
  173. function displayHelp() {
  174. activatePackage(Help);
  175.  
  176. // Notes on logmode: console logging is written to console.log.
  177. // -log 0 disables console logging.
  178. // -log 1 appends to existing logfile; it also closes the file
  179. // (flushing the write buffer) after every write.
  180. // -log 2 overwrites any existing logfile; it also only closes
  181. // the logfile when the application shuts down. (default)
  182.  
  183. error(
  184. "Torque Demo command line options:\n"@
  185. " -log <logmode> Logging behavior; see main.cs comments for details\n"@
  186. " -game <game_name> Reset list of mods to only contain <game_name>\n"@
  187. " <game_name> Works like the -game argument\n"@
  188. " -dir <dir_name> Add <dir_name> to list of directories\n"@
  189. " -console Open a separate console\n"@
  190. " -show <shape> Deprecated\n"@
  191. " -jSave <file_name> Record a journal\n"@
  192. " -jPlay <file_name> Play back a journal\n"@
  193. " -jDebug <file_name> Play back a journal and issue an int3 at the end\n"@
  194. " -help Display this help message\n"
  195. );
  196. }
  197.  
  198.  
  199. //--------------------------------------------------------------------------
  200.  
  201. // Default to a new logfile each session.
  202. if( !$logModeSpecified )
  203. {
  204. if( $platform !$= "xbox" && $platform !$= "xenon" )
  205. setLogMode(6);
  206. }
  207.  
  208. // Get the first dir on the list, which will be the last to be applied... this
  209. // does not modify the list.
  210. nextToken($userDirs, currentMod, ";");
  211.  
  212. // Execute startup scripts for each mod, starting at base and working up
  213. exec("Scripts/coremain.cs"); // Execute coremain before anything else
  214.  
  215. echo("--------- Loading DIRS ---------");
  216. function loadDirs(%dirPath)
  217. {
  218. %dirPath = nextToken(%dirPath, token, ";");
  219. if (%dirPath !$= "")
  220. loadDirs(%dirPath);
  221.  
  222. if(exec(%token @ "/main.cs") != true)
  223. {
  224. error("Error: Unable to find specified directory: " @ %token );
  225. $dirCount--;
  226. }
  227. }
  228. loadDirs($userDirs);
  229. echo("");
  230.  
  231. if($dirCount == 0) {
  232. enableWinConsole(true);
  233. error("Error: Unable to load any specified directories");
  234. quit();
  235. }
  236. // Parse the command line arguments
  237. echo("--------- Parsing Arguments ---------");
  238. parseArgs();
  239.  
  240. // Either display the help message or startup the app.
  241. if ($displayHelp) {
  242. enableWinConsole(true);
  243. displayHelp();
  244. quit();
  245. }
  246. else {
  247. onStart();
  248. echo("Engine initialized...");
  249.  
  250. if( !$isDedicated )
  251. {
  252. // As we know at this point that the initial load is complete,
  253. // we can hide any splash screen we have, and show the canvas.
  254. // This keeps things looking nice, instead of having a blank window
  255. closeSplashWindow();
  256. Canvas.showWindow();
  257. }
  258.  
  259.  
  260. // Display an error message for unused arguments
  261. for ($i = 1; $i < $Game::argc; $i++) {
  262. if (!$argUsed[$i])
  263. error("Error: Unknown command line argument: " @ $Game::argv[$i]);
  264. }
  265.  
  266. // Automatically start up the appropriate eidtor, if any
  267. if ($startWorldEditor) {
  268. Canvas.setCursor("DefaultCursor");
  269. Canvas.setContent(EditorChooseLevelGui);
  270. } else if ($startGUIEditor) {
  271. Canvas.setCursor("DefaultCursor");
  272. Canvas.setContent(EditorChooseGUI);
  273. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment