DeleteAssetDialog.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. function DeleteAssetDialog::init(%this, %width, %height)
  2. {
  3. //Get the dialog contents
  4. %window = %this.getObject(0);
  5. %content = %window.getObject(0);
  6. %this.feedback = new GuiControl()
  7. {
  8. HorizSizing = "right";
  9. VertSizing = "bottom";
  10. Position = "12 12";
  11. Extent = (%width - 24) SPC 70;
  12. text = "Whoa there! Once you delete this asset, it's long gone! There's no undo. Are you sure you want to move forward?";
  13. textWrap = true;
  14. };
  15. ThemeManager.setProfile(%this.feedback, "infoProfile");
  16. %content.add(%this.feedback);
  17. //Create the file text box
  18. %form = new GuiGridCtrl()
  19. {
  20. class = "EditorForm";
  21. extent = %width SPC %height;
  22. Position = "0 80";
  23. cellSizeX = %width / 2;
  24. cellSizeY = 50;
  25. };
  26. %form.addListener(%this);
  27. %item = %form.addFormItem("Delete Dependencies", %width SPC 30);
  28. %this.deleteDependenaciesBox = %form.createCheckboxItem(%item);
  29. %this.deleteDependenaciesBox.textExtent = (%width / 2) SPC "30";
  30. %item = %form.addFormItem("Delete Loose Files", %width SPC 30);
  31. %this.deleteLooseFilesBox = %form.createCheckboxItem(%item);
  32. %this.deleteLooseFilesBox.textExtent = (%width / 2) SPC "30";
  33. %content.add(%form);
  34. %this.cancelButton = new GuiButtonCtrl()
  35. {
  36. HorizSizing = "right";
  37. VertSizing = "bottom";
  38. Position = "478 160";
  39. Extent = "100 30";
  40. Text = "Cancel";
  41. Command = %this.getID() @ ".onClose();";
  42. };
  43. ThemeManager.setProfile(%this.cancelButton, "buttonProfile");
  44. %this.deleteButton = new GuiButtonCtrl()
  45. {
  46. HorizSizing = "right";
  47. VertSizing = "bottom";
  48. Position = "588 158";
  49. Extent = "100 34";
  50. Text = "Delete";
  51. Command = %this.getID() @ ".onDelete();";
  52. };
  53. ThemeManager.setProfile(%this.deleteButton, "primaryButtonProfile");
  54. %content.add(%this.cancelButton);
  55. %content.add(%this.deleteButton);
  56. }
  57. function DeleteAssetDialog::onClose(%this)
  58. {
  59. Canvas.popDialog(%this);
  60. }
  61. function DeleteAssetDialog::onDelete(%this)
  62. {
  63. %assetID = %this.doomedAsset.getAssetId();
  64. %deleteDependants = %this.deleteDependenaciesBox.getStateOn();
  65. //Remove the asset...
  66. AssetDatabase.deleteAsset(%assetID, %this.deleteLooseFilesBox.getStateOn(), %deleteDependants);
  67. //Remove the button, but we don't know who has it. So just try them all...
  68. %killedAnImage = AssetAdmin.Dictionary["ImageAsset"].removeButton(%assetID);
  69. %killedAnAnimation = AssetAdmin.Dictionary["AnimationAsset"].removeButton(%assetID);
  70. AssetAdmin.Dictionary["ParticleAsset"].removeButton(%assetID);
  71. AssetAdmin.Dictionary["FontAsset"].removeButton(%assetID);
  72. AssetAdmin.Dictionary["AudioAsset"].removeButton(%assetID);
  73. if(%killedAnImage && %deleteDependants)
  74. {
  75. AssetAdmin.Dictionary["AnimationAsset"].reload();
  76. AssetAdmin.Dictionary["FontAsset"].reload();
  77. }
  78. if((%killedAnImage || %killedAnAnimation) && %deleteDependants)
  79. {
  80. AssetAdmin.Dictionary["ParticleAsset"].reload();
  81. }
  82. AssetAdmin.inspector.hideInspector();
  83. AssetAdmin.AssetScene.clear(true);
  84. AssetAdmin.audioPlayButtonContainer.setVisible(false);
  85. AssetAdmin.AssetWindow.setVisible(false);
  86. %this.onClose();
  87. }