postFxEditor.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 PostFXEditor::refresh(%this)
  33. {
  34. PostEffectEditorList.clear();
  35. %count = PostFXManager.Count();
  36. for(%i=0; %i < %count; %i++)
  37. {
  38. %postEffect = PostFXManager.getKey(%i);
  39. if(%postEffect.isEnabled())
  40. PostEffectEditorList.addRow( %i, %postEffect.getName() );
  41. }
  42. }
  43. function PostFXEditor::apply(%this)
  44. {
  45. %count = PostFXManager.Count();
  46. for(%i=0; %i < %count; %i++)
  47. {
  48. %postEffect = PostFXManager.getKey(%i);
  49. if(isObject(%postEffect) && %postEffect.isMethod("applyFromPreset"))
  50. {
  51. %postEffect.applyFromPreset();
  52. }
  53. }
  54. }
  55. function PostFXEditor::revert(%this)
  56. {
  57. %targetPreset = $PostFXManager::currentPreset;
  58. if(%targetPreset $= "")
  59. %targetPreset = $PostFXManager::defaultPreset;
  60. PostFXManager::loadPresetHandler(%targetPreset);
  61. %this.refresh();
  62. PostEffectEditorInspector.clearFields();
  63. PostEffectEditorList.setSelectedRow(1);
  64. }
  65. function PostEffectEditorList::onSelect( %this, %id, %text )
  66. {
  67. PostEffectEditorInspector.clearFields();
  68. %postEffect = PostFXManager.getKey(%id);
  69. if(isObject(%postEffect) && %postEffect.isMethod("populatePostFXSettings"))
  70. {
  71. %postEffect.populatePostFXSettings();
  72. }
  73. }
  74. function PostFXEditor::addNewPostFXs(%this)
  75. {
  76. %rowIndex = PostFXEditorNewPFXList.getSelectedRow();
  77. %postFXName = PostFXEditorNewPFXList.getRowText(%rowIndex);
  78. %postFXName.enable();
  79. %this.refresh();
  80. %rowIndex = PostEffectEditorList.findTextIndex(%postFXName);
  81. PostEffectEditorList.setSelectedRow(%rowIndex);
  82. PostFXEditorNewPFXWindow.setHidden(true);
  83. }
  84. function PostFXEditor::removePostFX(%this)
  85. {
  86. %rowIndex = PostEffectEditorList.getSelectedRow();
  87. %postFXName = PostEffectEditorList.getRowText(%rowIndex);
  88. %postFXName.disable();
  89. %this.refresh();
  90. PostEffectEditorInspector.clearFields();
  91. PostEffectEditorList.setSelectedRow(1);
  92. }
  93. function editScenePostEffects(%scene)
  94. {
  95. if(EditorIsActive())
  96. PostFXEditor.editScenePostFXSettings();
  97. }
  98. function PostFXEditorNewPFXWindow::showDialog(%this)
  99. {
  100. %this.setHidden(false);
  101. PostFXEditorNewPFXWindow.selectWindow();
  102. PostFXEditorNewPFXList.clear();
  103. %count = PostFXManager.Count();
  104. for(%i=0; %i < %count; %i++)
  105. {
  106. %postEffect = PostFXManager.getKey(%i);
  107. if(!%postEffect.isEnabled())
  108. PostFXEditorNewPFXList.addRow( %i, %postEffect.getName() );
  109. }
  110. }