ソースを参照

Internal Change to Editor Dialogs

This is an internal change to make working with editor dialogs (which are created purely programmatically) a little easier. Specifically it handles the deletion of the dialog automatically when it's closed and removes a lot of repetitive code.
Peter Robinson 2 年 前
コミット
f4314d2ca0

+ 0 - 6
editor/AssetAdmin/NewAnimationAssetDialog.cs

@@ -154,12 +154,6 @@ function NewAnimationAssetDialog::Validate(%this)
 	return true;
 }
 
-function NewAnimationAssetDialog::onClose(%this)
-{
-	Canvas.popDialog(%this);
-	%this.postEvent("DialogClosed", %this);
-}
-
 function NewAnimationAssetDialog::onCreate(%this)
 {
 	if(%this.validate())

+ 0 - 16
editor/AssetAdmin/NewAssetButton.cs

@@ -18,7 +18,6 @@ function NewAssetButton::onNewImageAsset(%this)
 		dialogText = "New Image Asset";
 	};
 	%dialog.init(%width, %height);
-	%this.startListening(%dialog);
 
 	Canvas.pushDialog(%dialog);
 }
@@ -36,7 +35,6 @@ function NewAssetButton::onNewAnimationAsset(%this)
 		dialogText = "New Animation Asset";
 	};
 	%dialog.init(%width, %height);
-	%this.startListening(%dialog);
 
 	Canvas.pushDialog(%dialog);
 }
@@ -54,7 +52,6 @@ function NewAssetButton::onNewParticleAsset(%this)
 		dialogText = "New Particle Asset";
 	};
 	%dialog.init(%width, %height);
-	%this.startListening(%dialog);
 
 	Canvas.pushDialog(%dialog);
 }
@@ -72,7 +69,6 @@ function NewAssetButton::onNewFontAsset(%this)
 		dialogText = "New Bitmap Font Asset";
 	};
 	%dialog.init(%width, %height);
-	%this.startListening(%dialog);
 
 	Canvas.pushDialog(%dialog);
 }
@@ -90,18 +86,6 @@ function NewAssetButton::onNewAudioAsset(%this)
 		dialogText = "New Audio Asset";
 	};
 	%dialog.init(%width, %height);
-	%this.startListening(%dialog);
 
 	Canvas.pushDialog(%dialog);
 }
-
-function NewAssetButton::onDialogClosed(%this, %dialog)
-{
-	%this.dialog = %dialog;
-	%this.schedule(100, "deleteDialog");
-}
-
-function NewAssetButton::deleteDialog(%this)
-{
-	%this.dialog.delete();
-}

+ 0 - 6
editor/AssetAdmin/NewAudioAssetDialog.cs

@@ -146,12 +146,6 @@ function NewAudioAssetDialog::Validate(%this)
 	return true;
 }
 
-function NewAudioAssetDialog::onClose(%this)
-{
-	Canvas.popDialog(%this);
-	%this.postEvent("DialogClosed", %this);
-}
-
 function NewAudioAssetDialog::onCreate(%this)
 {
 	if(%this.validate())

+ 0 - 6
editor/AssetAdmin/NewFontAssetDialog.cs

@@ -146,12 +146,6 @@ function NewFontAssetDialog::Validate(%this)
 	return true;
 }
 
-function NewFontAssetDialog::onClose(%this)
-{
-	Canvas.popDialog(%this);
-	%this.postEvent("DialogClosed", %this);
-}
-
 function NewFontAssetDialog::onCreate(%this)
 {
 	if(%this.validate())

+ 0 - 6
editor/AssetAdmin/NewImageAssetDialog.cs

@@ -153,12 +153,6 @@ function NewImageAssetDialog::Validate(%this)
 	return true;
 }
 
-function NewImageAssetDialog::onClose(%this)
-{
-	Canvas.popDialog(%this);
-	%this.postEvent("DialogClosed", %this);
-}
-
 function NewImageAssetDialog::onCreate(%this)
 {
 	if(%this.validate())

+ 0 - 6
editor/AssetAdmin/NewParticleAssetDialog.cs

@@ -165,12 +165,6 @@ function NewParticleAssetDialog::Validate(%this)
 	return true;
 }
 
-function NewParticleAssetDialog::onClose(%this)
-{
-	Canvas.popDialog(%this);
-	%this.postEvent("DialogClosed", %this);
-}
-
 function NewParticleAssetDialog::onCreate(%this)
 {
 	if(%this.validate())

+ 5 - 0
editor/EditorCore/EditorCore.cs

@@ -524,4 +524,9 @@ function EditorCore::alert(%this, %text)
 {
 	//Eventually this should open a dialog with this text. For now we'll dump it into the console and hope the user notices.
 	warn(%text);
+}
+
+function EditorCore::deleteDialog(%this)
+{
+	%this.dialog.delete();
 }

+ 8 - 1
editor/EditorCore/EditorDialog.cs

@@ -65,7 +65,14 @@ function EditorDialog::onAdd(%this)
 	%this.window.add(%this.content);
 }
 
+function EditorDialog::onClose(%this)
+{
+	Canvas.popDialog(%this);
+	EditorCore.dialog = %this;
+	EditorCore.schedule(100, "deleteDialog");
+}
+
 function EditorDialogWindow::onClose(%this)
 {
-	%this.dialog.call("onClose");
+	%this.dialog.onClose();
 }

+ 0 - 11
editor/EditorCore/scripts/EditorProjectSelector.cs

@@ -204,17 +204,6 @@ function EditorProjectSelector::onNewProject(%this)
 	Canvas.pushDialog(%dialog);
 }
 
