123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- function NewParticleEmitterDialog::init(%this, %width, %height)
- {
- //Get the dialog contents
- %window = %this.getObject(0);
- %content = %window.getObject(0);
- //Create the file text box
- %form = new GuiGridCtrl()
- {
- class = "EditorForm";
- extent = %width SPC %height;
- cellSizeX = %width;
- cellSizeY = 50;
- };
- %form.addListener(%this);
- %item = %form.addFormItem("Image Asset", %width SPC 30);
- %this.imageDropDown = %form.createDropDownItem(%item);
- %this.populateImageDropDown();
- %item = %form.addFormItem("Animation Asset", %width SPC 30);
- %this.animationDropDown = %form.createDropDownItem(%item);
- %this.populateAnimationDropDown();
- %item = %form.addFormItem("Emitter Name", %width SPC 30);
- %this.emitterNameBox = %form.createTextEditItem(%item);
- %this.emitterNameBox.Command = %this.getId() @ ".Validate();";
- %content.add(%form);
- %this.cancelButton = new GuiButtonCtrl()
- {
- HorizSizing = "right";
- VertSizing = "bottom";
- Position = "478 160";
- Extent = "100 30";
- Text = "Cancel";
- Command = %this.getID() @ ".onClose();";
- };
- ThemeManager.setProfile(%this.cancelButton, "buttonProfile");
- %this.createButton = new GuiButtonCtrl()
- {
- HorizSizing = "right";
- VertSizing = "bottom";
- Position = "588 158";
- Extent = "100 34";
- Text = "Create";
- Command = %this.getID() @ ".onCreate();";
- Active = false;
- };
- ThemeManager.setProfile(%this.createButton, "primaryButtonProfile");
- %content.add(%this.cancelButton);
- %content.add(%this.createButton);
- }
- function NewParticleEmitterDialog::Validate(%this)
- {
- %this.createButton.active = false;
- %emitterName = %this.emitterNameBox.getText();
- %imageAssetID = %this.imageDropDown.getText();
- %animationAssetID = %this.animationDropDown.getText();
- if(%emitterName !$= "" && (%imageAssetID $= "" || %animationAssetID $= ""))
- {
- %this.createButton.active = true;
- return true;
- }
- return false;
- }
- function NewParticleEmitterDialog::onClose(%this)
- {
- Canvas.popDialog(%this);
- }
- function NewParticleEmitterDialog::onCreate(%this)
- {
- if(%this.validate())
- {
- %emitter = %this.parentAsset.createEmitter();
- if(%emitter != 0)
- {
- %emitter.setEmitterName(%this.emitterNameBox.getText());
- if(%this.imageDropDown.getText() !$= "")
- {
- %emitter.setImage(%this.imageDropDown.getText());
- }
- else
- {
- %emitter.setAnimation(%this.animationDropDown.getText());
- }
- %i = %this.parentAsset.getEmitterCount();
- AssetAdmin.Inspector.titleDropDown.addItem("Emitter:" SPC %emitter.EmitterName);
- AssetAdmin.Inspector.titleDropDown.setItemColor(%i, ThemeManager.activeTheme.color5);
- AssetAdmin.Inspector.titleDropDown.setSelected(%i);
- AssetAdmin.Inspector.onChooseParticleAsset(%this.parentAsset);
- }
- else
- {
- warn("NewParticleEmitterDialog::onCreate - No emitter created!");
- }
- %this.onClose();
- }
- }
- function NewParticleEmitterDialog::onDropDownClosed(%this, %dropDown)
- {
- if(%dropDown == %this.imageDropDown && %dropDown.getText() !$= "")
- {
- %this.animationDropDown.setSelected(0);
- }
- else if(%dropDown == %this.animationDropDown && %dropDown.getText() !$= "")
- {
- %this.imageDropDown.setSelected(0);
- }
- %this.validate();
- }
- function NewParticleEmitterDialog::populateImageDropDown(%this)
- {
- %this.imageDropDown.clearItems();
- %query = new AssetQuery();
- AssetDatabase.findAllAssets(%query);
- AssetDatabase.findAssetType(%query, "ImageAsset", true);
- for(%i = 0; %i < %query.getCount(); %i++)
- {
- %assetID = %query.getAsset(%i);
- if(!AssetDatabase.isAssetInternal(%assetID))
- {
- %this.imageDropDown.addItem(%assetID);
- }
- }
- %query.delete();
- %this.imageDropDown.sortByText();
- %this.imageDropDown.insertItem(0, "");
- %this.imageDropDown.setSelected(0);
- }
- function NewParticleEmitterDialog::populateAnimationDropDown(%this)
- {
- %this.animationDropDown.clearItems();
- %query = new AssetQuery();
- AssetDatabase.findAllAssets(%query);
- AssetDatabase.findAssetType(%query, "AnimationAsset", true);
- for(%i = 0; %i < %query.getCount(); %i++)
- {
- %assetID = %query.getAsset(%i);
- if(!AssetDatabase.isAssetInternal(%assetID))
- {
- %this.animationDropDown.addItem(%assetID);
- }
- }
- %query.delete();
- %this.animationDropDown.sortByText();
- %this.animationDropDown.insertItem(0, "");
- %this.animationDropDown.setSelected(0);
- }
|