startupGui.tscript 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. // StartupGui is the splash screen that initially shows when the game is loaded
  24. //-----------------------------------------------------------------------------
  25. function loadStartup()
  26. {
  27. // The index of the current splash screen
  28. $StartupIdx = 0;
  29. // A list of the splash screens and logos
  30. // to cycle through. Note that they have to
  31. // be in consecutive numerical order
  32. StartupGui.bitmap[0] = "UI:backgrounddark_image";
  33. StartupGui.logo[0] = "UI:Torque_3D_logo_alt_image";
  34. StartupGui.logoPos[0] = "220 120";
  35. StartupGui.logoExtent[0] = "360 360";
  36. // Call the next() function to set our firt
  37. // splash screen
  38. StartupGui.next();
  39. StartupGui.setFirstResponder();
  40. // Play our startup sound
  41. //SFXPlayOnce(AudioGui, "data/ui/sounds/startup");//SFXPlay(startsnd);
  42. }
  43. function StartupGui::onWake(%this)
  44. {
  45. $enableDirectInput = "1";
  46. activateDirectInput();
  47. }
  48. function StartupGui::click(%this)
  49. {
  50. %this.done = true;
  51. %this.onDone();
  52. }
  53. function StartupGui::next(%this)
  54. {
  55. // Set us to a blank screen while we load the next one
  56. Canvas.setContent(BlankGui);
  57. // Set our bitmap and reset the done variable
  58. %this.setBitmap(%this.bitmap[$StartupIdx]);
  59. %this.done = false;
  60. // If we have a logo then set it
  61. if (isObject(%this->StartupLogo))
  62. {
  63. if (%this.logo[$StartupIdx] !$= "")
  64. {
  65. %this->StartupLogo.setBitmap(%this.logo[$StartupIdx]);
  66. if (%this.logoPos[$StartupIdx] !$= "")
  67. {
  68. %logoPosX = getWord(%this.logoPos[$StartupIdx], 0);
  69. %logoPosY = getWord(%this.logoPos[$StartupIdx], 1);
  70. %this->StartupLogo.setPosition(%logoPosX, %logoPosY);
  71. }
  72. if (%this.logoExtent[$StartupIdx] !$= "")
  73. %this->StartupLogo.setExtent(%this.logoExtent[$StartupIdx]);
  74. %this->StartupLogo.setVisible(true);
  75. }
  76. else
  77. %this->StartupLogo.setVisible(false);
  78. }
  79. // If we have a secondary logo then set it
  80. if (isObject(%this->StartupLogoSecondary))
  81. {
  82. if (%this.seclogo[$StartupIdx] !$= "")
  83. {
  84. %this->StartupLogoSecondary.setBitmap(%this.seclogo[$StartupIdx]);
  85. if (%this.seclogoPos[$StartupIdx] !$= "")
  86. {
  87. %logoPosX = getWord(%this.seclogoPos[$StartupIdx], 0);
  88. %logoPosY = getWord(%this.seclogoPos[$StartupIdx], 1);
  89. %this->StartupLogoSecondary.setPosition(%logoPosX, %logoPosY);
  90. }
  91. if (%this.seclogoExtent[$StartupIdx] !$= "")
  92. %this->StartupLogoSecondary.setExtent(%this.seclogoExtent[$StartupIdx]);
  93. %this->StartupLogoSecondary.setVisible(true);
  94. }
  95. else
  96. %this->StartupLogoSecondary.setVisible(false);
  97. }
  98. // Increment our screen index for the next screen
  99. $StartupIdx++;
  100. // Set the Canvas to our newly updated GuiFadeinBitmapCtrl
  101. Canvas.setContent(%this);
  102. }
  103. function StartupGui::onDone(%this)
  104. {
  105. // If we have been tagged as done decide if we need
  106. // to end or cycle to the next one
  107. if (%this.done)
  108. {
  109. // See if we have a valid bitmap for the next screen
  110. if (%this.bitmap[$StartupIdx] $= "")
  111. {
  112. // Clear our data and load the main menu
  113. %this.done = true;
  114. // NOTE: Don't ever ever delete yourself during a callback from C++.
  115. //
  116. // Deleting the whole gui itself seems a bit excessive, what if we want
  117. // to return to the startup gui at a later time? Any bitmaps set on
  118. // the controls should be unloaded automatically if the control is not
  119. // awake, if this is not the case then that's what needs to be fixed.
  120. //%this.delete();
  121. //BlankGui.delete();
  122. //flushTextureCache();
  123. %mainMenuGUI = ProjectSettings.value("UI/mainMenuName");
  124. if (isObject( %mainMenuGUI ))
  125. Canvas.setContent( %mainMenuGUI );
  126. }
  127. else
  128. {
  129. // We do have a bitmap so cycle to it
  130. %this.next();
  131. }
  132. }
  133. if ($startGUIEditor) fastLoadGUIEdit(1);
  134. if ($startWorldEditor) fastLoadWorldEdit(1);
  135. }