-function EditorProjectSelector::onDialogClosed(%this, %dialog)
-{
-	%this.dialog = %dialog;
-	%this.schedule(100, "deleteDialog");
-}
-
-function EditorProjectSelector::deleteDialog(%this)
-{
-	%this.dialog.delete();
-}
-
 function EditorProjectSelector::onProjectCreated(%this, %folder)
 {
 	%this.scanFolder(%folder);

+ 0 - 6
editor/EditorCore/scripts/NewProjectDialog.cs

@@ -115,12 +115,6 @@ function NewProjectDialog::Validate(%this)
 	return true;
 }
 
-function NewProjectDialog::onClose(%this)
-{
-	Canvas.popDialog(%this);
-	%this.postEvent("DialogClosed", %this);
-}
-
 function NewProjectDialog::onCreate(%this)
 {
 	if(%this.validate())

+ 0 - 1
editor/GuiEditor/GuiEditor.cs

@@ -299,7 +299,6 @@ function GuiEditor::SaveGuiAs(%this)
         defaultModule = %this.module;
 	};
 	%dialog.init(%width, %height);
-	%this.startListening(%dialog);
 
 	Canvas.pushDialog(%dialog);
 }

+ 0 - 6
editor/GuiEditor/scripts/GuiEditorSaveGuiDialog.cs

@@ -166,12 +166,6 @@ function GuiEditorSaveGuiDialog::Validate(%this)
 	return true;
 }
 
-function GuiEditorSaveGuiDialog::onClose(%this)
-{
-	Canvas.popDialog(%this);
-	%this.postEvent("DialogClosed", %this);
-}
-
 function GuiEditorSaveGuiDialog::onSave(%this)
 {
 	if(%this.validate())

+ 0 - 6
editor/ProjectManager/scripts/EditModuleDialog.cs

@@ -115,12 +115,6 @@ function EditModuleDialog::Validate(%this)
 	return true;
 }
 
-function EditModuleDialog::onClose(%this)
-{
-	Canvas.popDialog(%this);
-	%this.postEvent("DialogClosed", %this);
-}
-
 function EditModuleDialog::onSave(%this)
 {
 	if(%this.validate())

+ 0 - 6
editor/ProjectManager/scripts/NewDeclaredAssetDialog.cs

@@ -90,12 +90,6 @@ function NewDeclaredAssetDialog::Validate(%this)
 	return true;
 }
 
-function NewDeclaredAssetDialog::onClose(%this)
-{
-	Canvas.popDialog(%this);
-	%this.postEvent("DialogClosed", %this);
-}
-
 function NewDeclaredAssetDialog::onCreate(%this)
 {
 	if(%this.validate())

+ 0 - 6
editor/ProjectManager/scripts/NewDependencyDialog.cs

@@ -125,12 +125,6 @@ function NewDependencyDialog::Validate(%this)
 	return true;
 }
 
-function NewDependencyDialog::onClose(%this)
-{
-	Canvas.popDialog(%this);
-	%this.postEvent("DialogClosed", %this);
-}
-
 function NewDependencyDialog::onCreate(%this)
 {
 	if(%this.validate())

+ 0 - 6
editor/ProjectManager/scripts/NewModuleDialog.cs

@@ -108,12 +108,6 @@ function NewModuleDialog::Validate(%this)
 	return true;
 }
 
-function NewModuleDialog::onClose(%this)
-{
-	Canvas.popDialog(%this);
-	%this.postEvent("DialogClosed", %this);
-}
-
 function NewModuleDialog::onCreate(%this)
 {
 	if(%this.validate())

+ 0 - 11
editor/ProjectManager/scripts/ProjectGamePanel.cs

@@ -90,17 +90,6 @@ function ProjectGamePanel::createNewModule(%this)
 	Canvas.pushDialog(%dialog);
 }
 
-function ProjectGamePanel::onDialogClosed(%this, %dialog)
-{
-	%this.dialog = %dialog;
-	%this.schedule(100, "deleteDialog");
-}
-
-function ProjectGamePanel::deleteDialog(%this)
-{
-	%this.dialog.delete();
-}
-
 function ProjectGamePanel::onModuleCreated(%this, %data)
 {
 	if(%data.template !$= "none")

+ 0 - 11
editor/ProjectManager/scripts/ProjectModuleAssetList.cs

@@ -151,14 +151,3 @@ function ProjectModuleAssetList::onRemoveAsset(%this, %asset)
 	%this.activeModule.save();
 	%this.schedule(50, "show", %this.activeModule);
 }
-
-function ProjectModuleAssetList::onDialogClosed(%this, %dialog)
-{
-	%this.dialog = %dialog;
-	%this.schedule(100, "deleteDialog");
-}
-
-function ProjectModuleAssetList::deleteDialog(%this)
-{
-	%this.dialog.delete();
-}

+ 0 - 11
editor/ProjectManager/scripts/ProjectModuleDependList.cs

@@ -151,17 +151,6 @@ function ProjectModuleDependList::onRemoveDepend(%this, %data)
 	%this.schedule(50, "show", %this.activeModule);
 }
 
-function ProjectModuleDependList::onDialogClosed(%this, %dialog)
-{
-	%this.dialog = %dialog;
-	%this.schedule(100, "deleteDialog");
-}
-
-function ProjectModuleDependList::deleteDialog(%this)
-{
-	%this.dialog.delete();
-}
-
 function ProjectModuleDependList::buildPossibleDependList(%this)
 {
 	%allModules = ModuleDatabase.findModules(false);