VObject.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //-----------------------------------------------------------------------------
  2. // Verve
  3. // Copyright (C) - Violent Tulip
  4. //-----------------------------------------------------------------------------
  5. function VObject::OnAdd( %this )
  6. {
  7. // Fetch Parent.
  8. %parentObject = %this.getParent();
  9. %rootObject = %this.getRoot();
  10. if ( !%parentObject || ( %rootObject.getId() != $VerveEditor::Controller.getId() ) )
  11. {
  12. return true;
  13. }
  14. if ( !VerveEditorHistoryManager.Locked )
  15. {
  16. // Add History Item.
  17. %historyObject = new UndoScriptAction()
  18. {
  19. Class = "VerveEditorHistoryCreateObject";
  20. SuperClass = "VerveEditorHistoryObject";
  21. ActionName = "Create Object";
  22. // Store Object References.
  23. Parent = %parentObject;
  24. Object = %this;
  25. };
  26. }
  27. // Valid.
  28. return true;
  29. }
  30. function VObject::OnRemove( %this )
  31. {
  32. // Void.
  33. }
  34. function VObject::Delete( %this )
  35. {
  36. // Fetch Parent.
  37. %parentObject = %this.getParent();
  38. %rootObject = %this.getRoot();
  39. if ( !%parentObject || ( %rootObject.getId() != $VerveEditor::Controller.getId() ) )
  40. {
  41. // Callback.
  42. %this.OnRemove();
  43. // Not Editing, Delete.
  44. Parent::delete( %this );
  45. return;
  46. }
  47. if ( !VerveEditorHistoryManager.Locked )
  48. {
  49. // Add History Item.
  50. %historyObject = new UndoScriptAction()
  51. {
  52. Class = "VerveEditorHistoryDeleteObject";
  53. SuperClass = "VerveEditorHistoryObject";
  54. ActionName = "Delete Object";
  55. // Store Object References.
  56. Parent = %parentObject;
  57. Object = %this;
  58. };
  59. }
  60. // Callback.
  61. %this.OnRemove();
  62. // Detach Object.
  63. %parentObject.removeObject( %this );
  64. }
  65. function VObject::OnFieldChange( %this, %fieldName, %oldValue, %newValue )
  66. {
  67. if ( !VerveEditorHistoryManager.Locked )
  68. {
  69. // Add History Item.
  70. %historyObject = new UndoScriptAction()
  71. {
  72. Class = "VerveEditorHistoryChangeProperty";
  73. SuperClass = "VerveEditorHistoryObject";
  74. ActionName = "Change Property (" @ %fieldName @ ")";
  75. // Store References.
  76. Object = %this;
  77. FieldName = %fieldName;
  78. OldValue = %oldValue;
  79. NewValue = %newValue;
  80. };
  81. }
  82. }