postFxEditor.tscript 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. function PostFXEditor::onDialogPush( %this )
  2. {
  3. //Apply the settings to the controls
  4. postVerbose("% - PostFX Editor - Loading GUI.");
  5. %this.refresh();
  6. PostEffectEditorList.setSelectedById( 1 );
  7. }
  8. function PostFXEditor::onDialogPop( %this )
  9. {
  10. //Always change the manager target back to the scene's just to be save when done editing
  11. $PostFXManager::currentPreset = $Client::LevelAsset.getPostFXPresetPath();
  12. PostFXManager.loadPresetHandler($PostFXManager::currentPreset);
  13. PostFXEditorWindow.text = "PostFX Editor";
  14. }
  15. function PostFXEditor::editScenePostFXSettings( %this )
  16. {
  17. $PostFXManager::currentPreset = $Client::LevelAsset.getPostFXPresetPath();
  18. Canvas.pushDialog(%this);
  19. PostFXEditorWindow.text = "PostFX Editor - " @ getScene(0).getName();
  20. PostFXEditorActionButton.text = "Revert";
  21. PostFXEditorActionButton.command = "PostFXEditor.revert();";
  22. }
  23. function PostFXEditor::editDefaultPostFXSettings( %this )
  24. {
  25. $PostFXManager::currentPreset = $PostFXManager::defaultPreset;
  26. PostFXManager.loadPresetHandler($PostFXManager::currentPreset);
  27. Canvas.pushDialog(%this);
  28. PostFXEditorWindow.text = "PostFX Editor - Default Config";
  29. PostFXEditorActionButton.text = "Save";
  30. PostFXEditorActionButton.command = "PostFXManager::savePresetHandler($PostFXManager::defaultPreset);";
  31. }
  32. function PostEffectEditorInspector::refresh(%this)
  33. {
  34. PostFXEditor.refresh();
  35. }
  36. function PostFXEditor::refresh(%this)
  37. {
  38. %selectedItem = PostEffectEditorList.getSelectedRow();
  39. PostEffectEditorList.clear();
  40. %count = PostFXManager.Count();
  41. for(%i=0; %i < %count; %i++)
  42. {
  43. %postEffect = PostFXManager.getKey(%i);
  44. if(%postEffect.isEnabled())
  45. PostEffectEditorList.addRow( %i, %postEffect.getName() );
  46. }
  47. PostEffectEditorList.setSelectedRow(%selectedItem);
  48. }
  49. function PostFXEditor::apply(%this)
  50. {
  51. %count = PostFXManager.Count();
  52. for(%i=0; %i < %count; %i++)
  53. {
  54. %postEffect = PostFXManager.getKey(%i);
  55. if(isObject(%postEffect) && %postEffect.isMethod("applyFromPreset"))
  56. {
  57. %postEffect.applyFromPreset();
  58. }
  59. }
  60. }
  61. function PostFXEditor::revert(%this)
  62. {
  63. %targetPreset = $PostFXManager::currentPreset;
  64. if(%targetPreset $= "")
  65. %targetPreset = $PostFXManager::defaultPreset;
  66. PostFXManager::loadPresetHandler(%targetPreset);
  67. %this.refresh();
  68. PostEffectEditorInspector.clearFields();
  69. PostEffectEditorList.setSelectedRow(1);
  70. }
  71. function PostEffectEditorList::onSelect( %this, %id, %text )
  72. {
  73. PostEffectEditorInspector.clearFields();
  74. %postEffect = PostFXManager.getKey(%id);
  75. if(isObject(%postEffect) && %postEffect.isMethod("populatePostFXSettings"))
  76. {
  77. %postEffect.populatePostFXSettings();
  78. }
  79. }
  80. function PostFXEditor::addNewPostFXs(%this)
  81. {
  82. %rowIndex = PostFXEditorNewPFXList.getSelectedRow();
  83. %postFXName = PostFXEditorNewPFXList.getRowText(%rowIndex);
  84. %postFXName.enable();
  85. %this.refresh();
  86. %rowIndex = PostEffectEditorList.findTextIndex(%postFXName);
  87. PostEffectEditorList.setSelectedRow(%rowIndex);
  88. PostFXEditorNewPFXWindow.setHidden(true);
  89. }
  90. function PostFXEditor::removePostFX(%this)
  91. {
  92. %rowIndex = PostEffectEditorList.getSelectedRow();
  93. %postFXName = PostEffectEditorList.getRowText(%rowIndex);
  94. %postFXName.disable();
  95. %this.refresh();
  96. PostEffectEditorInspector.clearFields();
  97. PostEffectEditorList.setSelectedRow(1);
  98. }
  99. function editScenePostEffects(%scene)
  100. {
  101. if(EditorIsActive())
  102. PostFXEditor.editScenePostFXSettings();
  103. }
  104. function PostFXEditorNewPFXWindow::showDialog(%this)
  105. {
  106. %this.setHidden(false);
  107. PostFXEditorNewPFXWindow.selectWindow();
  108. PostFXEditorNewPFXList.clear();
  109. %count = PostFXManager.Count();
  110. for(%i=0; %i < %count; %i++)
  111. {
  112. %postEffect = PostFXManager.getKey(%i);
  113. if(!%postEffect.isEnabled())
  114. PostFXEditorNewPFXList.addRow( %i, %postEffect.getName() );
  115. }
  116. }