startupGui.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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.bitmap0 = "art/gui/background";
  33. StartupGui.logo0 = "art/gui/Torque-3D-logo";
  34. StartupGui.logoPos0 = "178 251";
  35. StartupGui.logoExtent0 = "443 139";
  36. // Call the next() function to set our firt
  37. // splash screen
  38. StartupGui.next();
  39. // Play our startup sound
  40. //SFXPlayOnce(AudioGui, "art/sound/gui/startup");//SFXPlay(startsnd);
  41. }
  42. function StartupGui::onWake(%this)
  43. {
  44. $enableDirectInput = "1";
  45. activateDirectInput();
  46. }
  47. function StartupGui::click(%this)
  48. {
  49. %this.done = true;
  50. %this.onDone();
  51. }
  52. function StartupGui::next(%this)
  53. {
  54. // Set us to a blank screen while we load the next one
  55. Canvas.setContent(BlankGui);
  56. // Set our bitmap and reset the done variable
  57. %this.setBitmap(getVariable(%this @ ".bitmap" @ $StartupIdx));
  58. %this.done = false;
  59. // If we have a logo then set it
  60. if (isObject(%this->StartupLogo))
  61. {
  62. if (getVariable(%this @ ".logo" @ $StartupIdx) !$= "")
  63. {
  64. %this->StartupLogo.setBitmap(getVariable(%this @ ".logo" @ $StartupIdx));
  65. if (getVariable(%this @ ".logoPos" @ $StartupIdx) !$= "")
  66. {
  67. %logoPosX = getWord(getVariable(%this @ ".logoPos" @ $StartupIdx), 0);
  68. %logoPosY = getWord(getVariable(%this @ ".logoPos" @ $StartupIdx), 1);
  69. %this->StartupLogo.setPosition(%logoPosX, %logoPosY);
  70. }
  71. if (getVariable(%this @ ".logoExtent" @ $StartupIdx) !$= "")
  72. %this->StartupLogo.setExtent(getVariable(%this @ ".logoExtent" @ $StartupIdx));
  73. %this->StartupLogo.setVisible(true);
  74. }
  75. else
  76. %this->StartupLogo.setVisible(false);
  77. }
  78. // If we have a secondary logo then set it
  79. if (isObject(%this->StartupLogoSecondary))
  80. {
  81. if (getVariable(%this @ ".seclogo" @ $StartupIdx) !$= "")
  82. {
  83. %this->StartupLogoSecondary.setBitmap(getVariable(%this @ ".seclogo" @ $StartupIdx));
  84. if (getVariable(%this @ ".seclogoPos" @ $StartupIdx) !$= "")
  85. {
  86. %logoPosX = getWord(getVariable(%this @ ".seclogoPos" @ $StartupIdx), 0);
  87. %logoPosY = getWord(getVariable(%this @ ".seclogoPos" @ $StartupIdx), 1);
  88. %this->StartupLogoSecondary.setPosition(%logoPosX, %logoPosY);
  89. }
  90. if (getVariable(%this @ ".seclogoExtent" @ $StartupIdx) !$= "")
  91. %this->StartupLogoSecondary.setExtent(getVariable(%this @ ".seclogoExtent" @ $StartupIdx));
  92. %this->StartupLogoSecondary.setVisible(true);
  93. }
  94. else
  95. %this->StartupLogoSecondary.setVisible(false);
  96. }
  97. // Increment our screen index for the next screen
  98. $StartupIdx++;
  99. // Set the Canvas to our newly updated GuiFadeinBitmapCtrl
  100. Canvas.setContent(%this);
  101. }
  102. function StartupGui::onDone(%this)
  103. {
  104. // If we have been tagged as done decide if we need
  105. // to end or cycle to the next one
  106. if (%this.done)
  107. {
  108. // See if we have a valid bitmap for the next screen
  109. if (getVariable(%this @ ".bitmap" @ $StartupIdx) $= "")
  110. {
  111. // Clear our data and load the main menu
  112. %this.done = true;
  113. // NOTE: Don't ever ever delete yourself during a callback from C++.
  114. //
  115. // Deleting the whole gui itself seems a bit excessive, what if we want
  116. // to return to the startup gui at a later time? Any bitmaps set on
  117. // the controls should be unloaded automatically if the control is not
  118. // awake, if this is not the case then that's what needs to be fixed.
  119. //%this.delete();
  120. //BlankGui.delete();
  121. //flushTextureCache();
  122. loadMainMenu();
  123. }
  124. else
  125. {
  126. // We do have a bitmap so cycle to it
  127. %this.next();
  128. }
  129. }
  130. }