Particle Editor Demo
import Felgo 3.0
import QtQuick 2.2
Column {
id: column
property int cnt: sliderCount.value
property int buttonHeight: 30
property variant dialogCaller
property string oldName: ""
width: innerSpace
anchors.horizontalCenter: parent.horizontalCenter
spacing: 6
Text {
color: "white"
text: "Creation Count "+column.cnt
}
GameSlider {
id: sliderCount
width: column.width
maximumValue: 30
value: 1
stepSize: 1
}
GameButton {
width: column.width
height: column.buttonHeight
text: "Add "+scene.itemEditor.currentEditableType
onClicked: {
createParticle()
}
}
GameButton {
id: filename
width: column.width
height: column.buttonHeight
text: "Save as"
onClicked: {
column.oldName = scene.itemEditor.currentEditableType
column.dialogCaller = filename
nativeUtils.displayTextInput("Save as", "Enter Particle Name", scene.itemEditor.currentEditableType)
}
}
GameButton {
width: column.width
height: column.buttonHeight
text: "Respawn Particles"
onClicked: {
flurry.logEvent("Respawn")
var entities = entityManager.getEntityArrayByType("particleEntity")
for(var i=0; i<entities.length; ++i) {
entities[i].respawnParticle()
}
}
}
GameButton {
width: column.width
height: column.buttonHeight
text: "Remove All"
onClicked: {
flurry.logEvent("RemoveAll")
var entities = entityManager.getEntityArrayByType("particleEntity")
for(var i=0; i<entities.length; ++i) {
entityManager.removeEntityById(entities[i].entityId)
}
}
}
GameButton {
width: column.width
height: column.buttonHeight
text: "Remove First"
onClicked: {
flurry.logEvent("RemoveFirst")
var entities = entityManager.getEntityArrayByType("particleEntity")
if(entities.length > 0) {
entityManager.removeEntityById(entities[0].entityId)
}
}
}
GameButton {
width: column.width
height: column.buttonHeight
text: "Remove Last"
onClicked: {
flurry.logEvent("RemoveLast")
var entities = entityManager.getEntityArrayByType("particleEntity")
if(entities.length > 0) {
entityManager.removeEntityById(entities[entities.length-1].entityId)
}
}
}
GameButton {
width: column.width
height: column.buttonHeight
text: "Save to .plist"
onClicked: {
flurry.logEvent("SavePlist","name",scene.itemEditor.currentEditableType)
var entities = entityManager.getEntityArrayByType("particleEntity")
for(var i=0; i<entities.length; ++i) {
if(scene.itemEditor.currentEditableType+".json" === entities[i].particleType) {
entities[i].saveToPList()
}
}
}
}
GameButton {
id: mail
width: column.width
height: column.buttonHeight
text: "Send Particle .json"
onClicked: {
column.dialogCaller = mail
nativeUtils.displayTextInput("Send to", "Enter Email", "your@email.com")
}
}
GameButton {
id: mailPList
width: column.width
height: column.buttonHeight
text: "Send Particle .plist"
onClicked: {
column.dialogCaller = mailPList
nativeUtils.displayTextInput("Send to", "Enter Email", "your@email.com")
}
}
Connections {
target: nativeUtils
onTextInputFinished: {
if(accepted) {
if(column.dialogCaller === filename) {
flurry.logEvent("Save","Particle",filename)
scene.itemEditor.saveItem(getInternalStorageLocation(),scene.itemEditor.currentEditableType,enteredText)
mainMenu.mainMenuContentParticles.dataStorageLocation = true
var entities = entityManager.getEntityArrayByType("particleEntity")
for(var i=0; i<entities.length; ++i) {
if(column.oldName+".json" === entities[i].particleType) {
entities[i].dataStorageLocation = true
entities[i].particleType = scene.itemEditor.currentEditableType+".json"
}
}
mainMenu.mainMenuContentParticles.fillListWithFiles()
} else if(column.dialogCaller === mail) {
flurry.logEvent("SendJSON","name",scene.itemEditor.currentEditableType)
var entities = entityManager.getEntityArrayByType("particleEntity")
for(var i=0; i<entities.length; ++i) {
if(entities[i].particleType === scene.itemEditor.currentEditableType+".json") {
entities[i].sendParticlePerMail(enteredText)
return
}
}
} else if(column.dialogCaller === mailPList) {
flurry.logEvent("SendPList","name",scene.itemEditor.currentEditableType)
var entities = entityManager.getEntityArrayByType("particleEntity")
for(var i=0; i<entities.length; ++i) {
if(entities[i].particleType === scene.itemEditor.currentEditableType+".json") {
entities[i].sendParticlePListPerMail(enteredText)
return
}
}
}
}
}
}
function createParticle() {
flurry.logEvent("Add",scene.itemEditor.currentEditableType,column.cnt)
for(var i = 0; i < column.cnt; ++i) {
var newEntityProperties = {
x: Math.random()*scene.usageAreaWidth,
y: Math.random()*scene.usageAreaHeight,
particleType: scene.itemEditor.currentEditableType+".json",
dataStorageLocation: scene.itemEditor.dataStorageLocation,
entityBaseVisible: scene.entityBaseVisible
}
var entityID = entityManager.createEntityFromUrlWithProperties(Qt.resolvedUrl("particles/ParticleEntity.qml"), newEntityProperties)
}
}
Component.onCompleted: {