/// <summary> /// When the user clicks export, display an output filename dialog box and save /// when the appropriate button is pressed /// </summary> /// <param name="skin">UI Skin.</param> void exportPexClicked(Skin skin) { var canvas = entity.scene.createEntity("save-dialog").addComponent(new UICanvas()); var dialog = canvas.stage.addElement(new Dialog("Output Filename", skin)); var contentTable = dialog.getContentTable(); contentTable.add("Filename: ").left(); contentTable.row(); var outField = new TextField("output.pex", skin); contentTable.add(outField).center(); var buttonTable = dialog.getButtonTable(); var cancelButton = new TextButton("Cancel", skin); var okButton = new TextButton("OK", skin); cancelButton.onClicked += butt => { entity.scene.findEntity("save-dialog").destroy(); }; okButton.onClicked += butt => { var outFilename = outField.getText(); if (outFilename.Length > 0) { var exporter = new PexExporter(); exporter.export(_particleEmitterConfig, outFilename); } entity.scene.findEntity("save-dialog").destroy(); }; dialog.addButton(okButton); dialog.addButton(cancelButton); dialog.setMovable(true); dialog.setResizable(true); dialog.setPosition((Screen.width - dialog.getWidth()) / 2f, (Screen.height - dialog.getHeight()) / 2f); var uiCanvas = entity.scene.createEntity("particles-ui").addComponent(new UICanvas()); }
/// <summary> /// When the user clicks export, display an output filename dialog box and save /// when the appropriate button is pressed /// </summary> /// <param name="skin">UI Skin.</param> void ExportPexClicked(Skin skin) { var canvas = Entity.Scene.CreateEntity("save-dialog").AddComponent(new UICanvas()); var dialog = canvas.Stage.AddElement(new Dialog("Output Filename", skin)); var contentTable = dialog.GetContentTable(); contentTable.Add("Filename: ").Left(); contentTable.Row(); var outField = new TextField("output.pex", skin); contentTable.Add(outField).Center(); var buttonTable = dialog.GetButtonTable(); var cancelButton = new TextButton("Cancel", skin); var okButton = new TextButton("OK", skin); cancelButton.OnClicked += butt => { Entity.Scene.FindEntity("save-dialog").Destroy(); }; okButton.OnClicked += butt => { var outFilename = outField.GetText(); if (outFilename.Length > 0) { var exporter = new PexExporter(); exporter.Export(_particleEmitterConfig, outFilename); } Entity.Scene.FindEntity("save-dialog").Destroy(); }; dialog.AddButton(okButton); dialog.AddButton(cancelButton); dialog.SetMovable(true); dialog.SetResizable(true); dialog.SetPosition((Screen.Width - dialog.GetWidth()) / 2f, (Screen.Height - dialog.GetHeight()) / 2f); var uiCanvas = Entity.Scene.CreateEntity("particles-ui").AddComponent(new UICanvas()); }