Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
4CS 3.34 KB | None | 0 0
  1. //------------------------------------------------------------------------------
  2. function createCanvas(%windowTitle)
  3. {
  4.    if ($isDedicated)
  5.    {
  6.       GFXInit::createNullDevice();
  7.       return true;
  8.    }
  9.  
  10.    // Create the Canvas
  11.    %foo = new GuiCanvas(Canvas);
  12.    
  13.    return true;
  14. }
  15.  
  16. //------------------------------------------------------------------------------
  17. // Check if a script file exists, compiled or not.
  18. function isScriptFile(%path)
  19. {
  20.    if( isFile(%path @ ".dso") || isFile(%path) )
  21.       return true;
  22.    
  23.    return false;
  24. }
  25.  
  26. //-----------------------------------------------------------------------------
  27. // The displayHelp, onStart, onExit and parseArgs function are overriden
  28. // by mod packages to get hooked into initialization and cleanup.
  29.  
  30. function onStart()
  31. {
  32.    // Default startup function
  33. }
  34.  
  35. function onExit()
  36. {
  37.    // OnExit is called directly from C++ code, whereas onStart is
  38.    // invoked at the end of this file.
  39. }
  40.  
  41. function compileFiles(%pattern)
  42. {  
  43.    echo("\n--------- Compiling Files ---------");
  44.    %path = filePath(%pattern);
  45.  
  46.    %saveDSO    = $Scripts::OverrideDSOPath;
  47.    %saveIgnore = $Scripts::ignoreDSOs;
  48.    
  49.    $Scripts::OverrideDSOPath  = %path;
  50.    $Scripts::ignoreDSOs       = false;
  51.    %mainCsFile = makeFullPath("main.cs");
  52.  
  53.    for (%file = findFirstFileMultiExpr(%pattern); %file !$= ""; %file = findNextFileMultiExpr(%pattern))
  54.    {
  55.       // we don't want to try and compile the primary main.cs
  56.       if(%mainCsFile !$= %file)      
  57.          compile(%file, true);
  58.    }
  59.    
  60.    $Scripts::OverrideDSOPath  = %saveDSO;
  61.    $Scripts::ignoreDSOs       = %saveIgnore;
  62.    
  63. }
  64.  
  65. package Help {
  66.    function onExit() {
  67.       // Override onExit when displaying help
  68.    }
  69. };
  70.  
  71. function displayHelp() {
  72.    activatePackage(Help);
  73.  
  74.       // Notes on logmode: console logging is written to console.log.
  75.       // -log 0 disables console logging.
  76.       // -log 1 appends to existing logfile; it also closes the file
  77.       // (flushing the write buffer) after every write.
  78.       // -log 2 overwrites any existing logfile; it also only closes
  79.       // the logfile when the application shuts down.  (default)
  80.  
  81.    error(
  82.       "Torque Demo command line options:\n"@
  83.       "  -log <logmode>         Logging behavior; see main.cs comments for details\n"@
  84.       "  -game <game_name>      Reset list of mods to only contain <game_name>\n"@
  85.       "  <game_name>            Works like the -game argument\n"@
  86.       "  -dir <dir_name>        Add <dir_name> to list of directories\n"@
  87.       "  -console               Open a separate console\n"@
  88.       "  -show <shape>          Deprecated\n"@
  89.       "  -jSave  <file_name>    Record a journal\n"@
  90.       "  -jPlay  <file_name>    Play back a journal\n"@
  91.       "  -jDebug <file_name>    Play back a journal and issue an int3 at the end\n"@
  92.       "  -help                  Display this help message\n"
  93.    );
  94. }
  95.  
  96. //------------------------------------------------------------------------------
  97. // Execute startup scripts for each mod, starting at base and working up
  98. function loadDir(%dir)
  99. {
  100.    pushback($userDirs, %dir, ";");
  101.  
  102.    if (isScriptFile(%dir @ "/main.cs"))
  103.    exec(%dir @ "/main.cs");
  104. }
  105.  
  106. function loadDirs(%dirPath)
  107. {
  108.    %dirPath = nextToken(%dirPath, token, ";");
  109.    if (%dirPath !$= "")
  110.       loadDirs(%dirPath);
  111.  
  112.    if(exec(%token @ "/main.cs") != true)
  113.    {
  114.       error("Error: Unable to find specified directory: " @ %token );
  115.       $dirCount--;
  116.    }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement