main.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 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. function Sandbox::create( %this )
  23. {
  24. // Load the preferences.
  25. %this.loadPreferences();
  26. // Load Sandbox scripts.
  27. exec( "./scripts/console.cs" );
  28. exec( "./scripts/toolbox.cs" );
  29. exec( "./scripts/customToolboxGui.cs" );
  30. exec( "./scripts/manipulation.cs" );
  31. exec( "./scripts/scene.cs" );
  32. exec( "./scripts/toys.cs" );
  33. // Load GUI profiles.
  34. exec("./gui/guiProfiles.cs");
  35. // Create the sandbox window.
  36. CreateSandboxWindow();
  37. // Load and configure the console.
  38. //Sandbox.add( TamlRead("./gui/ConsoleDialog.gui.taml") );
  39. //GlobalActionMap.bind( keyboard, "ctrl tilde", toggleConsole );
  40. // Load and configure the toolbox.
  41. Sandbox.add( TamlRead("./gui/ToolboxDialog.gui.taml") );
  42. // Load and configure the main overlay.
  43. Sandbox.add( TamlRead("./gui/MainOverlay.gui.taml") );
  44. // Scan for toys.
  45. scanForToys();
  46. // Initialize the toolbox.
  47. initializeToolbox();
  48. // Initialize the input controller.
  49. Sandbox.InputController.initialize();
  50. // Initialize the "cannot render" proxy.
  51. new RenderProxy(CannotRenderProxy)
  52. {
  53. Image = "Sandbox:CannotRender";
  54. };
  55. Sandbox.add( CannotRenderProxy );
  56. }
  57. //-----------------------------------------------------------------------------
  58. function Sandbox::destroy( %this )
  59. {
  60. // Save sandbox preferences.
  61. %this.savePreferences();
  62. // Unload the active toy.
  63. unloadToy();
  64. // Destroy the sandbox window.
  65. destroySandboxWindow();
  66. // Destroy the sandbox scene.
  67. destroySandboxScene();
  68. }
  69. //-----------------------------------------------------------------------------
  70. function Sandbox::loadPreferences( %this )
  71. {
  72. // Load the default preferences.
  73. exec( "./scripts/sandboxPreferences.cs" );
  74. // Load the last session preferences if available.
  75. if ( isFile("preferences.cs") )
  76. exec( "preferences.cs" );
  77. }
  78. //-----------------------------------------------------------------------------
  79. function Sandbox::savePreferences( %this )
  80. {
  81. // Export only the sandbox preferences.
  82. export("$pref::Sandbox::*", "preferences.cs", false );
  83. export("$pref::Video::*", "preferences.cs", true );
  84. }