VerveCinematicController.tscript 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //-----------------------------------------------------------------------------
  2. // Verve
  3. // Copyright (C) 2014 - Violent Tulip
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to
  7. // deal in the Software without restriction, including without limitation the
  8. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. // sell copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. // IN THE SOFTWARE.
  22. //-----------------------------------------------------------------------------
  23. $Verve::CinematicController = 0;
  24. //-----------------------------------------------------------------------------
  25. function Verve::GetCinematicController()
  26. {
  27. // Valid Controller?
  28. if ( !isObject( $Verve::CinematicController ) )
  29. {
  30. $Verve::CinematicController = new VController()
  31. {
  32. Class = "VerveCinematicController";
  33. };
  34. }
  35. // Return Controller.
  36. return $Verve::CinematicController;
  37. }
  38. //-----------------------------------------------------------------------------
  39. // Verve::PlayCinematic( "sequences/BurgFlythrough.vsf" );
  40. function Verve::PlayCinematic( %sequenceFile )
  41. {
  42. if ( !isFile( %sequenceFile ) )
  43. {
  44. error ( "Verve::PlayCinematic() - Invalid Sequence File." );
  45. return 0;
  46. }
  47. // Fetch Controller.
  48. %controller = Verve::GetCinematicController();
  49. // Already Playing?
  50. if ( %controller.isPlaying() )
  51. {
  52. error ( "Verve::PlayCinematic() - Cinematic in Progress." );
  53. return 0;
  54. }
  55. // Load the Sequence.
  56. if ( !%controller.readFile( %sequenceFile ) )
  57. {
  58. return 0;
  59. }
  60. // Stop Input.
  61. if ( isObject( moveMap ) )
  62. {
  63. moveMap.pop();
  64. }
  65. // Store the Current Gui.
  66. $Verve::StoredGui = Canvas.getContent();
  67. // Valid GUI?
  68. if ( !isObject( VerveCinematicGui ) )
  69. {
  70. // Execute GUI Script.
  71. exec( "art/gui/VerveCinematic.gui" );
  72. }
  73. // Set the Cinematic Gui.
  74. Canvas.setContent( VerveCinematicGui );
  75. // Clear First Person.
  76. %clientCount = ClientGroup.getCount();
  77. for ( %i = 0; %i < %clientCount; %i++ )
  78. {
  79. // Fetch Client.
  80. %clientConnection = ClientGroup.getObject( %i );
  81. // Store Status.
  82. %clientConnection.FirstPerson = %clientConnection.isFirstPerson();
  83. // Clear.
  84. %clientConnection.setFirstPerson( false );
  85. }
  86. // Play the Sequence.
  87. %controller.play();
  88. // Return the Controller.
  89. return %controller;
  90. }
  91. //-----------------------------------------------------------------------------
  92. function VerveCinematicController::onStop( %this )
  93. {
  94. // Reset First Person Status.
  95. %clientCount = ClientGroup.getCount();
  96. for ( %i = 0; %i < %clientCount; %i++ )
  97. {
  98. // Fetch Client.
  99. %clientConnection = ClientGroup.getObject( %i );
  100. // Reset.
  101. %clientConnection.setFirstPerson( %clientConnection.FirstPerson );
  102. }
  103. // Reset the Canvas.
  104. Canvas.setContent( $Verve::StoredGui );
  105. // Resume Input.
  106. if ( isObject( moveMap ) )
  107. {
  108. moveMap.push();
  109. }
  110. }